Set the kMultiMaster_FontFlag in DirectWrite.

DirectWrite can now produce system font typefaces which are variations,
so mark these as multiple masters so printing knows what to do.

BUG=chromium:697916

Change-Id: Idf09ebba3c7002a09ff2e4a2dbae13dbce4e79d4
Reviewed-on: https://skia-review.googlesource.com/12101
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Hal Canary <halcanary@google.com>
This commit is contained in:
Ben Wagner 2017-04-07 16:07:46 -04:00
parent 868d52be4e
commit f1bc5e8b78
2 changed files with 64 additions and 0 deletions

View File

@ -18,6 +18,7 @@
#include "SkDWriteFontFileStream.h"
#include "SkFontDescriptor.h"
#include "SkFontStream.h"
#include "SkOTTable_fvar.h"
#include "SkOTTable_head.h"
#include "SkOTTable_hhea.h"
#include "SkOTTable_OS_2.h"
@ -376,6 +377,13 @@ SkAdvancedTypefaceMetrics* DWriteFontTypeface::onGetAdvancedTypefaceMetrics(
return info;
}
// 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());
if (fvarTable.fExists) {
info->fFlags |= SkAdvancedTypefaceMetrics::kMultiMaster_FontFlag;
}
//There exist CJK fonts which set the IsFixedPitch and Monospace bits,
//but have full width, latin half-width, and half-width kana.
bool fixedWidth = (postTable->isFixedPitch &&

56
src/sfnt/SkOTTable_fvar.h Normal file
View File

@ -0,0 +1,56 @@
/*
* Copyright 2017 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkOTTable_fvar_DEFINED
#define SkOTTable_fvar_DEFINED
#include "SkEndian.h"
#include "SkOTTableTypes.h"
#pragma pack(push, 1)
struct SkOTTableFontVariations {
static const SK_OT_CHAR TAG0 = 'f';
static const SK_OT_CHAR TAG1 = 'v';
static const SK_OT_CHAR TAG2 = 'a';
static const SK_OT_CHAR TAG3 = 'r';
static const SK_OT_ULONG TAG = SkOTTableTAG<SkOTTableFontVariations>::value;
SK_OT_USHORT majorVersion;
SK_OT_USHORT minorVersion;
SK_OT_USHORT offsetToAxesArray;
SK_OT_USHORT reserved;
SK_OT_USHORT axisCount;
SK_OT_USHORT axisSize; // Must be 0x0014 in v1.0
SK_OT_USHORT instanceCount;
SK_OT_USHORT instanceSize; // Must be axisCount * sizeof(Fixed) + (4 | 6)
struct VariationAxisRecord {
SK_OT_ULONG axisTag;
SK_OT_Fixed minValue;
SK_OT_Fixed defaultValue;
SK_OT_Fixed maxValue;
SK_OT_USHORT flags; // Must be 0
SK_OT_USHORT axisNameID;
}; // axes[axisCount];
template <size_t AxisCount> struct InstanceRecord {
SK_OT_USHORT subfamilyNameID;
SK_OT_USHORT flags; // Must be 0
SK_OT_Fixed coordinates[AxisCount];
SK_OT_USHORT postScriptNameID;
}; // instances[instanceCount];
};
#pragma pack(pop)
#include <stddef.h>
static_assert(offsetof(SkOTTableFontVariations, instanceSize) == 14, "SkOTTableFontVariations_instanceSize_not_at_14");
static_assert(sizeof(SkOTTableFontVariations) == 16, "sizeof_SkOTTableFontVariations_not_16");
#endif