1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
#+TITLE: Exploring OpenType Font Features
#+DATE: 2022-01-22T19:10:17-05:00
#+DRAFT: false
#+DESCRIPTION: Checking out the OpenType features of a font
#+TAGS[]: font emacs
#+KEYWORDS[]: font emacs
#+SLUG:
#+SUMMARY:
#+ATTR_HTML: :title Italic and Script font options
#+ATTR_HTML: :alt Italic and Script font options
[[file:cover.png]]
I just bought a new font to use as my primary face in Emacs. It's a
cool one called [[https://www.monolisa.dev][MonoLisa]], I think it looks great.
It has a nice looking script variant that lets you turn your italics
into a cursive looking font. Unfortunately it's a fancy OpenType
feature that most things, including Emacs don't support properly yet.
In their [[https://www.monolisa.dev/faq][FAQ]] they mention that you can use a tool called [[https://github.com/twardoch/fonttools-opentype-feature-freezer][OpenType
Feature Freezer]] to modify the font so that the optional glyphs become
the default. They get used all the time without requiring the editor
to properly support the OpenType feature.
This is a good opportunity to explore OpenType features.
To get the list of possible font features you can pass the Font Freezer
the =-r= flag, it will list out the features supported by the font.
#+begin_src shell
pyftfeatfreeze -r MonoLisa-RegularItalic.otf
# Scripts and languages:
-s 'DFLT'
-s 'cyrl'
-s 'cyrl' -l 'BGR '
-s 'cyrl' -l 'SRB '
-s 'latn'
-s 'latn' -l 'AZE '
-s 'latn' -l 'CRT '
-s 'latn' -l 'KAZ '
-s 'latn' -l 'MOL '
-s 'latn' -l 'ROM '
-s 'latn' -l 'TAT '
-s 'latn' -l 'TRK '
# Features:
-f aalt,calt,case,ccmp,dnom,frac,liga,locl,numr,onum,ordn,salt,sinf,ss01,ss02,ss05,ss06,subs,sups,zero
#+end_src
While it's possible to find a list of what the OpenType features do on
[[https://en.wikipedia.org/wiki/List_of_typographic_features][Wikipedia]], in many cases we're still left not knowing what the
Stylistic Sets are.
Once we have a list of features supported by the font, it's possible
to test these features out on the MonoLisa website by modifying CSS
variables.
If we load the [[https://www.monolisa.dev/specimen][specimin]] or [[https://www.monolisa.dev/playground][playground]] page and find the CSS rule that
sets the font for the page, we can add =font-feature-settings:= rules
to test out the different options.
For example, if we add =font-feature-settings: "ss02";=, this will
enable the =ss02= feature on all text on the website. We can then go
through each of the features listed out by the Feature Freezer and try
them all out.
From there we can figure out which features we want to enable and pass
them to as arguments to the Feature Freezer and produce a font we with
those features enabled by default.
If we wanted to produce a font with the =ss01= and =ss02= features
enabled by default, we could then run this command.
#+begin_src shell
pyftfeatfreeze -n -v -f ‘ss01,ss02’ source-font.otf output-font.otf
#+end_src
|