UI: Configurable UI Font Weight #112454

Merged
Harley Acheson merged 36 commits from Harley/blender:TextUiStyles into main 2023-10-21 00:28:37 +02:00
Member

Allows selecting different font weights in Text Styles


Our new Interface font, Inter, is a variable font, which means the one font can be used for almost any weight. It is as if we shipped with an entire family of the font in all its weights. This PR allows us to change the weight for each of the Text Styles:

image

The "Weight" value is like CSS:

  • 100 Thin
  • 200 Extra Light
  • 300 Light
  • 400 Normal
  • 500 Medium
  • 600 Semi Bold
  • 700 Bold
  • 800 Extra Bold
  • 900 Ultra Bold

If a font is variable yet does not offer the full range from 100-900 then the weights are augmented with glyph emboldening.

Allows selecting different font weights in Text Styles --- Our new Interface font, Inter, is a variable font, which means the one font can be used for almost any weight. It is as if we shipped with an entire family of the font in all its weights. This PR allows us to change the weight for each of the Text Styles: ![image](/attachments/dfa16cd3-1f77-43b2-b6a3-a95eb9d0c132) The "Weight" value is like CSS: * 100 Thin * 200 Extra Light * 300 Light * 400 Normal * 500 Medium * 600 Semi Bold * 700 Bold * 800 Extra Bold * 900 Ultra Bold If a font is variable yet does not offer the full range from 100-900 then the weights are augmented with glyph emboldening.
Harley Acheson added 1 commit 2023-09-16 17:30:25 +02:00
67d6334a37 WIP: UI: Configurable UI Text Styles
Allows text character manipulation in Text Style
Harley Acheson added this to the User Interface project 2023-09-16 17:31:15 +02:00
Harley Acheson added 2 commits 2023-09-17 19:58:48 +02:00
Harley Acheson added 2 commits 2023-09-22 00:06:41 +02:00
Harley Acheson changed title from WIP: UI: Configurable UI Text Styles to UI: Configurable UI Text Styles 2023-09-22 00:24:42 +02:00
Harley Acheson changed title from UI: Configurable UI Text Styles to UI: Configurable UI Variable Text Styles 2023-09-22 00:25:01 +02:00
Harley Acheson requested review from Pablo Vazquez 2023-09-22 00:25:43 +02:00
Member

Ooh nice! Already reaping the benefits of variable fonts :D

Any particular reason for the weight values to be normalised? 100-900 is a range many designers will understand.

Positive slant values do nothing for me here, negative values do. Not sure if it is a limitation of the font. Also perhaps this should be a value slider instead of a numeric one?

Ooh nice! Already reaping the benefits of variable fonts :D Any particular reason for the weight values to be normalised? 100-900 is a range many designers will understand. Positive slant values do nothing for me here, negative values do. Not sure if it is a limitation of the font. Also perhaps this should be a value slider instead of a numeric one?
Author
Member

Any particular reason for the weight values to be normalised? 100-900 is a range many designers will understand.
Positive slant values do nothing for me here, negative values do. Not sure if it is a limitation of the font.

It is complicated.

With variable fonts each design aspect that can change is an "axis". The font designer can add any arbitrary value for the min, max, and default values. And these just correspond to the minimum and maximum variation in the design and a default they like. The Inter font is made by someone sane so he uses proper css weight values. But I have seen fonts that have amazingly strange values in there. It all works just fine if they use -1000 and +1000 and min and max.

Right now I am treating all the variable axes generically, so that default becomes "0" for no change, the min maps to -1 and the max to 1.

Slant values are backwards from what you expect. This is because when this value is used properly it defines a rotation in counter-clockwise degrees. Inter allows a rightward slant, but not a leftward one. So for this axis it has a max of 0, a default of 0, and a negative minimum value, which is considered quite normal. Apparently this counter-clockwise rotation nonsense was to keep the value similar to one that was used in a really old font table (post, for "Postscript").

You can see this stupid behavior on Google Fonts site too. If you go here and play with "Slant". https://fonts.google.com/specimen/Inter/tester

But keep in mind that I was playing with these variable fonts when they first coming out. So some of the weirdness of the early fonts could be gone by now. We might be able to assume now that sane fonts will use these values sanely now.

But this range is nice for things like node inputs.

One option that DOESN'T easily work is to keep them as -1 to 1 ranges internally but expose them to users as weights like 100, 400, etc that get converted to the normalized range. This is because I don't actually know what the range is, as in a font might be variable but only support 200-800. To do that right I'd have to expose the variable stuff to the higher level BLF code. BLF_Variable_Axis_Maximum(axisname) or similar.

Then you might even be able to get a slant value that goes the right way.

I guess it all depends on whether we can get this stuff exposed to users. If yes, I think @brecht and @HooglyBoogly might have to weigh in about these values.

