Skip to content

Provide none-static interface for TTF#22098

Merged
linev merged 19 commits into
root-project:masterfrom
linev:ttf_normal_class
May 6, 2026
Merged

Provide none-static interface for TTF#22098
linev merged 19 commits into
root-project:masterfrom
linev:ttf_normal_class

Conversation

@linev
Copy link
Copy Markdown
Member

@linev linev commented Apr 29, 2026

Now TTF class uses fully static API - no chance to run code in parallel.
Also there are several static arrays preallocated - which leads to certain limitations.

Introduce new TTFhandle class which provides "normal" API without all previous static limitations.
ttf library handle and fonts lists created per-thread using thread_local instances.
Thus functionality can be used from many threads without limitation.

Old TTF class API preserved until ROOT7.
It creates static instance of std::unique_ptr<TTFhandle> and redirect all calls to it.

All ROOT classes tested first with modified TTF implementation and then converted to use
new API.

Important improvement - there is no global state for text attributes which was always set to static TTF members
by each call to TAttText::Modify(). Now text attributes preserved in TVirtualX instance and applied to temporary
TTFhandle instance only when text is painted.

Adjust all DrawFTGlyph methods to have similar structure. Avoid static variables for smooth colors

linev added 2 commits April 29, 2026 11:04
Provide several getters which replace such direct access.
Remove friend classes - no any allows to use members from outside.
They will disappear soon
@linev linev self-assigned this Apr 29, 2026
@linev linev requested a review from couet as a code owner April 29, 2026 09:10
@linev linev marked this pull request as draft April 29, 2026 09:10
It is future replacement for static TTF interface.
For now it define similar methods and TTF just call to static instance -
fully preserve API as it was before.
In ROOT7 TTFhandle class will fully replace TTF.
All ROOT classes will use new API
Comment thread graf2d/graf/inc/TTF.h
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 29, 2026

Test Results

    22 files      22 suites   3d 13h 16m 41s ⏱️
 3 850 tests  3 849 ✅ 0 💤 1 ❌
76 936 runs  76 935 ✅ 0 💤 1 ❌

For more details on these failures, see this check.

Results for commit ca0efb7.

♻️ This comment has been updated with latest results.

Idea to make library and fonts handles thread local
In such case multi-threaded usage will be safe.

Make special method to intialize or close library
Inside thread_local library handle is managed

And also add SelectFontHandle method where thread_local
list of font handles are trated.

Directly change TMathText while it used font index functions
which are now gone - but were introduced few days ago
@linev linev force-pushed the ttf_normal_class branch from 4dbdefd to 5aa2911 Compare May 4, 2026 06:11
linev added 9 commits May 4, 2026 10:15
When every symbol drawn in TMathText, use `bounding_box_char`
method to get current position. Only in `bounding_box_char`
analyze cyrillic symbols and adjust TTF settings.

Use new TPad method to get width and height, remove unused members
It does not rely on global TTF state.
Several methods was introduced to TTF class for TMathText support.
Now these methods no longer used and can be removed
Instead of global state - use temporary handle for
getting text extent
Like in old interface, for new TTFhandle class make these members static
They are changed in the very beginning and globally depending from display
Avoid change of global state
Fully avoids global state,
text attributes applied only when actual renderning happens
Avoid change of global state
Apply text attributes only when needed
As on other platforms, make single method to render string
Like on X11, combine all in one method
@linev linev marked this pull request as ready for review May 5, 2026 05:37
linev added 2 commits May 5, 2026 08:18
It converts Glyph to bitmap by calling FT_Glyph_To_Bitmap.
Let incapsulate ttf functionality in central class
Simplify loops over the glyphs,
expose less FT functionality to next level
linev added 4 commits May 5, 2026 10:43
Use std::vector to calculate average background color
Do not use static colors to avoid potential conflicts
Always QueryColors and recalculate smoothing colors
Use unsigned x/y index values
Do not use static variables for colors
Use proper signed/unsigned for loop indexes
Do not use static colors
Correctly count average for background color
Use proper signed/unsigned indecies in loops
Correctly recalculate smooth colors - no static use
Use proper signed/unsigned for loop indecies
@linev linev merged commit ae522f4 into root-project:master May 6, 2026
27 of 30 checks passed
@linev linev deleted the ttf_normal_class branch May 6, 2026 05:20
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.

3 participants