#Code that splits mixed-language strings and chooses fallback fonts? Itemize?

10 messages · Page 1 of 1 (latest)

glacial citrus
#

I'm curious about the code that splits by unicode ranges and uses different fonts to render the different parts of the string. Where in the flow does that happen?

We're using Opentype.js in our web-based CAD app, and I'd like to have backup fonts to not show rectangles when a particular font doesn't support the language that people put into our template.

glacial citrus
#

When processing text, Typst tries all specified font families in order until it finds a font that has the necessary glyphs. In the example below, the font Inria Serif is preferred, but since it does not contain Arabic glyphs, the arabic text uses Noto Sans Arabic instead.

https://typst.app/docs/reference/text/text/#parameters-font

Does this mean that it doesn't split the string on unicode ranges at the start, but just goes down the fallback list once it finds some unsupported characters?

The disadvantage in a web context is that we would need to keep loading the fonts in the fallback list until we find one that supports the characters. Knowing “this range is covered by Noto Emoji” would make that process faster.

Interested in the code that does fallback font search.

woven cloak
glacial citrus
#

Thanks for the pointer.

fervent schooner
fervent schooner
#

This is where it happens.

glacial citrus
fervent schooner