Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Font rendering with vertical text #890

Open
sugi2000 opened this issue Feb 27, 2025 · 11 comments
Open

Font rendering with vertical text #890

sugi2000 opened this issue Feb 27, 2025 · 11 comments

Comments

@sugi2000
Copy link

sugi2000 commented Feb 27, 2025

I appreciate that resvg supports vertical writing-mode. When testing with Japanese vertical text, I noticed some characters are rotated incorrectly.

The issue appears to affect specific characters like 'yoon', 'sokuon' in vertical writing mode.
https://en.wikipedia.org/wiki/Y%C5%8Don
https://en.wikipedia.org/wiki/Sokuon

As shown in the attached image:

  • Left: SVG rendered correctly in browser
  • Right: svg2png-wasm output using resvg (incorrect rotation)

Image

@RazrFalcon
Copy link
Collaborator

Can you post the input SVG or at least the string itself?

@sugi2000
Copy link
Author

Here is the text element.

<text style="writing-mode: vertical-rl;">(すーっ)</text>

@RazrFalcon
Copy link
Collaborator

This character is marked as Transformed typographically, with fallback to Upright in unicode-vo. But we handle only Upright in usvg.
Therefore I assume this code should be adjusted.

@sugi2000
Copy link
Author

Thank you for pointing this out. I am wondering some characters like the following are rotated correctly:

  • U+FF08 FULLWIDTH LEFT PARENTHESIS
  • U+30FC KATAKANA-HIRAGANA PROLONGED SOUND MARK

https://www.unicode.org/reports/tr50/tr50-19.html

@sugi2000
Copy link
Author

I saw your unicode-vo code. What is the difference between Orientation::TransformedOrUpright and Orientation::Upright?

@RazrFalcon
Copy link
Collaborator

What is the difference between Orientation::TransformedOrUpright and Orientation::Upright?

I have absolutely no idea...

@sugi2000
Copy link
Author

sugi2000 commented Feb 27, 2025

I understood the way the current code does it. It just rotates upright characters 90 degrees. That's why the parenthesis and prolonged sound mark are positioned slightly offset. But we should change the vertical glyph for these characters. The Japanese fonts have the vertical glyphs, but I don't know how to extract them.

@RazrFalcon
Copy link
Collaborator

The Japanese fonts have the vertical glyphs, but I don't know how to extract them.

Are you sure? Fonts can have vertical layout specific metrics, but not separate glyphs.
So the current code is correct, we just have to figure out how to improve it.

@sugi2000
Copy link
Author

Yes, I'm sure.

Especially in Japanese and Chinese text, when characters like U+2329 (〈) use different glyphs for horizontal and vertical writing, the substitution is specified in the font's GSUB (Glyph Substitution) table, and the placement information for the substituted glyph is obtained from the vmtx table.

Image
https://www.unicode.org/reports/tr50/tr50-19.html

@RazrFalcon
Copy link
Collaborator

GSUB and vmtx are already handled for us by harfbuzz/rustybuzz.
Either way, I would not have time to look into this anytime soon. Maybe someone would send a PR.

@sugi2000
Copy link
Author

Thank you. I hope someone would handle if orientation == Orientation::TransformedOrUpright.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants