Fonts may be created enabling optionality in relation to OpenType features, which drives different presentation of characters. A prime example is ligatures, which, for example, will take a combination of characters like !=
and present them as something that should mean the same thing but is not a 1:1 representation of the code points, e.g., ≠
, which appears as being one character. Some programmers like ligatures, and arguably, they are “pretty”, however other do not like them because commonly they are not literal representations of the code points they are displaying.
Whether a particular application “honours” feature settings is up to it. Even within the same application, there may be other factors dictating whether certain features will apply. For example, in default gvim, the ligatures of the font Fira Code will not be displayed unless the user is using Windows and has render options set for specific DirectX attributes. The problem is, sometimes it’s all or nothing. So, although in this scenario, i.e., gvim + Windows + DirectX, fonts display much nicer generally there is no option, when the font enables ligatures, to disable ligatures (and other features). Tou get whatever you get, unless …
It is possible to restrict fonts to only have the specific combination of options that you want. So, taking FiraCode as an example, you may want it generally, want some characters like the ampersand to have the non-default presentation, but you do not want ligatures to be activated. No problem! That’s what font freezing allows you to do.
There are only a few steps, though within those steps some factors may need repeating.
This gist example uses FiraCode’s Nerd Font.[1]
You need the font files for the font you want to freeze. For FiraCode Nerd font, I used https://www.nerdfonts.com/font-downloads - navigating to FiraCode Nerd Font and clicking “Download”, downloads v3.3.0 (at the time of writing) of the font as FiraCode.zip.
Once downloaded, you need to determine the font files you want. This will vary but let’s presume you only want the Regular/Roman and Bold. Sometimes there is also an Italic and BoldItalic version. When that is not presented as an option, the italic and bold-italic types may appear as oblique, which is a slanted variant, but not a true italic. That’s not so important here so, for this example, we’re only working with the Regular and Bold versions, which, in the FiraCode.zip
file were:
- FiraCodeNerdFontMono-Regular.ttf
, and
- FiraCodeNerdFontMono-Bold.ttf
Extract the desired fonts. Use whatever means you want to do this. That could be using Windows Explorer to copy the files from the .zip (which can be clicked in Windows Explorer to open it in a window, to another location), 7zip, or whatever.
Once extracted, now it’s time to consider the features/settings you want to freeze. This is a reasonably complicated step, but only because there are so many options, not because each option itself is super technical.
Note
|
To freeze the font, you can either use the command line and some processes or, for an interactive option, there are websites, such as FontFreeze. That’s what we’re going to use because, unless you want to freeze masses of fonts (unlikely), using a GUI is a simple choice. |
Once in Font Freeze’s website, you need to upload the first of the font files you extracted. The icon is self evident:
Before freezing each .ttf
, you’ll need to know what at least some of the options in FontFreeze mean. Here’s what you’re presented with:
Note
|
The boxes will be empty/unchecked when loaded. These are the settings that are explained, below. |
That’s a load of stuff! They are OpenType features. Here’s a condensed breakdown of what each means and why is is either checked or not:
Feature | ? | Description | Rationale |
---|---|---|---|
aalt |
Access All Alternates - provides a menu of all alternate glyphs for a character. |
Keep all defaults unless specifically overwritten. |
|
calt |
Contextual Alternates - replaces glyph sequences with designed ligatures based on surrounding characters. |
This enables ligatures, which I specifically do not want. |
|
case |
Case-Sensitive Forms - shifts punctuation marks up to work better with capital letters. |
Leave punctuation alone (and consistent). |
|
cv01 |
Character Variant 1 - provides alternative style for lowercase 'a'. |
The default a glyph is preferrable, IMO. |
|
cv02 |
Character Variant 2 - provides alternative style for lowercase 'g'. |
The default g glyph is preferrable, IMO. |
|
cv03 |
Character Variant 3 - provides alternative style for lowercase 'i'. |
cv05 is my preference for the i glyph. This cv03 one produces a sans serif one. |
|
cv04 |
Character Variant 4 - provides alternative style for lowercase 'i'. |
cv05 is my preference for the i glyph. This cv04 one produces a strange looking gglyph. |
|
cv05 |
Character Variant 5 - provides alternative style for lowercase 'i'. |
cv05 is my preference for the i glyph because it has similarities to the shape of the default j and l glyphs, so (right angled top, curved bottom) so looks consistent and is easily distinguished from others. |
|
cv06 |
Character Variant 6 - provides alternative style for lowercase 'i'. |
cv05 is my preference for the i glyph. This cv06 one produces a more extreme version of cv05, with a long curved bottom. |
|
cv07 |
Character Variant 7 - provides alternative style for lowercase 'l'. |
The default l glyph is preferrable, IMO. |
|
cv08 |
Character Variant 8 - provides alternative style for lowercase 'l'. |
The default l glyph is preferrable, IMO. |
|
cv09 |
Character Variant 9 - provides alternative style for lowercase 'l'. |
The default l glyph is preferrable, IMO. |
|
cv10 |
Character Variant 10 - provides alternative style for lowercase 'l'. |
The default l glyph is preferrable, IMO. |
|
cv11 |
Character Variant 11 - provides alternative style for the number '0'. |
The default (slashed) 0 glyph is preferrable, IMO. |
|
cv12 |
Character Variant 12 - provides alternative style for the number '0'. |
The default (slashed) 0 glyph is preferrable, IMO. |
|
cv13 |
Character Variant 13 - provides alternative style for the number '0'. |
The default (slashed) 0 glyph is preferrable, IMO. |
|
cv14 |
Character Variant 14 - provides alternative style for the number '3'. |
This alternate makes the 3 glyph more distinctive by making the top flat. It’s 50/50, I think, but I kind of like it. |
|
cv15 |
Character Variant 15 - provides alternative style for the asterisk '*'. |
The default * glyph is preferrable, IMO. |
|
cv16 |
Character Variant 16 - provides alternative style for the asterisk '*'. |
The default * glyph is preferrable, IMO. |
|
cv17 |
Character Variant 17 - provides alternative style for the tilde '~'. |
The default ~ glyph is fine, IMO. |
|
cv18 |
Character Variant 18 - provides alternative style for the percent sign '%'. |
The default % glyph is much better, IMO. This cv18 variant has no 'holes' in the o parts of the percentage sign, so looks odd. |
|
cv19 |
Character Variants 19 and 20 - provide alternative styles for specific characters (font dependent); in FiraCode those are for |
Neither are wanted. (That applies to all of the options through to cv28, inclusive, plus cv32, which are all ligature-related.) |
|
cv20 |
Character Variant 20 - provides alternative styles for specific characters (font dependent). |
Refer cv19, above. This is another ligature-specific feature. |
|
cv21 |
Character Variant 21 - provides alternative styles for specific characters (font dependent). |
Refer cv19, above. This is another ligature-specific feature. |
|
cv22 |
Character Variant 22 - provides alternative styles for specific characters (font dependent). |
Refer cv19, above. This is another ligature-specific feature. |
|
cv23 |
Character Variant 23 - provides alternative styles for specific characters (font dependent). |
Refer cv19, above. This is another ligature-specific feature. |
|
cv24 |
Character Variant 24 - provides alternative styles for specific characters (font dependent). |
Refer cv19, above. This is another ligature-specific feature. |
|
cv25 |
Character Variant 25 - provides alternative styles for specific characters (font dependent). |
Refer cv19, above. This is another ligature-specific feature. |
|
cv26 |
Character Variant 26 - provides alternative styles for specific characters (font dependent). |
Refer cv19, above. This is another ligature-specific feature. |
|
cv27 |
Character Variant 27 - provides alternative styles for specific characters (font dependent). |
Refer cv19, above. This is another ligature-specific feature. |
|
cv28 |
Character Variant 28 - provides alternative styles for specific characters (font dependent). |
Refer cv19, above. This is another ligature-specific feature. |
|
cv29 |
Character Variant 29 - provides alternative style for curly braces '{}'. |
This provides a subtly different left curly bracked |
|
cv30 |
Character Variant 30 - provides alternative style for the vertical bar '|'. |
This would create a very long vertical line, which is messy (IMO). |
|
cv31 |
Character Variant 31 - provides alternative style for parentheses '()'. |
This would create very rounded left and right parehtheses, which looks odd (IMO). |
|
cv32 |
Character Variant 32 - provides alternative styles for specific characters (font dependent). |
Refer cv19, above. This is another ligature-specific feature. |
|
dnom |
Denominators - formats numbers for the bottom part of fractions. |
This is used with frac and numr to manipulate the appearance of fractions typed as character sequences. (E.g., presenting |
|
frac |
Fractions - creates diagonal fractions from separate numerator and denominator. |
This is used with dnom and numr to manipulate the appearance of fractions typed as character sequences. (E.g., presenting |
|
hwid |
Half-width - adjusts glyphs to half-width form, primarily for East Asian typography. |
I don’t need this. |
|
numr |
Numerators - formats numbers for the top part of fractions. |
This is used with frac and numr to manipulate the appearance of fractions typed as character sequences. (E.g., presenting |
|
onum |
Old-style Numerals - replaces default numerals with figures that have varying heights and alignments. |
This makes numerals appear variably horizontally, which may be wanted for some contexts, but for monospaced fonts and clarity, not (IMO). |
|
ordn |
Ordinals - automatically formats 1st, 2nd, 3rd with proper superscript styling. |
Replacing default alphabetic glyphs with the corresponding ordinal/superscript forms is not wanted. |
|
salt |
Stylistic Alternates - provides alternative designs for characters that don’t fit in other categories. |
It’s unclear whether this would add any value, so it’s 'x'. |
|
sinf |
Scientific Inferiors - formats numbers as scientific inferior figures. |
This is another feature that presents a character other than what the code point would suggest it is, so is not wanted. |
|
ss01 |
Stylistic Set 1 - provides alternative style for lowercase 'r'. |
This removes some of the RHS of the 'r' character, making it harder to read. |
|
ss02 |
Stylistic Set 2 - applies a predefined set of stylistic alternatives to characters. |
If |
|
ss03 |
Stylistic Set 3 - provides alternative style for the ampersand '&'. |
The default ampersand for FiraCode is a curly/rounds one whereas the |
|
ss04 |
Stylistic Set 4 - provides alternative style for the dollar sign '$'. |
This is a bit marginal, but the dollar sige without the vertical bar inside the S, so with the top and bottom only with vertical, small strokes, is a bit nicer (IMO). |
|
ss05 |
Stylistic Set 5 - provides alternative style for the at sign '@'. |
The @ with an almost full “circle” surrounding the a is not as nice as it only half the way (IMO). |
|
ss06 |
Stylistic Set 6 - applies a predefined set of stylistic alternatives to characters. |
This enables different presentation of |
|
ss07 |
Stylistic Set 7 - applies a predefined set of stylistic alternatives to characters. |
These are more ligature-related variants involving tilde and |
|
ss08 |
Stylistic Set 8 - applies a predefined set of stylistic alternatives to characters. |
Similar to |
|
ss09 |
Stylistic Set 9 - applies a predefined set of stylistic alternatives to characters. |
More ligatures' variants like |
|
ss10 |
Stylistic Set 10 - applies a predefined set of stylistic alternatives to characters. |
This one is more marginal. If it was in writing, I’d probably activate it but, for code, wouldn’t. It is the “Fl”, “Tl”, “fi”, “fj”, “fl”, and “ft” combinations. It looks a bit odd in code having the strokes of, for example, “f” and “i” join, so I’d leave this feature as no. |
|
subs |
Subscript - replaces characters with subscript versions. |
Once again, this makes a character look like a different code point to what it is in practice. If you really want a subscript numeral, use the explicit code point (they exist). |
|
sups |
Superscript - replaces characters with superscript versions. |
For the same reason as |
|
tnum |
Tabular Numbers - adjusts numbers to all have the same width for better alignment in tables. |
This is n/a for a monospaced font. |
|
zero |
Slashed Zero - replaces the standard '0' with a slashed version to distinguish it from the letter 'O'. |
FiraCode’s default 0 glyph is a slashed version anyway. |
To summarise what the ticked features do:
For the specifics relating to your font, you may need to go to the Font’s source to see what what’s what in relation to the variable features. For the FiraCode example, that’s https://github.com/tonsky/FiraCode/wiki/How-to-enable-stylistic-sets - it shows:
There’s not much else to do. The remaining settings are:
-
Font family suffix
-
Output format
-
Target feature for activation
-
Checkbox for “Apply substitution by single-glyph features
The following image shows my settings for these:
-
“Freeze” makes sense so you know when you are installing the font (or referencing it, e.g., in a
_gvimrc
it is not the “normal” version. -
“TTF” is True Type Font, and mirrors the FiraCode
.ttf
files. -
calt
is one of two options - leave it alone -
Checking single glyph features ensures those are applied
-
There is also a macOS checkbox - self evident - leave it unchecked unless you….
Generate font! button is next - hopefully when clicked there is no error. It takes almost no time to generate the font. Once it’s ready, Download font, saving it to where you wish.
Use whatever procedure to install the fonts you would normally. For Windows, it’s easy to right click one or more and Install.