GNOME Bugzilla – Bug 166709
Handle font variants more consistently
Last modified: 2009-01-06 11:35:49 UTC
Current going to/from a font description to a string doesn't recognise the font weight "Book". Attaching a patch to fix this.
Created attachment 37200 [details] [review] Handle the "book" weight
Created attachment 37262 [details] [review] Handle Book, Roman and Black New patch extending support to Roman, Book, and Black. Lots of high quality commerical fonts come in many widths and without these patches it is impossible to use pango_font_description_from_string().
Created attachment 37893 [details] [review] New patch file I propose that Regular be treated as a synonym for Roman as many fonts use Regular rather than Roman as the description.
Created attachment 37909 [details] [review] Black is synonym for Heavy, add Demi My previous attachment kept Ross' addition of Black which I think may not be the right thing to do -- fontconfig treats Black and Heavy as synonyms -- this patch proposal realizes this synonym. I have also added Demi to augment Ross' addition of Demi-Bold.
* These changes, of course, only have an effect for Pango font descriptions that are hand-crafted; they (especially the addition of synonyms) have no effect, for say, * Can you give citations for fonts using Regular/Roman, since these are not supported by fontconfig. I wouldn't consider Roman to be a weight in general, and am not positive about Regular.
$ fc-list |grep Roman Myriad:style=Roman ITC New Baskerville:style=Roman URW Palladio L:style=Roman ITC Galliard:style=Roman Bitstream Vera Sans:style=Roman Franklin Gothic:style=No. 2 Roman Bitstream Vera Serif:style=Roman Bernhard Modern:style=Roman Bitstream Vera Sans Mono:style=Roman Kaufmann:style=Roman Century Schoolbook L:style=Roman Vera Sans comes in Roman, Oblique, Bold, and Bold Oblique styles.
*** Bug 171362 has been marked as a duplicate of this bug. ***
Comment on attachment 37909 [details] [review] Black is synonym for Heavy, add Demi * If we want to support Roman/Regular at all, I think they should be handled in find_field_any() like "Normal". * Any aliases added to weight_map have to be added *after* the standard field, or they will be preferred by append_field() * The BOOK addition would need the corresponding change to pangofc-fontmap.c to be of any use. I'd also like to see some evidence that: - "book" is used consistently in different font APIs (Windows, Java, OS X, e.g.) - There are fonts that have both a "book" weight and a "normal" weight.
myfonts.com, the Bitstream store, is good for finding fonts. http://www.myfonts.com/fonts/urw/corporate-a/ has Regular and Medium weights. http://www.myfonts.com/fonts/linotype/palatino/ has Roman and Medium weights.
*** Bug 334616 has been marked as a duplicate of this bug. ***
from https://bugs.freedesktop.org/show_bug.cgi?id=6255 Here are some sample fonts: http://home.sus.mcgill.ca/~moyogo/fonts/test/ Jaja Thin, Light, Book, Medium, Demi, Bold, Black and Heavy. fc-list lists them as Jaja:style=Book Jaja:style=Bold Jaja:style=Light Jaja:style=Medium Jaja:style=Black Jaja:style=Heavy Jaja:style=Demi Jaja:style=Thin Applications get mixed up between some of them in different ways. Gimp has Black renamed Heavy, Heavy renamed Ultra-Bold, Demi renamed Semi-Bold, Thin renamed Ultra-Light, with Book and Medium sharing the same plain "Jaja" name. In the GTK font selector Medium is ordered before Book and displays the same weight. Here's how the weight's are listed in the font properties in Fontlab and Fontforge: FontLab weights: Thin 100 UltraLight 200 ExtraLight 200 Light 300 Book 400 Regular 400 Normal 400 Medium 500 DemiBold 600 SemiBold 600 Bold 700 ExtraBold 800 Heavy 900 Black 900 Ultra 900 UltraBlack 900 Fat 1000 ExtraBlack 1000 Fontforge weights: Thin 100 Extra-Light 200 Light 300 Book 400 Medium 500 Demi-Bold 600 Bold 700 Heavy 800 Black 900
http://bugzilla.gnome.org/show_bug.cgi?id=334370#c2 from Patrick Lam > This is not a fontconfig bug, it is a pango bug. Pango should not be using the > weight of a font to determine its style, it should use the style to determine > the style.
Can someone explain what exactly this means? Anybody cooking a test patch for Pango to show what it should look like?
Created attachment 61565 [details] [review] handle more weights in markup, etc. Added weights: thin, medium, font_desc is more flexible Book, 380 should probably be added too. Pango markup <span font_family="Yanone Kaffeesatz" weight="thin">weight:thin</span> <span font_desc="Yanone Kaffeesatz Thin">desc:Thin</span> works with Yanone Kaffeesatz and the Jaja test fonts.
Created attachment 61577 [details] [review] Book, Medium, Thin, etc. and Regular/Roman as aliases of Normal. same patch with Book added and Regular/Roman as aliases of Normal. The sample Jaja fonts can be selected without collision in the gtk-fontselector as well as in the Gimp. Yanone Kaffeesatz still has issues in gtk-fontselector between thin and regular but that might be because the font has style:Thin,Regular. No problem in the Gimp.
I think multiple issues are muddied together here. See bug 95043 for more relevant discussion, changing how font description names are parsed really has at best marginal relevance to how choosing fonts through the font selector works.
My patch only deals with weights, allowing 11 different weights from 100 to 900, including Book (380). It should cover most if not all the weights available out there. Styles should be dealt with in another way. Some professional fonts actually have their Style set to Regular for other weights than Regular, with TTF Preferred Style set to the more specific weight. Anyway Styles cannot be predefined in a list since font designers might use orignal style names. I don't know if the changes to pango/fonts.c are necessary but those in other files are, or seem to make sense.
The weights of M+ fonts are also poorly handled. They are downloadable from http://mplus-fonts.sourceforge.jp/mplus-outline-fonts/download/index.html $ fc-list "M+ 1c" family style weight M+ 1c:style=medium:weight=100 M+ 1c:style=light:weight=40 M+ 1c:style=thin:weight=0 M+ 1c:style=heavy:weight=205 M+ 1c:style=regular:weight=80 M+ 1c:style=bold:weight=200 M+ 1c:style=black:weight=210 In the gtk font selector: M+ 1c thin, M+ 1mn thin and M+ 1m thin are mistaken for their light variants in the font selector ; medium variants are mistaken for regular ones. Bold, Heavy and Black are properly shown when selected. This means thin and medium cannot be accessed through pango as light and regular are returned instead. This also happens with M+ 1m and M+ 1mn. This is really two bugs. Fontconfig fitting a 1 to 1000 scale into a 0 to 210 scale, and Pango rounding to fit in the 8 weights defined in fonts.c or somewhere else. Font families could potentially use the full 1 to 1000 scale. They obviously don't need to to already hit bugs.
I believe I've committed all the bits in the patch now. 2009-01-06 Behdad Esfahbod <behdad@gnome.org> Bug 166709 – Handle font variants more consistently * configure.in: Require fontconfig >= 2.5.0 * pango/fonts.c: Parse "Roman" as style=normal instead of weight=normal. Doesn't make much difference in reality. * pango/pangofc-fontmap.c (pango_fc_convert_weight_to_fc), (pango_fc_convert_weight_to_pango): Update to reflect newly added weights. 2009-01-06 Behdad Esfahbod <behdad@gnome.org> Bug 166709 – Handle font variants more consistently * pango/pango-font.h: Add enum values PANGO_WEIGHT_BOOK and PANGO_WEIGHT_ULTRAHEAVY. * pango/fonts.c: * docs/tmpl/fonts.sgml: Add new weights with their aliases, as well as aliasing "Roman" to the normal weight. 2009-01-03 Behdad Esfahbod <behdad@gnome.org> Bug 384362 – pango can't select some font styles * pango/pango-font.h: Add enum values PANGO_WEIGHT_THIN and PANGO_WEIGHT_MEDIUM to PangoWeight. * pango/fonts.c: Parse "Thin", "Extra-Light", "Regular", "Demi-Bold", "Extra-Bold", and "Black" as weight descriptors (from the OpenType spec).