Skip to content

Commit

Permalink
Add text::Font::antialias() getter
Browse files Browse the repository at this point in the history
  • Loading branch information
dacap committed Apr 25, 2024
1 parent cf2eb4b commit 4291c70
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions text/empty_font_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class EmptyFont : public Font {
const os::Paint*) const override { return 0.0f; }
bool isScalable() const override { return false; }
void setSize(int) override { }
bool antialias() const override { return false; }
void setAntialias(bool) override { }
bool hasCodePoint(int) const override { return false; }
gfx::RectF getGlyphBounds(GlyphID) const override { return gfx::RectF(); }
Expand Down
1 change: 1 addition & 0 deletions text/font.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ namespace text {
const os::Paint* paint = nullptr) const = 0;
virtual bool isScalable() const = 0;
virtual void setSize(int size) = 0;
virtual bool antialias() const = 0;
virtual void setAntialias(bool antialias) = 0;
virtual bool hasCodePoint(int codepoint) const = 0;
virtual gfx::RectF getGlyphBounds(GlyphID glyph) const = 0;
Expand Down
5 changes: 5 additions & 0 deletions text/freetype_font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ void FreeTypeFont::setSize(int size)
m_face.setSize(size);
}

bool FreeTypeFont::antialias() const
{
return m_face.antialias();
}

void FreeTypeFont::setAntialias(bool antialias)
{
m_face.setAntialias(antialias);
Expand Down
1 change: 1 addition & 0 deletions text/freetype_font.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ namespace text {
const os::Paint* paint) const override;
bool isScalable() const override;
void setSize(int size) override;
bool antialias() const override;
void setAntialias(bool antialias) override;
bool hasCodePoint(int codepoint) const override;
gfx::RectF getGlyphBounds(GlyphID glyph) const override;
Expand Down
5 changes: 5 additions & 0 deletions text/skia_font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ void SkiaFont::setSize(int size)
m_skFont.setSize(size);
}

bool SkiaFont::antialias() const
{
return (m_skFont.getEdging() != SkFont::Edging::kAlias);
}

void SkiaFont::setAntialias(bool antialias)
{
m_skFont.setEdging(antialias ? SkFont::Edging::kAntiAlias:
Expand Down
1 change: 1 addition & 0 deletions text/skia_font.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ namespace text {
const os::Paint* paint) const override;
bool isScalable() const override;
void setSize(int size) override;
bool antialias() const override;
void setAntialias(bool antialias) override;
bool hasCodePoint(int codepoint) const override;
gfx::RectF getGlyphBounds(GlyphID glyph) const override;
Expand Down
4 changes: 4 additions & 0 deletions text/sprite_sheet_font.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ class SpriteSheetFont : public Font {
// Do nothing
}

bool antialias() const override {
return false;
}

void setAntialias(bool antialias) override {
// Do nothing
}
Expand Down

0 comments on commit 4291c70

Please sign in to comment.