#Multiple fonts, each for a script with OTF features appled

22 messages · Page 1 of 1 (latest)

glass plinth
#

?r ```
#show text.where(lang: "de"): set text(font: "Comic Neue", red)
#show text.where(lang: "zh"): set text(font: "Noto Sans CJK SC", yellow)

Hello, old bean!
#text(lang: "de", region: "at")[Seă's, Åidă!]
#text(lang: "zh", region: "tw")[你好,老人家!]

glass plinth
#

Notice how it doesn't work for the apostrophe.

#

Has to be a bug.

glass plinth
#

?r ```
#let fonts = (
en: "Computer Modern",
de: "Comic Neue",
zh: "Noto Sans CJK SC",
)
#let colors = (
en: blue,
de: red,
zh: yellow,
)
#show text: it=> text(
font: fonts.at(default: fonts.en, text.lang),
colors.at(default: colors.en, text.lang),
it,
)

Hello, old bean!
#text(lang: "de", region: "at")[Seă's, Åidă!]
#text(lang: "zh", region: "tw")[你好,老人家!]

glass plinth
#

That way you could concisely associate the font & other features, but also lead that structured data from TOML, YAML …

marsh hollyBOT
open plover
#

I'd recommend you define functions for typesetting with each language instead

#

Text show rules just aren't robust enough to be used for this

random fiber
#

Yeah there definitely should be an easier way of doing it

echo lynx
#

you cannot do this easily at this moment

#

typst lacks virtual font and unicode-range support. this is a tracking issue for this

#

for now you will have to define functions like #ar-text() #en-text(), set relevant properties, and call them whenever you need use them

#

FYI

#

mostly yes. but the ar-text, en-text approach doesnt use show rule and might be more maintainable

echo lynx
#

i have trouble understanding what you are looking for in "it would be lovely to have..."

iiuc you can make several functions, to set correct styles and fonts. and you can compose them freely to achieve what you want

#

about document: it's another question. the page you posted is the reference(but not the guide)