freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ft-devel] ttfautohint 0.6 has been released


From: Werner LEMBERG
Subject: Re: [ft-devel] ttfautohint 0.6 has been released
Date: Sat, 31 Dec 2011 16:12:25 +0100 (CET)

> Today in the morning, while still dozing, I had a great idea how to
> largely simplify hinting of composite glyphs, and which solves the
> Roboto issue at the same time.  In particular, I believe that I've
> found a way to completely avoid fiddling with point indices.

Following this route I shot myself in the foot :-(

Some details:

Let's assume that we have glyph `Agrave', a composite of `A' and
`grave'.  Before version 0.6, ttfautohint hinted `A' first, then
`grave', and the hinted subglyphs got glued together afterwards.

In 0.6, however, ttfautohint works differently: It now hints the whole
glyph, this is, composites get recursively expanded so that they form
simple glyphs, then hints are applied -- this is the normal working
mode of FreeType's autohinter.  Obviously, this gives better rendering
results because the autohinter can consider the glyph's complete
shape.  The only drawback is an increased output font size since more
glyphs are fully hinted.

One problem, however, must be solved: We have to deactivate hinting
for subglyphs (which usually are used as normal glyphs also) so that
nothing but the final bytecode of the composite gets executed.

The trick introduced in 0.6 is to prepend a composite called
`.ttfautohint', a dummy glyph with a single point, and which has a
single job: Its bytecode increases a CVT register (I call it
`cvtl_is_subglyph'), indicating that we are within a composite glyph.
Returning to our example, `Agrave' now consists of three subglyphs:
`.ttfautohint', `A', and `grave' (in this order).  The bytecode
generated by ttfautohint has been slightly modified so that
`cvtl_is_subglyph' is honoured, and the bytecode of the composite
glyph decrements this counter accordingly:

  bytecode of        action
  ---------------------------------------------------------------
  .ttfautohint       cvtl_is_subglyph += 1 (now: 1)
  A                  do nothing because cvtl_is_subglyph > 0
  grave              do nothing because cvtl_is_subglyph > 0
  Agrave             cvtl_is_subglyph -= 1 (now: 0)
                     apply hints because cvtl_is_subglyph == 0

The trickiest part was to adjust glyph point indices since each
`.ttfautohint' subglyph shifts all following indices by one.  This
must be done for both the bytecode and one subformat of GPOS anchor
tables.

Back to my `great idea'.  The Roboto font makes ttfautohint crash
because I didn't consider the case that a composite glyph references
an empty glyph.  In this font, `nonbreakingspace' contains `space' as
its only subglyph.  But wait: What if I use this technique also?
Bingo!  The new code which I have been writing the last few days
replaces the simple glyph `.ttfautohint' with a composite glyph,
referencing an empty glyph.  Doing so I can prepend the necessary
bytecode to increase the counter while no contour gets added so that
point indices stay the same.

Very, very unfortunately this approach fails with FreeType, as I have
discovered today: Due to a bug it executes bytecode only if there is
at least one contour.  Apparently noone has ever considered the
construction which I envisioned while dozing...  Maybe other engines
implement a similar shortcut; I've asked this question on the OpenType
list.

Even if other TrueType engines handle this case correctly, I have to
reject the new route because I can't expect that all applications
which use FreeType immediately upgrade to the newest version.

Anyway, 0.6.1 is coming soon (with point index shifts)!


    Werner



reply via email to

[Prev in Thread] Current Thread [Next in Thread]