| 1 |
Hinting |
| 2 |
======= |
| 3 |
|
| 4 |
PostScript originally required that hints should not overlap. Now it requires |
| 5 |
that any active set of hints be non-overlapping, but it allows you to change |
| 6 |
sets as you move through the glyph. |
| 7 |
|
| 8 |
So to implement hinting with hint substitution FontForge needs to know not only |
| 9 |
the position and width of the stem being hinted, but also where the stem should |
| 10 |
be active. And it needs to know what stems overlap which other stems. |
| 11 |
|
| 12 |
.. image:: /images/Hints.png |
| 13 |
:align: left |
| 14 |
|
| 15 |
The horizontal stems are drawn in light green. The vertical stems are drawn in |
| 16 |
light blue. The areas where the stems are active are filled in as rectangles, |
| 17 |
outside of that area the stems' outlines are drawn with dotted lines. Most of |
| 18 |
these stems do not conflict with any other stems, but two, the bottom two |
| 19 |
horizontal stems conflict with each other. All the non-overlapping stem hints |
| 20 |
may be active at the same time, but only one of the two conflicting stem hints |
| 21 |
may be active. As FontForge outputs the glyph it decides at each point what |
| 22 |
stems need to be active, and activates them. |
| 23 |
|
| 24 |
PostScript now allows FontForge to control relative counter sizes. Counters are |
| 25 |
the spaces between adjacent stems. In the example at left there are two counters |
| 26 |
of equal sizes between the horizontal stems on the left, and three counters of |
| 27 |
equal sizes on the right. These form two independent counter groups, and |
| 28 |
FontForge's :menuselection:`Hints --> Auto Counter` command will generate a |
| 29 |
counter description for each of them. You may also control the counters directly |
| 30 |
by using the Counters pane of the :menuselection:`Element --> Char Info` dialog. |
| 31 |
|
| 32 |
Counters spaces appear between vertical stems too, and in this case FontForge |
| 33 |
would output one counter group for the vertical stems. |
| 34 |
|
| 35 |
|
| 36 |
Serifs |
| 37 |
------ |
| 38 |
|
| 39 |
.. image:: /images/serif.png |
| 40 |
:align: right |
| 41 |
|
| 42 |
One of the major advantages of hint substitution is that it allows certain |
| 43 |
standard serif situations to be described. In the example at right, the serif |
| 44 |
one the left is smaller than the stem a bit further right. |
| 45 |
|
| 46 |
.. image:: /images/serif2.png |
| 47 |
:align: left |
| 48 |
|
| 49 |
But it doesn't solve all problems (or I don't know how to use it to do so). |
| 50 |
Consider the serif on the right. Hint substitution would allow us to define a |
| 51 |
hint for the main vertical stem and for the short vertical stem that corresponds |
| 52 |
to the serif. But the problem that needs to be solved is making the distance |
| 53 |
between the left edge of the serif and the left edge of the stem be the same as |
| 54 |
the distance between the right edge of the stem and the right edge of the serif. |
| 55 |
But doing so would require overlapping hints, active at the same time. |
| 56 |
:small:`I think` |
| 57 |
|
| 58 |
|
| 59 |
Automatic Hinting |
| 60 |
----------------- |
| 61 |
|
| 62 |
FontForge's AutoHint command can be used to figure out horizontal and vertical |
| 63 |
stem hints. It will also find hint substitution points (if any are needed), and |
| 64 |
will check for the simple counter description allowed by OpenType for non-Asian |
| 65 |
fonts (the equivalent of h/vstem3 hints in type1 fonts). |
| 66 |
|
| 67 |
Whenever you change a glyph FontForge keeps track of that fact that the hints |
| 68 |
are out of date (when you autohint a glyph, or make a manual change to the hints |
| 69 |
FontForge resets this flag). If you generate a postscript font from something |
| 70 |
that contains glyphs with out of date hints, then FontForge will automagically |
| 71 |
regenerate them. |
| 72 |
|
| 73 |
This may not always be appropriate. You can turn this off in general with the |
| 74 |
:ref:`AutoHint preference item <prefs.AutoHint>`. You may turn it off for an |
| 75 |
individual glyph with the :menuselection:`Hints --> Don't AutoHint` command. |
| 76 |
|
| 77 |
|
| 78 |
Manual Hinting |
| 79 |
-------------- |
| 80 |
|
| 81 |
I hope that the FontForge's autohint command will be good enough that manual |
| 82 |
efforts will not be needed. But hopes like this are rarely fulfilled. |
| 83 |
|
| 84 |
The AutoHint command should find all stems in a glyph. Some of them it deems to |
| 85 |
be useless and will remove them. If you find that FontForge is removing a hint |
| 86 |
that you think is important then invoke :menuselection:`Hint --> AutoHint` with |
| 87 |
the shift key held down, this will tell FontForge not to prune any of the stems. |
| 88 |
You may then use Review Hints to prune things yourself. |
| 89 |
|
| 90 |
If you find that you must create your own hints, FontForge will only allow you |
| 91 |
to specify the position and width of the hint, it will then go off and try to |
| 92 |
guess the extents where the hint should be active. |
| 93 |
|
| 94 |
You may manually: |
| 95 |
|
| 96 |
* Clear all horizontal stem hints |
| 97 |
* Clear all vertical stem hints |
| 98 |
* Select two points and create a vertical stem hint that whose width is horizontal |
| 99 |
distance between the two points |
| 100 |
* Select two points and create a horizontal stem hint whose width is the vertical |
| 101 |
distance between the two points |
| 102 |
* Create a horizontal hint starting at an arbitrary y location with an arbitrary |
| 103 |
vertical width. |
| 104 |
* Create a vertical hint starting at an arbitrary x location with an arbitrary |
| 105 |
horizontal width. |
| 106 |
* Review all your hints, manually changing or removing any (or all). |
| 107 |
|
| 108 |
Once you have made a manual change to a glyph's hints with any of the above |
| 109 |
commands, that glyph will be marked "Don't AutoHint" until you explicitly call |
| 110 |
the AutoHint command on it. You may also explicitly use the |
| 111 |
:menuselection:`Hints --> Don't AutoHint` command to turn off FontForge's |
| 112 |
automatic hinting attempts. |
| 113 |
|
| 114 |
You may also manually |
| 115 |
|
| 116 |
* Set hint change-over points |
| 117 |
* Set counter groups for a glyph |
| 118 |
|
| 119 |
These do not set the "Don't AutoHint" bit. |
| 120 |
|
| 121 |
|
| 122 |
Manual Hint Substitution Points |
| 123 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 124 |
|
| 125 |
FontForge's :menuselection:`Hints --> Hint Substitution Pts` command will |
| 126 |
automatically figure out where hint substitution should occur, but if this isn't |
| 127 |
good enough you may do it manually with the |
| 128 |
:ref:`Element->Get Info <getinfo.HintMask>` command (when the selection is a |
| 129 |
single point to which you want to attach a hintmask). |
| 130 |
|
| 131 |
If a glyph has conflicting hints then the first point in the glyph (the first |
| 132 |
point on the first contour) MUST have a hintmask attached to it. If it does not, |
| 133 |
the FontForge will automatically figure substitution points when it generates |
| 134 |
the font. Other points are not required (but may) have a hintmask. |
| 135 |
|
| 136 |
The hintmask specifies what hints should be active when that point is |
| 137 |
positioned, and will control all subsequent points until a new hintmask is |
| 138 |
established. So in the following example, the selected point (on left) has the |
| 139 |
highlight hints active at it, In the glyph view the currently active stems are |
| 140 |
drawn much darker than the inactive ones. Points with hintmasks attached to |
| 141 |
them have circles drawn around them. |
| 142 |
|
| 143 |
.. flex-grid:: |
| 144 |
|
| 145 |
* - .. image:: /images/charwithhintmask.png |
| 146 |
- .. image:: /images/hintmaskinfo.png |
| 147 |
|
| 148 |
Remember to hold the control key down when making disjoint selections. |
| 149 |
|
| 150 |
.. _hinting.Counter: |
| 151 |
|
| 152 |
Manual Counter Groups |
| 153 |
^^^^^^^^^^^^^^^^^^^^^ |
| 154 |
|
| 155 |
FontForge also has a :menuselection:`Hints --> Auto Counter` command which tries |
| 156 |
to figure out what stems form a counter group. |
| 157 |
|
| 158 |
Again you can do this manually, with the :ref:`Counter <charinfo.CounterMasks>` |
| 159 |
pane of the :menuselection:`Element --> Char Info` dialog. When creating a new |
| 160 |
counter group you are presented with a dialog very similar to the one above in |
| 161 |
which you must select a set of hints that bound a set of counters. |
| 162 |
|
| 163 |
|
| 164 |
The Private dictionary |
| 165 |
^^^^^^^^^^^^^^^^^^^^^^ |
| 166 |
|
| 167 |
This contains font-wide hinting information. Things like: The standard width of a |
| 168 |
stem in the font (StdVW, StdHW), The standard height of capitals and lower case |
| 169 |
letters (BlueValues, OtherBlues), and so forth. These live in the PostScript |
| 170 |
Private dictionary. Once you have hinted your font fontforge can generate |
| 171 |
reasonable values for these settings (But you must have hinted the font first!) |
| 172 |
-- See the [Guess] button in the |
| 173 |
:ref:`Element->Font Info->PS Private <fontinfo.Private>` dialog. Then once you |
| 174 |
have generated BlueValues you should rehint the font (the hints depend on the |
| 175 |
BlueValues, just as the BlueValues depend on the hints:-). |
| 176 |
|
| 177 |
|
| 178 |
Hints and previously existing fonts. |
| 179 |
------------------------------------ |
| 180 |
|
| 181 |
FontForge will not be able to convert TrueType instructions into PostScript |
| 182 |
hints when it reads a TrueType font (the format is too complex, there are too |
| 183 |
many possibilities, instead FontForge stores all the truetype instructions and |
| 184 |
writes them back out uninterpreted). |
| 185 |
|
| 186 |
From a Type1 font it will happily read all the hints in a glyph, and keep track |
| 187 |
of hint substitution points. It will not read counter hints though. |
| 188 |
|
| 189 |
In an OpenType (Type2) font FontForge will read in all the hints, keep track of |
| 190 |
hint substitution points and the counter hints. |
| 191 |
|
| 192 |
|
| 193 |
Hinting and TrueType |
| 194 |
-------------------- |
| 195 |
|
| 196 |
FontForge can auto-instruct a truetype font |
| 197 |
(:menuselection:`Hints --> AutoInstr`). FontForge also allows you the somewhat |
| 198 |
arcane practice of editing glyph instruction programs directly |
| 199 |
(:menuselection:`Hints --> Edit Instructions`). |
| 200 |
|
| 201 |
FontForge's Auto Instructor bases its output on the PostScript Stem Hints, the |
| 202 |
contents of the Private dictionary, and diagonal stems. You can create diagonal |
| 203 |
stems manually (:menuselection:`Hints --> Add DHint`), or you can let the |
| 204 |
autohinter do this for you |
| 205 |
(:menuselection:`File --> Preferences --> PSHints --> DetectDiagonalStems`). |
| 206 |
|
| 207 |
Please look at the :doc:`page on instructing fonts </ui/dialogs/ttfinstrs>`. |
| 208 |
|
| 209 |
|
| 210 |
Hint questions: |
| 211 |
--------------- |
| 212 |
|
| 213 |
I find the hint documentation inadequate for me to do a good job at hinting. |
| 214 |
|
| 215 |
* Section 2.4 of |
| 216 |
`T1_Supp.pdf <http://adobe-type-tools.github.io/font-tech-notes/pdfs/5015.Type1_Supp.pdf>`__ |
| 217 |
says that vertical counters are offset from the lbearing, but the example 2.6 |
| 218 |
shows them being offset from 0. |
| 219 |
* In `Type2 <http://adobe-type-tools.github.io/font-tech-notes/pdfs/5177.Type2.pdf>`__ is |
| 220 |
it ok to use Counter mask if LanguageGroup is not 1 and the stems don't fit into |
| 221 |
a \*stem3 pattern? Or can cntrmask only be used for \*stem3 in latin letters? |
| 222 |
* .. image:: /images/NoPointHint.png |
| 223 |
:align: right |
| 224 |
|
| 225 |
How do hints work? Is a hint meaningful if there are no points associated with |
| 226 |
it? As in the "O" at right, where the two vertical stems have no points |
| 227 |
associated with them. |
| 228 |
* Is it meaningful for a hint to have points only on one side of it? Can |
| 229 |
reasonable hints be written for the serif cap above left? |
| 230 |
|
| 231 |
:ref:`Overview of Hinting in PostScript and TrueType <overview.Hints>`. |
| 232 |
|
| 233 |
:doc:`Hinting menu. </ui/menus/hintsmenu>` |