[Fontconfig] Font weights?
Dave Pawson
dave.pawson at gmail.com
Sat Sep 17 08:05:34 PDT 2011
On 17 September 2011 14:34, Behdad Esfahbod <behdad at behdad.org> wrote:
> On 09/17/11 08:00, Dave Pawson wrote:
>> W3c css has
>> http://www.w3.org/TR/css3-fonts/#font-weight-prop
>>
>> 100 - Thin
>> 200 - Extra Light (Ultra Light)
>> 300 - Light
>> 400 - Normal
>> 500 - Medium
>> 600 - Semi Bold (Demi Bold)
>> 700 - Bold
>> 800 - Extra Bold (Ultra Bold)
>> 900 - Black (Heavy)
>>
>> fontconfig has
>>
>> #define FC_WEIGHT_THIN 0
>> #define FC_WEIGHT_EXTRALIGHT 40
>> #define FC_WEIGHT_ULTRALIGHT FC_WEIGHT_EXTRALIGHT
>> #define FC_WEIGHT_LIGHT 50
>> #define FC_WEIGHT_BOOK 75
>> #define FC_WEIGHT_REGULAR 80
>> #define FC_WEIGHT_NORMAL FC_WEIGHT_REGULAR
>> #define FC_WEIGHT_MEDIUM 100
>> #define FC_WEIGHT_DEMIBOLD 180
>> #define FC_WEIGHT_SEMIBOLD FC_WEIGHT_DEMIBOLD
>> #define FC_WEIGHT_BOLD 200
>> #define FC_WEIGHT_EXTRABOLD 205
>> #define FC_WEIGHT_ULTRABOLD FC_WEIGHT_EXTRABOLD
>> #define FC_WEIGHT_BLACK 210
>> #define FC_WEIGHT_HEAVY FC_WEIGHT_BLACK
>> #define FC_WEIGHT_EXTRABLACK 215
>> #define FC_WEIGHT_ULTRABLACK FC_WEIGHT_EXTRABLACK
>>
>> Is there any clear relationship between them please?
So from the figures below, mapping backwards
<40 : 75
<50 : 245
<75 : 365
<80 : 420
<100: 500
<180: 600
<200: 700
<205: 800
else 900
Thanks for that.
Shame there are no standards in this area.
DaveP
>
> This is how Pango maps them:
>
>
> static int
> pango_fc_convert_weight_to_fc (PangoWeight pango_weight)
> {
> if (pango_weight <= (PANGO_WEIGHT_THIN + PANGO_WEIGHT_ULTRALIGHT) / 2)
> return FC_WEIGHT_THIN;
> else if (pango_weight <= (PANGO_WEIGHT_ULTRALIGHT + PANGO_WEIGHT_LIGHT) / 2)
> return FC_WEIGHT_ULTRALIGHT;
> else if (pango_weight <= (PANGO_WEIGHT_LIGHT + PANGO_WEIGHT_BOOK) / 2)
> return FC_WEIGHT_LIGHT;
> else if (pango_weight <= (PANGO_WEIGHT_BOOK + PANGO_WEIGHT_NORMAL) / 2)
> return FC_WEIGHT_BOOK;
> else if (pango_weight <= (PANGO_WEIGHT_NORMAL + PANGO_WEIGHT_MEDIUM) / 2)
> return FC_WEIGHT_NORMAL;
> else if (pango_weight <= (PANGO_WEIGHT_MEDIUM + PANGO_WEIGHT_SEMIBOLD) / 2)
> return FC_WEIGHT_MEDIUM;
> else if (pango_weight <= (PANGO_WEIGHT_SEMIBOLD + PANGO_WEIGHT_BOLD) / 2)
> return FC_WEIGHT_DEMIBOLD;
> else if (pango_weight <= (PANGO_WEIGHT_BOLD + PANGO_WEIGHT_ULTRABOLD) / 2)
> return FC_WEIGHT_BOLD;
> else if (pango_weight <= (PANGO_WEIGHT_ULTRABOLD + PANGO_WEIGHT_HEAVY) / 2)
> return FC_WEIGHT_ULTRABOLD;
> else if (pango_weight <= (PANGO_WEIGHT_HEAVY + PANGO_WEIGHT_ULTRAHEAVY) / 2)
> return FC_WEIGHT_BLACK;
> else
> return FC_WEIGHT_EXTRABLACK;
> }
>
> where:
>
> typedef enum {
> PANGO_WEIGHT_THIN = 100,
> PANGO_WEIGHT_ULTRALIGHT = 200,
> PANGO_WEIGHT_LIGHT = 300,
> PANGO_WEIGHT_BOOK = 380,
> PANGO_WEIGHT_NORMAL = 400,
> PANGO_WEIGHT_MEDIUM = 500,
> PANGO_WEIGHT_SEMIBOLD = 600,
> PANGO_WEIGHT_BOLD = 700,
> PANGO_WEIGHT_ULTRABOLD = 800,
> PANGO_WEIGHT_HEAVY = 900,
> PANGO_WEIGHT_ULTRAHEAVY = 1000
> } PangoWeight;
>
>
> behdad
>
>> TIA
>
--
Dave Pawson
XSLT XSL-FO FAQ.
Docbook FAQ.
http://www.dpawson.co.uk
More information about the Fontconfig
mailing list