SkTypeface_win_dw, SkTypeface_Mac: set NotEmbeddable_FontFlag

BUG=skia:7275
BUG=skia:7276
Change-Id: I5376c39ddc3e9fcb1c8cb76001f3969b84bb2c96
Reviewed-on: https://skia-review.googlesource.com/69360
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
This commit is contained in:
Hal Canary 2017-11-09 11:09:34 -05:00 committed by Skia Commit-Bot
parent f0da706998
commit 4a851ca334
4 changed files with 35 additions and 4 deletions

View File

@ -1516,6 +1516,14 @@ std::unique_ptr<SkAdvancedTypefaceMetrics> SkTypeface_Mac::onGetAdvancedMetrics(
populate_glyph_to_unicode(ctFont.get(), glyphCount, &info->fGlyphToUnicode);
SkOTTableOS2_V4::Type fsType;
if (sizeof(fsType) == this->getTableData(SkTEndian_SwapBE32(SkOTTableOS2::TAG),
offsetof(SkOTTableOS2_V4, fsType),
sizeof(fsType),
&fsType)) {
SkOTUtils::SetAdvanvedTypefaceFlags(fsType, info.get());
}
// If it's not a truetype font, mark it as 'other'. Assume that TrueType
// fonts always have both glyf and loca tables. At the least, this is what
// sfntly needs to subset the font. CTFontCopyAttribute() does not always

View File

@ -372,6 +372,8 @@ std::unique_ptr<SkAdvancedTypefaceMetrics> DWriteFontTypeface::onGetAdvancedMetr
return info;
}
SkOTUtils::SetAdvanvedTypefaceFlags(os2Table->version.v4.fsType, info.get());
// There are versions of DirectWrite which support named instances for system variation fonts,
// but no means to indicate that such a typeface is a variation.
AutoTDWriteTable<SkOTTableFontVariations> fvarTable(fDWriteFontFace.get());

View File

@ -5,14 +5,16 @@
* found in the LICENSE file.
*/
#include "SkOTUtils.h"
#include "SkAdvancedTypefaceMetrics.h"
#include "SkData.h"
#include "SkEndian.h"
#include "SkSFNTHeader.h"
#include "SkStream.h"
#include "SkOTTableTypes.h"
#include "SkOTTable_head.h"
#include "SkOTTable_name.h"
#include "SkOTTableTypes.h"
#include "SkOTUtils.h"
#include "SkSFNTHeader.h"
#include "SkStream.h"
extern const uint8_t SK_OT_GlyphData_NoOutline[] = {
0x0,0x0, //SkOTTableGlyphData::numberOfContours
@ -201,3 +203,17 @@ SkOTUtils::LocalizedStrings_NameTable::familyNameTypes[3] = {
SkOTTableName::Record::NameID::Predefined::PreferredFamily,
SkOTTableName::Record::NameID::Predefined::WWSFamilyName,
};
void SkOTUtils::SetAdvanvedTypefaceFlags(SkOTTableOS2_V4::Type fsType,
SkAdvancedTypefaceMetrics* info) {
SkASSERT(info);
// The logic should be identical to SkTypeface_FreeType::onGetAdvancedMetrics().
if (fsType.raw.value != 0) {
if (SkToBool(fsType.field.Restricted) || SkToBool(fsType.field.Bitmap)) {
info->fFlags |= SkAdvancedTypefaceMetrics::kNotEmbeddable_FontFlag;
}
if (SkToBool(fsType.field.NoSubsetting)) {
info->fFlags |= SkAdvancedTypefaceMetrics::kNotSubsettable_FontFlag;
}
}
}

View File

@ -9,11 +9,13 @@
#define SkOTUtils_DEFINED
#include "SkOTTableTypes.h"
#include "SkOTTable_OS_2_V4.h"
#include "SkOTTable_name.h"
#include "SkTypeface.h"
class SkData;
class SkStream;
struct SkAdvancedTypefaceMetrics;
struct SkOTUtils {
/**
@ -86,6 +88,9 @@ struct SkOTUtils {
SkString fLanguage;
bool fHasNext;
};
static void SetAdvanvedTypefaceFlags(SkOTTableOS2_V4::Type fsType,
SkAdvancedTypefaceMetrics* info);
};
#endif