You are not logged in.
I'm not sure in which sub-forum to post this, so feel free to move this thread to a more appropriate location.
I'm trying to substitute fonts wanted by a PDF (not embedded) with appropriate fonts installed on my system. However, fontconfig doesn't seem to read the user rules, I defined.
The fonts in the PDF are:
$ pdffonts keigo.pdf
name type encoding emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
MS-Mincho CID TrueType 90ms-RKSJ-H no no no 78 0
MS-Gothic CID TrueType 90ms-RKSJ-H no no no 90 0
I'm trying to do the following replacements:
MS-Mincho --> IPAMincho
MS-Gothic --> IPAGothic
Both target fonts are installed:
$ fc-list | grep -E "IPA(Mincho|Gothic)"
/usr/share/fonts/OTF/ipam.ttf: IPAMincho,IPA明朝:style=Regular
/usr/share/fonts/OTF/ipag.ttf: IPAGothic,IPAゴシック:style=Regular
I wrote the following rules
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match target="pattern">
<test name="family" qual="any" >
<string>MS-Mincho</string>
</test>
<edit name="family" mode="assign" binding="same">
<string>IPAMincho</string>
</edit>
</match>
<match target="pattern">
<test name="family" qual="any" >
<string>MS-Gothic</string>
</test>
<edit name="family" mode="assign" binding="same">
<string>IPAGothic</string>
</edit>
</match>
</fontconfig>
and tried placing this code in the following files:
~/.config/fontconfig/fonts.conf
~/.config/fontconfig/conf.d/00-japanese.conf
/etc/fonts/conf.d/99-japanese.conf
After that, I tried
fc-list -f
and even rebooting, but I keep getting
$ fc-match "MS-Gothic"
DejaVuSans.ttf: "DejaVu Sans" "Book"
Any ideas on how to convince fontconfig that I want MS-(Mincho|Gothic) replaced?
Last edited by vdrummer (2019-09-18 15:30:51)
Offline
Bogus test, try
fc-match "MS\-Gothic"
I'd not hold my breath that this carries over to the pdf (maybe depending on the viewer)
Offline
Wow, that actually works! I didn't think "-" was a character that needs to be escaped...
Unfortunately, this doesn't carry over to the PDF (using evince), so it's still displayed in the fallback font.
But now that I know the "-" is the problem, I could just get rid of it and change my rule:
$ sed -i 's/MS-Gothic/MSGothic/g;s/MS-Mincho/MSMincho/g' keigo.pdf
$ cat .config/fontconfig/fonts.conf
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match target="pattern">
<test name="family" qual="any" >
<string>MSMincho</string>
</test>
<edit name="family" mode="assign" binding="same">
<string>IPAMincho</string>
</edit>
</match>
<match target="pattern">
<test name="family" qual="any" >
<string>MSGothic</string>
</test>
<edit name="family" mode="assign" binding="same">
<string>IPAGothic</string>
</edit>
</match>
</fontconfig>
$ fc-cache -f
Not the most elegant solution, but at least I now can read my PDF the way it's supposed to be.
Offline
Please always remember to mark resolved threads by editing your initial posts subject - so others will know that there's no task left, but maybe a solution to find.
Thanks.
Offline
Done. Thanks for the reminder.
And thanks for your help!
Last edited by vdrummer (2019-09-18 15:31:15)
Offline