slint icon indicating copy to clipboard operation
slint copied to clipboard

Font is clipped almost in half if you don't set a height on it.

Open NigelBreslaw opened this issue 1 month ago • 3 comments

Bug Description

test.zip

Image

This font is badly clipped when used. I have attached the example project.

Reproducible Code (if applicable)


Environment Details

  • Slint Version: 1.4.1 and 1.5.0
  • Platform/OS: MacOS
  • Programming Language:
  • Backend/Renderer: Skia

Product Impact

Depends on how many fonts have this issue.

NigelBreslaw avatar Nov 26 '25 14:11 NigelBreslaw

I believe that this is how the font designers designed the font. Take a look at letters "H" and "e" in FontForge:

Image

The grey lines are the em square and the outline is scaled to it. The designers basically gave no spacing between the bottom of the design square and the bottom of the glyph.

As data points: The em square is 2048 here and the ascent is 1638 and the descent is 410.

The only other way of adding a spacing would be to always add half-leading around text elements at the bottom or the top, but I'd like to see an argument to be made as to why we should do that.

tronical avatar Nov 26 '25 15:11 tronical

(Note, I might be mis-interpreting this)

tronical avatar Nov 26 '25 15:11 tronical

I edited the report as I had 2 fonts in my project. The other one is part of MacOS but this font is not. How is this acceptable?

Image

NigelBreslaw avatar Nov 26 '25 21:11 NigelBreslaw

Nigel and I discussed this. I propose that we extend the TextOverflow enum:

enum TextOverflow {
        /// The text will simply be clipped.
        Clip,
        /// The text will be elided with `…`.
        Elide,
        /// The text will be rendered without any clipping or elision.
        Unclipped
}

tronical avatar Dec 16 '25 13:12 tronical