Number: 1304
Title: Inconsistent font mapping within and between SVG and PDF
Submitter: Pander
Date: Wed Mar 5 16:57:28 2008
Subsys: Dot
Version: 2.17 cvs
System: *-*-
Severity: minor
Problem:
Inconsistent font mapping within and between SVG and PDF.

See text example below. Note the differences when vieweing the PDF output (with xpdf) and viewing the SVG output (with inkscape, note the errors on the command line when selecting text with F8).

Please implement this so at least no differences occur between the PDF and the SVG. Furthermore fix the incorrect mappings to valid ones. Or just document what to use and what not to use as fontname.

mainly "Fontname-Appearance" versus "Fontname Appearance"

These test have been performed on a Ubuntu Linux machine with most of the (Western) distribution fonts installed.
Input:

digraph "test" {
	a1 [label="fontname=Helvetica" fontname="Helvetica" ]
	b1 [label="fontname=Helvetica Bold" fontname="Helvetica Bold" ]
	c1 [label="fontname=Helvetica-Bold" fontname="Helvetica-Bold" ]
	d1 [label="fontname=Helvetica Oblique" fontname="Helvetica Oblique" ]
	e1 [label="fontname=Helvetica-Oblique" fontname="Helvetica-Oblique" ]
	a1 -> b1 -> c1 -> d1 -> e1
	a2 [label="fontname=Times-Roman" fontname="Times-Roman" ]
	b2 [label="fontname=Times-Roman Bold" fontname="Times-Roman Bold" ]
	c2 [label="fontname=Times-Roman-Bold" fontname="Times-Roman-Bold" ]
	d2 [label="fontname=Times-Roman Oblique" fontname="Times-Roman Oblique" ]
	e2 [label="fontname=Times-Roman-Oblique" fontname="Times-Roman-Oblique" ]
	a2 -> b2 -> c2 -> d2 -> e2
	a3 [label="fontname=Times" fontname="Times" ]
	b3 [label="fontname=Times Bold" fontname="Times Bold" ]
	c3 [label="fontname=Times-Bold" fontname="Times-Bold" ]
	d3 [label="fontname=Times Oblique" fontname="Times Oblique" ]
	e3 [label="fontname=Times-Oblique" fontname="Times-Oblique" ]
	a3 -> b3 -> c3 -> d3 -> e3
	a4 [label="fontname=Courier" fontname="Courier" ]
	b4 [label="fontname=Courier Bold" fontname="Courier Bold" ]
	c4 [label="fontname=Courier-Bold" fontname="Courier-Bold" ]
	d4 [label="fontname=Courier Oblique" fontname="Courier Oblique" ]
	e4 [label="fontname=Courier-Oblique" fontname="Courier-Oblique" ]
	a4 -> b4 -> c4 -> d4 -> e4
}
Comments:
[ellson]

This is not a bug fix. Just a status update.

I've finally worked out how to convince pango+fontconfig+freetype to tell me what face, and font pathname it is actually using.

Running "dot -v b1304.dot" now gives:


