Bug 157282 - v-aligning text to center fails to v-center text with some fonts
Summary: v-aligning text to center fails to v-center text with some fonts
Status: UNCONFIRMED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Impress (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-09-16 22:07 UTC by Eyal Rozenberg
Modified: 2023-10-02 13:54 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Presentation with boxes demonstrating the bug (examine at different zoom levels) (19.68 KB, application/vnd.oasis.opendocument.presentation)
2023-09-16 22:07 UTC, Eyal Rozenberg
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eyal Rozenberg 2023-09-16 22:07:06 UTC
Created attachment 189642 [details]
Presentation with boxes demonstrating the bug (examine at different zoom levels)

When we v-align the text of an object (say, a shape) to the center - the distance from the baseline to the edge of the bottom margin should be equal to the distance from the cap line (or if you like, the ascender line) to the edge of the top margin. And if the margins are equal, then we should have:

|box bottom to baseline| = |cap line to top|

the farther we are from an equality, the more it will seem the text is not centered.

Of course, this may be affected by the nature of the font itself, e.g. whether it seems that the caps are somehow "too high"; and there will be some difference between the choice of the ascender or the cap etc. - but that's the general rule.

The farther we are from this equality, the more the text appear not to be vertically centered.

Now, with some fonts, there is a significant difference between the two distances - especially in lower zoom levels. See the attached document, comparing v-centered text in DejaVu Sans vs Liberation Sans: 

Font                           to top    to bottom
-----------------------------------------------------
DejaVu Sans regular 20pt       ~0.25 cm  ~0.28 cm
Liberation Sans regular 20pt   ~0.28 cm  ~0.27 cm

both v-aligned center of course. Regular spacing, no v-spacing after paragraph, default (and identical) bottom and top margin settings.

Seen with:

Version: 7.6.0.3 (X86_64) / LibreOffice Community
Build ID: 69edd8b8ebc41d00b4de3915dc82f8f0fc3b6265
CPU threads: 4; OS: Linux 6.4; UI render: default; VCL: gtk3
Locale: en-IL (en_IL); UI: en-US

but I've noticed this several times over the years.

Also saw this with a font named Stencil, and probably several others.
Comment 1 Stéphane Guillou (stragu) 2023-10-02 12:49:34 UTC
Looks the same in OOo 3.3.
Khaled, what's your take on this?
Comment 2 ⁨خالد حسني⁩ 2023-10-02 13:03:45 UTC
Most likely it is centering the font height, i.e. ascender + descender, and it does not look at the content at all, probably be design. DejaVu Sans has less space above the capitals than below baseline, while Liberation Sans has more or less the same space.

If you middle-align in a web browser, you get the same effect, and some fonts are intentionally designed to look vertically centered in such situations https://twitter.com/romanshamin_en/status/1562801657691672576
Comment 3 Eyal Rozenberg 2023-10-02 13:24:18 UTC
(In reply to ⁨خالد حسني⁩ from comment #2)
> Most likely it is centering the font height, i.e. ascender + descender

1. I'm not sure that we should think of the font height (w.r.t vertical positioning) as the difference between the ascender and the descender lines, as opposed to baseline to cap line. Of course line spacing should account for those, but not necessarily centering.

2. Are you sure this is the case for these specific fonts? A cursory inspection doesn't seem to agree with that.

> and it does not look at the content at all, probably be design.

Yes, that's certain. I'm not arguing against this design choice (although that might be an interesting discussion to have).

> DejaVu Sans has
> less space above the capitals than below baseline, while Liberation Sans has
> more or less the same space.

But the ascenders are about as high as Liberation Sans... so,

> If you middle-align in a web browser, you get the same effect, and some
> fonts are intentionally designed to look vertically centered in such
> situations https://twitter.com/romanshamin_en/status/1562801657691672576

is ours a case of the font artificially using a larger above-caps space?

Also, suppose a font does this intentionally. Why should we respect its desire for extra space, when the user has indicated something different, and the extra space is known not to be necessary?
Comment 4 ⁨خالد حسني⁩ 2023-10-02 13:54:10 UTC
The ascenders and descenders I’m talking are font settings (number in OS/2 and/or hhea tables) not the actual glyph ascenders and descenders (glyph ascenders and descenders are rarely if ever taking account of for anything as getting them requires measuring the bounding boxes of the glyphs which is both slow and often undesirable as then the measures are dependent on the text content and leads to inconsistencies).