> Any particular reason for the weight values to be normalised? 100-900 is a range many designers will understand. > Positive slant values do nothing for me here, negative values do. Not sure if it is a limitation of the font. It is complicated. With variable fonts each design aspect that can change is an "axis". The font designer can add any arbitrary value for the min, max, and default values. And these just correspond to the minimum and maximum variation in the design and a default they like. The Inter font is made by someone sane so he uses proper css weight values. But I have seen fonts that have amazingly strange values in there. It all works just fine if they use -1000 and +1000 and min and max. Right now I am treating all the variable axes generically, so that default becomes "0" for no change, the min maps to -1 and the max to 1. Slant values are backwards from what you expect. This is because when this value is used properly it defines a rotation in counter-clockwise degrees. Inter allows a rightward slant, but not a leftward one. So for this axis it has a max of 0, a default of 0, and a negative minimum value, which is considered quite normal. Apparently this counter-clockwise rotation nonsense was to keep the value similar to one that was used in a really old font table (post, for "Postscript"). You can see this stupid behavior on Google Fonts site too. If you go here and play with "Slant". https://fonts.google.com/specimen/Inter/tester But keep in mind that I was playing with these variable fonts when they first coming out. So some of the weirdness of the early fonts could be gone by now. We might be able to assume now that sane fonts will use these values sanely now. But this range is nice for things like node inputs. One option that DOESN'T easily work is to keep them as -1 to 1 ranges internally but expose them to users as weights like 100, 400, etc that get converted to the normalized range. This is because I don't actually know what the range is, as in a font might be variable but only support 200-800. To do that right I'd have to expose the variable stuff to the higher level BLF code. BLF_Variable_Axis_Maximum(axisname) or similar. Then you might even be able to get a slant value that goes the right way. I guess it all depends on whether we can get this stuff exposed to users. If yes, I think @brecht and @HooglyBoogly might have to weigh in about these values.
Member

Any particular reason for the weight values to be normalised? 100-900 is a range many designers will understand.
Positive slant values do nothing for me here, negative values do. Not sure if it is a limitation of the font.

It is complicated.

Thanks for the thorough explanation! I was just asking as I didn't know how this works.

If the values are normalized then having a value slider (instead of number slider) probably works best? Either way it's fine and would be a great addition to have with the new font in 4.0

> > Any particular reason for the weight values to be normalised? 100-900 is a range many designers will understand. > > Positive slant values do nothing for me here, negative values do. Not sure if it is a limitation of the font. > > It is complicated. Thanks for the thorough explanation! I was just asking as I didn't know how this works. If the values are normalized then having a value slider (instead of number slider) probably works best? Either way it's fine and would be a great addition to have with the new font in 4.0
Harley Acheson changed title from UI: Configurable UI Variable Text Styles to WIP: UI: Configurable UI Variable Text Styles 2023-10-02 03:07:04 +02:00
Author
Member

Any particular reason for the weight values to be normalised? 100-900 is a range many designers will understand...Positive slant values do nothing for me here, negative values do.

Okay, I think I can get us what we want. I just need to do the following:

  • Ignore fonts that might do it wrong, and instead strictly follow the definitions of the axes in OpenType® Specification Version 1.9
  • Allow a combination of variable axis changes with synthesized glyph changes like obliquing and emboldening.
  • Treat the "known" axes (the lowercase axes in the Design-Variation Axis Tag Registry) specially
  • Treat unknown (uppercase axes) generically with -1 <- 0 -> 1 normalized values.

For example, the "wght". 1-1000 values only, treated as values from OS/2 usWeightClass (100-900, with 400 being normal or regular). Allow full 100-900 range, even if the font supports only a subset, by adding emboldening when needed. For non-variable fonts I'll need to get the regular weight value from the OS/2 table usWeightClass value, so that bold fonts stay properly in the range.

For 'slnt" support subset of the -90 - 90 range (+- 15?). Angle of slant in counter-clockwise degrees from upright. 0 is normal. Use obliquing to fill holes in coverage. Get font's regular slant from "post" table "italicAngle". Expose to users as clockwise degrees.

For "wdth", positive values interpreted as a percentage of normal (whatever that means to the designer). 100 is normal. Do a width transform without advance change to fill in coverage. For non-variable fonts get the normal value from OS./2 table usWidthClass value. note this is just 9 values so needs interpolation.

Since the above fills in coverage holes with synthetic changes we don't need to expose min and maxes to users. Weight, for example, can always be 100-900 regardless of that the font actually supports.

> Any particular reason for the weight values to be normalised? 100-900 is a range many designers will understand...Positive slant values do nothing for me here, negative values do. Okay, I think I can get us what we want. I just need to do the following: * Ignore fonts that might do it wrong, and instead strictly follow the definitions of the axes in OpenType® Specification Version 1.9 * Allow a combination of variable axis changes with synthesized glyph changes like obliquing and emboldening. * Treat the "known" axes (the lowercase axes in the Design-Variation Axis Tag Registry) specially * Treat unknown (uppercase axes) generically with -1 <- 0 -> 1 normalized values. For example, the "wght". 1-1000 values only, treated as values from OS/2 usWeightClass (100-900, with 400 being normal or regular). Allow full 100-900 range, even if the font supports only a subset, by adding emboldening when needed. For non-variable fonts I'll need to get the regular weight value from the OS/2 table usWeightClass value, so that bold fonts stay properly in the range. For 'slnt" support subset of the -90 - 90 range (+- 15?). Angle of slant in counter-clockwise degrees from upright. 0 is normal. Use obliquing to fill holes in coverage. Get font's regular slant from "post" table "italicAngle". Expose to users as clockwise degrees. For "wdth", positive values interpreted as a percentage of normal (whatever that means to the designer). 100 is normal. Do a width transform without advance change to fill in coverage. For non-variable fonts get the normal value from OS./2 table usWidthClass value. note this is just 9 values so needs interpolation. Since the above fills in coverage holes with synthetic changes we don't need to expose min and maxes to users. Weight, for example, can always be 100-900 regardless of that the font actually supports.
Harley Acheson added 2 commits 2023-10-03 00:58:29 +02:00
Author
Member

