本文整理汇总了C++中SkTScopedComPtr::GetFontCount方法的典型用法代码示例。如果您正苦于以下问题:C++ SkTScopedComPtr::GetFontCount方法的具体用法?C++ SkTScopedComPtr::GetFontCount怎么用?C++ SkTScopedComPtr::GetFontCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkTScopedComPtr
的用法示例。
在下文中一共展示了SkTScopedComPtr::GetFontCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onCreateFromStream
SkTypeface* SkFontMgr_DirectWrite::onCreateFromStream(SkStreamAsset* stream, int ttcIndex) const {
SkTScopedComPtr<StreamFontFileLoader> fontFileLoader;
// This transfers ownership of stream to the new object.
HRN(StreamFontFileLoader::Create(stream, &fontFileLoader));
HRN(fFactory->RegisterFontFileLoader(fontFileLoader.get()));
SkAutoIDWriteUnregister<StreamFontFileLoader> autoUnregisterFontFileLoader(
fFactory.get(), fontFileLoader.get());
SkTScopedComPtr<StreamFontCollectionLoader> fontCollectionLoader;
HRN(StreamFontCollectionLoader::Create(fontFileLoader.get(), &fontCollectionLoader));
HRN(fFactory->RegisterFontCollectionLoader(fontCollectionLoader.get()));
SkAutoIDWriteUnregister<StreamFontCollectionLoader> autoUnregisterFontCollectionLoader(
fFactory.get(), fontCollectionLoader.get());
SkTScopedComPtr<IDWriteFontCollection> fontCollection;
HRN(fFactory->CreateCustomFontCollection(fontCollectionLoader.get(), nullptr, 0, &fontCollection));
// Find the first non-simulated font which has the given ttc index.
UINT32 familyCount = fontCollection->GetFontFamilyCount();
for (UINT32 familyIndex = 0; familyIndex < familyCount; ++familyIndex) {
SkTScopedComPtr<IDWriteFontFamily> fontFamily;
HRN(fontCollection->GetFontFamily(familyIndex, &fontFamily));
UINT32 fontCount = fontFamily->GetFontCount();
for (UINT32 fontIndex = 0; fontIndex < fontCount; ++fontIndex) {
SkTScopedComPtr<IDWriteFont> font;
HRN(fontFamily->GetFont(fontIndex, &font));
if (font->GetSimulations() != DWRITE_FONT_SIMULATIONS_NONE) {
continue;
}
SkTScopedComPtr<IDWriteFontFace> fontFace;
HRN(font->CreateFontFace(&fontFace));
UINT32 faceIndex = fontFace->GetIndex();
if (faceIndex == ttcIndex) {
return DWriteFontTypeface::Create(fFactory.get(),
fontFace.get(), font.get(), fontFamily.get(),
autoUnregisterFontFileLoader.detatch(),
autoUnregisterFontCollectionLoader.detatch());
}
}
}
return nullptr;
}
示例2: count
int SkFontStyleSet_DirectWrite::count() {
return fFontFamily->GetFontCount();
}