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

Implement half-width glyph substitution #12

Merged
merged 2 commits into from
Sep 17, 2023
Merged

Implement half-width glyph substitution #12

merged 2 commits into from
Sep 17, 2023

Conversation

otya128
Copy link
Contributor

@otya128 otya128 commented Sep 17, 2023

TR-B14 and TR-B15 specify that the MSZ control code can be used to make 1-6 rows(区) and alphanumeric, hiragana, and katakana characters halfwidth.
Previously, the MSZ was rendered by shrinking fullwidth characters, which halved the width of the stroke and rendered it terribly.
#9 improved alphanumeric rendering, but requires halfwidth fonts to display properly.
This PR adds the ability to use the hwid feature of a font and replace it with the halfwidth glyphs contained in the font.
This improves rendering if the font is supported.

Most fonts do not contain halfwidth glyphs at all or only partially. For example, MS Gothic and M+ do not contain any at all. Noto Sans and Source Han Sans contain only halfwidth alphanumeric characters.

Adobe-Japan1, a commonly used character collection, defines halfwidth hiragana, halfwidth katakana, and halfwidth symbols. Although it does not cover all of 1-6 rows, Adobe-Japan1 OpenType fonts contain glyphs for commonly used halfwidth characters. Also, even TrueType fonts that are not Adobe-Japan1, such as Meiryo, may contain halfwidth glyphs defined by Adobe-Japan1.

image
image

FreeType, モトヤマルベリ Pr6 W4, SetReplaceMSZFullWidthAlphanumeric(false), SetReplaceMSZFullWidthJapanese(false), SetReplaceMSZHalfWidthGlyph(false)
FreeType, モトヤマルベリ Pr6 W4, SetReplaceMSZFullWidthAlphanumeric(true), SetReplaceMSZFullWidthJapanese(true), SetReplaceMSZHalfWidthGlyph(false)
FreeType, モトヤマルベリ Pr6 W4, SetReplaceMSZHalfWidthGlyph(true)
FreeType, Noto Sans JP Regular, SetReplaceMSZFullWidthAlphanumeric(false), SetReplaceMSZFullWidthJapanese(false), SetReplaceMSZHalfWidthGlyph(false)
FreeType, Noto Sans JP Regular, SetReplaceMSZFullWidthAlphanumeric(true), SetReplaceMSZFullWidthJapanese(true), SetReplaceMSZHalfWidthGlyph(false)
FreeType, Noto Sans JP Regular, SetReplaceMSZHalfWidthGlyph(true)

@xqq
Copy link
Owner

xqq commented Sep 17, 2023

Thank you for your great contribution!
Merged.

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

Successfully merging this pull request may close these issues.

None yet

2 participants