Index: tests/SerializationTest.cpp |
diff --git a/tests/SerializationTest.cpp b/tests/SerializationTest.cpp |
index dd9b938d52e26df4d9761144db484c35a90c4b08..dd4c89b09c5022e7034b28494b0a778b02e73d18 100644 |
--- a/tests/SerializationTest.cpp |
+++ b/tests/SerializationTest.cpp |
@@ -17,6 +17,9 @@ |
#include "SkWriteBuffer.h" |
#include "SkValidatingReadBuffer.h" |
#include "SkXfermodeImageFilter.h" |
+#ifdef SK_BUILD_FOR_MAC |
+#include "SkTypeface_mac.h" |
+#endif |
#include "Test.h" |
static const uint32_t kArraySize = 64; |
@@ -316,21 +319,7 @@ static void compare_bitmaps(skiatest::Reporter* reporter, |
REPORTER_ASSERT(reporter, 0 == pixelErrors); |
} |
-static void TestPictureTypefaceSerialization(skiatest::Reporter* reporter) { |
- // Load typeface form file. |
- // This test cannot run if there is no resource path. |
- SkString resourcePath = GetResourcePath(); |
- if (resourcePath.isEmpty()) { |
- SkDebugf("Could not run fontstream test because resourcePath not specified."); |
- return; |
- } |
- SkString filename = SkOSPath::Join(resourcePath.c_str(), "test.ttc"); |
- SkTypeface* typeface = SkTypeface::CreateFromFile(filename.c_str(), 1); |
- if (!typeface) { |
- SkDebugf("Could not run fontstream test because test.ttc not found."); |
- return; |
- } |
- |
+static void TestPictureTypefaceSerialization(skiatest::Reporter* reporter, SkTypeface* typeface) { |
// Create a paint with the typeface we loaded. |
SkPaint paint; |
paint.setColor(SK_ColorGRAY); |
@@ -527,5 +516,36 @@ DEF_TEST(Serialization, reporter) { |
REPORTER_ASSERT(reporter, readPict.get()); |
} |
- TestPictureTypefaceSerialization(reporter); |
+ { |
+ // Load typeface form file. |
+ // This test cannot run if there is no resource path. |
+ SkString resourcePath = GetResourcePath(); |
+ if (resourcePath.isEmpty()) { |
+ SkDebugf("Could not run fontstream test because resourcePath not specified."); |
+ return; |
+ } |
+ SkString filename = SkOSPath::Join(resourcePath.c_str(), "test.ttc"); |
+ SkTypeface* typeface = SkTypeface::CreateFromFile(filename.c_str(), 1); |
+ if (!typeface) { |
+ SkDebugf("Could not run fontstream test because test.ttc not found."); |
+ return; |
+ } |
+ |
+ TestPictureTypefaceSerialization(reporter, typeface); |
+ |
+#ifdef SK_BUILD_FOR_MAC |
+ // Now do almost the same but use SkCreateTypefaceFromCTFont |
+ CGDataProviderRef provider = CGDataProviderCreateWithFilename(filename.c_str()); |
+ CGFontRef cgFont = CGFontCreateWithDataProvider(provider); |
+ if (NULL == cgFont) { |
+ SkDebugf("Could not run fontstream test, CGFontCreateWithDataProvider failed."); |
+ return; |
+ } |
+ CTFontRef ctFont = CTFontCreateWithGraphicsFont(cgFont, 0, NULL, NULL); |
+ typeface = SkCreateTypefaceFromCTFont(ctFont); |
+ TestPictureTypefaceSerialization(reporter, typeface); |
+ CFRelease(cgFont); |
+ CFRelease(provider); |
+#endif // SK_BUILD_FOR_MAC |
+ } |
} |