Hack Font too high compared to other terminals #10584

Closed
opened 2026-01-31 02:25:10 +00:00 by claunia · 8 comments
Owner

Originally created by @W4RH4WK on GitHub (Sep 10, 2020).

Environment

Windows build number: Microsoft Windows [Version 10.0.18363.1082]
Windows Terminal version (if applicable): 1.2.2381.0

wsl-terminal, mintty 3.1.6

Steps to reproduce

Use Hack font (size 10) in Windows Terminal and wsl-terminal and compare them side-by-side.

Expected behavior

Content of both terminals should look identical.

Actual behavior

The font seems to be out of proportion in Windows Terminal.
The following screenshot compares them side by side.

winterm_font_1

Here wsl-terminal's transparency setting is set to high and wsl-terminal was moved right over Windows Terminal for better comparison. In Windows Terminal, the characters are taller while having the same width.

winterm_font_2

Originally created by @W4RH4WK on GitHub (Sep 10, 2020). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment ```none Windows build number: Microsoft Windows [Version 10.0.18363.1082] Windows Terminal version (if applicable): 1.2.2381.0 wsl-terminal, mintty 3.1.6 ``` # Steps to reproduce Use [Hack](https://sourcefoundry.org/hack/) font (size 10) in Windows Terminal and [wsl-terminal](https://github.com/mskyaxl/wsl-terminal) and compare them side-by-side. # Expected behavior Content of both terminals should look identical. # Actual behavior The font seems to be out of proportion in Windows Terminal. The following screenshot compares them side by side. ![winterm_font_1](https://user-images.githubusercontent.com/328798/92769022-dc033e00-f398-11ea-84a6-3972158b3ae5.png) Here wsl-terminal's transparency setting is set to high and wsl-terminal was moved right over Windows Terminal for better comparison. In Windows Terminal, the characters are taller while having the same width. ![winterm_font_2](https://user-images.githubusercontent.com/328798/92769835-a6128980-f399-11ea-9507-edf020004ce0.png)
claunia added the Resolution-Duplicate label 2026-01-31 02:25:10 +00:00
Author
Owner

@DHowett commented on GitHub (Sep 10, 2020):

after you read this, see https://github.com/microsoft/terminal/issues/7596#issuecomment-692919542 for a bit more information. I don't necessarily think Hack is incorrect. I'm keeping the original comment body for posterity.

This is an unfortunate result of the way the Hack font is authored.

There was, for a long time, a divide in font rendering technology on Windows and other platforms. Because of this, fonts had separate fields for "how big is a character?" on Windows and all other platforms.

That disparity was fixed in approximately 2009 when Windows 7 shipped with DirectWrite, our modern font rendering technology.

Because of that, the "Windows" measurements are considered legacy.

Unfortunately, the Hack font contains the following measurements and flags:

    <sTypoAscender value="1556"/>    <!-- modern measurements -->
    <sTypoDescender value="-492"/>
    <usWinAscent value="1901"/>      <!-- legacy measurements -->
    <usWinDescent value="483"/>
    <fsSelection value="00000000 01000000"/>
    <!--                         ^ if this is a 0, use the legacy measurements. if 1, use the modern ones. -->

Following the legacy measurements, a single cell in this font is 2384 units tall. Following the modern measurements, it is 2048 units tall.

WT uses DirectWrite, which has a strict interpretation of this flag. It is following the legacy measurements because the font told it to.

mintty's renderer seems to be behaving out-of-spec:

Some legacy applications use the usWinAscent and usWinDescent values to determine default line spacing. This is strongly discouraged. The sTypo* fields should be used for this purpose.
OS/2 and Windows Metrics Table specification

Emphasis mine. The line measurer in use in mintty appears to be disregarding the discouragement and it results in a tighter line spacing than it should.


It looks like gvim also "follows the rules"; the line spacing matches Terminal, even though gvim uses GDI (legacy) for measurement:

image

@DHowett commented on GitHub (Sep 10, 2020): _after you read this, see https://github.com/microsoft/terminal/issues/7596#issuecomment-692919542 for a bit more information. I don't necessarily think Hack is incorrect. I'm keeping the original comment body for posterity._ This is an unfortunate result of the way the Hack font is authored. There was, for a long time, a divide in font rendering technology on Windows and other platforms. Because of this, fonts had separate fields for "how big is a character?" on Windows and all other platforms. That disparity was fixed in approximately 2009 when Windows 7 shipped with DirectWrite, our modern font rendering technology. Because of that, the "Windows" measurements are considered _legacy_. Unfortunately, the Hack font contains the following measurements and flags: ``` <sTypoAscender value="1556"/> <!-- modern measurements --> <sTypoDescender value="-492"/> <usWinAscent value="1901"/> <!-- legacy measurements --> <usWinDescent value="483"/> <fsSelection value="00000000 01000000"/> <!-- ^ if this is a 0, use the legacy measurements. if 1, use the modern ones. --> ``` Following the legacy measurements, a single cell in this font is 2384 units tall. Following the _modern_ measurements, it is 2048 units tall. WT uses DirectWrite, which has a strict interpretation of this flag. It is following the legacy measurements because the font told it to. mintty's renderer seems to be behaving out-of-spec: > Some legacy applications use the `usWinAscent` and `usWinDescent` values to determine default line spacing. **This is strongly discouraged. The `sTypo*` fields should be used for this purpose.** > [OS/2 and Windows Metrics Table specification](https://docs.microsoft.com/en-us/typography/opentype/spec/os2#uswinascent) Emphasis mine. The line measurer in use in mintty appears to be disregarding the discouragement and it results in a tighter line spacing than it should. --- It looks like gvim also "follows the rules"; the line spacing matches Terminal, even though gvim uses GDI (legacy) for measurement: ![image](https://user-images.githubusercontent.com/189190/92775631-6de85800-f353-11ea-9833-e187da75c8fe.png)
Author
Owner

