Bug 885307

Summary: RFE: Install STIX-General fonts
Product: [Fedora] Fedora Reporter: Paulo Andrade <paulo.cesar.pereira.de.andrade>
Component: stix-fontsAssignee: Nicolas Mailhot <nicolas.mailhot>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: fonts-bugs, nicolas.mailhot, paul
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-12-08 11:24:06 EST Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:

Description Paulo Andrade 2012-12-08 09:32:29 EST
I see that when "rpmbuild -bp" the stix-fonts package
it creates:

$ ls -R BUILD/stix-fonts-1.1.0/Fonts/
BUILD/stix-fonts-1.1.0/Fonts/:
STIX-General  STIX-Word

BUILD/stix-fonts-1.1.0/Fonts/STIX-General:
STIXGeneral-BoldItalic.otf     STIXNonUnicode-Bold.otf
STIXGeneral-Bold.otf           STIXNonUnicode-Italic.otf
STIXGeneral-Italic.otf         STIXNonUnicode-Regular.otf
STIXGeneral-Regular.otf        STIXSizeFiveSym-Regular.otf
STIXIntegralsD-Bold.otf        STIXSizeFourSym-Bold.otf
STIXIntegralsD-Regular.otf     STIXSizeFourSym-Regular.otf
STIXIntegralsSm-Bold.otf       STIXSizeOneSym-Bold.otf
STIXIntegralsSm-Regular.otf    STIXSizeOneSym-Regular.otf
STIXIntegralsUp-Bold.otf       STIXSizeThreeSym-Bold.otf
STIXIntegralsUpD-Bold.otf      STIXSizeThreeSym-Regular.otf
STIXIntegralsUpD-Regular.otf   STIXSizeTwoSym-Bold.otf
STIXIntegralsUp-Regular.otf    STIXSizeTwoSym-Regular.otf
STIXIntegralsUpSm-Bold.otf     STIXVariants-Bold.otf
STIXIntegralsUpSm-Regular.otf  STIXVariants-Regular.otf
STIXNonUnicode-BoldItalic.otf

BUILD/stix-fonts-1.1.0/Fonts/STIX-Word:
STIX-BoldItalic.otf  STIX-Italic.otf       STIX-Regular.otf
STIX-Bold.otf        STIXMath-Regular.otf

but %install only installs the ones under STIX-Word

This causes some python-matplotlib failures due to the missing
fonts, e.g:

