Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(950)

Unified Diff: tests/SerializationTest.cpp

Issue 692553002: Add a flag indicating locally-created fonts to SkCreateTypefaceFromCTFont (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fixed line length Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/ports/SkFontHost_mac.cpp ('K') | « src/ports/SkFontHost_mac.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
+ }
}
« src/ports/SkFontHost_mac.cpp ('K') | « src/ports/SkFontHost_mac.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698