[webkit-dev] Font Name

Eric Seidel eric at webkit.org
Sun May 29 09:59:32 PDT 2011

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

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:

> Hi,
> 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">
> body.rahaman{
> font:30px courier;
> }
> </style>
> <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.
> Thanks,
> Rahaman
> On Fri, May 20, 2011 at 12:22 AM, Soheil Servati Beiragh <
> sservati at yahoo.com> wrote:
>> Hi
>> 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
>> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20110529/cdf069cb/attachment.html>

More information about the webkit-dev mailing list