Skip to content

Commit c580239

Browse files
committed
[BugFix] enable slight hinting for skity
1 parent 6ca96a0 commit c580239

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

public/textra/platform/skity/skity_canvas_helper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ class SkityCanvasHelper : public ICanvasHelper {
9595
}
9696
std::vector<skity::TextRun> runs;
9797
skity::Font skity_font(typeface->GetTypeface(), paint->GetTextSize());
98+
skity_font.SetHinting(skity::Font::FontHinting::kSlight);
9899
skity_font.SetEmbolden(painter->IsBold());
99100
skity_font.SetSkewX(painter->IsItalic() ? -0.25f : 0);
100101
runs.emplace_back(skity_font, glyph_vector, p_x, p_y);

src/ports/shaper/skshaper/font.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313

1414
namespace ttoffice {
1515
namespace tttext {
16+
enum class FontHinting {
17+
kNone, //!< glyph outlines unchanged
18+
kSlight, //!< minimal modification to improve constrast
19+
kNormal, //!< glyph outlines modified to improve constrast
20+
kFull, //!< modifies glyph outlines for maximum constrast
21+
};
1622
class Font final {
1723
public:
1824
Font() = delete;
@@ -54,6 +60,8 @@ class Font final {
5460
bool IsFakeBold() const { return fake_bold_; }
5561
void SetSkewX(float skew_x) { skew_x_ = skew_x; }
5662
float SkewX() const { return skew_x_; }
63+
void SetHinting(FontHinting hinting) { hinting_ = hinting; }
64+
FontHinting GetHinting() const { return hinting_; }
5765

5866
private:
5967
std::shared_ptr<ITypefaceHelper> typeface_;
@@ -62,6 +70,7 @@ class Font final {
6270
bool fake_bold_ = false;
6371
float scale_x_ = 1.0f;
6472
float skew_x_ = 0.f;
73+
FontHinting hinting_ = FontHinting::kSlight;
6574
};
6675
} // namespace tttext
6776
} // namespace ttoffice

src/ports/shaper/skshaper/one_line_shaper.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,8 +587,8 @@ bool OneLineShaper::shape(const char32_t* content, uint32_t len,
587587
matchResolvedFonts(style, [&](std::shared_ptr<ITypefaceHelper> typeface) {
588588
// Create one more font to try
589589
Font font(typeface, style.GetFontSize());
590-
// font.setEdging(SkFont::Edging::kAntiAlias);
591-
// font.setHinting(SkFontHinting::kSlight);
590+
// font.setEdging(SkFont::Edging::kAntiAlias);
591+
font.SetHinting(FontHinting::kSlight);
592592
font.SetSubpixel(true);
593593

594594
// Apply fake bold and/or italic settings to the font if the

0 commit comments

Comments
 (0)