[webkit-dev] Font Name

Soheil Servati Beiragh sservati at yahoo.com
Mon May 30 08:59:54 PDT 2011

I can add to this that If someone wants to work on text rendering and doesn't want to deal with html or CSS parsing, he can find an index for the font family under:


I know for example that index for monospace family is 67 or for times new roman is 84 but I still don't know if there is a table some where about all indexes for font families.
Soheil Servati Beiragh
PhD Candidate, ECE Department,

Research Center for Integrated Microsystems,
University of Windsor.
Room 268 Essex Hall
401 Sunset Avenue
Windsor, Ontario
Canada, N9B 3P4
Phone: 519-253-3000 Ext 3396
Email: servati at uwindsor.ca

From: Eric Seidel <eric at webkit.org>
To: Mustafizur Rahaman <mustaf.here at gmail.com>
Cc: Soheil Servati <sservati at yahoo.com>; WebKit Development <webkit-dev at lists.webkit.org>
Sent: Sunday, May 29, 2011 12:59 PM
Subject: Re: [webkit-dev] Font Name

There are a couple steps missing, but this hits most of the important points.

I think one could turn such into a blog post with diagrams if so desired.


On Sat, May 21, 2011 at 5:55 PM, Mustafizur Rahaman <mustaf.here at gmail.com> wrote:

>When you are drawing  some text, you create a RenderText(RenderObject) which has all the rendering info & the m_style of RenderText has the style info required to render the text.
>Let's consider the following style data I have in my html page
><style type="text/css">
>font:30px courier;
><body class="rahaman"> Rahaman </body>
>Once the HTMLTreeBuilder parses the token, it creates HTMLStyleElement & CSSStyleSheet & then asks the CSSParser to parse the StyleSheet. From there it comes to CSSParser::parseValue()=>CSSParser::parseFont() as the I have only used font property
>We create a FontValue (which contain all the attribute a font property can have like style, size, variant, family etc=> in this font_family, you can actually see the font name you have used ). In CSSParser::parseFont, we populate the FontValue structure (you can find the font family name in font->family), calls CSSParser::addProperty() where we create a CSSProperty with the FontValue/CSSValue being passed & this property is being stored in CSSParser::m_parsedProperties.
>Then we call CSSParser::createStyleRule where we used the m_parsedProperties mentioned before to create a CSSMutableStyleDeclaration & set this declaration for the CSSRule.
>We then create CSSStyleSelector and call CSSStyleSelector::styleForElement for the root element. Here somehow (I don't have much details what happens in berween but figured out that we retrieve the same CSSMutableStyleDeclaration mentioned above) & call CSSStyleSelector::applyProperty(). Here each StyleSelector has its RenderStyle (m_style), where from we retrieve the FontDescription & add the properties accordingly. On the other hand, each RenderObject (the corresponding node in the RenderTree for a node in DOM tree) has RenderStyle, which gets the value we retrieved above.
>Finally we call GraphicsContext::drawText() passing the Font which we have retrieved from the RenderStyle we dsicussed above. 
>I am not sure if this is what you were looking for, I just shared whatever I knew of the related area. Please let me know if you need anything else.
>On Fri, May 20, 2011 at 12:22 AM, Soheil Servati Beiragh <sservati at yahoo.com> wrote:
>>I want to know after webkit parses the html file where does it save the font that is used for text? It definitely won't save a name for the font but there should be some kind of index or sth to tell the rendering engine which font is being used.
>>Thanks in advance 
>>Soheil Servati Beiragh
>>PhD Candidate, ECE Department,
>>Research Center for Integrated Microsystems,
>>University of Windsor.
>>Room 268 Essex Hall
>>401 Sunset Avenue
>>Windsor, Ontario
>>Canada, N9B 3P4
>>Phone: 519-253-3000 Ext 3396
>>Email: servati at uwindsor.ca
>>webkit-dev mailing list
>>webkit-dev at lists.webkit.org
>webkit-dev mailing list
>webkit-dev at lists.webkit.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20110530/713f9d82/attachment.html>

More information about the webkit-dev mailing list