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

How to split a string into different WritingSystems/ScriptRuns ? #225

Open
ststeiger opened this issue Sep 7, 2021 · 0 comments
Open

How to split a string into different WritingSystems/ScriptRuns ? #225

ststeiger opened this issue Sep 7, 2021 · 0 comments

Comments

@ststeiger
Copy link

ststeiger commented Sep 7, 2021

Is there any example on how to best split a string into different WritingSystems aka ScriptRuns ?
E.g. I have this string Hello World Привет мир مرحبا بالعالم 你好世界 and I want to have it separated by font support.
So if font file 1 supports Latin, font file 2 supports Cyrillic, font file 3 supports Arabic, font file 4 supports Chinese,
e.g. more or less exactly as with the Google Noto fonts, the ScriptRuns would be:

Hello World
Привет мир
مرحبا بالعالم
你好世界

I want to split the string into its font-file parts, so I can draw a multi-language string with SkiaSharp:
For that, I'd like to create a list of Tuples, with the string-part, and the typeface-instance.
So far, I can take each word and figure out the font file by checking if each glyph is in the font file.
Is there no better way, such as reading the codepoint-range/ranges from the font file, and checking if character x is in said range ?
I've seen code in Typography.TextBreak -> ScriptTagsAndLanguageSystemTags ->UnicodeRangeFinder -> GetUniCodeRangeFor that goes into that direction. but it doesn't read any font file, it just checks the range of the codepoint.

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

1 participant