bug 831687 - make graphite shaping use hinted widths if implemented by the font. r=jdaggett
authorJonathan Kew <jkew@mozilla.com>
Mon, 21 Jan 2013 09:24:24 +0000
changeset 130074 0ac50fa858a75243ef900d34a87d6f220799b5f0
parent 130073 cd882f775915447284231dc037f5f0663c352c7e
child 130075 cc202449de94c0e8447e3c267a4d114c6a7e3000
push id317
push userbbajaj@mozilla.com
push dateTue, 07 May 2013 01:20:33 +0000
treeherdermozilla-release@159a10910249 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdaggett
bugs831687
milestone21.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 831687 - make graphite shaping use hinted widths if implemented by the font. r=jdaggett
gfx/thebes/gfxGraphiteShaper.cpp
gfx/thebes/gfxGraphiteShaper.h
--- a/gfx/thebes/gfxGraphiteShaper.cpp
+++ b/gfx/thebes/gfxGraphiteShaper.cpp
@@ -36,18 +36,17 @@ using namespace mozilla; // for AutoSwap
 
 /*
  * Creation and destruction; on deletion, release any font tables we're holding
  */
 
 gfxGraphiteShaper::gfxGraphiteShaper(gfxFont *aFont)
     : gfxFontShaper(aFont),
       mGrFace(nullptr),
-      mGrFont(nullptr),
-      mUseFontGlyphWidths(false)
+      mGrFont(nullptr)
 {
     mTables.Init();
     mCallbackData.mFont = aFont;
     mCallbackData.mShaper = this;
 }
 
 PLDHashOperator
 ReleaseTableFunc(const uint32_t& /* aKey */,
@@ -152,21 +151,29 @@ gfxGraphiteShaper::ShapeText(gfxContext 
 
     mCallbackData.mContext = aContext;
 
     if (!mGrFont) {
         mGrFace = gr_make_face(&mCallbackData, GrGetTable, gr_face_default);
         if (!mGrFace) {
             return false;
         }
-        mGrFont = mUseFontGlyphWidths ?
-            gr_make_font_with_advance_fn(mFont->GetAdjustedSize(),
-                                         &mCallbackData, GrGetAdvance,
-                                         mGrFace) :
-            gr_make_font(mFont->GetAdjustedSize(), mGrFace);
+
+        if (mFont->ProvidesGlyphWidths()) {
+            gr_font_ops ops = {
+                sizeof(gr_font_ops),
+                &GrGetAdvance,
+                nullptr // vertical text not yet implemented
+            };
+            mGrFont = gr_make_font_with_ops(mFont->GetAdjustedSize(),
+                                            &mCallbackData, &ops, mGrFace);
+        } else {
+            mGrFont = gr_make_font(mFont->GetAdjustedSize(), mGrFace);
+        }
+
         if (!mGrFont) {
             gr_face_destroy(mGrFace);
             mGrFace = nullptr;
             return false;
         }
     }
 
     gfxFontEntry *entry = mFont->GetFontEntry();
--- a/gfx/thebes/gfxGraphiteShaper.h
+++ b/gfx/thebes/gfxGraphiteShaper.h
@@ -53,18 +53,14 @@ protected:
 
     gr_face *mGrFace;
     gr_font *mGrFont;
 
     CallbackData mCallbackData;
 
     nsDataHashtable<nsUint32HashKey,TableRec> mTables;
 
-    // Whether the font implements GetGlyphWidth, or we should read tables
-    // directly to get ideal widths
-    bool mUseFontGlyphWidths;
-
     // Convert HTML 'lang' (BCP47) to Graphite language code
     static uint32_t GetGraphiteTagForLang(const nsCString& aLang);
     static nsTHashtable<nsUint32HashKey> sLanguageTags;
 };
 
 #endif /* GFX_GRAPHITESHAPER_H */