Godot-proposals: Add support for using variable fonts in DynamicFont

Created on 22 Oct 2020  路  1Comment  路  Source: godotengine/godot-proposals

Describe the project you are working on:

The Godot editor :slightly_smiling_face:

Describe the problem or limitation you are having in your project:

Godot currently only supports "fixed" fonts. It doesn't support variable fonts, which are font files that include an arbitrary amount of weights that can be interpolated between each other.

Variable fonts are becoming increasingly common on the web. For some recently designed fonts, no fixed font variant may be available.

Describe the feature / enhancement and how it helps to overcome the problem or limitation:

Add support for using variable fonts in DynamicFont, with tooling in the editor to configure their usage.

Variable fonts have many upsides over traditional "fixed" fonts:

  • Use "intermediate" font weights which were not previously available (such as a blend between Regular and Bold, or Light and Regular). This lets you tailor the font weight to individual font sizes better.
  • Smaller file sizes when you use many weights. This can be important on mobile/HTML5.
  • Variable fonts aren't limited to variable weight and slant. They can also expose other configurable axes such as "casualness".

Quoting from variablefonts.io:

Why this matters

Downloading a single file instead of multiple individual fonts can yield a significant performance gain in reduced file size and fewer file requests.

"Variable fonts are better for web and mobile apps"

Since that single file includes the entire design space instead of a few very specific weights or other variants, the design vocabulary is much greater. Instead of only 1 or 2 weights, the entire available range can be referenced directly via CSS鈥攆rom extra-light to extra-heavy, narrow to wide, upright to italic.

Effective use of type generates greater clarity and hierarchy, which benefits both design and user experience. There are accessibility benefits, too, like providing a way for users to increase font weight and color contrast to help with low vision, or making subtle adjustments to the typography for a dark-mode implementation for people who are sensitive to light.

In the long term, we could also swap the editor's default fonts for a variable font, but this is out of scope for this proposal.

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:

Recent FreeType versions support variable fonts. We just need to find a convenient way to expose this in the editor.

Keep in mind variable font axes vary across fonts, so we can't hardcode their name in the editor inspector. We may need to use a dictionary property or a comma-separated string as is used for custom OpenType features in the TextServer PR.

If this enhancement will not be used often, can it be worked around with a few lines of script?:

No, as this is core font rendering functionality.

Is there a reason why this should be core and not an add-on in the asset library?:

This is core font rendering functionality.

gui

Most helpful comment

Here's quick, experimental implementation on top of TextServer: https://github.com/bruvzg/godot/tree/ctl_var_font (godotengine/godot#43030)

Video: https://bruvzg.github.io/godot-var-fonts.html

Online test for the same font: https://v-fonts.com/fonts/estedad

>All comments

Here's quick, experimental implementation on top of TextServer: https://github.com/bruvzg/godot/tree/ctl_var_font (godotengine/godot#43030)

Video: https://bruvzg.github.io/godot-var-fonts.html

Online test for the same font: https://v-fonts.com/fonts/estedad

Was this page helpful?
0 / 5 - 0 ratings