@DHowett commented on GitHub (Sep 10, 2020):

I am clearly deluded about the vim thing. That's definitely not the same.

I had accidentally returned my font to Cascadia Code and tried to measure again. Hack is working as in my screenshot.

@DHowett commented on GitHub (Sep 10, 2020): ~I am clearly deluded about the vim thing. That's definitely not the same.~ I had accidentally returned my font to Cascadia Code and tried to measure again. Hack is working as in my screenshot.
Author
Owner

@ghost commented on GitHub (Sep 14, 2020):

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

@ghost commented on GitHub (Sep 14, 2020): This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for **4 days**. It will be closed if no further activity occurs **within 3 days of this comment**.
Author
Owner

@W4RH4WK commented on GitHub (Sep 15, 2020):

This seems to be a miss-configuration of the font itself. I've opened an issue, but the project seems rather inactive at the moment. I'd welcome an option (maybe as temporary workaround) to switch the rendering engine to use legacy measurement --- similar to the way mintty handles it. However, I fully understand that this may not be technically feasible or desired by the devs as it is basically a hack.

@W4RH4WK commented on GitHub (Sep 15, 2020): This seems to be a miss-configuration of the font itself. I've opened an issue, but the project seems rather inactive at the moment. I'd welcome an option (maybe as temporary workaround) to switch the rendering engine to use legacy measurement --- similar to the way mintty handles it. However, I fully understand that this may not be technically feasible or desired by the devs as it is basically a hack.
Author
Owner

@DHowett commented on GitHub (Sep 15, 2020):

So, this might not work. If you want to give it a shot, it should result in a version of Hack named Hack Patched.

prerequisites

Install fonttools (in WSL)

apt install -yy fonttools

Move to a folder that contains Hack-Regular.ttf

steps

ttx -o Hack-Patched.ttx Hack-Regular.ttf
sed -i -e '/Hack-/s/Hack/HackPatched/g; s/Hack\b/Hack Patched/g; /fsSelection/s/01000000/11000000/g; /sTypoLineGap/s/410/0/' Hack-Patched.ttx
ttx Hack-Patched.ttx
  1. decompile the font to xml
  2. sed script to do 3 things:
    1. Change the name of the font to Hack Patched (first two substitutions)
    2. Change fsSelection's 7th bit (0-indexed, count from the right) to 1 to indicate "use the typographic metrics"
    3. Zap the typographic line gap to 0 (from 410 design units). This makes the font very tight.
  3. recompile the font from xml

Here's what it looks line in my terminal.

(before on the left, after on the right)

image

This modification comes with no warranty; the font is MIT-licensed and does not appear to have a RFN; if it blows up in other applications, consider yourself warned.

@DHowett commented on GitHub (Sep 15, 2020): So, this might not work. If you want to give it a shot, it should result in a version of Hack named `Hack Patched`. ### prerequisites Install fonttools (in WSL) ``` apt install -yy fonttools ``` Move to a folder that contains `Hack-Regular.ttf` ### steps ``` ttx -o Hack-Patched.ttx Hack-Regular.ttf sed -i -e '/Hack-/s/Hack/HackPatched/g; s/Hack\b/Hack Patched/g; /fsSelection/s/01000000/11000000/g; /sTypoLineGap/s/410/0/' Hack-Patched.ttx ttx Hack-Patched.ttx ``` 1. decompile the font to xml 2. sed script to do 3 things: 1. Change the name of the font to Hack Patched (first two substitutions) 2. Change `fsSelection`'s 7th bit (0-indexed, count from the right) to `1` to indicate "use the typographic metrics" 3. Zap the typographic line gap to 0 (from 410 design units). This makes the font very tight. 3. recompile the font from xml Here's what it looks line in my terminal. (before on the left, after on the right) ![image](https://user-images.githubusercontent.com/189190/93248776-2f80dd80-f745-11ea-8086-d9c1ca1750f2.png) _This modification comes with no warranty; the font is MIT-licensed and does not appear to have a RFN; if it blows up in other applications, consider yourself **warned**._
Author
Owner

@DHowett commented on GitHub (Sep 15, 2020):

For our side, I'm gonna close this as a /duplicate of #3498.

I'm no longer certain it's the font that's wrong. That "line gap" value actually makes it render exactly the same in [legacy] mode as it does in [modern] mode. An application that is ignoring the "line gap" value is, to a rough first approximation, incorrect. I do think it should be configurable, though.

@DHowett commented on GitHub (Sep 15, 2020): For our side, I'm gonna close this as a /duplicate of #3498. I'm no longer certain it's the font that's wrong. That "line gap" value actually makes it render exactly the same in [legacy] mode as it does in [modern] mode. An application that is ignoring the "line gap" value is, to a rough first approximation, _incorrect_. I do think it should be configurable, though.
Author
Owner

@ghost commented on GitHub (Sep 15, 2020):

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@ghost commented on GitHub (Sep 15, 2020): Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!
Author
Owner

@W4RH4WK commented on GitHub (Sep 15, 2020):

Thank you for describing how to patch the font.

@W4RH4WK commented on GitHub (Sep 15, 2020): Thank you for describing how to patch the font.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#10584