本文整理汇总了C++中Scanner::scanFont方法的典型用法代码示例。如果您正苦于以下问题:C++ Scanner::scanFont方法的具体用法?C++ Scanner::scanFont怎么用?C++ Scanner::scanFont使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scanner
的用法示例。
在下文中一共展示了Scanner::scanFont方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SkFontStyleSet_Android
explicit SkFontStyleSet_Android(const FontFamily& family, const Scanner& scanner,
const bool cacheFontFiles) {
const SkString* cannonicalFamilyName = nullptr;
if (family.fNames.count() > 0) {
cannonicalFamilyName = &family.fNames[0];
}
// TODO? make this lazy
for (int i = 0; i < family.fFonts.count(); ++i) {
const FontFileInfo& fontFile = family.fFonts[i];
SkString pathName(family.fBasePath);
pathName.append(fontFile.fFileName);
SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(pathName.c_str()));
if (!stream.get()) {
SkDEBUGF(("Requested font file %s does not exist or cannot be opened.\n",
pathName.c_str()));
continue;
}
const int ttcIndex = fontFile.fIndex;
SkString familyName;
SkFontStyle style;
bool isFixedWidth;
Scanner::AxisDefinitions axisDefinitions;
if (!scanner.scanFont(stream.get(), ttcIndex,
&familyName, &style, &isFixedWidth, &axisDefinitions))
{
SkDEBUGF(("Requested font file %s exists, but is not a valid font.\n",
pathName.c_str()));
continue;
}
int weight = fontFile.fWeight != 0 ? fontFile.fWeight : style.weight();
SkFontStyle::Slant slant = style.slant();
switch (fontFile.fStyle) {
case FontFileInfo::Style::kAuto: slant = style.slant(); break;
case FontFileInfo::Style::kNormal: slant = SkFontStyle::kUpright_Slant; break;
case FontFileInfo::Style::kItalic: slant = SkFontStyle::kItalic_Slant; break;
default: SkASSERT(false); break;
}
style = SkFontStyle(weight, style.width(), slant);
const SkLanguage& lang = family.fLanguage;
uint32_t variant = family.fVariant;
if (kDefault_FontVariant == variant) {
variant = kCompact_FontVariant | kElegant_FontVariant;
}
// The first specified family name overrides the family name found in the font.
// TODO: SkTypeface_AndroidSystem::onCreateFamilyNameIterator should return
// all of the specified family names in addition to the names found in the font.
if (cannonicalFamilyName != nullptr) {
familyName = *cannonicalFamilyName;
}
SkAutoSTMalloc<4, SkFixed> axisValues(axisDefinitions.count());
Scanner::computeAxisValues(axisDefinitions,
fontFile.fAxes.begin(), fontFile.fAxes.count(),
axisValues, familyName);
fStyles.push_back().reset(new SkTypeface_AndroidSystem(
pathName, cacheFontFiles, ttcIndex, axisValues.get(), axisDefinitions.count(),
style, isFixedWidth, familyName, lang, variant));
}
}