aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-10-24 22:32:43 +0000
committerGravatar bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-10-24 22:32:43 +0000
commitfb1663a0a57656328277d02bef088d3afb695a7c (patch)
treeadf8e2b38eda296dfee4fe5355606665e80e9312
parent172c363a68da7b46562fa9c6c8f15f3a7ffce5a1 (diff)
Fix non-bmp in generateCharToGlyph on Mac.
git-svn-id: http://skia.googlecode.com/svn/trunk@11957 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--gm/verttext.cpp1
-rw-r--r--include/ports/SkFontMgr.h5
-rwxr-xr-xsrc/ports/SkFontHost_mac.cpp20
3 files changed, 15 insertions, 11 deletions
diff --git a/gm/verttext.cpp b/gm/verttext.cpp
index 1f1c64dfe6..c17b0db710 100644
--- a/gm/verttext.cpp
+++ b/gm/verttext.cpp
@@ -90,6 +90,7 @@ protected:
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 4e5055246a..2a4219d4e3 100644
--- a/include/ports/SkFontMgr.h
+++ b/include/ports/SkFontMgr.h
@@ -99,7 +99,10 @@ protected:
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 987f185101..0b77aa20f7 100755
--- a/src/ports/SkFontHost_mac.cpp
+++ b/src/ports/SkFontHost_mac.cpp
@@ -945,21 +945,21 @@ unsigned SkScalerContext_Mac::generateGlyphCount(void) {
}
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) {