After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 166709 - Handle font variants more consistently
Handle font variants more consistently
Status: RESOLVED FIXED
Product: pango
Classification: Platform
Component: general
1.8.x
Other Linux
: Normal normal
: Small API
Assigned To: pango-maint
pango-maint
: 171362 334616 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2005-02-08 20:20 UTC by Ross Burton
Modified: 2009-01-06 11:35 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Handle the "book" weight (1.57 KB, patch)
2005-02-08 20:21 UTC, Ross Burton
none Details | Review
Handle Book, Roman and Black (1.29 KB, patch)
2005-02-09 19:00 UTC, Ross Burton
none Details | Review
New patch file (1.33 KB, patch)
2005-02-24 12:16 UTC, Russel Winder
none Details | Review
Black is synonym for Heavy, add Demi (1.38 KB, patch)
2005-02-24 17:28 UTC, Russel Winder
needs-work Details | Review
handle more weights in markup, etc. (6.00 KB, patch)
2006-03-19 19:25 UTC, Denis Jacquerye
none Details | Review
Book, Medium, Thin, etc. and Regular/Roman as aliases of Normal. (6.03 KB, patch)
2006-03-19 22:35 UTC, Denis Jacquerye
none Details | Review

Description Ross Burton 2005-02-08 20:20:38 UTC
Current going to/from a font description to a string doesn't recognise the font
weight "Book".  Attaching a patch to fix this.
Comment 1 Ross Burton 2005-02-08 20:21:18 UTC
Created attachment 37200 [details] [review]
Handle the "book" weight
Comment 2 Ross Burton 2005-02-09 19:00:07 UTC
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().
Comment 3 Russel Winder 2005-02-24 12:16:46 UTC
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.
Comment 4 Russel Winder 2005-02-24 17:28:02 UTC
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.
Comment 5 Owen Taylor 2005-03-02 22:48:41 UTC
* 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.
Comment 6 Ross Burton 2005-04-04 14:38:07 UTC
$ 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.
Comment 7 Owen Taylor 2005-06-14 22:34:03 UTC
*** Bug 171362 has been marked as a duplicate of this bug. ***
Comment 8 Owen Taylor 2005-08-15 20:45:11 UTC
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.
Comment 9 Ross Burton 2005-08-16 08:50:48 UTC
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.
Comment 10 Behdad Esfahbod 2006-03-15 07:55:03 UTC
*** Bug 334616 has been marked as a duplicate of this bug. ***
Comment 11 Denis Jacquerye 2006-03-18 20:00:01 UTC
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
Comment 12 Denis Jacquerye 2006-03-19 00:29:35 UTC
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.
Comment 13 Behdad Esfahbod 2006-03-19 06:29:58 UTC
Can someone explain what exactly this means?  Anybody cooking a test patch for Pango to show what it should look like?
Comment 14 Denis Jacquerye 2006-03-19 19:25:06 UTC
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.
Comment 15 Denis Jacquerye 2006-03-19 22:35:37 UTC
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.
Comment 16 Owen Taylor 2006-03-20 02:09:28 UTC
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.
Comment 17 Denis Jacquerye 2006-03-21 20:09:55 UTC
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.
Comment 18 Denis Jacquerye 2007-07-23 05:34:15 UTC
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.
Comment 19 Behdad Esfahbod 2009-01-06 11:35:49 UTC
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).