Skip to content

Commit

Permalink
use font for settings
Browse files Browse the repository at this point in the history
Bug: skia:
Change-Id: Ia1ebd888bf0f0ce9c0c6dfdceff92be59db02a85
Reviewed-on: https://skia-review.googlesource.com/c/171650
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
  • Loading branch information
reed-at-google authored and Skia Commit-Bot committed Nov 17, 2018
1 parent 2812240 commit 7fb30f1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
10 changes: 7 additions & 3 deletions src/core/SkFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ SkScalar SkFont::setupForAsPaths(SkPaint* paint) {
fFlags = (fFlags & ~flagsToIgnore) | kSubpixel_PrivFlag;
this->setHinting(kNo_SkFontHinting);

if (this->getEdging() == Edging::kSubpixelAntiAlias) {
this->setEdging(Edging::kAntiAlias);
}

if (paint) {
paint->setStyle(SkPaint::kFill_Style);
paint->setPathEffect(nullptr);
Expand Down Expand Up @@ -379,9 +383,9 @@ SkFont SkFont::LEGACY_ExtractFromPaint(const SkPaint& paint) {
Edging edging = Edging::kAlias;
if (paint.isAntiAlias()) {
edging = Edging::kAntiAlias;
}
if (paint.isLCDRenderText()) {
edging = Edging::kSubpixelAntiAlias;
if (paint.isLCDRenderText()) {
edging = Edging::kSubpixelAntiAlias;
}
}

SkFont font(sk_ref_sp(paint.getTypeface()), paint.getTextSize(), paint.getTextScaleX(),
Expand Down
22 changes: 10 additions & 12 deletions src/core/SkScalerContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -854,18 +854,16 @@ static SkScalar sk_relax(SkScalar x) {
return n / 1024.0f;
}

static SkMask::Format compute_mask_format(const SkPaint& paint) {
uint32_t flags = paint.getFlags();

// Antialiasing being disabled trumps all other settings.
if (!(flags & SkPaint::kAntiAlias_Flag)) {
return SkMask::kBW_Format;
}

if (flags & SkPaint::kLCDRenderText_Flag) {
return SkMask::kLCD16_Format;
static SkMask::Format compute_mask_format(const SkFont& font) {
switch (font.getEdging()) {
case SkFont::Edging::kAlias:
return SkMask::kBW_Format;
case SkFont::Edging::kAntiAlias:
return SkMask::kA8_Format;
case SkFont::Edging::kSubpixelAntiAlias:
return SkMask::kLCD16_Format;
}

SkASSERT(false);
return SkMask::kA8_Format;
}

Expand Down Expand Up @@ -976,7 +974,7 @@ void SkScalerContext::MakeRecAndEffects(const SkFont& font, const SkPaint& paint
rec->fStrokeCap = 0;
}

rec->fMaskFormat = SkToU8(compute_mask_format(paint));
rec->fMaskFormat = SkToU8(compute_mask_format(font));

if (SkMask::kLCD16_Format == rec->fMaskFormat) {
if (too_big_for_lcd(*rec, checkPost2x2)) {
Expand Down

0 comments on commit 7fb30f1

Please sign in to comment.