Forum Bugs

Noto Sans Devanagari rendering issue

mcmeeking
Hi, I'm seeing an odd bug with the rendering of Noto Sans Devanagari where the characters in the word "ड्युडेनम" are being displayed incorrectly.

The attached screenshot shows how Prince is rendering the text incorrectly - however when using the default Lohit Devanagari font the word is displayed correctly by Prince.

Noto Sans Devanagari also renders the word fine in the browser, so this seems like something specific to the way Prince is handling the script.

I'm using system font discovery for the fonts, so my question is: Is there any way I can ensure that Noto Sans Devanagari is handled correctly by Prince using CSS font-features or something similar (i.e. by manually defining the fonts)?

My current workflow looks like this:

  • Prince is installed on a docker image (using
    python:3.13
    as the base image) with the following fonts installed:
    • fonts-lato
    • fonts-noto
    • fonts-noto-cjk
    • fonts-noto-extra
    • fonts-noto-cjk-extra
    • fonts-noto-ui-core
    • fonts-noto-ui-extra
    • fonts-khmeros
    • fonts-lklug-sinhala
    • fonts-tlwg-garuda-otf
    • fonts-lohit-orya
    • fonts-lohit-mlym
    • fonts-lohit-knda
    • fonts-lohit-telu
    • fonts-lohit-taml
    • fonts-lohit-gujr
    • fonts-lohit-guru
    • fonts-lohit-beng-bengali
    • fonts-lohit-deva
    • fonts-baekmuk
    • fonts-ipafont-mincho
    • fonts-arphic-uming
    • fonts-opensymbol
    • fonts-liberation2
    • ttf-mscorefonts-installer
  • Prince CLI is then called via Python
    os.popen
    to render HTML in a file to a PDF
  • CSS stylesheets and a layout JS script are passed as
    --style=
    and
    --script=
    args

The docker base image uses Debian 12, and I am running Prince 15.4.1.

Thanks,

James
  1. incorrect.png44.2 kB
    Incorrectly rendered word
wezm
Hi mcmeeking,

I have tried to reproduce your issue but have not been able to so far. Here's what I tried:
$ docker run --rm -it -v $(pwd):/src --entrypoint bash python:3.13
# apt install fonts-lato fonts-noto fonts-noto-cjk fonts-noto-extra fonts-noto-cjk-extra fonts-noto-ui-core fonts-noto-ui-extra fonts-khmeros fonts-lklug-sinhala fonts-tlwg-garuda-otf fonts-lohit-orya fonts-lohit-mlym fonts-lohit-knda fonts-lohit-telu fonts-lohit-taml fonts-lohit-gujr fonts-lohit-guru fonts-lohit-beng-bengali fonts-lohit-deva fonts-baekmuk fonts-ipafont-mincho fonts-arphic-uming fonts-opensymbol fonts-liberation2

## Note I dropped ttf-mscorefonts-installer due to this error from apt:
Package ttf-mscorefonts-installer is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

# curl -OL https://www.princexml.com/download/prince_15.4.1-1_debian12_amd64.deb
# dpkg -i prince_15.4.1-1_debian12_amd64.deb
# apt --fix-broken install
# cd /src
# prince --verbose noto-sans-devanagari-rendering-issue.html -o noto-sans-devanagari-rendering-issue-debian.pdf
prince: loading document: /usr/lib/prince/license/license.dat
prince: Loading document...
prince: loading HTML5 input: noto-sans-devanagari-rendering-issue.html
prince: loading document: noto-sans-devanagari-rendering-issue.html
prince: Applying style sheets...
prince: Preparing document...
prince: Converting document...
prince: loading font: /usr/share/fonts/truetype/lohit-devanagari/Lohit-Devanagari.ttf
prince: used font: Lohit Devanagari, Regular
prince: loading font: /usr/share/fonts/truetype/noto/NotoSansDevanagari-Regular.ttf
prince: used font: Noto Sans Devanagari, Regular
prince: writing PDF to file: noto-sans-devanagari-rendering-issue-debian.pdf
prince: Finished: success


where noto-sans-devanagari-rendering-issue.html is:

<!DOCTYPE html>
<html lang="hi">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>noto-sans-devanagari-rendering-issue</title>
  <style type="text/css">
    body {
      margin:40px auto;
      max-width:650px;
      line-height:1.6;
      font-size:18px;
      padding:0 10px;
      font-family: sans-serif;
    }
  </style>
</head>
<body>
  <p style="font-family: Lohit Devanagari, sans-serif">ड्युडेनम</p>
  <p style="font-family: Noto Sans Devanagari, sans-serif">ड्युडेनम</p>
</body>
</html>


This produces the attached output.

Perhaps you could share the HTML you are using?
  1. Screenshot from 2025-02-18 10-37-41.png3.6 kB
    output.png
mcmeeking
Thanks for the reply, this is odd. I get the correct output with your HTML snippet.

Here's a sample which replicates the issue:

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta content="width=device-width,initial-scale=1" name="viewport">
    <title>noto-sans-devanagari-rendering-issue</title>
    <link href="/static/dist/favicon.ico" rel="shortcut icon">
    <style type="text/css">
        body {
            font-family: "Noto Sans Devanagari", sans-serif;
            font-size: 1rem;
            line-height: 1.5;
            margin: 0;
            padding: 0;
        }
        .lohit {
            font-family: "Lohit Devanagari", sans-serif;
        }
    </style>
</head>

<body>
    <h2>ड्युडेनम Noto</h2>
    <h2 class="lohit">ड्युडेनम Lohit</h2>
    <h2 dir="ltr" lang="ne">ड्युडेनम Noto with lang</h2>
    <h2 dir="ltr" lang="ne" class="lohit">ड्युडेनम Lohit with lang</h2>
</body>

</html>


It seems to be the "lang" attribute which is causing the problem - if I remove it, the string displays correctly.

Seems like this might be a bug with the "ne" language code specifically, this snippet works fine with lang="hi" and lang="mr".

Edited by mcmeeking

wezm
The issue seems to be with the font. Debian are shipping a very old version of NotoSansDevanagari. The copyright in it says 2015, Version 2.001. It seems the issue is fixed in Version 2.002 of the font onwards, although I can't pinpoint the exact commit that fixed the issue. The current version is 2.006. Using a newer version of the font produces the attached output.
  1. Screenshot from 2025-02-19 10-29-25.png12.5 kB
    NotoSans Version 2.006

Edited by wezm

mcmeeking
Thanks so much for your help with this wezm, I really appreciate you tracking this down.

I'll see if I can build something into the workflow to grab the fonts from somewhere more up to date than the Debian default repo.

Cheers!