Skip to content

[ttf] Provide consistent way to switch on/off smoothing - #24214

Open
linev wants to merge 9 commits into
root-project:masterfrom
linev:next_ttf
Open

linev wants to merge 9 commits into
root-project:masterfrom
linev:next_ttf

Conversation

@linev

@linev linev commented Nov 17, 2026

Copy link
Copy Markdown
Member

There is smoothing parameter in TTF/TTFhandle classes.
Normally it fixed by platform/display colors depth.
Old static interface provides possibility to change it - but only globally.

Now provide consistent way to configure smoothing/kerning/hinting with TTFhandle class.
Predefined values are set with static methods like:

  void TTFhandle::SetKerningPrefer(Bool_t on)
  void TTFhandle::SetSmoothingPrefer(Bool_t on)
  void TTFhandle::SetHintingPrefer(Bool_t on)

When new display is created (TGX11TTF/TGQuartz/TGWin32), depending from colors depth smoothing is enabled or disabled. Normally it is always ON for all recent display kinds.

When TTFhandle instance is created, it has internal three-state parameters for smoothing/hinting/kerning.
If parameters not explicitly set in the code (now everywhere the case) - current default values are used.
So one always can switch on/off all three features freely.

Adjust code in gtk4canv and qt6canv canvases to correctly display not-smoothed TTF.

After this PR one can at any time in ROOT call TTFhandle::SetSmoothingPrefer(false); to change painting in all canvases.

In the future one can add handling of all these three parameters in our TLatex syntax.

Do not convert to/from colors/pixels/ColorStruct_t,
just use RGB for calculation of mean background color
and for interpolation between backround and text
With TTFhandle::SetSmoothingPrefer() one can
enabled/disable global state which define is smoothing should be used.
Default is on while all modern displays support enough number of colors.

TTFHanlde::fSmoothing has now three states. When state not set before, GetSmoothingPrefer() is used.
Do not force usage of smoothing to let configure
custom value via global preference
To be able preconfigure them in the same way as with smoothing.
Kerning explicitely used in one place to get text metrics,
potentially can be switched on/off from the TLatex

Internally use `Tristate` class which handle undefined state for the variable.
In TTFhandle::LayoutGlyphs() set smooth/kern/hint flags if was not defined before.
This exclude further interfearance from global state
In such case binary format is just bitmap image which can be plotted directly
Make smoothing and not smoothing very similar
Need special bit reversing to support Cairo::Surface::Format::A1 which is differ from TTF source bitmap
@linev linev self-assigned this Nov 17, 2026
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Test Results

    22 files      22 suites   3d 11h 34m 47s ⏱️
 3 886 tests  3 885 ✅ 0 💤 1 ❌
76 064 runs  76 063 ✅ 0 💤 1 ❌

For more details on these failures, see this check.

Results for commit 3af38f6.

♻️ This comment has been updated with latest results.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant