Skip to content

OHOS: Also push HarmonyOS Sans SC & HarmonyOS Sans TC as candidate fallback fonts when special characters are encountered. - #47116

Merged
yezhizhen merged 1 commit into
servo:mainfrom
RichardTjokroutomo:ohos-font
Aug 11, 2026
Merged

yezhizhen merged 1 commit into
servo:mainfrom
RichardTjokroutomo:ohos-font

Conversation

@RichardTjokroutomo

@RichardTjokroutomo RichardTjokroutomo commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Currently, fallback_font_families() only push HarmonyOS Sans SC & HarmonyOS Sans TC when a character is a Chinese character (e.g. 你, 我, etc.). However, there are also Chinese special characters such as Chinese brackets ( 【】). These special characters are not considered as Han scripts by unicode_script. As a result, these special characters won't be rendered on OHOS devices.

Therefore, we need to also consider HarmonyOS Sans SC & HarmonyOS Sans TC if we encounter special characters.

Testing: Manual testing.

@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Aug 10, 2026
@RichardTjokroutomo RichardTjokroutomo changed the title OHOS: Also push HarmonyOS Sans SC & TC as candidate fallback fonts when special characters are encountered. OHOS: Also push HarmonyOS Sans SC & HarmonyOS Sans TC as candidate fallback fonts when special characters are encountered. Aug 10, 2026
@RichardTjokroutomo
RichardTjokroutomo marked this pull request as draft August 10, 2026 06:55
@RichardTjokroutomo
RichardTjokroutomo marked this pull request as ready for review August 10, 2026 07:16

@yezhizhen yezhizhen left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +442 to +443
Script::from(options.character) == Script::Common
{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems too broad. But I don't know how this system works.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From wikipedia,

However, many characters—those that are not part of a formal natural-language writing system or are unified across many writing systems—may be used in more than one script (for example, currency signs, symbols, numerals, and punctuation marks). In these cases Unicode defines them as belonging to the "common" script (ISO 15924 code "Zyyy").

I think this is what we want? After all, brackets & fullstops exist in more than one language

@yezhizhen yezhizhen Aug 10, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is what we want?

I don't think we want to change Latin punctuation.

I think we should do Unicode block match right below.
UnicodeBlock::CJKSymbolsandPunctuation

@RichardTjokroutomo RichardTjokroutomo Aug 10, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, I'm not aware of this before. let me check it out

edit: oh ok; this one is more specific

Signed-off-by: Richard Tjokroutomo <richard.tjokro2@gmail.com>
@yezhizhen

Copy link
Copy Markdown
Member

@jschwe Does this look ok?

@jschwe

jschwe commented Aug 11, 2026

Copy link
Copy Markdown
Member

Hmm, I guess we can go ahead with this for now. There will be more cases like this though, where we are missing the fallback characters.

@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Aug 11, 2026
@yezhizhen
yezhizhen added this pull request to the merge queue Aug 11, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Aug 11, 2026
Merged via the queue into servo:main with commit eff9ff0 Aug 11, 2026
33 checks passed
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Aug 11, 2026
shubhamg13 pushed a commit to shubhamg13/servo that referenced this pull request Aug 31, 2026
Follow up from [servo#47116](servo#47116), now
more CJK blocks are covered by `HarmonyOS Sans SC` & `HarmonyOS Sans
TC`.

Testing: Manual testing.

Signed-off-by: Richard Tjokroutomo <richard.tjokro2@gmail.com>
@RichardTjokroutomo
RichardTjokroutomo deleted the ohos-font branch September 4, 2026 10:03
@RichardTjokroutomo

Copy link
Copy Markdown
Contributor Author

Hmm, I guess we can go ahead with this for now. There will be more cases like this though, where we are missing the fallback characters.

Yep. After some testing on different test sites, I noticed we hit the fallback path way too often; so up next we can fix the font matching procedure.

RichardTjokroutomo added a commit to RichardTjokroutomo/servo that referenced this pull request Oct 6, 2026
…e fallback fonts when special characters are encountered. (servo#47116)

Currently, `fallback_font_families()` only push `HarmonyOS Sans SC` &
`HarmonyOS Sans TC` when a character is a Chinese character (e.g. `你`,
`我`, etc.). However, there are also Chinese special characters such as
Chinese brackets ( `【】`). These special characters are not considered as
Han scripts by `unicode_script`. As a result, these special characters
won't be rendered on OHOS devices.

Therefore, we need to also consider `HarmonyOS Sans SC` & `HarmonyOS
Sans TC` if we encounter special characters.

Testing: Manual testing.

Signed-off-by: Richard Tjokroutomo <richard.tjokro2@gmail.com>
RichardTjokroutomo added a commit to RichardTjokroutomo/servo that referenced this pull request Oct 6, 2026
Follow up from [servo#47116](servo#47116), now
more CJK blocks are covered by `HarmonyOS Sans SC` & `HarmonyOS Sans
TC`.

Testing: Manual testing.

Signed-off-by: Richard Tjokroutomo <richard.tjokro2@gmail.com>
Psychpsyo pushed a commit to Psychpsyo/servo that referenced this pull request Oct 12, 2026
Follow up from [servo#47116](servo#47116), now
more CJK blocks are covered by `HarmonyOS Sans SC` & `HarmonyOS Sans
TC`.

Testing: Manual testing.

Signed-off-by: Richard Tjokroutomo <richard.tjokro2@gmail.com>
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.

4 participants