Skip to content

Adjust line spacing in Hack with a new line spacing modification tool #191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
chrissimpkins opened this issue Mar 26, 2016 · 16 comments
Closed

Comments

@chrissimpkins
Copy link
Member

By popular request among the crowds who want things "clown car tight" and "loosey goosey", here is a command line tool that will allow you to modify the line spacing in the fonts to any percentage of the font UPM size. We are currently defined at 20% UPM for your modification calculations. Decrease the value to make the line spacing tighter or increase the value to make it looser. Full details about the usage and OpenType table modifications that occur are available on the tool's repository README page.

Feel free to give it a try with Hack (or any other font) and please provide feedback through issue reports on the tool's repository:

https://github.com/source-foundry/font-line

The re-release of the Hack fonts (and any other FLOSS typeface with a reserved font name) with new vertical metrics warrants a change in the name of the fonts as per the Hack license. We fully support redistribution with new metrics according to these guidelines, but be aware that this will break all vertical alignment relationships in the fonts (e.g. box drawing glyphs and block element glyphs). If this matters to you, be prepared to modify these glyphs in a font editor before use, and definitely consider this issue prior to redistribution to others.

Please Note: font caching issues and multiple font install issues have plagued users who attempt to install new Hack fonts over previously installed versions. Please read our README file, have a look through active and previous issue reports, and do a bit of research into how you clear your font cache if installs do not lead to expected line spacing changes or cause the unexpected display of unusual characters in your text editors. There are a number of closed issue reports that have dealt with these issues. The Windows + JetBrains editor combination has been a particularly problematic area.

Enjoy.

@alphapapa
Copy link

Thanks for putting this together, Chris! I'm pretty satisfied with Hack, but there is a font or two that I would like to decrease the line spacing on. I'll let you know if I find any issues.

@chrissimpkins
Copy link
Member Author

Great! Let me know if you come across any issues. Codeface now contains vertical metrics for all included fonts if you need references as you make modifications. Check the individual font directories for the vertical_metrics.txt file.

https://github.com/chrissimpkins/codeface

@chrissimpkins
Copy link
Member Author

I just made these shell scripts available as well:

https://github.com/chrissimpkins/Hack/tree/master/tools/line-spacing

They automate the font-line install and modification of all .ttf and .otf files in the same directory for a range of % UPM line spacing values between 10 - 30%.

@alphapapa
Copy link

I must confess that I know very little about the inner workings of fonts, and most of what I read in the font-line readme went over my head, so I'm not sure how much use I can make of it. I guess I could just try a percentage reduction on, say, Fira Code, a font I like but would like to decrease the line spacing of, and see what happens, but all those metrics are meaningless to me. :)

@chrissimpkins
Copy link
Member Author

Use the reporting feature and check the ratios at the bottom of the report. Those are the ones that you can use as your reference point to modify from default values.

@chrissimpkins
Copy link
Member Author

And feel free to open issue reports on the tool's repo for any non-Hack questions. Happy to help with other fonts over there.

@alphapapa
Copy link

Thanks.

@chrissimpkins
Copy link
Member Author

no worries at all! let me know how I can help.

@chrissimpkins
Copy link
Member Author

@alphapapa Fira Code uses 20% UPM as well:

fira

You can try modifying to 15% with the following command:

font-line percent 15 FiraCode-*.otf

or 10% with:

font-line percent 10 FiraCode-*.otf

@alphapapa
Copy link

Thanks, I will give it a try! :)

@chrissimpkins
Copy link
Member Author

Great! Let me know how it goes.

@alphapapa
Copy link

Hey Chris,

I just tried the 15% command, but it increased the line spacing instead of reducing it:

$ font-line report FiraCode-Regular.otf 

=== FiraCode-Regular.otf ===
Version 1.102;PS 001.102;hotconv 1.0.88;makeotf.lib2.5.64775
SHA1: 87fda07094d49978382399e0532b021ef8fb6b02

--- Metrics ---
[head] Units per Em:    1000
[head] yMax:            1050
[head] yMin:            -500
[OS/2] TypoAscender:    935
[OS/2] TypoDescender:   -265
[OS/2] WinAscent:       935
[OS/2] WinDescent:      265
[hhea] Ascent:          935
[hhea] Descent:         -265

[hhea] LineGap:         0
[OS/2] TypoLineGap:     0

--- Height Calculations by Table Values ---
[OS/2] TypoAscender to TypoDescender:   1200
[OS/2] WinAscent to WinDescent:         1200
[hhea] Ascent to Descent:               1200

--- Delta Values ---
WinAscent to TypoAscender:      0
Ascent to TypoAscender:         0
WinDescent to TypoDescender:    0
Descent to TypoDescender:       0

--- Ratios ---
(Typo Asc + Desc + Linegap) / UPM:      1.2
(winAsc + winDesc) / UPM:               1.2
(hhea Asc + Desc) / UPM:                1.2


$ font-line percent 15 FiraCode-*.otf
[font-line] 'FiraCode-Bold.otf' successfully modified to 'FiraCode-Bold-linegap15.otf'.
[font-line] 'FiraCode-Regular.otf' successfully modified to 'FiraCode-Regular-linegap15.otf'.

$ font-line report FiraCode-Regular-linegap15.otf 

=== FiraCode-Regular-linegap15.otf ===
Version 1.102;PS 001.102;hotconv 1.0.88;makeotf.lib2.5.64775
SHA1: 269660e4c91ed4de6c91f7823514c4cafe4d3a93

--- Metrics ---
[head] Units per Em:    1000
[head] yMax:            1050
[head] yMin:            -500
[OS/2] TypoAscender:    935
[OS/2] TypoDescender:   -265
[OS/2] WinAscent:       1025
[OS/2] WinDescent:      355
[hhea] Ascent:          1025
[hhea] Descent:         -355

[hhea] LineGap:         0
[OS/2] TypoLineGap:     180

--- Height Calculations by Table Values ---
[OS/2] TypoAscender to TypoDescender:   1200
[OS/2] WinAscent to WinDescent:         1380
[hhea] Ascent to Descent:               1380

--- Delta Values ---
WinAscent to TypoAscender:      90
Ascent to TypoAscender:         90
WinDescent to TypoDescender:    90
Descent to TypoDescender:       90

--- Ratios ---
(Typo Asc + Desc + Linegap) / UPM:      1.38
(winAsc + winDesc) / UPM:               1.38
(hhea Asc + Desc) / UPM:                1.38

Then I uninstalled the original version of the fonts, installed the new fonts, and restarted Emacs, and the line spacing is indeed increased.

@chrissimpkins
Copy link
Member Author

This is a bug in font-line that appears to be occur because of the way that they defined their TypoAscender and TypoDescender values. They are not equal to the UPM.

I added an issue report here: source-foundry/font-line#6

And will try to fix it this week. Thanks for reporting it!

@alphapapa
Copy link

No problem, I look forward to trying the fix. :)

@chrissimpkins
Copy link
Member Author

Found the problem. Mind joining me in this issue report thread?

source-foundry/font-line#6

@chrissimpkins
Copy link
Member Author

Bug reported by @alphapapa was fixed. See linked font-line issue report thread above.

This tool is now available for use. Will close this thread as it is no longer necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants