Revision 136747 of Gfx

  • Revision slug: Gfx2
  • Revision title: Gfx
  • Revision id: 136747
  • Created:
  • Creator: ryoqun
  • Is current revision? No
  • Comment 158 words added, 29 words removed; page display name changed to 'Gfx'

Revision Content

As I study the code, I'm going to fill this page. Every sentence is of uncertainy. So, I don't use "maybe" or "perphaps". But that doesn't mean I'm sure that is correct. I just don't want to mess up readability with those unnessesary words. If you find errors, correct them.

Text rendering on Linux

Of cource, gfx takes text, and it breaks down to textruns. Then, what exactly happening under the hood? Basically, there is two dives into gfx to render the page. One is for making gfx do glyph-level layout, and auquiring the result of textruns, in turn, using that information, gecko do css-box-level layout with frames (a.k.a. reflow). The other is for actually making gfx draw graphics using the combined glyph-level- and css-box-level- geometric information.

Cairo

This is lying under gfx, with wearing thebes. ;) Cairo interacts with gfx's text rendering in some way. One is by becoming by proxy of gfx and Freetype. Because Freetype's glyph data is destined to Cairo, gfx instructs Freetype only via Cairo. Thus, actual glyph vector data are stop at Cairo, in the form which Cairo likes(cairo_scaled_font_t). To complicate this, mozilla-central contains cairo. What's happening here? Is it modified and/or used on Linux? Also, Cairo is used even on Windows and Mac OS X. So, gfxFont is associated with Cairo to some extent.

Pango

Pango is for doing layout of glyphs. But, gfx doesn't use the high level PangoLayout. Instead, it interacts it deeply. First of all, Pango doesn't render at all. Pango is only used for calculating positions of glyphs. Then evenry resultant information are passed back to gfx. How gfx communicate with Pango?

Fontconfig

This enables font selection. Various CSS values are passed as FC_Pattern. Genelly FC_Pattern is used passing around information between gfx, pango, freetype. Because of modular neture, pango uses callbacks. Thus this kind of method is neccesary.

Freetype

This extracts glyphs from actual font files residing in the system. At this level, RTL glyphs are exactly same as LTR glyphs. This means. glyph's coordinate is tied to screen coordinate, not the text coordinate in which the glyph may belong to. So, while we render glyphs, we must do x-=width.

The files

gfxFont.cpp gfxFont.h: this is for platform-independent header related Fonts.

gfxPangoFont.cpp

Various caches:

textrun, glyph metrics, extents.

The flowchart.

1st: Glyph Layout part.

How extents are retreaved??? And cached??

gfx_pango_fc_font_get_glyph_extents() is called every time glyph extents is needed by Pango's shapers.

2nd: Glyph Rendering part.

nsSVGGlyphFrame::FillCharacters -> gfxTextRun::Draw -> gfxFont::Draw()

gfxFont.cpp:333 gfxFont::Draw() does final rendering of all glyphs rendered on Firefox, even including UI.

Revision Source

<p>As I study the code, I'm going to fill this page. Every sentence is of uncertainy. So, I don't use "maybe" or "perphaps". But that doesn't mean I'm sure that is correct. I just don't want to mess up readability with those unnessesary words. If you find errors, correct them.</p>
<h2><span style="font-size: x-large;">Text rendering on Linux</span></h2>
<p>Of cource, gfx takes text, and it breaks down to textruns. Then, what exactly happening under the hood? Basically, there is two dives into gfx to render the page. One is for making gfx do glyph-level layout, and auquiring the result of textruns, in turn, using that information, gecko do css-box-level layout with frames (a.k.a. reflow). The other is for actually making gfx draw graphics using the combined glyph-level- and css-box-level- geometric information.</p>
<h3><span style="font-size: x-large;">Cairo</span></h3>
<p>This is lying under gfx, with wearing thebes. ;) Cairo interacts with gfx's text rendering in some way. One is by becoming by proxy of gfx and Freetype. Because Freetype's glyph data is destined to Cairo, gfx instructs Freetype only via Cairo. Thus, actual glyph vector data are stop at Cairo, in the form which Cairo likes(cairo_scaled_font_t). To complicate this, mozilla-central contains cairo. What's happening here? Is it modified and/or used on Linux? Also, Cairo is used even on Windows and Mac OS X. So, gfxFont is associated with Cairo to some extent.</p>
<h3><span style="font-size: x-large;">Pango</span></h3>
<p>Pango is for doing layout of glyphs. But, gfx doesn't use the high level PangoLayout. Instead, it interacts it deeply. First of all, Pango doesn't render at all. Pango is only used for calculating positions of glyphs. Then evenry resultant information are passed back to gfx. How gfx communicate with Pango?</p>
<h3><span style="font-size: x-large;">Fontconfig</span></h3>
<p>This enables font selection. Various CSS values are passed as FC_Pattern. Genelly FC_Pattern is used passing around information between gfx, pango, freetype. Because of modular neture, pango uses callbacks. Thus this kind of method is neccesary.</p>
<h3><span style="font-size: x-large;">Freetype</span></h3>
<p>This extracts glyphs from actual font files residing in the system. At this level, RTL glyphs are exactly same as LTR glyphs. This means. glyph's coordinate is tied to screen coordinate, not the text coordinate in which the glyph may belong to. So, while we render glyphs, we must do x-=width.</p>
<h3><span style="font-size: x-large;">The files</span></h3>
<p>gfxFont.cpp gfxFont.h: this is for platform-independent header related Fonts.</p>
<p>gfxPangoFont.cpp</p>
<h3><span style="font-size: x-large;">Various caches:</span></h3>
<p>textrun, glyph metrics, extents.</p>
<h3><span style="font-size: x-large;">The flowchart.</span></h3>
<p>1st: Glyph Layout part.</p>
<p>How extents are retreaved??? And cached??</p>
<p>gfx_pango_fc_font_get_glyph_extents() is called every time glyph extents is needed by Pango's shapers.</p>
<p>2nd: Glyph Rendering part.</p>
<p>nsSVGGlyphFrame::FillCharacters -&gt; gfxTextRun::Draw -&gt; gfxFont::Draw()</p>
<p>gfxFont.cpp:333 gfxFont::Draw() does final rendering of all glyphs rendered on Firefox, even including UI.</p>
Revert to this revision