Diagnosing a diacritics compiling issue

I’ve written something with the Barlow font, which specifically notes it supports Vietnamese diacritics. In the browser compiler, this looks fine.

image

image

Compiling it to PDF results in the font apparently falling back to Times New Roman or similar for certain accented characters. Acute and grave accents are fine, but the underdots and hooks fail.

image

image

It doesn’t matter whether I use precomposed characters or a simple character with a combining diacritic, the result is the same. Similarly it doesn’t matter what I use to view the PDF, so it doesn’t appear to be an issue with the PDF reader.

I’m trying to work out what is causing this and whether I can fix it. Any ideas? I would guess the compiler is where the issue happens.

A possibly-related issue is that selecting the PDF text for the above reveals a duplicated letter and a space: rượu rắắ n
These are not in the original Typst code.

rượu rắn

I can work around this by changing font, but it’d be nice to know what’s happening to help avoid future issues and maybe discover a fix, since the issue does not seem to be the font itself.

I can’t seem to reproduce the issue. Compiling

#set text(font: "Barlow", weight: "bold")

rượu rắn Mù Căng Chải 

with the Barlow font that comes with the web app, results in identical (to me) outputs in the preview and compiled PDFs:

preview:
{E3779B29-24F1-4DBF-A727-61EFEFB4B988}

compiled PDF (firefox viewer, but it looks the same on other viewers)

Without further information, this seems like a font issue. Are you using the web app or compiling locally? Which version of the font are you using (if you’re compiling locally you can check the installation path with typst fonts --variants).

It could also be that something in your template is causing the issue. Does it also occur on a fresh document?

Thanks. Compiling from the web app seems fine, so the issue is only on the desktop compiler. I am on the current release, Typst 0.15.1 (9dfd3a08)

The font has normal, italic, and bold variants installed. Changing from bold (as in the images) to regular doesn’t resolve the issue.

Barlow

  • Style: Normal, Weight: 700, Stretch: FontStretch(1000)
  • Style: Italic, Weight: 400, Stretch: FontStretch(1000)
  • Style: Normal, Weight: 400, Stretch: FontStretch(1000)

The same issue occurs in a new, simple document with no template.

#text(font: "Barlow")[=== Mù Tạc Cao]

#text(font: "Barlow")[rượu rắn]

The issue also occurs with some other fonts, e.g. Comic Sans, Century Gothic. On the other hand, Noto Sans and Open Sans seem fine.

I installed the Barlow font (and all its variants) from google fonts https://fonts.google.com/specimen/Barlow and compiling locally seems to work fine for me:

Could you try deleting the fonts from your machine and re-installing through the link above?

1 Like

Good call! That seems to have done the trick. Presumably there was a missing font version that the diacritics and/or compiler expected and that caused the issue.

I may do further checking with other fonts if time permits, but for now this solves the problem I had and explains the discrepancy between display and compiled output.

1 Like