[HarfBuzz] Problems with TTB Japanese

Behdad Esfahbod behdad.esfahbod at gmail.com
Thu Jun 11 17:17:40 PDT 2015


On 15-06-11 12:14 AM, Simon Cozens wrote:
> Hello! I am working on adding vertical typesetting support to SILE, and
> have come across a couple of issues.
> 
> The first is that all characters with direction set to TTB seem to have
> x_offset and y_offset positions set even when this does not make sense:
> 
>> a = "aあ"
> 
>> SILE.call("font", { family = "MS Gothic", direction = "TTB" })
>> SILE.shaper:shapeToken(a, SILE.font.loadDefaults({}))
> {
>   {
>     codepoint = 68,
>     depth = -0.078125,
>     height = 5.4296875,
>     name = "",
>     width = 5,
>     x_offset = -2,
>     y_offset = -8,
>   },
>   {
>     codepoint = 2102,
>     depth = 0.8984375,
>     height = 8.0859375,
>     name = "",
>     width = 10,
>     x_offset = -5,
>     y_offset = -8,
>   },
> }
> 
> This happens for all fonts. I don't know why a fairly normal Japanese
> character would be set downwards and to the left; it's causing things
> not to line up to the kihonhanmen (character grid). Am I right in
> thinking the idea is to cause Japanese and non-Japanese characters to be
> aligned on the center axis?

This happens because HarfBuzz thinks your font instance is set for horizontal
typesetting.  That is, this returns offsets that work with a font that has
origin at baseline-left.  What you expect instead can be achieved by
configuring the font to use a top-center origin.

What font funcs are you using?  You need to provide the get_glyph_h_origin /
get_glyph_v_origin functions for that.


> The other problem I just solved by talking to the rubber duck.

Haha.  Awesome.


More information about the HarfBuzz mailing list