Ubuntu – Evince and fc-match think Windows 8.1 courbd.ttf is worse match than DejaVu Sans Book font

evincefonts

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.

Best Answer