The test case image-svg-text-font does not work as expected
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
Direzione di ricerca
The issue points to tests/suite/visualize/image.typ lines 76–83 and the image-svg-text-font visual test. Start by reading that test and comparing its expected output with the reproduction and font selection results described here. Done means SVG text follows the font set by show image: set text(font: ...), with the visual test updated to capture the corrected behavior.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
The following test case implies that show image: set text(font: (…, …)) can control the font of <text> in SVG images.
chinese.svg in the current typst-dev-assets:
<svg xmlns="http://www.w3.org/2000/svg" width="250" height="24" viewBox="0 0 250 22">
<text x="0" y="10" font-size="10">此文本为中文。</text>
<text x="0" y="22" font-size="10">The text above is in Chinese.</text>
</svg>
However, if I add Source Han Sans TC VF (default weight: ExtraLight) to typst-dev-assets and rerun cargo testit (without editing any test case), then the Chinese text in the SVG changes from serif to sans-serif, indicating that the show-set rule does not really work:
Links
This test case was added in #2122. It attempted to fix #1154.
Background: #8991, typst/typst-dev-assets#18.
Further investigations
pdffonts shows that the Chinese characters in the reference PDF 10665a9d33a3ea4626a24fb49769456e_image-svg-text-font.pdf indeed use Noto Serif CJK SC.
However, that's because 为 in the text only exists in Noto Serif CJK SC, but not in Noto Serif CJK JP/KR/TC.
If I change it to #show image: set text(font: ("Roboto", "Noto Serif CJK JP")) (SC → JP) and rerun cargo testit, the live output still uses SC, even the hashes remain unchanged.
More tests
#set page(height: auto, width: auto, margin: 2em)
#set text(fallback: false)
#show image: set text(font: ("Libertinus Serif", "Noto Serif CJK SC"))
#image(bytes(
```svg
<svg xmlns="http://www.w3.org/2000/svg" width="80" height="30" viewBox="0 0 80 30">
<text x="0" y="10" font-size="10">骨返</text>
</svg>
```.text,
))
#pagebreak()
#image(bytes(
```svg
<svg xmlns="http://www.w3.org/2000/svg" width="80" height="30" viewBox="0 0 80 30">
<text x="0" y="10" font-size="10">此文本为中文。</text>
</svg>
```.text,
))
#pagebreak()
#image(bytes(
```svg
<svg xmlns="http://www.w3.org/2000/svg" width="80" height="30" viewBox="0 0 80 30">
<text x="0" y="10" font-size="10">骨返为</text>
</svg>
```.text,
))
#pagebreak()
#table(
columns: 2,
stroke: none,
..for locale in ("JP", "KR", "SC", "TC") {
(locale, text(font: "Noto Serif CJK " + locale)[骨返;此文本为中文。])
}
)
Compile the above document with typst compile a.typ --font-path …/dev-assets/files/fonts/ --ignore-system-fonts, and you'll get the following results:
- 骨返 in page 1 uses Noto Serif CJK JP.
- 此文本为中文。 in page 2 uses Noto Serif CJK SC.
- 骨返为 in page 3 uses Noto Serif CJK SC.
- For reference, page 4 shows the character coverages and glyph variants for Noto Serif CJK fonts.
$ pdffonts a.pdf -f 1 -l 1 # -f and -l specify the first and last page to examine
name type encoding emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
NKCZKJ+NotoSerifCJKjp-Regular-Identity-H CID Type 0C Identity-H yes yes yes 26 0
$ pdffonts a.pdf -f 2 -l 3
name type encoding emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
VXVQFG+NotoSerifCJKsc-Regular-Identity-H CID Type 0C Identity-H yes yes yes 32 0
$ pdffonts a.pdf -f 4 -l 4
name type encoding emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
MEASXG+LibertinusSerif-Regular-Identity-H CID Type 0C Identity-H yes yes yes 35 0
NKCZKJ+NotoSerifCJKjp-Regular-Identity-H CID Type 0C Identity-H yes yes yes 29 0
XMHHWR+NotoSerifCJKkr-Regular-Identity-H CID Type 0C Identity-H yes yes yes 38 0
VXVQFG+NotoSerifCJKsc-Regular-Identity-H CID Type 0C Identity-H yes yes yes 32 0
GABABY+NotoSerifCJKtc-Regular-Identity-H CID Type 0C Identity-H yes yes yes 41 0
Operating system
Linux, Windows
Typst version
- I am using the latest version of Typst
- Lingua principale
- Rust
- Stelle
- 57.2k
- Fork
- 1.8k
- Merge medio
- 1g 17h
- PR unite (30g)
- 22
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di typst/typst
-
bibliography feature request
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 2 giorni
-
bug foundations
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
typst/typst#9047 · 2 commenti · 2 reazioni ·
I maintainer di solito rispondono entro 2 giorni
-
`h3` font size is too smallApertadocs-infra
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
typst/typst#9020 · 2 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
typst/typst#8987 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
docs-infra
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
typst/typst#8934 · 2 commenti ·
I maintainer di solito rispondono entro 2 giorni
Issue simili
-
ライブラリを追加Apertapriority middle
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
KATO-Hiro/AtCoderClans#13015 ·
I maintainer di solito rispondono entro 1 giorno
-
needs-review
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
UCS-Care-Group/mailcraft#1429 ·
I maintainer di solito rispondono entro 1 giorno
-
priority: medium ready
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
TusanHomichi/PSIV#646 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
area:tui bug P1
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
agent-of-empires/agent-of-empires#5705 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno