# using freetype's embolden allows us to adjust fake bold settings at
# draw-time, at which point we know which SkTypeface is being drawn
'SK_USE_FREETYPE_EMBOLDEN',
- 'SK_SFNTLY_SUBSETTER "sample/chromium/font_subsetter.h"',
# When built as part of the system image we can enable certian non-NDK
# compliant optimizations.
'SK_BUILD_FOR_ANDROID_FRAMEWORK',
'conditions': [
[ 'skia_pdf_use_sfntly and not skia_android_framework and \
skia_os in ["win", "android", "linux", "mac"]',
- { 'dependencies': [ 'sfntly.gyp:sfntly' ] }
+ {
+ 'dependencies': [ 'sfntly.gyp:sfntly' ],
+ 'defines': [ 'SK_PDF_USE_SFNTLY' ],
+ }
],
[ 'skia_android_framework', {
# Add SFTNLY support for PDF (which in turns depends on ICU)
- 'include_dirs': [
- 'external/sfntly/cpp/src',
- ],
+ 'include_dirs': [ 'external/sfntly/cpp/src' ],
+ 'defines': [ 'SK_PDF_USE_SFNTLY' ],
'libraries': [
'libsfntly.a',
'-licuuc',
#include "SkTypes.h"
#include "SkUtils.h"
-#if defined (SK_SFNTLY_SUBSETTER)
- #if defined (GOOGLE3)
- // #including #defines doesn't work with this build system.
- #include "sample/chromium/font_subsetter.h"
- #else
- #include SK_SFNTLY_SUBSETTER
- #endif
+// TODO(halcanary): Switch Chrome from SK_SFNTLY_SUBSETTER to SK_PDF_USE_SFNTLY.
+#if defined(SK_SFNTLY_SUBSETTER) && !defined(SK_PDF_USE_SFNTLY)
+ #define SK_PDF_USE_SFNTLY
+#endif
+
+#ifdef SK_PDF_USE_SFNTLY
+ #include "sample/chromium/font_subsetter.h"
#endif
namespace {
return !SkToBool(metrics.fFlags & SkAdvancedTypefaceMetrics::kNotEmbeddable_FontFlag);
}
-#ifdef SK_SFNTLY_SUBSETTER
+#ifdef SK_PDF_USE_SFNTLY
static bool can_subset(const SkAdvancedTypefaceMetrics& metrics) {
return !SkToBool(metrics.fFlags & SkAdvancedTypefaceMetrics::kNotSubsettable_FontFlag);
}
}
#endif
-#ifdef SK_SFNTLY_SUBSETTER
+#ifdef SK_PDF_USE_SFNTLY
// if possible, make no copy.
static sk_sp<SkData> stream_to_data(std::unique_ptr<SkStreamAsset> stream) {
SkASSERT(stream);
subsetStream->dict()->insertInt("Length1", subsetFontSize);
return subsetStream;
}
-#endif // SK_SFNTLY_SUBSETTER
+#endif // SK_PDF_USE_SFNTLY
void SkPDFType0Font::getFontSubset(SkPDFCanon* canon) {
const SkAdvancedTypefaceMetrics* metricsPtr =
return;
}
- #ifdef SK_SFNTLY_SUBSETTER
+ #ifdef SK_PDF_USE_SFNTLY
if (can_subset(metrics)) {
// Generate glyph id array. in format needed by sfntly
SkTDArray<uint32_t> glyphIDs;
// If subsetting fails, fall back to original font data.
fontAsset.reset(face->openStream(&ttcIndex));
}
- #endif // SK_SFNTLY_SUBSETTER
+ #endif // SK_PDF_USE_SFNTLY
auto fontStream = sk_make_sp<SkPDFSharedStream>(std::move(fontAsset));
fontStream->dict()->insertInt("Length1", fontSize);
descriptor->insertObjRef("FontFile2", std::move(fontStream));