[HarfBuzz] About GSUB backtrack, lookahead glyph for first and last character
Richard Wordingham
richard.wordingham at ntlworld.com
Mon Jan 26 12:50:46 PST 2015
On Tue, 27 Jan 2015 00:12:41 +0900
Leone Kim <lordchiwoo at gmail.com> wrote:
> the problem is I can't figure it out how to organize backtrack,
> lookahead Glyph coverage for the first and last character (For
> example 'x' & 'g' in "xyzabcdefg")
> What should I set backtrack glyph for 'x' and lookahead glyph for 'g'?
No.
> every character i designed has
> 1 Ini (which has no previous latin glyph, but has latin glyph after
> it) 1 Fin (which has latin glypf in front of it, no latin glyph after
> itself) 26 Mid (which has latin glyph both front and end of it)
Conflating lookup and subtable, and falsely assuming one only
needed one medial form for each letter, I would proceed along the
following lines.
1) Map letters to isolated form, e.g. a.isol for 'a'.
2) Define a 'coverage' for letters, say 'letters'
3) Set up transforms such as the following. I use '|' to separate the
backtrack context (which may have length 0), input and lookahead
(which may have length 0).
-- Lookups in features:
lookup lookup_1 -- Make letters before another 'initial'.
type chained
| letter | letter
0 isolated_to_initial
end lookup
lookup lookup_2 -- Make letters after another 'medial' or 'final'.
type chained
letter | letter |
0 isolated_to_final_or_initial_to_medial
end lookup
-- Lookups outside features:
lookup isolated_to_initial
type single
a.isol > a.initial
b.isol > b.initial
...
end lookup
lookup isolated_to_final_or_initial_to_medial
type single
a.isol > a.final
a.initial > a.medial
b.isol > b.final
b.initial > b.medial
...
end lookup
Then truncated your example to "xyzag", cmap lookup would convert your
string to the glyph sequence
x.isol y.isol z.isol a.isol g.isol
Lookup 1 would convert it to
x.initial y.initial z.initial a.initial g.isol
Lookup 2 would convert it to
x.initial y.medial z.medial a.medial g.final
I think you'll find this much simpler than what you were looking at.
You will actually need extra lookups insides the features such as
lookup special_shapes
type chained
e.* | o.* | r.*
0 eor_form
end lookup
that use both a backtrack and a lookahead list. You can either go for
simplicity - make e.* a coverage for all types of 'e' - or more compact
lists in the GSUB table. In the latter case, you may then have
relevant questions about the order in which substitutions are
considered. I'd recommend avoiding such issues if possible, for there
is no guarantee that Micosoft, Apple and HarfBuzz will have the same
logic, even though HarfBuzz has been tested against Microsoft for many
fonts.
Richard.
More information about the HarfBuzz
mailing list