aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar bungeman <bungeman@google.com>2016-08-19 08:45:37 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-08-19 08:45:37 -0700
commit01a16992cc9297d4985dc80e3177cc7475b9b385 (patch)
tree0073a83f2e60a4d960d05fc5146e3d5d05f393c2 /src
parent9da5a5a198e5dc9148f7f30a6089377590eee55b (diff)
Simplify embeddability test.
There is no reason to read the whole OS/2 table, and no need to spell out the full names of all the types over and over. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2256783002 Review-Url: https://codereview.chromium.org/2256783002
Diffstat (limited to 'src')
-rw-r--r--src/core/SkTypeface.cpp14
-rw-r--r--src/sfnt/SkOTTable_OS_2.h10
2 files changed, 11 insertions, 13 deletions
diff --git a/src/core/SkTypeface.cpp b/src/core/SkTypeface.cpp
index cda9b5ce5e..0c960d5915 100644
--- a/src/core/SkTypeface.cpp
+++ b/src/core/SkTypeface.cpp
@@ -291,16 +291,14 @@ SkAdvancedTypefaceMetrics* SkTypeface::getAdvancedTypefaceMetrics(
SkAdvancedTypefaceMetrics* result =
this->onGetAdvancedTypefaceMetrics(info, glyphIDs, glyphIDsCount);
if (result && result->fType == SkAdvancedTypefaceMetrics::kTrueType_Font) {
- struct SkOTTableOS2 os2table;
- if (this->getTableData(SkTEndian_SwapBE32(SkOTTableOS2::TAG), 0,
- sizeof(os2table), &os2table) > 0) {
- if (os2table.version.v2.fsType.field.Bitmap ||
- (os2table.version.v2.fsType.field.Restricted &&
- !(os2table.version.v2.fsType.field.PreviewPrint ||
- os2table.version.v2.fsType.field.Editable))) {
+ SkOTTableOS2::Version::V2::Type::Field fsType;
+ constexpr SkFontTableTag os2Tag = SkTEndian_SwapBE32(SkOTTableOS2::TAG);
+ constexpr size_t fsTypeOffset = offsetof(SkOTTableOS2::Version::V2, fsType);
+ if (this->getTableData(os2Tag, fsTypeOffset, sizeof(fsType), &fsType) == sizeof(fsType)) {
+ if (fsType.Bitmap || (fsType.Restricted && !(fsType.PreviewPrint || fsType.Editable))) {
result->fFlags |= SkAdvancedTypefaceMetrics::kNotEmbeddable_FontFlag;
}
- if (os2table.version.v2.fsType.field.NoSubsetting) {
+ if (fsType.NoSubsetting) {
result->fFlags |= SkAdvancedTypefaceMetrics::kNotSubsettable_FontFlag;
}
}
diff --git a/src/sfnt/SkOTTable_OS_2.h b/src/sfnt/SkOTTable_OS_2.h
index 4a09a78605..438257805c 100644
--- a/src/sfnt/SkOTTable_OS_2.h
+++ b/src/sfnt/SkOTTable_OS_2.h
@@ -18,11 +18,11 @@
#pragma pack(push, 1)
struct SkOTTableOS2 {
- static const SK_OT_CHAR TAG0 = 'O';
- static const SK_OT_CHAR TAG1 = 'S';
- static const SK_OT_CHAR TAG2 = '/';
- static const SK_OT_CHAR TAG3 = '2';
- static const SK_OT_ULONG TAG = SkOTTableTAG<SkOTTableOS2>::value;
+ static constexpr SK_OT_CHAR TAG0 = 'O';
+ static constexpr SK_OT_CHAR TAG1 = 'S';
+ static constexpr SK_OT_CHAR TAG2 = '/';
+ static constexpr SK_OT_CHAR TAG3 = '2';
+ static constexpr SK_OT_ULONG TAG = SkOTTableTAG<SkOTTableOS2>::value;
union Version {
SK_OT_USHORT version;