[HarfBuzz] HarfBuzz 1.0 API; the message you were hoping would never come

James Clark jjc at jclark.com
Fri Jan 3 03:28:09 PST 2014


On Fri, Jan 3, 2014 at 5:07 PM, Jonathan Kew <jfkthame at googlemail.com>wrote:

>
>>  In order to do fallback,
>> you need to do character to glyph mapping.
>>
>
> Not necessarily. You need to know the character repertoire supported by
> the font, but you may not need to actually map to glyphs. In Firefox, for
> instance, font fallback is done based on a per-font *bit* map of supported
> Unicode codepoints. So at the font fallback stage, we know whether the
> character is present, but do not map it to a glyph.


Isn't this introducing an additional step that's not strictly necessary?
Presumably the bitmap is constructed from the font's cmap (unless you use
the OS/2 ulUnicodeCodeRange*, which wouldn't be 100% accurate).

 If the application is
>> expected to do fallback before calling harfbuzz, why does harfbuzz
>> expect chars rather than glyphs as input to the shaping process?
>>
>
> One good reason, at least, would be that shaping requires harfbuzz to have
> access to Unicode character properties, and it is not necessarily possible
> to derive these from glyph IDs.


Good point.

 I
>> would have expected there to be some application callback that harfbuzz
>> would call when there is a need to do fallback; the application would
>> use this to tell harfbuzz how to handle this situation for this
>> particular character. Some of these harfbuzz could handle by itself,
>> others would require cooperation between the application and harfbuzz.
>>
>
> This doesn't fit into the harfbuzz model, where the "unit of work" is a
> buffer that is shaped with one specified font according to the rules of one
> script and language system.
>

I agree that the "unit of work" has to be one font (in a particular size)
in one script/language system/direction.  I don't see that as a limitation
of harfbuzz, but rather of OpenType.  However, I'm not sure that this is
necessarily incompatible with the sort of callback scheme I was thinking of.

In doing fallback for a particular font/code point, we can distinguish two
categories of fallback:

a) something that replaces the code point by a sequence of one or more code
points (possibly with positioning adjustments) in the same font/size as was
requested

b) anything else

In the case of (a), the callback can tell harfbuzz what the replacement
sequence is, and harfbuzz can then incorporate it into the buffer.

In the case of (b), the callback can tell harfbuzz that it needs to be
handled as a separate "unit of work". This would cause harfbuzz to shape
only up to (but not including) the problematic code point, and return a
value to the application indicating where it has stopped.


> Using compatibility decompositions to provide a fallback rendering would
> be one of the options such a higher-level component might use. Pushing this
> down into HB itself seems quite problematic to me, given the huge variety
> of types of compatibility decompositions, some of which require some kind
> of additional styling to avoid corrupting the intended meaning of the data.


I agree.  One important case is the various kinds of spaces (2000-200B).
 Just using the compatibility decomposition is suboptimal.  If I have an em
space, I don't want it replaced by just a space, but by a space with a 1 em
width.

James
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/harfbuzz/attachments/20140103/09107612/attachment.html>


More information about the HarfBuzz mailing list