FontBLF: Store Sizes, Styles, and Other Metrics #113432

Merged
Harley Acheson merged 6 commits from Harley/blender:FontMetrics into main 2023-10-14 02:43:56 +02:00
Member

When loading a font, gather metrics and other information that can help
use it more correctly. Default weight and slant, X-height, cap height,
locations for underline, strike-through, subscripts, etc. Family and
style flags, etc.


This PR, on its own, has no effects. It simply gathers and stores values that could be used to help us use the font in better and more typographically correct ways.

Some of this data could be obtained directly from the FT_Face at any time, but we are wanting to sometimes run with FontBLFs that are without faces all the time when not needed. Other data is taken from the font's OS/2 and Post tables, while other data is calculated. The data includes:

  • weight - the font's default weight (100-900)
  • width - condensed versus wide in a range, with 1 as normal
  • slant - in clockwise degrees
  • x-height - distance from baseline to lowercase mean line
  • cap height - distance from baseline to the top of capital letters
  • much, much more...

PR #112454 would use the data here to find the starting default weights, slant values, widths, etc. Because that PR sets absolute values, rather than make relative changes, it needs the starting position. For example, it allows changing the weight of any font to be in the range of 100-900 weight class, but how much is done depends on the starting weight of the font, which might be a non-variable light or heavy version. Similarly it allows setting any slant in positive or negative degrees, but it needs to know if the font already starts with a slant.

PR #110187 would need the data here to determine the starting vfont scale without needing to use FreeType directly itself. And it could later use the data to make the output more correct. For example, "small caps" is meant to be at x-height. Underline is best set at a location and thickness specified by the font designer. We might want to eventually set the initial scale based on cap height so that fonts have a more consistent size. We could even use the family and style and other data to allow working with a full family of fonts, not just the four font variations we accept now. We could allow setting of subscript and superscript since this data includes the information on how to construct those.

When loading a font, gather metrics and other information that can help use it more correctly. Default weight and slant, X-height, cap height, locations for underline, strike-through, subscripts, etc. Family and style flags, etc. --- This PR, on its own, has no effects. It simply gathers and stores values that _could_ be used to help us use the font in better and more typographically correct ways. Some of this data could be obtained directly from the FT_Face at any time, but we are wanting to sometimes run with FontBLFs that are without faces all the time when not needed. Other data is taken from the font's OS/2 and Post tables, while other data is calculated. The data includes: * weight - the font's default weight (100-900) * width - condensed versus wide in a range, with 1 as normal * slant - in clockwise degrees * x-height - distance from baseline to lowercase mean line * cap height - distance from baseline to the top of capital letters * much, much more... PR #112454 would use the data here to find the starting default weights, slant values, widths, etc. Because that PR sets absolute values, rather than make relative changes, it needs the starting position. For example, it allows changing the weight of any font to be in the range of 100-900 weight class, but how much is done depends on the starting weight of the font, which might be a non-variable light or heavy version. Similarly it allows setting any slant in positive or negative degrees, but it needs to know if the font already starts with a slant. PR #110187 would need the data here to determine the starting vfont scale without needing to use FreeType directly itself. And it could later use the data to make the output more correct. For example, "small caps" is meant to be at x-height. Underline is best set at a location and thickness specified by the font designer. We might want to eventually set the initial scale based on cap height so that fonts have a more consistent size. We could even use the family and style and other data to allow working with a full family of fonts, not just the four font variations we accept now. We could allow setting of subscript and superscript since this data includes the information on how to construct those.
Harley Acheson added 1 commit 2023-10-09 00:15:03 +02:00
293606fc54 FontBLF: Store Sizes, Styles, and Other Metrics
When loading a font, gather metrics and other information that can help
use it more correctly. Default weight and slant, X-height, cap height,
locations for underline, strike-through, subscripts, etc. Family and
style flags, etc.
Harley Acheson added this to the Core project 2023-10-09 00:15:12 +02:00
Harley Acheson added 2 commits 2023-10-12 01:43:07 +02:00
Author
Member

@blender-bot build

@blender-bot build
Author
Member

Notes:

I think I should add one more metric, the proportion of width to height of lowercase "O". This gives a nice indication of horizontal "Proportion" that could be useful for font comparisons, classification, sorting, replacement. https://medium.com/@getflourish/the-anatomy-of-a-thousand-typefaces-f7b9088eed1

Since blf_font_metrics is made to work with just an FT_Face as input, and does not depend on FontBLF, make sure it is in a nice place that it could be used by thumbnail code. This way some information could be added to the thumbnail meta-data and shown on the hover tooltip.

Notes: I think I should add one more metric, the proportion of width to height of lowercase "O". This gives a nice indication of horizontal "Proportion" that could be useful for font comparisons, classification, sorting, replacement. https://medium.com/@getflourish/the-anatomy-of-a-thousand-typefaces-f7b9088eed1 Since `blf_font_metrics` is made to work with just an FT_Face as input, and does not depend on FontBLF, make sure it is in a nice place that it could be used by thumbnail code. This way some information could be added to the thumbnail meta-data and shown on the hover tooltip.
Harley Acheson added 3 commits 2023-10-12 21:47:32 +02:00
Author
Member

I want to work on a (simplified) variation of #112454 for inclusion before the Conference. Therefore I need this before the weekend.

I want to work on a (simplified) variation of #112454 for inclusion before the Conference. Therefore I need this before the weekend.
Harley Acheson merged commit 83705a87cb into main 2023-10-14 02:43:56 +02:00
Harley Acheson deleted branch FontMetrics 2023-10-14 02:43:58 +02:00
Sign in to join this conversation.
No reviewers
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
1 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#113432
No description provided.