bug 728866 - pt 2 - implement canonical composition callbacks for harfbuzz. r=smontagu
authorJonathan Kew <jfkthame@gmail.com>
Mon, 20 Feb 2012 20:39:59 +0000
changeset 87249 2c3f7f3ace8913fa91417c4dc9c462b536a031fb
parent 87248 8ee6310cecda70be036be4eadd436735677d0898
child 87250 969493463a87c7942ac30d75c9548e547f03b976
push id22103
push userbmo@edmorley.co.uk
push dateTue, 21 Feb 2012 12:01:45 +0000
treeherdermozilla-central@4038ffaa5d82 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmontagu
bugs728866
milestone13.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 728866 - pt 2 - implement canonical composition callbacks for harfbuzz. r=smontagu
gfx/thebes/gfxHarfBuzzShaper.cpp
--- a/gfx/thebes/gfxHarfBuzzShaper.cpp
+++ b/gfx/thebes/gfxHarfBuzzShaper.cpp
@@ -45,23 +45,23 @@
 
 #include "gfxTypes.h"
 
 #include "gfxContext.h"
 #include "gfxPlatform.h"
 #include "gfxHarfBuzzShaper.h"
 #include "gfxFontUtils.h"
 #include "gfxUnicodeProperties.h"
+#include "nsUnicodeNormalizer.h"
 
 #include "harfbuzz/hb-unicode.h"
 #include "harfbuzz/hb-ot.h"
 
 #include "cairo.h"
 
-#include "nsUnicodeRange.h"
 #include "nsCRT.h"
 
 #if defined(XP_WIN)
 #include "gfxWindowsPlatform.h"
 #endif
 
 #define FloatToFixed(f) (65536 * (f))
 #define FixedToFloat(f) ((f) * (1.0 / 65536.0))
@@ -695,16 +695,36 @@ HBGetCombiningClass(hb_unicode_funcs_t *
 }
 
 static unsigned int
 HBGetEastAsianWidth(hb_unicode_funcs_t *ufuncs, hb_codepoint_t aCh, void *user_data)
 {
     return gfxUnicodeProperties::GetEastAsianWidth(aCh);
 }
 
+static hb_bool_t
+HBUnicodeCompose(hb_unicode_funcs_t *ufuncs,
+                 hb_codepoint_t      a,
+                 hb_codepoint_t      b,
+                 hb_codepoint_t     *ab,
+                 void               *user_data)
+{
+    return nsUnicodeNormalizer::Compose(a, b, ab);
+}
+
+static hb_bool_t
+HBUnicodeDecompose(hb_unicode_funcs_t *ufuncs,
+                   hb_codepoint_t      ab,
+                   hb_codepoint_t     *a,
+                   hb_codepoint_t     *b,
+                   void               *user_data)
+{
+    return nsUnicodeNormalizer::DecomposeNonRecursively(ab, a, b);
+}
+
 /*
  * gfxFontShaper override to initialize the text run using HarfBuzz
  */
 
 static hb_font_funcs_t * sHBFontFuncs = nsnull;
 static hb_unicode_funcs_t * sHBUnicodeFuncs = nsnull;
 
 bool
@@ -748,16 +768,22 @@ gfxHarfBuzzShaper::ShapeWord(gfxContext 
                                                        HBGetGeneralCategory,
                                                        nsnull, nsnull);
             hb_unicode_funcs_set_combining_class_func(sHBUnicodeFuncs,
                                                       HBGetCombiningClass,
                                                       nsnull, nsnull);
             hb_unicode_funcs_set_eastasian_width_func(sHBUnicodeFuncs,
                                                       HBGetEastAsianWidth,
                                                       nsnull, nsnull);
+            hb_unicode_funcs_set_compose_func(sHBUnicodeFuncs,
+                                              HBUnicodeCompose,
+                                              nsnull, nsnull);
+            hb_unicode_funcs_set_decompose_func(sHBUnicodeFuncs,
+                                                HBUnicodeDecompose,
+                                                nsnull, nsnull);
         }
 
         mHBFace = hb_face_create_for_tables(HBGetTable, this, nsnull);
 
         if (!mUseFontGetGlyph) {
             // get the cmap table and find offset to our subtable
             mCmapTable = mFont->GetFontTable(TRUETYPE_TAG('c','m','a','p'));
             if (!mCmapTable) {