Last modified: 2012-09-07 07:10:46 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T40299, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 38299 - Installation of Computer Modern Unicode font family for SVG rendering
Installation of Computer Modern Unicode font family for SVG rendering
Status: RESOLVED FIXED
Product: Wikimedia
Classification: Unclassified
SVG rendering (Other open bugs)
unspecified
All All
: Unprioritized enhancement (vote)
: ---
Assigned To: Antoine "hashar" Musso (WMF)
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-07-11 07:57 UTC by Gauravjuvekar
Modified: 2012-09-07 07:10 UTC (History)
5 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
File showing rendering with the cmr10 alias enabled in fontconfig. (7.38 KB, image/png)
2012-09-03 20:59 UTC, Antoine "hashar" Musso (WMF)
Details
file rendered using a default Precise install (aka no Computer Modern font installed) (6.79 KB, image/png)
2012-09-03 21:01 UTC, Antoine "hashar" Musso (WMF)
Details
Rendering with cmr10 aliases to "Computer Modern":style=Roman (6.89 KB, image/png)
2012-09-04 13:31 UTC, Antoine "hashar" Musso (WMF)
Details
rendering with ttf-lyx package (104.94 KB, image/png)
2012-09-05 08:34 UTC, Antoine "hashar" Musso (WMF)
Details

