UI: Improved Initial Vfont Sizes #109228

Closed
Harley Acheson wants to merge 1 commits from Harley/blender:vfontsize into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Member

Better consistency between initial text object sizes by using Cap
height instead of maximum bounding box height.


Text objects can obviously be scaled to any size. But the initial sizes, when the text is first added, create a lot of variation in the visual size of different fonts. With Blender 4.0 it might be a nice time to improve this.

This problem occurs now because we base the initial scale on the maximum top and bottom of all the glyphs in the font, which is not a normal metric for this use. If you start with two identically-designed fonts that just have coverage of lower Latin and then add extra characters outside of that range to one then it will be shown as smaller in Blender. This is because it is more likely to contain characters, like symbols, that might extend further above or below the other characters. This will increase the maximal vertical range and result in a smaller scale.

The most normal metric to keep different fonts at nearly the same size is to use Cap height, or the height of a capital letter above the baseline. Specifically it is the height of flat capitals (like H or I), rather than rounded (O) or pointed (A). So the informal definition is the height of a capital H.

This PR refactors the scale calculations to use Cap height. But then scales the result so that our default font is the same height as it is today. This also means that most sane fonts - that have capitals that take up the space between baseline and top of the em-square are also that same height.

Following shows an assortment of fonts at initial sizes in current code:

image

The following shows the same fonts with this PR.:

image

You should notice that the second image has improved consistency. It is not perfect though, as that is impossible, because font designers are free to make glyphs of any size within their design sizes. But you should notice that for most of the "normal" fonts the tops of the "f" are perfectly aligned.

This PR first checks to see if the font itself actually defines a "cap height" metric within it. If not, this falls back to measuring the height of an "H". And if the font does not contain an "H" then it uses 70% of design height.

Note that with this code change VFontData->em_height would always be exactly 1.0f. As in the font is 1em high and then scaled by VFontData->scale. This em_height was never needed but sometimes had a non-one value because of the current wonky calculations. So this PR removes it, simplifying some other calculations.

Better consistency between initial text object sizes by using Cap height instead of maximum bounding box height. --- Text objects can obviously be scaled to any size. But the initial sizes, when the text is first added, create a lot of variation in the visual size of different fonts. With Blender 4.0 it might be a nice time to improve this. This problem occurs now because we base the initial scale on the maximum top and bottom of all the glyphs in the font, which is not a normal metric for this use. If you start with two identically-designed fonts that just have coverage of lower Latin and then add extra characters outside of that range to one then it will be shown as _smaller_ in Blender. This is because it is more likely to contain characters, like symbols, that might extend further above or below the other characters. This will increase the maximal vertical range and result in a smaller scale. The most normal metric to keep different fonts at nearly the same size is to use Cap height, or the height of a capital letter above the baseline. Specifically it is the height of flat capitals (like H or I), rather than rounded (O) or pointed (A). So the informal definition is the height of a capital H. This PR refactors the scale calculations to use Cap height. But then scales the result so that our default font is the same height as it is today. This also means that most sane fonts - that have capitals that take up the space between baseline and top of the em-square are also that same height. Following shows an assortment of fonts at initial sizes in current code: ![image](/attachments/519bba81-859e-458d-8705-bb0333a686bc) The following shows the same fonts with this PR.: ![image](/attachments/ebc6a60d-354e-474b-9d50-c32e9867aa36) You should notice that the second image has improved consistency. It is not perfect though, as that is impossible, because font designers are free to make glyphs of any size within their design sizes. But you should notice that for most of the "normal" fonts the tops of the "f" are perfectly aligned. This PR first checks to see if the font itself actually defines a "cap height" metric within it. If not, this falls back to measuring the height of an "H". And if the font does not contain an "H" then it uses 70% of design height. Note that with this code change VFontData->em_height would always be exactly 1.0f. As in the font is 1em high and then scaled by VFontData->scale. This em_height was never needed but sometimes had a non-one value because of the current wonky calculations. So this PR removes it, simplifying some other calculations.
Harley Acheson added this to the User Interface project 2023-06-22 05:48:45 +02:00
Harley Acheson requested review from Hans Goudey 2023-06-22 17:12:45 +02:00
Hans Goudey approved these changes 2023-06-23 13:55:53 +02:00
Hans Goudey left a comment
Member

I don't know too much about this area, but the description makes sense, and the code change looks reasonable to me. 4.0 does seem like a nice time to change this.

I don't know too much about this area, but the description makes sense, and the code change looks reasonable to me. 4.0 does seem like a nice time to change this.
Harley Acheson requested review from Campbell Barton 2023-06-24 00:49:34 +02:00
Author
Member

@ideasman42 - What do you think of this?

On the one hand it would be nice to finally clean this up. Users could (generally) replace one normal font with one of similar design and have them be the same height.

On the other hand we end up with small font size differences for files made prior to 4.0. Is it worth the hassle or is 4.0 the first and best chance to do this? Not sure.

@ideasman42 - What do you think of this? On the one hand it would be nice to finally clean this up. Users could (generally) replace one normal font with one of similar design and have them be the same height. On the other hand we end up with small font size differences for files made prior to 4.0. Is it worth the hassle or is 4.0 the first and best chance to do this? Not sure.
Harley Acheson force-pushed vfontsize from d67265957c to 70d810682f 2023-07-14 01:48:17 +02:00 Compare
Member

How complex would it be to add versioning that scales the text height by the difference in the new behavior? Then the different results in 4.0 argument wouldn't apply. That breaking change does make me a bit hesitant about this too actually.

How complex would it be to add versioning that scales the text height by the difference in the new behavior? Then the different results in 4.0 argument wouldn't apply. That breaking change does make me a bit hesitant about this too actually.
Author
Member

Actually I also don't like having this change of behavior between versions for so little gain.

Actually I also don't like having this change of behavior between versions for so little gain.
Harley Acheson closed this pull request 2023-07-20 23:25:32 +02:00

Pull request closed

Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#109228
No description provided.