10#if defined(SK_BUILD_FOR_WIN)
40 int weight =
font->GetWeight();
43 switch (
font->GetStyle()) {
50#if defined(NTDDI_WIN10_RS3) && NTDDI_VERSION >= NTDDI_WIN10_RS3
51 [&weight, &
width, &slant, fontFace]() ->
void {
52 SkTScopedComPtr<IDWriteFontFace5> fontFace5;
53 if (
FAILED(fontFace->QueryInterface(&fontFace5))) {
56 if (!fontFace5->HasVariations()) {
60 UINT32 fontAxisCount = fontFace5->GetFontAxisValueCount();
61 SkTScopedComPtr<IDWriteFontResource> fontResource;
62 HRV(fontFace5->GetFontResource(&fontResource));
65 HRV(fontFace5->GetFontAxisValues(fontAxisValue.get(), fontAxisCount));
66 for (UINT32 axisIndex = 0; axisIndex < fontAxisCount; ++axisIndex) {
67 if (fontAxisValue[axisIndex].axisTag == DWRITE_FONT_AXIS_TAG_WEIGHT) {
68 weight = fontAxisValue[axisIndex].value;
70 if (fontAxisValue[axisIndex].axisTag == DWRITE_FONT_AXIS_TAG_WIDTH) {
71 SkScalar wdthValue = fontAxisValue[axisIndex].value;
74 if (fontAxisValue[axisIndex].axisTag == DWRITE_FONT_AXIS_TAG_SLANT &&
77 if (fontAxisValue[axisIndex].
value == 0) {
90 IDWriteFactory* factory,
91 IDWriteFontFace* fontFace,
93 IDWriteFontFamily* fontFamily,
98 GetStyle(
font, fontFace), factory, fontFace,
font, fontFamily, std::move(loaders), palette));
101HRESULT DWriteFontTypeface::initializePalette() {
107 if (dwPaletteCount == 0) {
113 UINT32 basePaletteIndex = 0;
123 0, dwPaletteEntryCount,
125 "Could not retrieve palette entries.");
128 fDWPalette.reset(
new DWRITE_COLOR_F[dwPaletteEntryCount]);
129 for (UINT32
i = 0;
i < dwPaletteEntryCount; ++
i) {
139 if (SkTFitsIn<UINT32>(paletteOverride.
index) &&
140 SkTo<UINT32>(paletteOverride.
index) < dwPaletteEntryCount)
147 const SkColor4f skColor = SkColor4f::FromColor(paletteOverride.
color);
149 dwColor.r = skColor.fR;
150 dwColor.g = skColor.fG;
151 dwColor.b = skColor.fB;
152 dwColor.a = skColor.fA;
160DWriteFontTypeface::DWriteFontTypeface(
const SkFontStyle& style,
161 IDWriteFactory* factory,
162 IDWriteFontFace* fontFace,
164 IDWriteFontFamily* fontFamily,
168 , fFactory(SkRefComPtr(factory))
169 , fDWriteFontFamily(SkRefComPtr(fontFamily))
170 , fDWriteFont(SkRefComPtr(
font))
171 , fDWriteFontFace(SkRefComPtr(fontFace))
172 , fRequestedPaletteEntryOverrides(palette.overrideCount
176 palette.overrideCount * sizeof(palette.overrides[0]))
178 , fRequestedPalette{palette.index,
179 fRequestedPaletteEntryOverrides.
get(), palette.overrideCount }
180 , fPaletteEntryCount(0)
181 , fLoaders(
std::move(loaders))
183 if (!
SUCCEEDED(fDWriteFontFace->QueryInterface(&fDWriteFontFace1))) {
188 if (!
SUCCEEDED(fDWriteFontFace->QueryInterface(&fDWriteFontFace2))) {
191 if (!
SUCCEEDED(fDWriteFontFace->QueryInterface(&fDWriteFontFace4))) {
194#if DWRITE_CORE || (defined(NTDDI_WIN11_ZN) && NTDDI_VERSION >= NTDDI_WIN11_ZN)
195 if (!
SUCCEEDED(fDWriteFontFace->QueryInterface(&fDWriteFontFace7))) {
199 if (!
SUCCEEDED(fFactory->QueryInterface(&fFactory2))) {
203 if (fDWriteFontFace1 && fDWriteFontFace1->IsMonospacedFont()) {
204 this->setIsFixedPitch(
true);
207 fIsColorFont = fFactory2 && fDWriteFontFace2 && fDWriteFontFace2->IsColorFont();
208 this->initializePalette();
212#if DWRITE_CORE || (defined(NTDDI_WIN11_ZN) && NTDDI_VERSION >= NTDDI_WIN11_ZN)
225 SK_TRACEHR(hr,
"FontCollectionLoader");
230 SK_TRACEHR(hr,
"FontFileLoader");
235 SkTScopedComPtr<IDWriteLocalizedStrings> familyNames;
243 SkTScopedComPtr<IDWriteLocalizedStrings> postScriptNames;
246 DWRITE_INFORMATIONAL_STRING_POSTSCRIPT_NAME,
254 if (skPostScriptName) {
255 *skPostScriptName = localSkPostScriptName;
263 SkTScopedComPtr<IDWriteLocalizedStrings> familyNames;
269 desc->setFamilyName(utf8FamilyName.
c_str());
293 DWRITE_FONT_METRICS metrics;
295 return metrics.designUnitsPerEm;
301 explicit LocalizedStrings_IDWriteLocalizedStrings(IDWriteLocalizedStrings* strings)
302 : fIndex(0), fStrings(strings)
306 if (fIndex >= fStrings->GetCount()) {
312 HRBM(fStrings->GetStringLength(fIndex, &stringLen),
"Could not get string length.");
315 HRBM(fStrings->GetString(fIndex, wString.get(), stringLen+1),
"Could not get string.");
321 HRBM(fStrings->GetLocaleNameLength(fIndex, &localeLen),
"Could not get locale length.");
324 HRBM(fStrings->GetLocaleName(fIndex, wLocale.get(), localeLen+1),
"Could not get locale.");
334 SkTScopedComPtr<IDWriteLocalizedStrings> fStrings;
341 SkTScopedComPtr<IDWriteLocalizedStrings> familyNames;
342 HRNM(
fDWriteFontFamily->GetFamilyNames(&familyNames),
"Could not obtain family names.");
343 nameIter = sk_make_sp<LocalizedStrings_IDWriteLocalizedStrings>(familyNames.release());
356#if defined(NTDDI_WIN10_RS3) && NTDDI_VERSION >= NTDDI_WIN10_RS3
358 SkTScopedComPtr<IDWriteFontFace5> fontFace5;
364 if (!fontFace5->HasVariations()) {
368 UINT32 fontAxisCount = fontFace5->GetFontAxisValueCount();
369 SkTScopedComPtr<IDWriteFontResource> fontResource;
370 HR_GENERAL(fontFace5->GetFontResource(&fontResource),
nullptr, -1);
371 UINT32 variableAxisCount = 0;
372 for (UINT32
i = 0;
i < fontAxisCount; ++
i) {
373 if (fontResource->GetFontAxisAttributes(
i) & DWRITE_FONT_AXIS_ATTRIBUTES_VARIABLE) {
378 if (!coordinates || coordinateCount < 0 || (
unsigned)coordinateCount < variableAxisCount) {
379 return SkTo<int>(variableAxisCount);
383 HR_GENERAL(fontFace5->GetFontAxisValues(fontAxisValue.get(), fontAxisCount),
nullptr, -1);
384 UINT32 coordIndex = 0;
385 for (UINT32 axisIndex = 0; axisIndex < fontAxisCount; ++axisIndex) {
386 if (fontResource->GetFontAxisAttributes(axisIndex) & DWRITE_FONT_AXIS_ATTRIBUTES_VARIABLE) {
388 coordinates[coordIndex].
value = fontAxisValue[axisIndex].value;
393 SkASSERT(coordIndex == variableAxisCount);
394 return SkTo<int>(variableAxisCount);
405#if defined(NTDDI_WIN10_RS3) && NTDDI_VERSION >= NTDDI_WIN10_RS3
407 SkTScopedComPtr<IDWriteFontFace5> fontFace5;
413 if (!fontFace5->HasVariations()) {
417 UINT32 fontAxisCount = fontFace5->GetFontAxisValueCount();
418 SkTScopedComPtr<IDWriteFontResource> fontResource;
419 HR_GENERAL(fontFace5->GetFontResource(&fontResource),
nullptr, -1);
420 int variableAxisCount = 0;
421 for (UINT32
i = 0;
i < fontAxisCount; ++
i) {
422 if (fontResource->GetFontAxisAttributes(
i) & DWRITE_FONT_AXIS_ATTRIBUTES_VARIABLE) {
427 if (!parameters || parameterCount < variableAxisCount) {
428 return variableAxisCount;
432 HR_GENERAL(fontResource->GetFontAxisRanges(fontAxisRange.get(), fontAxisCount),
nullptr, -1);
434 HR_GENERAL(fontResource->GetDefaultFontAxisValues(fontAxisDefaultValue.get(), fontAxisCount),
436 UINT32 coordIndex = 0;
438 for (UINT32 axisIndex = 0; axisIndex < fontAxisCount; ++axisIndex) {
439 if (fontResource->GetFontAxisAttributes(axisIndex) & DWRITE_FONT_AXIS_ATTRIBUTES_VARIABLE) {
441 parameters[coordIndex].
min = fontAxisRange[axisIndex].minValue;
442 parameters[coordIndex].
def = fontAxisDefaultValue[axisIndex].value;
443 parameters[coordIndex].
max = fontAxisRange[axisIndex].maxValue;
444 parameters[coordIndex].
setHidden(fontResource->GetFontAxisAttributes(axisIndex) &
445 DWRITE_FONT_AXIS_ATTRIBUTES_HIDDEN);
450 return variableAxisCount;
459 if (
type != DWRITE_FONT_FACE_TYPE_CFF &&
460 type != DWRITE_FONT_FACE_TYPE_TRUETYPE &&
461 type != DWRITE_FONT_FACE_TYPE_TRUETYPE_COLLECTION)
475 if (!
table.fExists) {
496 reinterpret_cast<const void **
>(&
data), &
size, &lock, &exists);
501 Context(
void* lock, IDWriteFontFace* face) : fLock(lock), fFontFace(SkRefComPtr(face)) {}
502 ~Context() { fFontFace->ReleaseFontTable(fLock); }
504 SkTScopedComPtr<IDWriteFontFace> fFontFace;
507 [](
const void*,
void* ctx) {
delete (
Context*)ctx; },
517#if defined(NTDDI_WIN10_RS3) && NTDDI_VERSION >= NTDDI_WIN10_RS3
519 SkTScopedComPtr<IDWriteFontFace5> fontFace5;
522 UINT32 fontAxisCount = fontFace5->GetFontAxisValueCount();
523 UINT32 argsCoordCount =
args.getVariationDesignPosition().coordinateCount;
525 HRN(fontFace5->GetFontAxisValues(fontAxisValue.get(), fontAxisCount));
527 for (UINT32 fontIndex = 0; fontIndex < fontAxisCount; ++fontIndex) {
528 for (UINT32 argsIndex = 0; argsIndex < argsCoordCount; ++argsIndex) {
530 args.getVariationDesignPosition().coordinates[argsIndex].axis) {
531 fontAxisValue[fontIndex].value =
532 args.getVariationDesignPosition().coordinates[argsIndex].value;
536 SkTScopedComPtr<IDWriteFontResource> fontResource;
537 HRN(fontFace5->GetFontResource(&fontResource));
538 SkTScopedComPtr<IDWriteFontFace5> newFontFace5;
539 HRN(fontResource->CreateFontFace(
fDWriteFont->GetSimulations(),
544 SkTScopedComPtr<IDWriteFontFace> newFontFace;
545 HRN(newFontFace5->QueryInterface(&newFontFace));
578 "Could not get number of font files.");
583 SkTScopedComPtr<IDWriteFontFile> fontFile;
584 HRNM(
fDWriteFontFace->GetFiles(&numFiles, &fontFile),
"Could not get font files.");
586 const void* fontFileKey;
587 UINT32 fontFileKeySize;
588 HRNM(fontFile->GetReferenceKey(&fontFileKey, &fontFileKeySize),
589 "Could not get font file reference key.");
591 SkTScopedComPtr<IDWriteFontFileLoader> fontFileLoader;
592 HRNM(fontFile->GetLoader(&fontFileLoader),
"Could not get font file loader.");
594 SkTScopedComPtr<IDWriteFontFileStream> fontFileStream;
595 HRNM(fontFileLoader->CreateStreamFromKey(fontFileKey, fontFileKeySize,
597 "Could not create font file stream.");
605 return std::make_unique<SkScalerContext_DW>(
618 rec->
fFlags &= ~flagsWeDontSupport;
627#if defined(SK_FONT_HOST_USE_SYSTEM_SETTINGS)
629 if (factory !=
nullptr) {
630 SkTScopedComPtr<IDWriteRenderingParams> defaultRenderingParams;
631 if (
SUCCEEDED(factory->CreateRenderingParams(&defaultRenderingParams))) {
632 float gamma = defaultRenderingParams->GetGamma();
634 rec->setPaintGamma(gamma);
636 rec->
setContrast(defaultRenderingParams->GetEnhancedContrast());
645static void glyph_to_unicode_map(IDWriteFontFace* fontFace, DWRITE_UNICODE_RANGE range,
646 UINT32* remainingGlyphCount, UINT32 numGlyphs,
649 constexpr const int batchSize = 128;
650 UINT32 codepoints[batchSize];
652 for (UINT32 c = range.first; c <= range.last && *remainingGlyphCount != 0; c += batchSize) {
653 UINT32 numBatchedCodePoints = std::min<UINT32>(range.last - c + 1, batchSize);
654 for (UINT32
i = 0;
i < numBatchedCodePoints; ++
i) {
655 codepoints[
i] = c +
i;
657 HRVM(fontFace->GetGlyphIndices(codepoints, numBatchedCodePoints,
glyphs),
658 "Failed to get glyph indexes.");
659 for (UINT32
i = 0;
i < numBatchedCodePoints; ++
i) {
662 if (glyph >= numGlyphs) {
665 if (0 < glyph && glyphToUnicode[glyph] == 0) {
666 glyphToUnicode[glyph] = c +
i;
667 --*remainingGlyphCount;
675 UINT32 numGlyphs = face->GetGlyphCount();
677 UINT32 remainingGlyphCount = numGlyphs;
681 UINT32 numRanges = 0;
682 HRESULT hr = face1->GetUnicodeRanges(0,
nullptr, &numRanges);
683 if (hr != E_NOT_SUFFICIENT_BUFFER &&
FAILED(hr)) {
684 HRVM(hr,
"Failed to get number of ranges.");
686 std::unique_ptr<DWRITE_UNICODE_RANGE[]> ranges(
new DWRITE_UNICODE_RANGE[numRanges]);
687 HRVM(face1->GetUnicodeRanges(numRanges, ranges.get(), &numRanges),
"Failed to get ranges.");
688 for (UINT32
i = 0;
i < numRanges; ++
i) {
689 glyph_to_unicode_map(face1, ranges[
i], &remainingGlyphCount, numGlyphs, glyphToUnicode);
692 glyph_to_unicode_map(face, {0, 0x10FFFF}, &remainingGlyphCount, numGlyphs, glyphToUnicode);
698 std::unique_ptr<SkAdvancedTypefaceMetrics>
info(
nullptr);
700 DWRITE_FONT_METRICS dwfm;
710 SkTScopedComPtr<IDWriteLocalizedStrings> postScriptNames;
713 DWRITE_INFORMATIONAL_STRING_POSTSCRIPT_NAME,
719 SkDEBUGF(
"Unable to get postscript name for typeface %p\n",
this);
724 if (fontType == DWRITE_FONT_FACE_TYPE_TRUETYPE ||
725 fontType == DWRITE_FONT_FACE_TYPE_TRUETYPE_COLLECTION)
728 }
else if (fontType == DWRITE_FONT_FACE_TYPE_CFF ||
729 fontType == DWRITE_FONT_FACE_TYPE_OPENTYPE_COLLECTION)
737 if (
fDWriteFontFace->GetSimulations() != DWRITE_FONT_SIMULATIONS_NONE) {
745 if (!headTable.fExists || !postTable.fExists || !hheaTable.fExists || !os2Table.fExists) {
754 if (fvarTable.fExists) {
760 bool fixedWidth = (postTable->isFixedPitch &&
767 if (os2Table->version.v0.fsSelection.field.Italic) {
772 SerifStyle serifStyle = os2Table->version.v0.panose.data.textAndDisplay.bSerifStyle;
774 if (SerifStyle::Cove == serifStyle ||
775 SerifStyle::ObtuseCove == serifStyle ||
776 SerifStyle::SquareCove == serifStyle ||
777 SerifStyle::ObtuseSquareCove == serifStyle ||
778 SerifStyle::Square == serifStyle ||
779 SerifStyle::Thin == serifStyle ||
780 SerifStyle::Bone == serifStyle ||
781 SerifStyle::Exaggerated == serifStyle ||
782 SerifStyle::Triangle == serifStyle)
800class StreamFontFileLoader :
public IDWriteFontFileLoader {
809 void const* fontFileReferenceKey,
810 UINT32 fontFileReferenceKeySize,
811 IDWriteFontFileStream** fontFileStream)
override;
814 static HRESULT
Create(std::unique_ptr<SkStreamAsset>
stream,
815 StreamFontFileLoader** streamFontFileLoader) {
816 *streamFontFileLoader =
new StreamFontFileLoader(std::move(
stream));
817 if (
nullptr == *streamFontFileLoader) {
818 return E_OUTOFMEMORY;
824 StreamFontFileLoader(std::unique_ptr<SkStreamAsset>
stream)
825 : fStream(
std::move(
stream)), fRefCount(1)
827 virtual ~StreamFontFileLoader() { }
829 std::unique_ptr<SkStreamAsset> fStream;
833SK_STDMETHODIMP StreamFontFileLoader::QueryInterface(REFIID iid,
void** ppvObject) {
834 if (iid == IID_IUnknown || iid == __uuidof(IDWriteFontFileLoader)) {
839 *ppvObject =
nullptr;
840 return E_NOINTERFACE;
845 return InterlockedIncrement(&fRefCount);
849 ULONG newCount = InterlockedDecrement(&fRefCount);
857 void const* fontFileReferenceKey,
858 UINT32 fontFileReferenceKeySize,
859 IDWriteFontFileStream** fontFileStream)
861 SkTScopedComPtr<SkDWriteFontFileStreamWrapper>
stream;
863 *fontFileStream =
stream.release();
867class StreamFontFileEnumerator :
public IDWriteFontFileEnumerator {
876 SK_STDMETHODIMP GetCurrentFontFile(IDWriteFontFile** fontFile)
override;
878 static HRESULT
Create(IDWriteFactory* factory, IDWriteFontFileLoader* fontFileLoader,
879 StreamFontFileEnumerator** streamFontFileEnumerator) {
880 *streamFontFileEnumerator =
new StreamFontFileEnumerator(factory, fontFileLoader);
881 if (
nullptr == *streamFontFileEnumerator) {
882 return E_OUTOFMEMORY;
887 StreamFontFileEnumerator(IDWriteFactory* factory, IDWriteFontFileLoader* fontFileLoader);
888 virtual ~StreamFontFileEnumerator() { }
892 SkTScopedComPtr<IDWriteFactory>
fFactory;
893 SkTScopedComPtr<IDWriteFontFile> fCurrentFile;
894 SkTScopedComPtr<IDWriteFontFileLoader> fFontFileLoader;
898StreamFontFileEnumerator::StreamFontFileEnumerator(IDWriteFactory* factory,
899 IDWriteFontFileLoader* fontFileLoader)
903 , fFontFileLoader(SkRefComPtr(fontFileLoader))
907SK_STDMETHODIMP StreamFontFileEnumerator::QueryInterface(REFIID iid,
void** ppvObject) {
908 if (iid == IID_IUnknown || iid == __uuidof(IDWriteFontFileEnumerator)) {
913 *ppvObject =
nullptr;
914 return E_NOINTERFACE;
919 return InterlockedIncrement(&fRefCount);
923 ULONG newCount = InterlockedDecrement(&fRefCount);
931 *hasCurrentFile =
FALSE;
938 UINT32 fontFileReferenceKey = 0;
939 HR(fFactory->CreateCustomFontFileReference(
940 &fontFileReferenceKey,
941 sizeof(fontFileReferenceKey),
942 fFontFileLoader.get(),
945 *hasCurrentFile =
TRUE;
949SK_STDMETHODIMP StreamFontFileEnumerator::GetCurrentFontFile(IDWriteFontFile** fontFile) {
950 if (fCurrentFile.get() ==
nullptr) {
955 *fontFile = SkRefComPtr(fCurrentFile.get());
959class StreamFontCollectionLoader :
public IDWriteFontCollectionLoader {
968 IDWriteFactory* factory,
969 void const* collectionKey,
970 UINT32 collectionKeySize,
971 IDWriteFontFileEnumerator** fontFileEnumerator)
override;
973 static HRESULT
Create(IDWriteFontFileLoader* fontFileLoader,
974 StreamFontCollectionLoader** streamFontCollectionLoader) {
975 *streamFontCollectionLoader =
new StreamFontCollectionLoader(fontFileLoader);
976 if (
nullptr == *streamFontCollectionLoader) {
977 return E_OUTOFMEMORY;
982 StreamFontCollectionLoader(IDWriteFontFileLoader* fontFileLoader)
984 , fFontFileLoader(SkRefComPtr(fontFileLoader))
986 virtual ~StreamFontCollectionLoader() { }
989 SkTScopedComPtr<IDWriteFontFileLoader> fFontFileLoader;
992SK_STDMETHODIMP StreamFontCollectionLoader::QueryInterface(REFIID iid,
void** ppvObject) {
993 if (iid == IID_IUnknown || iid == __uuidof(IDWriteFontCollectionLoader)) {
998 *ppvObject =
nullptr;
999 return E_NOINTERFACE;
1004 return InterlockedIncrement(&fRefCount);
1008 ULONG newCount = InterlockedDecrement(&fRefCount);
1009 if (0 == newCount) {
1015template <
typename T>
class SkAutoIDWriteUnregister {
1017 SkAutoIDWriteUnregister(IDWriteFactory* factory,
T* unregister)
1018 : fFactory(factory), fUnregister(unregister)
1020 SkAutoIDWriteUnregister(
const SkAutoIDWriteUnregister&) =
delete;
1021 SkAutoIDWriteUnregister& operator=(
const SkAutoIDWriteUnregister&) =
delete;
1022 SkAutoIDWriteUnregister(SkAutoIDWriteUnregister&&) =
delete;
1023 SkAutoIDWriteUnregister& operator=(SkAutoIDWriteUnregister&&) =
delete;
1025 ~SkAutoIDWriteUnregister() {
1027 unregister(fFactory, fUnregister);
1032 T* old = fUnregister;
1033 fUnregister =
nullptr;
1038 HRESULT unregister(IDWriteFactory* factory, IDWriteFontFileLoader* unregister) {
1039 return factory->UnregisterFontFileLoader(unregister);
1042 HRESULT unregister(IDWriteFactory* factory, IDWriteFontCollectionLoader* unregister) {
1043 return factory->UnregisterFontCollectionLoader(unregister);
1046 IDWriteFactory* fFactory;
1051 IDWriteFactory* factory,
1052 void const* collectionKey,
1053 UINT32 collectionKeySize,
1054 IDWriteFontFileEnumerator** fontFileEnumerator)
1056 SkTScopedComPtr<StreamFontFileEnumerator> enumerator;
1058 *fontFileEnumerator = enumerator.release();
1062static HRESULT apply_fontargument_variation(SkTScopedComPtr<IDWriteFontFace>& fontFace,
1065#if defined(NTDDI_WIN10_RS3) && NTDDI_VERSION >= NTDDI_WIN10_RS3
1067 SkTScopedComPtr<IDWriteFontFace5> fontFace5;
1068 if (
FAILED(fontFace->QueryInterface(&fontFace5)) || !fontFace5->HasVariations()) {
1072 UINT32 fontAxisCount = fontFace5->GetFontAxisValueCount();
1073 UINT32 argsCoordCount =
args.getVariationDesignPosition().coordinateCount;
1075 SkTScopedComPtr<IDWriteFontResource> fontResource;
1076 HR(fontFace5->GetFontResource(&fontResource));
1077 HR(fontResource->GetDefaultFontAxisValues(variation, fontAxisCount));
1079 for (UINT32 fontAxisIndex = 0; fontAxisIndex < fontAxisCount; ++fontAxisIndex) {
1080 DWRITE_FONT_AXIS_VALUE& fontCoordinate = variation[fontAxisIndex];
1082 for (UINT32 argsCoordIndex = argsCoordCount; argsCoordIndex --> 0;) {
1084 args.getVariationDesignPosition().coordinates[argsCoordIndex];
1086 fontCoordinate.value = argsCoordinate.
value;
1092 SkTScopedComPtr<IDWriteFontFace5> fontFace5_Out;
1093 HR(fontResource->CreateFontFace(DWRITE_FONT_SIMULATIONS_NONE,
1094 variation.get(), fontAxisCount,
1097 HR(fontFace5_Out->QueryInterface(&fontFace));
1106 if (
nullptr == factory) {
1110 SkTScopedComPtr<StreamFontFileLoader> fontFileLoader;
1112 HRN(factory->RegisterFontFileLoader(fontFileLoader.get()));
1113 SkAutoIDWriteUnregister<StreamFontFileLoader> autoUnregisterFontFileLoader(
1114 factory, fontFileLoader.get());
1116 SkTScopedComPtr<StreamFontCollectionLoader> fontCollectionLoader;
1118 HRN(factory->RegisterFontCollectionLoader(fontCollectionLoader.get()));
1119 SkAutoIDWriteUnregister<StreamFontCollectionLoader> autoUnregisterFontCollectionLoader(
1120 factory, fontCollectionLoader.get());
1122 SkTScopedComPtr<IDWriteFontCollection> fontCollection;
1123 HRN(factory->CreateCustomFontCollection(fontCollectionLoader.get(),
nullptr, 0,
1127 UINT32 familyCount = fontCollection->GetFontFamilyCount();
1128 for (UINT32 familyIndex = 0; familyIndex < familyCount; ++familyIndex) {
1129 SkTScopedComPtr<IDWriteFontFamily> fontFamily;
1130 HRN(fontCollection->GetFontFamily(familyIndex, &fontFamily));
1132 UINT32 fontCount = fontFamily->GetFontCount();
1133 for (UINT32 fontIndex = 0; fontIndex < fontCount; ++fontIndex) {
1134 SkTScopedComPtr<IDWriteFont>
font;
1135 HRN(fontFamily->GetFont(fontIndex, &
font));
1138 if (
font->GetSimulations() != DWRITE_FONT_SIMULATIONS_NONE) {
1141 SkTScopedComPtr<IDWriteFontFace> fontFace;
1142 HRN(
font->CreateFontFace(&fontFace));
1143 int faceIndex = fontFace->GetIndex();
1144 int ttcIndex =
args.getCollectionIndex();
1147 if (faceIndex != ttcIndex) {
1151 apply_fontargument_variation(fontFace,
args);
1154 factory, fontFace.get(),
font.get(), fontFamily.get(),
1155 sk_make_sp<DWriteFontTypeface::Loaders>(
1157 autoUnregisterFontFileLoader.detatch(),
1158 autoUnregisterFontCollectionLoader.detatch()),
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
sk_bzero(glyphs, sizeof(glyphs))
static float next(float f)
static sk_sp< Effect > Create()
#define SkASSERT_RELEASE(cond)
static constexpr SkColor SkColorSetARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
HRESULT sk_wchar_to_skstring(WCHAR *name, int nameLen, SkString *skname)
HRESULT sk_get_locale_string(IDWriteLocalizedStrings *names, const WCHAR *preferedLocale, SkString *skname)
IDWriteFactory * sk_get_dwrite_factory()
#define SkEndian_SwapBE32(n)
#define SkEndian_SwapBE16(n)
#define sk_float_round2int(x)
@ kNormal
glyph outlines modified to improve constrast
@ kNone
glyph outlines unchanged
static void * sk_careful_memcpy(void *dst, const void *src, size_t len)
#define SK_STDMETHODIMP_(type)
sk_sp< T > sk_ref_sp(T *obj)
static constexpr bool SkToBool(const T &x)
constexpr int16_t SkToS16(S x)
int onGetVariationDesignParameters(SkFontParameters::Variation::Axis parameters[], int parameterCount) const override
int onGetUPEM() const override
SkTScopedComPtr< IDWriteFontFace2 > fDWriteFontFace2
std::unique_ptr< SkScalerContext > onCreateScalerContext(const SkScalerContextEffects &, const SkDescriptor *) const override
static sk_sp< SkTypeface > SK_SPI MakeFromStream(std::unique_ptr< SkStreamAsset >, const SkFontArguments &)
SkTypeface::LocalizedStrings * onCreateFamilyNameIterator() const override
SkTScopedComPtr< IDWriteFactory2 > fFactory2
SkTScopedComPtr< IDWriteFactory > fFactory
SkFontArguments::Palette fRequestedPalette
void onFilterRec(SkScalerContextRec *) const override
void getGlyphToUnicodeMap(SkUnichar *glyphToUnicode) const override
size_t onGetTableData(SkFontTableTag, size_t offset, size_t length, void *data) const override
size_t fPaletteEntryCount
static SkFontStyle GetStyle(IDWriteFont *font, IDWriteFontFace *fontFace)
std::unique_ptr< SkAdvancedTypefaceMetrics > onGetAdvancedMetrics() const override
void onCharsToGlyphs(const SkUnichar *chars, int count, SkGlyphID glyphs[]) const override
std::unique_ptr< SkColor[]> fPalette
~DWriteFontTypeface() override
IDWriteFontFace7 * fDWriteFontFace7
SkTScopedComPtr< IDWriteFontFamily > fDWriteFontFamily
SkTScopedComPtr< IDWriteFontFace1 > fDWriteFontFace1
std::unique_ptr< SkStreamAsset > onOpenStream(int *ttcIndex) const override
int onGetTableTags(SkFontTableTag tags[]) const override
std::unique_ptr< DWRITE_COLOR_F[]> fDWPalette
int onCountGlyphs() const override
bool onGetPostScriptName(SkString *) const override
void getPostScriptGlyphNames(SkString *) const override
bool onGlyphMaskNeedsCurrentColor() const override
sk_sp< SkData > onCopyTableData(SkFontTableTag) const override
void onGetFamilyName(SkString *familyName) const override
static constexpr SkTypeface::FactoryId FactoryId
SkTScopedComPtr< IDWriteFontFace > fDWriteFontFace
SkTScopedComPtr< IDWriteFont > fDWriteFont
int onGetVariationDesignPosition(SkFontArguments::VariationPosition::Coordinate coordinates[], int coordinateCount) const override
static sk_sp< DWriteFontTypeface > Make(IDWriteFactory *factory, IDWriteFontFace *fontFace, IDWriteFont *font, IDWriteFontFamily *fontFamily, sk_sp< Loaders > loaders, const SkFontArguments::Palette &palette)
sk_sp< SkTypeface > onMakeClone(const SkFontArguments &) const override
void onGetFontDescriptor(SkFontDescriptor *, bool *) const override
static HRESULT Create(SkStreamAsset *stream, SkDWriteFontFileStreamWrapper **streamFontFileStream)
static sk_sp< SkData > MakeWithProc(const void *ptr, size_t length, ReleaseProc proc, void *ctx)
static SkFontStyle::Width SkFontStyleWidthForWidthAxisValue(SkScalar width)
void setPaletteIndex(int paletteIndex)
static int GetTableTags(SkStream *, int ttcIndex, SkFontTableTag tags[])
const char * c_str() const
SkFontStyle fontStyle() const
void serialize(SkWStream *, SerializeBehavior=SerializeBehavior::kIncludeDataIfLocal) const
std::unique_ptr< SkStreamAsset > openStream(int *ttcIndex) const
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
static float min(float r, float g, float b)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
font
Font Metadata and Metrics.
const myers::Point & get(const myers::Segment &)
SkTScopedComPtr< IDWriteFactory > fFactory
SkTScopedComPtr< IDWriteFontFileLoader > fDWriteFontFileLoader
SkTScopedComPtr< IDWriteFontCollectionLoader > fDWriteFontCollectionLoader
@ kVariable_FontFlag
May be true for Type1, CFF, or TrueType fonts.
const Override * overrides
void setHidden(bool hidden)
static constexpr SkIRect MakeLTRB(int32_t l, int32_t t, int32_t r, int32_t b)
@ kA8_Format
8bits per pixel mask (e.g. antialiasing)
static void SetAdvancedTypefaceFlags(SkOTTableOS2_V4::Type fsType, SkAdvancedTypefaceMetrics *info)
void setDeviceGamma(SkScalar g)
SkMask::Format fMaskFormat
void setContrast(SkScalar c)
SkFontHinting getHinting() const
void setHinting(SkFontHinting)
std::shared_ptr< const fml::Mapping > data