@pablovazquez

This PR now allows specifying font weight like css, with values between 100-900. Slant is in clockwise degrees and can lean both ways (rightward is built into the font, while leftward is done with glyph transformations). Width using 1.0 as normal, as does Spacing.

It is quite fun to play with. The only thing it doesn't do (yet) is deal properly with non-variable fonts that are bold or italic, and so won't add boldness or obliquing quite as I'd like, but that is fairly obscure anyway.

@pablovazquez This PR now allows specifying font weight like css, with values between 100-900. Slant is in **clockwise** degrees and can lean both ways (rightward is built into the font, while leftward is done with glyph transformations). Width using 1.0 as normal, as does Spacing. It is quite fun to play with. The only thing it doesn't do (yet) is deal properly with non-variable fonts that are bold or italic, and so won't add boldness or obliquing quite as I'd like, but that is fairly obscure anyway.
Harley Acheson added 2 commits 2023-10-05 04:05:11 +02:00
Harley Acheson added 2 commits 2023-10-07 01:52:27 +02:00
Harley Acheson added 1 commit 2023-10-07 03:39:07 +02:00
Harley Acheson added 1 commit 2023-10-07 04:18:13 +02:00
Harley Acheson added 1 commit 2023-10-07 19:37:28 +02:00
Harley Acheson added 1 commit 2023-10-07 19:40:35 +02:00
Harley Acheson added 1 commit 2023-10-07 21:04:20 +02:00
Harley Acheson added 2 commits 2023-10-08 02:48:12 +02:00
Harley Acheson added 1 commit 2023-10-08 03:30:23 +02:00
Harley Acheson added 2 commits 2023-10-08 20:29:14 +02:00
Harley Acheson added 1 commit 2023-10-08 20:35:40 +02:00
Harley Acheson added 1 commit 2023-10-14 03:32:44 +02:00
Harley Acheson added 2 commits 2023-10-15 00:31:25 +02:00
Harley Acheson changed title from WIP: UI: Configurable UI Variable Text Styles to UI: Configurable UI Font Weight 2023-10-19 23:42:41 +02:00
Member

Awesome!

I think this will improve accessibility a lot for people with low vision.

For reference:

Default (400) Bold(600)
blender_ui_font_weight_400 blender_ui_font_weight_600

Thanks for working on this!

Awesome! I think this will improve accessibility a lot for people with low vision. For reference: |Default (400)|Bold(600)| |----|----| |![blender_ui_font_weight_400](/attachments/f38fcdf4-84f8-4156-85e4-31237a4ab985)|![blender_ui_font_weight_600](/attachments/38ce702a-c4da-49dc-87cd-ba897d05d20b)| Thanks for working on this!
Pablo Vazquez approved these changes 2023-10-20 12:55:40 +02:00
Author
Member

I have also had reports of people running Blender with Inter Light, long before we made the change

image

I have also had reports of people running Blender with Inter **Light**, long before we made the change ![image](/attachments/003d66b0-ecbe-4d02-8116-c06f7773883d)
398 KiB
Harley Acheson added 2 commits 2023-10-20 19:24:00 +02:00
Author
Member

@blender-bot build

@blender-bot build
Harley Acheson added 1 commit 2023-10-20 21:46:48 +02:00
Harley Acheson added 1 commit 2023-10-20 21:49:51 +02:00
Harley Acheson added 1 commit 2023-10-20 21:50:53 +02:00
Harley Acheson added 1 commit 2023-10-20 22:05:09 +02:00
Harley Acheson added 1 commit 2023-10-20 22:14:55 +02:00
Harley Acheson added 1 commit 2023-10-20 22:27:31 +02:00
buildbot/vexp-code-patch-coordinator Build done. Details
f313e753f5
With version bump
Author
Member

@blender-bot build

@blender-bot build
Harley Acheson added 1 commit 2023-10-20 23:19:51 +02:00
Harley Acheson added 1 commit 2023-10-21 00:01:51 +02:00
Harley Acheson added 1 commit 2023-10-21 00:13:58 +02:00
Harley Acheson merged commit 0bde01eab5 into main 2023-10-21 00:28:37 +02:00
Harley Acheson deleted branch TextUiStyles 2023-10-21 00:28:38 +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
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#112454
No description provided.