Description Gauravjuvekar 2012-07-11 07:57:24 UTC
Install computer modern font(the one used by latex renderer to render <math></math> elements for SVG. Adds consistency to the rendered equations/proofs and the accompanying diagrams. If the exact font used by the Latex renderer is not available, this one (http://sourceforge.net/projects/cm-unicode) comes pretty close.
Comment 1 Antoine "hashar" Musso (WMF) 2012-07-11 08:41:32 UTC
http://en.wikipedia.org/wiki/Computer_Modern reference "Computer Modern" has the default font for TeX.  The wikipage also mention the "Latin Modern" which we might want to use has a default instead?

Anyway the related Ubuntu Precise packages seems to be:
* lmodern - Latin Modern
* cm-super - all of Computer Modern

I am not sure which puppet class is used for math. 

apaches::fonts just install texlive-fonts-recommended which, on Precise seems to provide cmextra which could be the Computer Modern font.
Comment 2 Gauravjuvekar 2012-07-12 10:48:36 UTC
I'm not sure. Isn't it possible to exactly find out which font is used by the renderer.
Comment 3 Antoine "hashar" Musso (WMF) 2012-07-12 16:03:38 UTC
I proposed the addition of the 'cm-super' packages with https://gerrit.wikimedia.org/r/15550

Note that will not magically rerender the already rendered math PNG.
Comment 4 Gauravjuvekar 2012-07-12 18:16:51 UTC
That's not the point of this enhancement report. I'm not asking for the inline <math> equations to be SVG images. I want the same font to be available for SVG diagrams accompanying the equations/formulae.
Comment 5 Gauravjuvekar 2012-07-12 18:22:22 UTC
I read the change, it states "When rendering <math /> elements in SVG, the client side renderer seems to use the Computer Modern fonts as a default."
I don't suppose <math /> elements are in SVG. They are in normal wikitext. The <text /> elements with Computer Modern font should be rendered in SVG and the fonts not substituted to the fall back Liberation Serif font (as I believe happens currently. I'm talking purely of SVG image files, the reference to <math /> was just to identify the exact font although I believe cm-super would do it.
Comment 6 Antoine "hashar" Musso (WMF) 2012-07-12 18:38:36 UTC
I have honestly no idea how librsvg select the default font or how it fallback. If it is somehow made to fallback to "Computer Modern", the change will make the font available.

Do you have any SVG file example?
Comment 7 Gauravjuvekar 2012-07-13 18:44:51 UTC
File:Test.svg on commons, version as of 00:09, 14 July 2012. The PNG rendering falls back to Liberation sans I suppose(i'm not sure). Firefox falls it back to Liberation serif (when opened in full) as I don't have any cm font on my ubuntu system (11.10).
Comment 8 Gauravjuvekar 2012-07-14 08:26:08 UTC
The same renders correctly with CM font in firefox on my winxp on which I have installed the cm font from sourceforge.
Comment 9 Marcin Cieślak 2012-07-14 08:43:26 UTC
Gauravjuveker,

I have downloaded this file https://upload.wikimedia.org/wikipedia/commons/b/bd/Test.svg (it's 2012-07-13T18:39:49 UTC version) and I don't see any math element there.

What it does it tries to get

font-family="CMU Serif" font-style="italic" 

from the rendering. On my system I don't have "CMU Serif" font so it gets substituted to something else by rsvg (and actually it goes a bit off-side)

Did you try to put a real MathML tags in the file?

(I have changed the subject line to be more precise)
Comment 10 Gauravjuvekar 2012-07-14 18:22:03 UTC
No, I don't know much about MathML or how it can be embedded in SVG. Also, I don't want to create SVG images of equations so MathMl wouldn't really be useful. Also, by 
"On my system I don't have "CMU Serif" font so it gets substituted to something else by rsvg",
do you mean that the preview on the file description page gets its font substituted or opening it in full gets it substituted because opening it in full makes the image render by your browsers renderer. Doesn't rsvg convert the SVG image to raster thumbnails on various pages where the file is used including the file description page?
Comment 11 Antoine "hashar" Musso (WMF) 2012-08-02 09:30:27 UTC
A similar request is Bug 38946 - Install Free Hebrew fonts, so that they will be available for SVG rendering
Comment 12 Antoine "hashar" Musso (WMF) 2012-08-30 12:23:00 UTC
Gerrit change #15550 has been merged. Package cm-super is now installed on image scalers:

dsh -M -g image_scalers dpkg --get-selections cm-super
srv224: cm-super					install
srv223: cm-super					install
srv222: cm-super					install
srv221: cm-super					install
srv220: cm-super					install
srv219: cm-super					install
$
Comment 13 Gauravjuvekar 2012-09-03 16:57:08 UTC
Okay but it doesn't seem to work. See http://commons.wikimedia.org/wiki/File:Segment_definition.svg It uses the cmr10 font family from cm-super but still the text gets substituted for other fonts.
Comment 14 Antoine "hashar" Musso (WMF) 2012-09-03 19:33:02 UTC
Indeed, cm-super provides fonts for Latex and no TTF fonts that librsvg could use :(
Comment 15 Antoine "hashar" Musso (WMF) 2012-09-03 19:50:54 UTC
So we got them all according to font-config: 


$ fc-match --all|grep -i 'pfb.*computer modern"'
sffb1000.pfb: "Computer Modern" "Fibonacci Medium"
sfrm1000.pfb: "Computer Modern" "Roman"
sfss1000.pfb: "Computer Modern" "Sans Serif"
sftt1000.pfb: "Computer Modern" "Typewriter"
sfvt1000.pfb: "Computer Modern" "Variable Width Typewriter"
sfcc1000.pfb: "Computer Modern" "Caps and Small Caps"
sfdh1000.pfb: "Computer Modern" "Dunhill Roman"
sftc1000.pfb: "Computer Modern" "Typewriter Caps and Small Caps"
sfssdc10.pfb: "Computer Modern" "Sans Serif Demi Condensed"
sfbm1000.pfb: "Computer Modern" "Roman Bold Variant"
sfrb1000.pfb: "Computer Modern" "Roman Bold"
sfbx1000.pfb: "Computer Modern" "Bold Extended"
sfsx1000.pfb: "Computer Modern" "Sans Serif Bold Extended"
sfxc1000.pfb: "Computer Modern" "Bold Extended Caps and Small Caps"
sfci1000.pfb: "Computer Modern" "Classical Serif Italic"
sfff1000.pfb: "Computer Modern" "Funny Roman"
sffi1000.pfb: "Computer Modern" "Funny Italic"
sffs1000.pfb: "Computer Modern" "Fibonacci Slanted"
sfit1000.pfb: "Computer Modern" "Typewriter Italic"
sfsi1000.pfb: "Computer Modern" "Sans Serif Slanted"
sfsl1000.pfb: "Computer Modern" "Slanted"
sfst1000.pfb: "Computer Modern" "Typewriter Slanted"
sfti1000.pfb: "Computer Modern" "Italic"
sfui1000.pfb: "Computer Modern" "Unslanted Italic"
sfvi1000.pfb: "Computer Modern" "Variable Width Typewriter Italic"
sfsc1000.pfb: "Computer Modern" "Slanted Caps and Small Caps"
sfbi1000.pfb: "Computer Modern" "Bold Extended Italic"
sfbl1000.pfb: "Computer Modern" "Bold Extended Slanted"
sfso1000.pfb: "Computer Modern" "Sans Serif Bold Extended Slanted"
sfoc1000.pfb: "Computer Modern" "Bold Extended Slanted Caps and Small Caps"
$

The file linked uses crm10 as a font name which in turns is resolved to "DejaVu Sans" "Book" :

$ fc-match cmr10
DejaVuSans.ttf: "DejaVu Sans" "Book"
$

I guess we need some alias in font-config.
Comment 16 Antoine "hashar" Musso (WMF) 2012-09-03 20:55:08 UTC
I have created an alias using fontconfig: https://gerrit.wikimedia.org/r/22533

$ fc-match cmr10
sffb1000.pfb: "Computer Modern" "Fibonacci Medium"
$

Should be "Roman" style though, but I have not find a way to set the style preference :(
Comment 17 Antoine "hashar" Musso (WMF) 2012-09-03 20:58:55 UTC
Running rsvg under strace, it se
open("/usr/share/fonts/X11/Type1/sffb1000.pfb", O_RDONLY) = 3
open("/proc/meminfo", O_RDONLY|O_CLOEXEC) = 3
open("/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf", O_RDONLY) = 3


Will attach the resulting output
Comment 18 Antoine "hashar" Musso (WMF) 2012-09-03 20:59:59 UTC
Created attachment 11061 [details]
File showing rendering with the cmr10 alias enabled in fontconfig.
Comment 19 Antoine "hashar" Musso (WMF) 2012-09-03 21:01:04 UTC
Created attachment 11062 [details]
file rendered using a default Precise install (aka no Computer Modern font installed)
Comment 20 Antoine "hashar" Musso (WMF) 2012-09-03 21:01:37 UTC
Let me know if the rendering from attachment 11061 [details] looks correct to you.
Comment 21 Gauravjuvekar 2012-09-04 07:35:33 UTC
Attachment 11062 [details] looks exactly the way I see it when opened in my browser and in inkscape.(I installed cm-super on my Linux Mint setup and I can select cmr10 as an option in Inkscape.)

Note:The intersection symbol that looks like an 'n' is slightly wider in my browser when opening the actual file from commons.


Font in attachment 11061 [details] is slightly bigger(the overscore should be exactly on top of the last AB).

Are you sure you named the attachments right, because "file rendered using a default Precise install (aka no Computer Modern font installed) " is more correct and I suppose it has the exact computer modern font.(how could this be if the font is not installed?)
Comment 22 Antoine "hashar" Musso (WMF) 2012-09-04 13:31:36 UTC
Created attachment 11066 [details]
Rendering with cmr10 aliases to "Computer Modern":style=Roman
Comment 23 Antoine "hashar" Musso (WMF) 2012-09-04 13:34:20 UTC
Maybe I have mixed up the previous attachements (11062 & 11061).

File in attachement 11066 has been made using patchset 2 of Gerrit change #22533. Aka:

$ fc-match cmr10
sfrm1000.pfb: "Computer Modern" "Roman"
$
Comment 24 Gauravjuvekar 2012-09-04 18:00:03 UTC
Yup, rendering in attachment 11066 [details] is perfect.
Comment 25 Gauravjuvekar 2012-09-04 18:04:31 UTC
On a similar note, could you also create aliases for cmmi10(mainly used in formulas where the convention is to use italic lowercase variables), cmsy10 and cmex10 fonts provided with the same cm-super package?
Comment 26 Antoine "hashar" Musso (WMF) 2012-09-04 18:43:52 UTC
Most probably doable. Would you mind creating a SVG file containing example for all the four fonts?  Would let me convert it to PNG on the integration machine so you can validate the output :-)
Comment 27 Antoine "hashar" Musso (WMF) 2012-09-04 18:59:50 UTC
List of style available to the font family "Computer Modern" using Ubuntu Precise cm-super :

$ fc-match --all|grep Computer| sort -t: -k2
sfbx1000.pfb: "Computer Modern" "Bold Extended"
sfxc1000.pfb: "Computer Modern" "Bold Extended Caps and Small Caps"
sfbi1000.pfb: "Computer Modern" "Bold Extended Italic"
sfbl1000.pfb: "Computer Modern" "Bold Extended Slanted"
sfoc1000.pfb: "Computer Modern" "Bold Extended Slanted Caps and Small Caps"
sfbbx10.pfb: "Computer Modern Bright" "Bold Extended"
sfbtl10.pfb: "Computer Modern Bright" "Light"
sfbto10.pfb: "Computer Modern Bright" "Light"
sfbmo10.pfb: "Computer Modern Bright" "Oblique"
sfbmr10.pfb: "Computer Modern Bright" "Roman"
sfbsr10.pfb: "Computer Modern Bright" "Semibold"
sfbso10.pfb: "Computer Modern Bright" "Semibold Oblique"
sfcc1000.pfb: "Computer Modern" "Caps and Small Caps"
sfci1000.pfb: "Computer Modern" "Classical Serif Italic"
sfocc10.pfb: "Computer Modern Concrete" "Caps and Small Caps"
sfoti10.pfb: "Computer Modern Concrete" "Italic"
sform10.pfb: "Computer Modern Concrete" "Roman"
sfosl10.pfb: "Computer Modern Concrete" "Slanted"
sfdh1000.pfb: "Computer Modern" "Dunhill Roman"
sffb1000.pfb: "Computer Modern" "Fibonacci Medium"
sffs1000.pfb: "Computer Modern" "Fibonacci Slanted"
sffi1000.pfb: "Computer Modern" "Funny Italic"
sfff1000.pfb: "Computer Modern" "Funny Roman"
sfti1000.pfb: "Computer Modern" "Italic"
sfrm1000.pfb: "Computer Modern" "Roman"
sfrb1000.pfb: "Computer Modern" "Roman Bold"
sfbm1000.pfb: "Computer Modern" "Roman Bold Variant"
sfss1000.pfb: "Computer Modern" "Sans Serif"
sfsx1000.pfb: "Computer Modern" "Sans Serif Bold Extended"
sfso1000.pfb: "Computer Modern" "Sans Serif Bold Extended Slanted"
sfssdc10.pfb: "Computer Modern" "Sans Serif Demi Condensed"
sfsi1000.pfb: "Computer Modern" "Sans Serif Slanted"
sfsl1000.pfb: "Computer Modern" "Slanted"
sfsc1000.pfb: "Computer Modern" "Slanted Caps and Small Caps"
sftt1000.pfb: "Computer Modern" "Typewriter"
sftc1000.pfb: "Computer Modern" "Typewriter Caps and Small Caps"
sfit1000.pfb: "Computer Modern" "Typewriter Italic"
sfst1000.pfb: "Computer Modern" "Typewriter Slanted"
sfui1000.pfb: "Computer Modern" "Unslanted Italic"
sfvt1000.pfb: "Computer Modern" "Variable Width Typewriter"
sfvi1000.pfb: "Computer Modern" "Variable Width Typewriter Italic"
$

The possible style aliases would be:

cmmi10 : "Italic"

cmsy10 seems to be for symbols and cmex10 for extensions. Maybe that is included by default and we could reuse the "Roman" style there too.
Comment 29 Antoine "hashar" Musso (WMF) 2012-09-05 08:34:55 UTC
Created attachment 11072 [details]
rendering with ttf-lyx package

Faidon pointed to the ttf-lyx package which provides TTF files for cmr10 and the like. Attached is the rendering of the second test file.
Comment 30 Antoine "hashar" Musso (WMF) 2012-09-05 08:38:26 UTC
ttf-lyx installation : https://gerrit.wikimedia.org/r/22705
Comment 31 Gauravjuvekar 2012-09-05 10:57:21 UTC
(In reply to comment #29)
> Created attachment 11072 [details]
> rendering with ttf-lyx package
> 
> Faidon pointed to the ttf-lyx package which provides TTF files for cmr10 and
> the like. Attached is the rendering of the second test file.

Rendering is correct. Now that you mention ttf-lyx, that's where the fonts become available in inkscape.
Comment 32 Antoine "hashar" Musso (WMF) 2012-09-06 15:56:57 UTC
Change was merged but not yet deployed apparently:


dsh -M -g image_scalers dpkg --get-selections ttf-lyx
srv224: No packages found matching ttf-lyx.
srv223: No packages found matching ttf-lyx.
srv222: No packages found matching ttf-lyx.
srv221: No packages found matching ttf-lyx.
srv220: No packages found matching ttf-lyx.
srv219: No packages found matching ttf-lyx.
Comment 33 Antoine "hashar" Musso (WMF) 2012-09-06 16:10:57 UTC
cm-super conflicts with tex-common anyway so I am removing it. https://gerrit.wikimedia.org/r/22907
Comment 34 Antoine "hashar" Musso (WMF) 2012-09-06 16:23:24 UTC
fixed on srv219, the other servers will be fixed automatically whenever puppet run on them. Should not get long.
Comment 35 Daniel Zahn 2012-09-06 21:38:37 UTC
cm-super conflicted with tex-common:

 dpkg: error processing /var/cache/apt/archives/cm-super-minimal_0.3.4-3_all.deb (--unpack): trying to overwrite '/usr/share/texmf/doc', which is also 
                 in package tex-common 0:2.06ubuntu0.1

cm-super has been removed in this change:

https://gerrit.wikimedia.org/r/#/c/22907/

dist-upgraded
root@srv219:~# dpkg -l | grep lyx
ii  ttf-lyx                         1.6.5-1ubuntu1                    TrueType versions of some TeX fonts

Now ttf-lyx is installed.
Comment 36 Gauravjuvekar 2012-09-07 07:10:46 UTC
Yup, it's fixed. Thanks a lot.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links