$ egrep -i 'STIX(General|Integral|NonUnicode|Size|Variant)' /usr/lib64/python2.7/site-packages/matplotlib/mathtext.py
    - handles sized alternative characters for the STIXSizeX fonts.
    _fontmap = { 'rm'  : 'STIXGeneral',
                 'it'  : 'STIXGeneral:italic',
                 'bf'  : 'STIXGeneral:weight=bold',
                 'nonunirm' : 'STIXNonUnicode',
                 'nonuniit' : 'STIXNonUnicode:italic',
                 'nonunibf' : 'STIXNonUnicode:weight=bold',
                 0 : 'STIXGeneral',
                 1 : 'STIXSizeOneSym',
                 2 : 'STIXSizeTwoSym',
                 3 : 'STIXSizeThreeSym',
                 4 : 'STIXSizeFourSym',
                 5 : 'STIXSizeFiveSym'

and in my sagemath package, the side effect is several
warnings like this:

    doctest:1214: UserWarning: findfont: Font family ['STIXGeneral'] not found. Falling back to Bitstream Vera Sans
    doctest:1214: UserWarning: findfont: Font family ['STIXSizeOneSym'] not found. Falling back to Bitstream Vera Sans
    doctest:1214: UserWarning: findfont: Font family ['STIXSizeThreeSym'] not found. Falling back to Bitstream Vera Sans
    doctest:1214: UserWarning: findfont: Font family ['STIXSizeFourSym'] not found. Falling back to Bitstream Vera Sans
    doctest:1214: UserWarning: findfont: Font family ['STIXSizeFiveSym'] not found. Falling back to Bitstream Vera Sans
    doctest:1214: UserWarning: findfont: Font family ['STIXSizeTwoSym'] not found. Falling back to Bitstream Vera Sans
    doctest:1214: UserWarning: findfont: Font family ['STIXNonUnicode'] not found. Falling back to Bitstream Vera Sans

  I do not know exactly what is done in the related debian
package, but looking at the fonts-stix_1.1.0-1.diff maybe the
call to defoma-font will rename STIXGeneral-Regular to
STIX-General, or create some fontconfig rule from
fonts-stix-1.1.0/debian/otf-stix.defoma-hints:
...
+category opentype
+begin /usr/share/fonts/opentype/stix/STIXGeneral.otf
+  Family = STIXGeneral
+  FontName = STIXGeneral
+  Encoding = Unicode
+  Location = English
+  Charset = ISO8859-1
+  GeneralFamily = Roman
+  Weight = Medium
+  Width = Variable
+  Shape = Normal Upright
+  Foundry = STI
+  Priority = 20
+end
...
Comment 1 Paulo Andrade 2012-12-08 09:41:29 EST
I added some comments to #885312 about a related issue
with missing jsmath fonts, and suggested that python-matplotlib
probably could also be patched to not "consider" the fonts
missing in fedora.
Comment 2 Nicolas Mailhot 2012-12-08 11:24:06 EST
StixGeneral is how the fonts were organised in the previous version, it's now deprecated for the font split Fedora installs. Moreover we do install the correct fontconfig aliasing rules so STIXGeneral is aliased to the new fonts

$ fc-match STIXGeneral
STIX-Regular.otf: "STIX" "Regular"

Therefore your software has two different bugs:

1. it has not been fixed to work with the new STIX split
2. it does not respect fontconfig aliasing

You should get this fixed upstream. But it's not a Fedora STIX package bug
Comment 3 Paulo Andrade 2012-12-08 11:56:40 EST
Ok. I am not an fonts specialist... It works in f17 but not rawhide:

In f17 I see this:
--%<---%<--%<---%<--%<---%<--%<---%<--%<---%<--%<---%<--%<---%<--%<---%<--%<---%<
$ rpm -q python-matplotlib
python-matplotlib-1.2.0-5.fc17.x86_64
$ rpm -qa | grep stix
stix-fonts-1.0.0-3.fc17.noarch
$ fc-match STIXGeneral
STIXGeneral.otf: "STIXGeneral" "Regular"
$ fc-list | grep -i stix
STIXGeneral:style=Bold
STIXGeneral:style=Italic
STIXGeneral:style=Regular
STIXGeneral:style=Bold Italic
$ sage -t  -force_lib "devel/sage/sage/geometry/cone.py"      
sage -t -force_lib "devel/sage/sage/geometry/cone.py"       
         [5.7 s]
 
----------------------------------------------------------------------
All tests passed!
Total time for all tests: 5.7 seconds
--%<---%<--%<---%<--%<---%<--%<---%<--%<---%<--%<---%<--%<---%<--%<---%<--%<---%<


And in rawhide:
--%<---%<--%<---%<--%<---%<--%<---%<--%<---%<--%<---%<--%<---%<--%<---%<--%<---%<
$ rpm -q python-matplotlib
python-matplotlib-1.2.0-5.fc19.x86_64
$ rpm -qa | grep stix
stix-math-fonts-1.1.0-3.fc19.noarch
stix-fonts-1.1.0-3.fc19.noarch
$ fc-match STIXGeneral
Fontconfig warning: "/etc/fonts/conf.d/50-user.conf", line 9: reading configurations from ~/.fonts.conf is deprecated.
STIX-Regular.otf: "STIX" "Regular"
$ fc-list | grep -i stix
Fontconfig warning: "/etc/fonts/conf.d/50-user.conf", line 9: reading configurations from ~/.fonts.conf is deprecated.
/usr/share/fonts/stix/STIX-Regular.otf: STIX:style=Regular
/usr/share/fonts/stix/STIX-Italic.otf: STIX:style=Italic
/usr/share/fonts/stix/STIX-Bold.otf: STIX:style=Bold
/usr/share/fonts/stix/STIX-BoldItalic.otf: STIX:style=Bold Italic
/usr/share/fonts/stix/STIXMath-Regular.otf: STIX Math:style=Regular
$ sage -t  -force_lib "devel/sage/sage/geometry/cone.py"
sage -t -force_lib "devel/sage/sage/geometry/cone.py"       
**********************************************************************
File "/usr/lib64/sagemath/devel/sage/sage/geometry/cone.py", line 930:
    sage: quadrant.plot()
Expected nothing
Got:
    doctest:1214: UserWarning: findfont: Font family ['STIXGeneral'] not found. Falling back to Bitstream Vera Sans
    doctest:1214: UserWarning: findfont: Font family ['STIXSizeOneSym'] not found. Falling back to Bitstream Vera Sans
    doctest:1214: UserWarning: findfont: Font family ['STIXSizeThreeSym'] not found. Falling back to Bitstream Vera Sans
    doctest:1214: UserWarning: findfont: Font family ['STIXSizeFourSym'] not found. Falling back to Bitstream Vera Sans
    doctest:1214: UserWarning: findfont: Font family ['STIXSizeFiveSym'] not found. Falling back to Bitstream Vera Sans
    doctest:1214: UserWarning: findfont: Font family ['STIXSizeTwoSym'] not found. Falling back to Bitstream Vera Sans
    doctest:1214: UserWarning: findfont: Font family ['STIXNonUnicode'] not found. Falling back to Bitstream Vera Sans
    doctest:1214: UserWarning: findfont: Font family ['cmb10'] not found. Falling back to Bitstream Vera Sans
    doctest:1214: UserWarning: findfont: Font family ['cmtt10'] not found. Falling back to Bitstream Vera Sans
    doctest:1214: UserWarning: findfont: Font family ['cmss10'] not found. Falling back to Bitstream Vera Sans
    <BLANKLINE>
**********************************************************************
1 items had failures:
   1 of   5 in __main__.example_17
***Test Failed*** 1 failures.
For whitespace errors, see the file /home/pcpa/.sage/tmp/cone_4295.py
         [5.8 s]
 
----------------------------------------------------------------------
The following tests failed:


        sage -t -force_lib "devel/sage/sage/geometry/cone.py"
Total time for all tests: 5.9 seconds
--%<---%<--%<---%<--%<---%<--%<---%<--%<---%<--%<---%<--%<---%<--%<---%<--%<---%<

Note that I have backported several f18/rawhide packages to f17 in
http://pcpa.fedorapeople.org/sagemath/f17/ and opened the bug report
to somehow try to get some hints on how to address the problem :-)
I see that %{python_sitearch}/matplotlib/font_manager.py does a
popen call to fc-list to find fonts, example in f17:

