add glyph->unichar query (inverse of a cmap)



git-svn-id: http://skia.googlecode.com/svn/trunk@472 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp
index d5a48a6..0974b8d 100644
--- a/src/ports/SkFontHost_FreeType.cpp
+++ b/src/ports/SkFontHost_FreeType.cpp
@@ -115,6 +115,7 @@
     virtual void generatePath(const SkGlyph& glyph, SkPath* path);
     virtual void generateFontMetrics(SkPaint::FontMetrics* mx,
                                      SkPaint::FontMetrics* my);
+    virtual SkUnichar generateGlyphToChar(uint16_t glyph);
 
 private:
     SkFaceRec*  fFaceRec;
@@ -470,6 +471,21 @@
     return SkToU16(FT_Get_Char_Index( fFace, uni ));
 }
 
+SkUnichar SkScalerContext_FreeType::generateGlyphToChar(uint16_t glyph) {
+    // iterate through each cmap entry, looking for matching glyph indices
+    FT_UInt glyphIndex;
+    SkUnichar charCode = FT_Get_First_Char( fFace, &glyphIndex );
+
+    while (glyphIndex != 0) {
+        if (glyphIndex == glyph) {
+            return charCode;
+        }
+        charCode = FT_Get_Next_Char( fFace, charCode, &glyphIndex );
+    }
+
+    return 0;
+}
+
 static FT_Pixel_Mode compute_pixel_mode(SkMask::Format format) {
     switch (format) {
         case SkMask::kHorizontalLCD_Format: