문제

I'm trying to setup kSar java tool for sar data visualization. Everything is fine except font settings.

kSar user jfreechart to build graphs and it uses some weird unreadable fonts. Here is output exapmle:

enter image description here

I installed new font in ~/.fonts (btw I don't have root permissions and not able to make changes system wide), however I didn't find any way to specify which font I'd like to use directly in java.

I tried to change font settings in ~/.fonts.conf and fc-match show me:

 $ fc-match -s
DejaVuSans.ttf: "DejaVu Sans" "Book"
n019003l.pfb: "Nimbus Sans L" "Regular"
s050000l.pfb: "Standard Symbols L" "Regular"

~/.fonts.conf content is:

<!--?xml version="1.0"?>-->
<!--DOCTYPE fontconfig SYSTEM "fonts.dtd">-->
<!-- ~/.fonts.conf for per-user font configuration -->
<fontconfig>
<alias>
    <family>sans-serif</family>
    <prefer>
        <family>DejaVu Sans</family>
    </prefer>
</alias>
<alias>
    <family>monospace</family>
    <prefer>
        <family>DejaVu Sans</family>
    </prefer>
</alias>
<match>
    <test name="family"><string>Arial</string></test>
    <edit name="family" mode="prepend" binding="strong">
        <string>DejaVu Sans</string>
    </edit>
</match>
<match>
    <test name="family"><string>helvetica</string></test>
    <edit name="family" mode="prepend" binding="strong">
        <string>DejaVu Sans</string>
    </edit>
</match>
</fontconfig>

and java reads this file (cause in case of typo in it the error occurs), but nothing changes.

On another box it works good with readable labels (on the same sar file). Is there any way to fix it?

enter image description here

도움이 되었습니까?

해결책

Finally solution was found. It's pretty dirty hack, unfortunately it is the only working way I found. Every time I need to launch this java, I'm generating special .fonts.conf to forbid all fonts except one I need. I do it with this code:

echo '<!--?xml version="1.0"?>-->
<!--DOCTYPE fontconfig SYSTEM "fonts.dtd">-->
<!-- ~/.fonts.conf for per-user font configuration -->
<fontconfig>' > ~/.fonts.conf
# here fc-list will produce small warning about bad ~/.fonts.conf
# don't worry about it
fc-list | grep -vi EXCLUDE_FONT | while read FONT ; do 
echo "<rejectfont><pattern><patelt name=\"family\"><string>${FONT%%:*}</string></patelt></pattern></rejectfont>" >> ~/.fonts.conf ; 
done
echo "</fontconfig>" >> ~/.fonts.conf

Of course I make backup of existing ~/.fonts.conf and put it back after java finish its work.

Hope someday somebody tell me real unix way solution (:

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top