VFont: Use BLF for font & glyph loading #110187
No reviewers
Labels
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
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#110187
Loading…
Reference in New Issue
No description provided.
Delete Branch "Harley/blender:vfontblf"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Load VFont curves using BLF API rather than local FreeType calls.
Text objects currently use the FreeType library directly. This is a duplication of code and also means that this area cannot take advantage of the more complex features of the BLF API. This PR allows VFont to use BFont.
This means that they can use the font, face, and lookup caches and have access to all the other BLF features. This also means that the default 3D Text font can participate in the fallback stack, so new users using the default font won't be frustrated with only having 239 characters, but instead have access to more than a hundred thousand of them. And also means I can later add support for variable axes features.
And if they select something that is not in any of the fallback fonts it will load a "last resort" glyph that contains information about what is missing, not just nothing or a "tofu" square. Following shows entering characters from the Duployan and Wancho alphabets:
In order for this to work we just need three new members added to the BLF API:
With
BLF_get_vfont_metrics
the current code is just copied from vfont so the values, and therefore the initial sizes of the text objects, remain exactly as they are now.For
BLF_character_to_curves
the entirety of the existingfreetype_outline_to_curves
is simply moved to blf_glyph.cc, renamedblf_glyph_to_curves
, along with the extensive existing comments about the process. There is a helper functionblf_character_to_curves
added that takes a Unicode character, gets a glyph from the font (and from the font stack if not found), callsblf_glyph_to_curves
and returns the scaled advance.There are some small changes in
blf_glyph.cc
mostly to handle getting outlines without rasterizing, and without needing to use GlyphCacheBLF at all. Otherwise there isn't too much to this.is arabic there ?
The answer is "no" to the question that you are probably really asking, in that this does not enable LTR/RTL reordering or text shaping. But "yes" in that an Arabic font is in our fallback stack, so it is easier to get to those characters.
A common thing for new users to do is just Add / Text then try copying in emoji, symbols, or characters from their own language. Unfortunately the default font that we include for this purpose (Bfont Regular) contains very few characters so nothing comes out. Users eventually figure out that they need to select some other font in order to see anything nice.
This patch loads characters the same way the interface does. So if you type a character not in that font it will look in the fallback stack of fonts. So almost anything you can think of will come out. With Arabic they would come out backwards and bad, but at least something comes out. Enough that it might prompt you to try a precomposed string instead.
WIP: VFont: Use BLF for font & glyph loadingto VFont: Use BLF for font & glyph loadingdd8e898d8a
to69db77403c
@JulianEisel - You had asked if this uses the glyph cache, and it does not. From the vfont side it loads fonts in the same way as for bfont, but then glyph outlines are loaded directly from them, with no need for the glpyh cache. And yes, this would all allow us to do the variable and synthetic changes as seen here, but for vfont: #112454. So we could have sliders for weight, width, slant, etc.
VFont: Use BLF for font & glyph loadingto WIP: VFont: Use BLF for font & glyph loadingThere would be no need for vfontdata_freetype.cc to have access to FT_Face or FT_GlyphSlot with a few more BLF calls (face name, some unscaled metrics), and moving
freetype_outline_to_curves
to BLF as something like BLF_character_as_curves(int fontid, uint character, ListBase *nurbs, const float scale)And this would work well with BLF_character_weight, BLF_character_slant, BLF_character_width, BLF_character_spacing of #112454
Both this and #112454 would need access to unscaled metrics so the FontInfo introduced there would work for this.
WIP: VFont: Use BLF for font & glyph loadingto VFont: Use BLF for font & glyph loading@blender-bot build
@blender-bot build
@blender-bot build
@blender-bot build