Kozea / WeasyPrint

The awesome document factory
https://weasyprint.org
BSD 3-Clause "New" or "Revised" License
7.11k stars 678 forks source link

font-feature-settings: "tnum" seems to be ignored #2177

Closed martijnhartlief closed 3 months ago

martijnhartlief commented 3 months ago

Are font-feature-settings supported?

liZe commented 3 months ago

Hi!

It seems to work for me:

<body style="font-family: Fira Sans">
  <div>Not tabular: 01234567890</div>
  <div style="font-variant-numeric: tabular-nums">Tabular: 01234567890</div>
  <div style="font-feature-settings: 'tnum'">Also tabular: 01234567890</div>
</body>

Capture d’écran du 2024-06-06 17-21-21

I’ve used Fira Sans. Maybe your font doesn’t support this OpenType feature?

martijnhartlief commented 3 months ago

Hey liZe, thanks for the quick reply!

I'm using Lora.

According to https://fontdrop.info/ the ttf, otf and woff all support tnum. The web preview I made works, but it's just not showing up in the PDF.

Do I need to do something specific to the font loading?

Scherm­afbeelding 2024-06-06 om 20 16 25

<style>
    @font-face {
        font-family: 'Lora';
        src: url('fonts/Lora/Lora-Regular.otf') format('opentype');
        font-weight: normal;
    }
</style>

<body style="font-family: Lora">
<div>01234567890: Not tabular</div>
<div style="font-variant-numeric: tabular-nums">01234567890: Tabular</div>
<div style="font-feature-settings: 'tnum'">01234567890: Also tabular</div>
</body>
liZe commented 3 months ago

Here’s what I get with your example:

Capture d’écran du 2024-06-06 20-34-19

Are you sure that the font you’re using is the one from your link? Otherwise I don’t know what’s wrong. Maybe using the --verbose CLI option could give interesting information.

martijnhartlief commented 3 months ago

After fiddling around I found out our staging server renders just fine.... The exact same code and weasyprint version on my dev machine unfortunately doesn't. The only difference being I'm using Mac OSX.

I'm using a few wrappers, but I'll come back to you with the cli output.

liZe commented 3 months ago

The exact same code and weasyprint version on my dev machine unfortunately doesn't.

Maybe you have another font with the same name installed system-wide?

martijnhartlief commented 3 months ago

Indeed I have. It is the exact same file as I load from the font directory.

But after I removed it, it worked. So I reinstalled it again and it keeps working... So perhaps it wasn't the same? It wasn't the same file.

Thanks for helping me out!