tags:

views:

190

answers:

2

I am using Pango in an application implementing part of the CSS specification and so far I have been stumped by the font-weight: (bolder|lighter) attribute.

According to specification,

'bolder' selects the next weight that is assigned to a font that is darker than the inherited one.

'lighter' is similar, but works in the opposite direction: it selects the next lighter keyword with a different font from the inherited one.

I can't seem to find a simple way of getting the weight value that would give me a darker (or lighter) font.

A: 

Take a look at the font_weight attribute.

GreenReign
The font-weight attribute only takes absolute values. I have the same issues with markup as I do with a PangoFontDescription
Alex Brault
I don't quite understand the context you're coming from. Can't you write a simple function "font_weight bolder(font_weight)" that parses the passed in font_weight and returns a slightly bolder one?(I'm not very familiar with Pango, as you might have guessed.)
GreenReign
A: 

I don't understand the issue?
Bolder and Lighter are relative CSS Styles, and will change the font weight of an element relative to its inherited value. Valid values are 100-900, however most fonts wont support all weights so things like 400-600 will all appear the same, etc.

As an example, if the normal font weight was normal font (like this, or weight = 500), bolder would be the next increment and would probably be 700 and look like this.

If the default font was weight 700, then lighter would make the new font appear as normal weight, or 500.

Ian Elliott
The issue is that I can't find a way to tell when my font is actually bolder.Like you and the CSS specs said, most fonts are mapped with 100-600 being a normal font and 700-900 being bold. The problem I have is, assuming I have a parent with a `font-weight: normal` (or 400) and a child with `bolder`, I don't know how to find out if I need to reach 700 to be bolder or if 500 is enough like with a fancier font
Alex Brault
The fact is you can't tell. It depends on the fonts that the user has installed. If they don't have the right fonts it won't be bold for any value. More common fonts like Arial should have more bold support than others.
Ian Elliott