$ fc-list STIXGeneral
STIXGeneral:style=Bold
STIXGeneral:style=Italic
STIXGeneral:style=Regular
STIXGeneral:style=Bold Italic

but rawhide returns nothing for the same command. Is it expected?
Comment 4 Nicolas Mailhot 2012-12-08 14:03:15 EST
This is a terrible way to use fontconfig, you need to link to the fontconfig library and evaluate fontconfig patterns every time you need to print a string, not do a few calls on fixed font names and hope the font coverage is suitable. Your upstream is trying to handle fontconfig the way it handled pre-fontconfig pre-unicode font management (which was no management at all, but reliance on small limited pre-known lists of fonts that never changed properties). That is never going to work properly now that fontconfig has been there for a decade, all major *nix software uses it properly, and fonts change a lot faster than before as a result.

(and usually you do *not* want to call fontconfig direcly, you use pango-cairo or another smart library that does the fontconfig heavy lifting and glyph shaping for you)

fc-list and fc-match are there mainly for debugging purposes, calling them directly can not simulate full fontconfig support and breaks as soon as fonts change (as seen there)

Lastly, fc-list lists installed fonts, fc-match finds the closest installed font, this is only the same thing when you happen to hit the font you requested directly.

PS You can also tell your upstream that every major distribution has been shipping DejaVu instead of Bistream Vera for at least five years.
Comment 5 Nicolas Mailhot 2012-12-08 14:05:56 EST
(In reply to comment #3)
> Ok. I am not an fonts specialist... It works in f17 but not rawhide:

I cut and pasted fc-match output from a rawhide system with rawhide font packages
Comment 6 Paulo Andrade 2012-12-08 14:42:15 EST
(In reply to comment #4)
> This is a terrible way to use fontconfig, you need to link to the fontconfig
> library and evaluate fontconfig patterns every time you need to print a
> string, not do a few calls on fixed font names and hope the font coverage is
> suitable.

Thanks. I made a simple hack patch (functionally making things
work if conditionally applied to f18 and rawhide) removing/renaming
patterns, but that clearly looks wrong, and asked for help and
information at
http://sourceforge.net/mailarchive/message.php?msg_id=30202451
Comment 7 Fedora Update System 2013-01-16 11:46:05 EST
python-matplotlib-1.2.0-7.fc18 has been submitted as an update for Fedora 18.
https://admin.fedoraproject.org/updates/python-matplotlib-1.2.0-7.fc18