2

I have invoice PDF where the shop's software uses Courier New and Courier New Bold fonts. However, both Evince and fc-match decide (assuming through Fontconfig) that my Windows 8.1 original Courier New Bold in courbd.ttf is not the best match and it decides to use DejaVu Sans Book instead. This completely breaks the PDF rendering in Evince.

This is best demonstrated using fc-match "Courier New Bold":

/usr/share/fonts> fc-match  "Courier New Bold"         
DejaVuSans.ttf: "DejaVu Sans" "Book"

If I up the debugging output for Fontconfig using FC_DEBUG=2 environment variable I can see it looking at my courbd.ttf but somehow it rejects it in favour of DejaVu Sans.

This is all on Ubuntu/Xubuntu 19.04.

UPDATE

I have managed to hack this using local Fontconfig setting like the following. But it seems like a hack and the issue lies elsewhere:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
    <match>
        <test name="family">
            <string>Courier New Bold</string>
        </test>
        <edit mode="assign" name="file">
            <string>/usr/share/fonts/truetype/win81-fonts/courbd.ttf</string>
        </edit>         
    </match>    
</fontconfig>

UPDATE 2

/usr/share/fonts/truetype/win81-fonts> fc-query /usr/share/fonts/truetype/win81-fonts/courbd.ttf | grep -E 'name:|family:|style:'
    family: "Courier New"(s)
    style: "Negreta"(s) "tučné"(s) "fed"(s) "Fett"(s) "Έντονα"(s) "Bold"(s) "Negrita"(s) "Lihavoitu"(s) "Gras"(s) "Félkövér"(s) "Grassetto"(s) "Vet"(s) "Halvfet"(s) "Pogrubiony"(s) "Negrito"(s) "Полужирный"(s) "Fet"(s) "Kalın"(s) "Krepko"(s) "đậm"(s) "Lodia"(s)
    fullname: "Courier New Negreta"(s) "Courier New tučné"(s) "Courier New fed"(s) "Courier New Fett"(s) "Courier New Έντονα"(s) "Courier New Bold"(s) "Courier New Negrita"(s) "Courier New Lihavoitu"(s) "Courier New Gras"(s) "Courier New Félkövér"(s) "Courier New Grassetto"(s) "Courier New Vet"(s) "Courier New Halvfet"(s) "Courier New Pogrubiony"(s) "Courier New Negrito"(s) "Courier New Полужирный"(s) "Courier New Fet"(s) "Courier New Kalın"(s) "Courier New Krepko"(s) "Courier New đậm"(s) "Courier New Lodia"(s)
    postscriptname: "CourierNewPS-BoldMT"(s)

UPDATE 3

Interestingly, Evince now says it was substituted with Courier New Negreta as if it did not see the other names stored in the font.

Courier New Negreta is substituted.

wilx
  • 696
  • Not sure why you consider that a hack. The default fontconfig configuration makes some educated guesses, but fontconfig is not a mind reader. I think you should submit an answer where you include that fontconfig recipe. It's a reasonable solution IMO. – Gunnar Hjalmarsson Jul 26 '19 at 22:28
  • @GunnarHjalmarsson My beef is that it does not use the font which has exactly the same name as required by the document. – wilx Jul 26 '19 at 23:23
  • The thing is that fontconfig on Linux works with family name and style, not fullname, and "Courier New Bold" does not exist as a family name by default. Your problem made me think of this question. Please study it including the pseudo answer I wrote. Then, to see how it applies to your problem, please run this command: fc-query /usr/share/fonts/truetype/win81-fonts/courbd.ttf | grep -E 'name:|family:|style:' – Gunnar Hjalmarsson Jul 27 '19 at 01:30
  • @GunnarHjalmarsson Updated with fc-query output. – wilx Jul 27 '19 at 07:18

0 Answers0