fontname: "Helvetica" resolved to: (ps) "Liberation Sans, Regular" /usr/share/fonts/liberation/LiberationSans-Regular.ttf
fontname: "Helvetica Bold" resolved to: "Nimbus Sans L, Bold" /usr/share/fonts/default/Type1/n019004l.pfb
fontname: "Helvetica-Bold" resolved to: (ps) "Liberation Sans, Bold" /usr/share/fonts/liberation/LiberationSans-Bold.ttf
fontname: "Helvetica Oblique" resolved to: "Nimbus Sans L, Regular Italic" /usr/share/fonts/default/Type1/n019023l.pfb
fontname: "Helvetica-Oblique" resolved to: (ps) "Liberation Sans, Italic" /usr/share/fonts/liberation/LiberationSans-Italic.ttf
fontname: "Times-Roman" resolved to: (ps) "Liberation Serif, Regular" /usr/share/fonts/liberation/LiberationSerif-Regular.ttf
fontname: "Times-Roman Bold" resolved to: "DejaVu Sans, Bold" /usr/share/fonts/dejavu/DejaVuSans-Bold.ttf
fontname: "Times-Roman-Bold" resolved to: "DejaVu Sans, Book" /usr/share/fonts/dejavu/DejaVuSans.ttf
fontname: "Times-Roman Oblique" resolved to: "DejaVu Sans, Oblique" /usr/share/fonts/dejavu/DejaVuSans-Oblique.ttf
fontname: "Times-Roman-Oblique" resolved to: "DejaVu Sans, Book" /usr/share/fonts/dejavu/DejaVuSans.ttf
fontname: "Times" resolved to: "Nimbus Roman No9 L, Regular" /usr/share/fonts/default/Type1/n021003l.pfb
fontname: "Times Bold" resolved to: "Nimbus Roman No9 L, Medium" /usr/share/fonts/default/Type1/n021004l.pfb
fontname: "Times-Bold" resolved to: (ps) "Liberation Serif, Regular" /usr/share/fonts/liberation/LiberationSerif-Regular.ttf
fontname: "Times Oblique" resolved to: "Nimbus Roman No9 L, Regular Italic" /usr/share/fonts/default/Type1/n021023l.pfb
fontname: "Times-Oblique" resolved to: "DejaVu Sans, Book" /usr/share/fonts/dejavu/DejaVuSans.ttf
fontname: "Courier" resolved to: (ps) "Courier, Regular" /usr/share/X11/fonts/Type1/cour.pfa
fontname: "Courier Bold" resolved to: "Courier, Bold" /usr/share/X11/fonts/Type1/courb.pfa
fontname: "Courier-Bold" resolved to: (ps) "Courier, Bold" /usr/share/X11/fonts/Type1/courb.pfa
fontname: "Courier Oblique" resolved to: "Courier, Italic" /usr/share/X11/fonts/Type1/couri.pfa
fontname: "Courier-Oblique" resolved to: (ps) "Courier, Italic" /usr/share/X11/fonts/Type1/couri.pfa

(ps) indicates the the fontname was recognized as a PostScript name and translated before being given to pango.

There is clearly a problem recognizing Times-Roman variants. The pango interface doesn't like '-' (e.g. "Times-Oblique")

Also, from other testing, pango recognizes "Times New Roman" but not "Times Roman" (see below)

Unrecognized fonts seem to default to "DejaVu Sans". You would think that "Times Roman" would fall back on Times, but it doesn't.

In plugin/pango/gvtextlayout_pango.c, after PostScript name translation, if any, the fontname is interpreted by pango-font-description-from-string() which is described here: http://library.gnome.org/devel/pango/unstable/pango-Fonts.html#pango-font-description-from-string

------ Creates a new font description from a string representation in the form "[FAMILY-LIST] [STYLE-OPTIONS] [SIZE]", where FAMILY-LIST is a comma separated list of families optionally terminated by a comma, STYLE_OPTIONS is a whitespace separated list of words where each WORD describes one of style, variant, weight, stretch, or gravity, and SIZE is a decimal number (size in points) or optionally followed by the unit modifier "px" for absolute size. Any one of the options may be absent. If FAMILY-LIST is absent, then the family_name field of the resulting font description will be initialized to |NULL| <http://library.gnome.org/devel/glib/stable/glib-Standard-Macros.html#NULL:CAPS>. If STYLE-OPTIONS is missing, then all style options will be set to the default values. If SIZE is missing, the size in the resulting font description will be set to 0. ------

(SIZE is ignored since it is over-ridden by dot's fontsize attribute.)

This syntax is NOT the same as fontconfig's syntax, which is described here: http://freedesktop.org/fontconfig/fontconfig-user.html This is presumably because fontconfig is only one possible font-resolver backend for pango. Other platforms can use something different.

I note that we can use fontnames like:


   "Times-Roman,Times,Serif,  Bold Italic" resolved to: "Nimbus Roman No9 L, Medium Italic"
to give more reasonable fallbacks.

The postscript fontname translator can be usefully disabled by appending a "," on the font-family name. So the Times-Roman problem can be seen with:


   "Times-Roman," resolved to: "DejaVu Sans, Book"
   "Times Roman," resolved to: "DejaVu Sans, Book"
but "Times New Roman," is ok:

   "Times New Roman," resolved to: "Liberation Serif, Regular"

Owner: *
Status: *