Fix non-bmp in generateCharToGlyph on Mac.

git-svn-id: http://skia.googlecode.com/svn/trunk@11957 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gm/verttext.cpp b/gm/verttext.cpp
index 1f1c64d..c17b0db 100644
--- a/gm/verttext.cpp
+++ b/gm/verttext.cpp
@@ -90,6 +90,7 @@
             SkPaint paint;
             paint.setAntiAlias(true);
             paint.setTextSize(SkIntToScalar(TEXT_SIZE));
+            paint.setTextSkewX(-SK_Scalar1 / 4);
             //paint.setTypeface(fFace);
             //paint.setFakeBoldText(true);
 
diff --git a/include/ports/SkFontMgr.h b/include/ports/SkFontMgr.h
index 4e50552..2a4219d 100644
--- a/include/ports/SkFontMgr.h
+++ b/include/ports/SkFontMgr.h
@@ -99,7 +99,10 @@
     virtual SkTypeface* onCreateFromData(SkData*, int ttcIndex) = 0;
     virtual SkTypeface* onCreateFromStream(SkStream*, int ttcIndex) = 0;
     virtual SkTypeface* onCreateFromFile(const char path[], int ttcIndex) = 0;
-    virtual SkTypeface* onLegacyCreateTypeface(const char familyName[], unsigned styleBits) = 0;
+
+    // TODO: make this pure-virtual once all ports know about it
+    virtual SkTypeface* onLegacyCreateTypeface(const char familyName[],
+                                               unsigned styleBits) = 0;
 private:
     static SkFontMgr* Factory();    // implemented by porting layer
 
diff --git a/src/ports/SkFontHost_mac.cpp b/src/ports/SkFontHost_mac.cpp
index 987f185..0b77aa2 100755
--- a/src/ports/SkFontHost_mac.cpp
+++ b/src/ports/SkFontHost_mac.cpp
@@ -945,21 +945,21 @@
 }
 
 uint16_t SkScalerContext_Mac::generateCharToGlyph(SkUnichar uni) {
-    CGGlyph     cgGlyph;
-    UniChar     theChar;
-
-    // Validate our parameters and state
-    SkASSERT(uni <= 0x0000FFFF);
-    SkASSERT(sizeof(CGGlyph) <= sizeof(uint16_t));
+    CGGlyph cgGlyph[2];
+    UniChar theChar[2];
 
     // Get the glyph
-    theChar = (UniChar) uni;
+    size_t numUniChar = SkUTF16_FromUnichar(uni, theChar);
+    SkASSERT(sizeof(CGGlyph) <= sizeof(uint16_t));
 
-    if (!CTFontGetGlyphsForCharacters(fCTFont, &theChar, &cgGlyph, 1)) {
-        cgGlyph = 0;
+    // Undocumented behavior of CTFontGetGlyphsForCharacters with non-bmp code points.
+    // When a surragate pair is detected, the glyph index used is the index of the first
+    // UniChar of the pair (the lower location).
+    if (!CTFontGetGlyphsForCharacters(fCTFont, theChar, cgGlyph, numUniChar)) {
+        cgGlyph[0] = 0;
     }
 
-    return cgGlyph;
+    return cgGlyph[0];
 }
 
 void SkScalerContext_Mac::generateAdvance(SkGlyph* glyph) {