Bug 163151 - vertical cell orientation: Chinese glyphs not displayed as rotated
Summary: vertical cell orientation: Chinese glyphs not displayed as rotated
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: CJK Vertical-Text
  Show dependency treegraph
 
Reported: 2024-09-25 15:16 UTC by Justin L
Modified: 2024-09-26 14:59 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
test_chinese_vertical.doc: Latin characters (A B C) are displayed rotated, but not the Chinese characters (26.00 KB, application/msword)
2024-09-25 15:16 UTC, Justin L
Details
test_chinese_vertical.pdf: page 1 is how it looks in Word 2010, and page 2 is how it is displayed in LO (91.51 KB, application/pdf)
2024-09-25 15:20 UTC, Justin L
Details
Eaxmple from the blog (10.85 KB, image/png)
2024-09-26 14:59 UTC, Timur
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Justin L 2024-09-25 15:16:57 UTC
Created attachment 196679 [details]
test_chinese_vertical.doc: Latin characters (A B C) are displayed rotated, but not the Chinese characters

In test_chinese_vertical.doc, the table properties are set so that the "text flow" has a "text orientation" of "Vertical (top to bottom)". The effect is that the characters should be rotated 90 degrees clockwise. While A, B, and C are rotated, the Chinese glyphs are not.

OOo 3.3 already looks like this.

There is code specifically intended to address this (or a similar) situation in vcl/source/gdi/CommonSalLayout.cxx's GenericSalLayout::LayoutText.

    // Characters with U and Tu vertical orientation should
    // be shaped in vertical direction. But characters
    // with Tr should be shaped in vertical direction
    // only if they have vertical alternates, otherwise
    // they should be shaped in horizontal direction
    // and then rotated.
    // See http://unicode.org/reports/tr50/#vo
    if (aVo == U_VO_UPRIGHT || aVo == U_VO_TRANSFORMED_UPRIGHT ||
       (aVo == U_VO_TRANSFORMED_ROTATED &&
            HasVerticalAlternate(aChar, aVariationSelector)))
    {
        aDirection = HB_DIRECTION_TTB;
    }

For this particular document, if we do NOT set the direction to HB_DIRECTION_TTB, then it displays the way we want it to.

Or, if nGlyphFlags is not set to GlyphItemFlags::IS_VERTICAL, then the Chinese characters remain rotated.
Comment 1 Justin L 2024-09-25 15:20:32 UTC
Created attachment 196680 [details]
test_chinese_vertical.pdf: page 1 is how it looks in Word 2010, and page 2 is how it is displayed in LO
Comment 2 Ming Hua 2024-09-26 13:00:00 UTC
I don't know much about MS Word specifications, but I want to chime in that for East Asian vertical text users (currently AFAIK only Japan and Taiwan use it in regular daily life), Han characters (Kanji) and Japanese Hiragana/Katakanas are supposed to be shown upright.  That is, we prefer the way LO display it, and would consider Word 2010 "wrong".

Of course, the example document is constructed in a rather strange way, it is essentially eight lines (rows for horizontal text, "columns" for vertical text) with one character in each line.  I'm not sure how a regular multiple-character line text would display in a similar setup.

I'm from mainland China, and don't use vertical text much, either in LO or with MS format.  But I would urge any developer working on this to consult with East Asian community/users first, before deciding we want to emulate MS Word's behavior.
Comment 3 Timur 2024-09-26 14:59:34 UTC
Created attachment 196725 [details]
Eaxmple from the blog

Someone else commented:

Considering examples from a Microsoft engineer (https://devblogs.microsoft.com/oldnewthing/20030929-02/?p=42363) and Unicode standard (https://unicode.org/reports/tr50/#vo) it seems that LibreOffice does the right thing, and Word has a bug.

From the blog:

Rotating text is problematic in languages that traditionally run vertically, such as Chinese. Since you probably don’t have Chinese fonts installed, pretend that X, Y, and Z are the Chinese characters for your name. In traditional vertical text, it would be written as shown in Example 1 below. Notice that the English text is rotated clockwise. This preserves the top-to-bottom reading order.
As a concession to Western influences, it is permissible to render Chinese characters left-to-right, in which case your name would be written as “XYZ (Amy Smith)”.
Compare this to the traditional Western way of rotating text. Text which would normally be rendered as “Amy Smith” is rotated counter-clockwise and rendered as shown in Example 2.
Now consider what happens if you take a Chinese name rendered the Western way, “XYZ (Amy Smith)”, then rotate the Western way, resulting in Example 3. Notice that from a Chinese point of view, everything is upside-down! The character that is supposed to be at the top (X) is now at the bottom.