freetype
[Top][All Lists]
Advanced

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

Re: [Freetype] Font files and vertical text


From: suzuki toshiya
Subject: Re: [Freetype] Font files and vertical text
Date: Sat, 15 May 2021 15:16:25 +0900
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1

Dear Mr. Hallikainen,

On 2021/05/15 4:47, Harold Hallikainen wrote:
I am trying to understand how font files are used when writing vertically
(such as for Japanese text). I'm pretty new to this, so please excuse my
ignorance.

Thanks, but I suggest, please do not try to understand it completely
by FreeType document. The modern applications trying to support the
CJK vertical writing mode use more complicated frameworks, like HarfBuzz.
The support of CJK vertical writing mode in FreeType is very fundamental
level. No line breaking, no auto-rotation, etc etc.

https://www.freetype.org/freetype2/docs/glyphs/glyphs-3.html shows the
horizontal and vertical baselines for horizontal and vertical text. I
THINK the glyph "drawing instructions" are relative to the horizontal
origin. When writing horizontally, the horizontal origin of a character is
placed at the pen position passed into the renderer, and the glyph is
drawn with reference to that position. The next character starts with its
pen position at the old pen position plus the AdvanceWidth.

For vertical text, it looks like there is a vertical origin that is
typically centered above the glyph. The Y offset from the horizontal
origin is either in the VORG table or can be calculated from yMax and the
top side bearing. It is very unclear to me how one determines the X offset
from the horizontal origin to the vertical origin. Is there a drawing or
something that shows how this is done? When rendering vertical text, I
assume the renderer is passed a pen position for the top character. The
renderer then applies the offset to get to the horizontal origin and draws
the glyph based on the horizontal origin (just as for horizontal text). Is
this anything close to correct?

The x position of the top pen position in the vertical writing mode
can be calculated by (advance / 2) - bearingX, both can be obtained
from hmtx table.

The y position of the top pen position in the vertical writing mode,
measured in the glyph-internal coordinate system, can be calculated
by yMax + bearingY. The bearingY can be obtained from vmtx table.
The yMax can be obtained from the glyph instructions.

Each glyph instruction in the glyf table has its header, which provides
the glyph bounding information, xMin, yMin, xMax, yMax.

Character positions in a cell change depending on whether the character is
in a horizontal or vertical string. For example, in Japanese, the comma in
horizontal text is low and to the left (so it "hugs" the previous word).

Such features are now regarded as a part of the line breaking features,
it is the task of the text layout system in the higher layer,
not the task of the FreeType rendering a glyph image from a font file.

Please take a look on Unicode Standard Annex #50 (to figure the terminology),
JLReq (https://www.w3.org/TR/jlreq/ to see the tons of the conventions
which Japanese experts hope). They are totally too much to put in FreeType.

In vertical text, it is high and to the right (so it, again, "hugs" the
previous word since text reads top to bottom and columns right to left).
It sees that this difference could be handled by changing the offset
between the horizontal and vertical position. It could also be handled
through glyph substitution. It could also be handled through the use of a
separate Unicode code point (for example, U+3001 for horizontal text and
U+FE11 for vertical text).

Using or avoiding the compatibility characters in Unicode is highly
dependent with the (computational) cultural region. These vertical
glyphs in the compatibility characters were introduced for legacy
character encodings in PRC or Taiwan, not those in Japan. Japanese
industrial character sets do not separate the codepoints for the
glyph for the horizontal and vertical writing mode, so most plain
texts produced by the software customized for Japanese market do
not include U+FE11, at least, most users are not trained how to input
them.

Hope if I could answer some of your questions.

Regards,
mpsuzuki



reply via email to

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