Skip to content

Provide new fonts handling routines in TVirtualX/TPadPainter classes#22059

Open
linev wants to merge 12 commits intoroot-project:masterfrom
linev:virtualx_text
Open

Provide new fonts handling routines in TVirtualX/TPadPainter classes#22059
linev wants to merge 12 commits intoroot-project:masterfrom
linev:virtualx_text

Conversation

@linev
Copy link
Copy Markdown
Member

@linev linev commented Apr 24, 2026

  1. When render text basic functions like text extent/ascent/descent are required. These values handled normally by TTF, but for Cocoa it is done differently. Also plain X11 uses simplified text rendering with own methods. Provide several new methods in TVirtualX interface which gives text metrics for specified font/size.
  2. Implement these methods in TGQuartz class, extend internal interfaces to avoid dependency on selected font.
  3. Provide in TVirtualPadPainter similar methods.
  4. In TPadPainterBase implement these methods with FFT support when it is desired. It will be central place where difference between TTF and not-TTF platform will be handled.
  5. Implement TAttText::GetTextSizePixels(TVirtualPad &pad) and TAttText::GetTextSizeRelative(TVirtualPad &pad). These methods uses pad attributes to correctly scale font size depending from font precision. One can see that pixel size used by TVirtualX and relative size used by TVirtualPS output
  6. Finally adjust all TText methods to get metrics via pad painter. In this respect text rendering now mostly do not depend from gVirtualX.

Really missing is functionality to get pad pixel width and height. All kind of workarounds are really annoying.
Using equation: pad_height = pad.YtoPixel(pad.GetY1()); is not that one expects.

linev added 3 commits April 24, 2026 10:33
Very often used method to calculate text size in pixels for specified pad.
Important that now pad is used as parameter
Old methods relies on global attributes which normally related to current window.
But text handling does not uses window context.
Add new methods where text font and size provided directly.
linev added 9 commits April 24, 2026 17:29
Used only when plain X11 without TTF fonts are involved - which is normally not a case.
This is special platform where TTF is not used by default.
So all methods must be correctly implemented

Adjust internal methods to avoid dependency from selected font.
Now font and size provided directly - one can directly use selected font handle
as method argument, also in old methods

Provide shortcut method to extract unichars for greek and math symbols
They let decouple graphics classes from gVirtualX
Here TTF handling performed when HasTTFonts are enabled. It also used when gVirtualX cannot provide font information for any reason
For these classes TTF will be used directly without involving of gVirtualX
Remove there dependency from gVirtualX.
One can potentially configure any other text engine
It returns text size in relative units for specified
pad

Use this method when apply to pad painter attributes
@github-actions
Copy link
Copy Markdown

Test Results

    22 files      22 suites   3d 10h 49m 41s ⏱️
 3 847 tests  3 794 ✅  1 💤 52 ❌
76 868 runs  76 798 ✅ 18 💤 52 ❌

For more details on these failures, see this check.

Results for commit 52087ed.

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