Basic font implementation
authorpekka.aho
Sat, 19 Apr 2008 18:37:47 +0300
changeset 16806 02bbde1c743c838d338df0fe25c9d46a932d4b54
parent 16805 4a15a0a88898751d919ecfd9892207004b74fb51
child 16807 ac82879b3f816b6ec7c60db45f66f5335237a6a1
push id1298
push userpavlov@mozilla.com
push dateSun, 17 Aug 2008 05:03:09 +0000
treeherderautoland@4a506fa751d8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone2.0a1pre
Basic font implementation
gfx/thebes/src/gfxQtFonts.cpp
--- a/gfx/thebes/src/gfxQtFonts.cpp
+++ b/gfx/thebes/src/gfxQtFonts.cpp
@@ -68,18 +68,16 @@ FFRECountHyphens (const nsAString &aFFRE
     return h;
 }
 
 PRBool
 gfxQtFontGroup::FontCallback (const nsAString& fontName,
                                  const nsACString& genericName,
                                  void *closure)
 {
-    qDebug("gfxQtFontGroup Func:%s::%d\n", __PRETTY_FUNCTION__, __LINE__);
-
     nsStringArray *sa = static_cast<nsStringArray*>(closure);
 
     // We ignore prefs that have three hypens since they are X style prefs.
     if (genericName.Length() && FFRECountHyphens(fontName) >= 3)
         return PR_TRUE;
 
     if (sa->IndexOf(fontName) < 0) {
         sa->AppendString(fontName);
@@ -247,18 +245,16 @@ g_utf8_get_char (const char *p)
   UTF8_GET (result, p, i, mask, len);
   return result;
 }
 
 nsresult
 gfxQtFontGroup::CreateGlyphRunsFast(gfxTextRun *aTextRun,
                                     const char *aUTF8, PRUint32 aUTF8Length)
 {
-    qDebug("gfxQtFontGroup Func:%s::%d\n", __PRETTY_FUNCTION__, __LINE__);
-
     const char *p = aUTF8;
     gfxQtFont *font = GetFontAt(0);
     const QFont& qFont = font->GetQFont();
     FT_Face face = qFont.freetypeFace();
     PRUint32 utf16Offset = 0;
     gfxTextRun::CompressedGlyph g;
     const PRUint32 appUnitsPerDevUnit = aTextRun->GetAppUnitsPerDevUnit();
 
@@ -279,20 +275,20 @@ gfxQtFontGroup::CreateGlyphRunsFast(gfxT
         } else {
             NS_ASSERTION(!IsInvalidChar(ch), "Invalid char detected");
             int glyph = 124;
             glyph = FT_Get_Char_Index (face, ch);
 
             if (!glyph)                  // character not in font,
                 return NS_ERROR_FAILURE; // fallback to CreateGlyphRunsItemizing
 
-            QRect rect;
-//            pango_font_get_glyph_extents (pangofont, glyph, NULL, &rect);
-            PRInt32 advance = 0;
-            //advance = PANGO_PIXELS (rect.width * appUnitsPerDevUnit);
+            FT_Load_Glyph(face, glyph, FT_LOAD_DEFAULT);
+            PRInt32 advance = face->glyph->advance.x;
+            advance = (advance >> 6) * appUnitsPerDevUnit;
+
             if (advance >= 0 &&
                 gfxTextRun::CompressedGlyph::IsSimpleAdvance(advance) &&
                 gfxTextRun::CompressedGlyph::IsSimpleGlyphID(glyph)) {
                 aTextRun->SetSimpleGlyph(utf16Offset,
                                          g.SetSimpleGlyph(advance, glyph));
             } else {
                 gfxTextRun::DetailedGlyph details;
                 details.mGlyphID = glyph;