Forum How do I...?

Inline font tags

mickyjtwin
We are using a WYSIWYG to dynamically build the html to be used for a pdf publish. What we've noticed is that when changing a font style, size or color, it adds the <font> tag. This does not get read by PrinceXML, as to my understanding about the product, it reads the style tag, or css classes. Would the only way to make this work be by converting the font tags into inline styles?
It's not really possible to create all the styles, as for things like colour etc, there are so many variations.
mikeday
Try adding these rules to your CSS style sheet:
font[color] { color: attr(color) }
font[face] { font-family: attr(face) }

This will make Prince use the color attribute for the color property and the face attribute for the font-family property, so that something like this will work:
<font face="Verdana" color="green">Hello!</font>

However, the size attribute is a bit more difficult, as it uses a number that does not directly correspond to font size in CSS. If you wish to use this attribute you will need to support each option:
font[size="1"] { font-size: xx-small }
font[size="2"] { font-size: small }
font[size="3"] { font-size: medium }
font[size="4"] { font-size: large }
font[size="5"] { font-size: x-large }
font[size="6"] { font-size: xx-large }
mickyjtwin
Brilliant! Works great.