| 1 |
Caveats about References |
| 2 |
======================== |
| 3 |
|
| 4 |
Different font formats place different restrictions on the use of references. |
| 5 |
This does NOT mean you should avoid references -- they are a useful way of |
| 6 |
encapsulating information even if the font format cannot support them directly. |
| 7 |
If FontForge finds a situation where it can't use a referred glyph as a reference |
| 8 |
it will fix it up somehow, usually this means replacing it with the equivalent |
| 9 |
outlines. |
| 10 |
|
| 11 |
Let us examine the most common font formats: |
| 12 |
|
| 13 |
.. object:: TrueType |
| 14 |
|
| 15 |
In TrueType any glyph may be referenced, and TrueType supports almost a full |
| 16 |
range of linear transformations that may be applied to a reference, however |
| 17 |
if a reference is scaled by 200% or more (or -200% or less) it cannot be |
| 18 |
represented in TrueType. |
| 19 |
|
| 20 |
TrueType also does not support mixing outlines and references. |
| 21 |
|
| 22 |
If you have a glyph containing a reference which cannot be used (or that |
| 23 |
mixes outlines and references) then ALL references will be converted to |
| 24 |
outlines during output. |
| 25 |
|
| 26 |
This means that any instructions in the glyph itself will be meaningless, and |
| 27 |
any instructions in referred glyphs will not be executed. |
| 28 |
|
| 29 |
NOTE: Just because general transformations are supported, it isn't always a |
| 30 |
good idea to use them. If you flip a reference, the rasterizer will probably |
| 31 |
have difficulties with it (its contours will run in the wrong direction). If |
| 32 |
you rotate a reference any instructions inside it will not work well. |
| 33 |
|
| 34 |
.. object:: Type1 |
| 35 |
|
| 36 |
Type1 (and Type2) fonts have the basic limitation that the only |
| 37 |
transformation that may be applied to a reference is translation no scaling, |
| 38 |
rotating or flipping are allowed. Type1 fonts have two different mechanisms |
| 39 |
for using references. The first is the simplest to describe. |
| 40 |
|
| 41 |
If you have a glyph which contains exactly two references to characters which |
| 42 |
are themselves part of the Adobe Standard Encoding, and one of those |
| 43 |
references has an identity transformation matrix applied to it (that is, it |
| 44 |
is not moved, scaled, rotated, flipped, etc.) and the width of the composite |
| 45 |
glyph is the same as the width of this referred glyph and the other is only |
| 46 |
translated (possibly by 0, but not scaled, rotated, flipped, etc.) THEN |
| 47 |
FontForge can generate two references (this is done with the 'seac' |
| 48 |
instruction). CID-keyed fonts do not support this. |
| 49 |
|
| 50 |
The implications of this are that this form of referencing is useless for |
| 51 |
non-latin scripts (except for glyphs shared by latin and another script, |
| 52 |
Greek and Cyrillic often share the glyph used for latin A). |
| 53 |
|
| 54 |
FontForge makes a slight extension, in that if you have a glyph which |
| 55 |
contains one single untranslated reference, then FontForge will add a dummy |
| 56 |
reference to the space glyph to make it fit the two reference requirement. |
| 57 |
|
| 58 |
The second format is more general in some ways but has more arcane |
| 59 |
restrictions imposed on it. PostScript fonts have the concept of |
| 60 |
"subroutines" which can be used to define the contours of several glyphs. |
| 61 |
FontForge's algorithm is quite complex and can depend on what other glyphs |
| 62 |
are referred to. But basically if a glyph contains no hint substitutions, nor |
| 63 |
flex hints it can be put into a subroutine. If it does contain these it can |
| 64 |
be put into a subroutine if it has not been translated. Even if one reference |
| 65 |
cannot be put into a subroutine, another may be (ie. TrueType references are |
| 66 |
an all or nothing affair, that is not true of PostScript subroutines). If a |
| 67 |
reference cannot be put in a subroutine, FF may still be able to put some of |
| 68 |
its components (assuming it is a glyph with references) in a subroutine. |
| 69 |
|
| 70 |
FontForge will recognize 'seac' as defining references, but it does not |
| 71 |
recognize subroutine calls. Use |
| 72 |
:ref:`Edit->Replace With Reference <editmenu.ReplaceRef>` after loading a |
| 73 |
Type1 font. |
| 74 |
|
| 75 |
FontForge can also break an outline into smaller segments and place those in |
| 76 |
subroutines these may be shared more easily among glyphs. They are no longer |
| 77 |
true references, but they will make the output font smaller. |
| 78 |
|
| 79 |
.. object:: Type2 ("OpenType") |
| 80 |
|
| 81 |
As above references may only be translated (not scaled, rotated, etc.). Type2 |
| 82 |
does not have anything equivalent to the 'seac' instruction (well, it sort of |
| 83 |
does, but the instruction is depreciated and FontForge will not generate it) |
| 84 |
but does support subroutines. |
| 85 |
|
| 86 |
Here a referenced glyph can be put into a subroutine if it contains no hint |
| 87 |
substitutions, or if it is not translated and none of the other components of |
| 88 |
the final composite contain any hints at all. Again this is not an all or |
| 89 |
nothing affair. |
| 90 |
|
| 91 |
And again FontForge can break glyphs into smaller segments which can be |
| 92 |
placed in subroutines and shared among glyphs. These are not true references |
| 93 |
but do make the font smaller. |
| 94 |
|
| 95 |
FontForge will not recognize any references when loading a Type2 (otf, cff, |
| 96 |
cef, gai) font. Use :ref:`Edit->Replace With Reference <editmenu.ReplaceRef>` |
| 97 |
after loading the font. |
| 98 |
|
| 99 |
.. object:: Type3 |
| 100 |
|
| 101 |
There are no restrictions on references. |
| 102 |
|
| 103 |
.. object:: SVG |
| 104 |
|
| 105 |
Does not seem to have an easy way of handling references. |