本文整理汇总了C++中SkFont::setLinearMetrics方法的典型用法代码示例。如果您正苦于以下问题:C++ SkFont::setLinearMetrics方法的具体用法?C++ SkFont::setLinearMetrics怎么用?C++ SkFont::setLinearMetrics使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkFont
的用法示例。
在下文中一共展示了SkFont::setLinearMetrics方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onDraw
void onDraw(SkCanvas* canvas) override {
SkFont font;
font.setSize(30);
const char* text = fApplyKerning ? "Type AWAY" : "Hamburgefons";
const size_t textLen = strlen(text);
SkScalar x = SkIntToScalar(10);
SkScalar dy = font.getMetrics(nullptr);
SkScalar y = dy;
if (fApplyKerning) {
font.setSubpixel(true);
} else {
font.setLinearMetrics(true);
}
SkPaint paint;
for (int i = 0; i < gStylesCount; i++) {
font.setTypeface(fFaces[i]);
canvas->drawSimpleText(text, textLen, SkTextEncoding::kUTF8, x, y, font, paint);
if (fApplyKerning) {
drawKernText(canvas, text, textLen, x + 240, y, font, paint);
}
y += dy;
}
}
示例2: TestPaintProps
// Verify that text-related properties are captured in run paints.
static void TestPaintProps(skiatest::Reporter* reporter) {
SkFont font;
// Kitchen sink font.
font.setSize(42);
font.setScaleX(4.2f);
font.setTypeface(ToolUtils::create_portable_typeface());
font.setSkewX(0.42f);
font.setHinting(SkFontHinting::kFull);
font.setEdging(SkFont::Edging::kSubpixelAntiAlias);
font.setEmbolden(true);
font.setLinearMetrics(true);
font.setSubpixel(true);
font.setEmbeddedBitmaps(true);
font.setForceAutoHinting(true);
// Ensure we didn't pick default values by mistake.
SkFont defaultFont;
REPORTER_ASSERT(reporter, defaultFont.getSize() != font.getSize());
REPORTER_ASSERT(reporter, defaultFont.getScaleX() != font.getScaleX());
REPORTER_ASSERT(reporter, defaultFont.getTypefaceOrDefault() != font.getTypefaceOrDefault());
REPORTER_ASSERT(reporter, defaultFont.getSkewX() != font.getSkewX());
REPORTER_ASSERT(reporter, defaultFont.getHinting() != font.getHinting());
REPORTER_ASSERT(reporter, defaultFont.getEdging() != font.getEdging());
REPORTER_ASSERT(reporter, defaultFont.isEmbolden() != font.isEmbolden());
REPORTER_ASSERT(reporter, defaultFont.isLinearMetrics() != font.isLinearMetrics());
REPORTER_ASSERT(reporter, defaultFont.isSubpixel() != font.isSubpixel());
REPORTER_ASSERT(reporter,
defaultFont.isEmbeddedBitmaps() != font.isEmbeddedBitmaps());
REPORTER_ASSERT(reporter, defaultFont.isForceAutoHinting() != font.isForceAutoHinting());
SkTextBlobBuilder builder;
AddRun(font, 1, SkTextBlobRunIterator::kDefault_Positioning, SkPoint::Make(0, 0), builder);
AddRun(font, 1, SkTextBlobRunIterator::kHorizontal_Positioning, SkPoint::Make(0, 0),
builder);
AddRun(font, 1, SkTextBlobRunIterator::kFull_Positioning, SkPoint::Make(0, 0), builder);
sk_sp<SkTextBlob> blob(builder.make());
SkTextBlobRunIterator it(blob.get());
while (!it.done()) {
REPORTER_ASSERT(reporter, it.font() == font);
it.next();
}
}