API blf.dimensions issue in 4.0b #113312
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
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#113312
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
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?
System Information
Operating system: Windows-10-10.0.22621-SP0 64 Bits
Graphics card: NVIDIA GeForce RTX 2080 with Max-Q Design/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 537.34
Blender Version
Broken: version: 4.0.0 Beta, branch: blender-v4.0-release, commit date: 2023-10-04 23:50, hash:
2f71d9f807
Worked:
Short description of error
blf.dimensions doesn't match the size
It use
blf.load
with same ttf file and the display and dimension value is different. (Text rendering settings are the same)In my project use
blf.dimensions
to calculate the beam cursor position, it works correctly in v3.6 but not in 4.0.Is there a way to render the same text and output same dimensions value in 4.0 as in 3.6?
I've provided a script to test, thank you.
blf.dimensions
Doesn't look accurate in 4.0/4.1 but not in 3.6Weird Font spacing in non-monospaced fonts, I wish there was an option setting to change back.
@Harley /
Hello,
I'm not certain whether you are saying that the result of blf.dimensions is incorrect or that the problem is that the length of the text string differs between Blender versions. For example you say that "display and dimension value is different" but I would expect the length value to be different in your supplied images because the text lengths are different.
There were definitely changes in the way that text is rendered with version 4.0 versus earlier versions. With version 4.0 we have more typographically correct placement, sizing, and rendering. In prior versions all text was placed too close by half a pixel. Because this is not related to text size, this meant that when you increased the font size by 2 the resulting string was not twice as wide.
So yes, things have changed, but for the better.
However the result of blf.dimensions should still be correct for the text that is shown.
In Blender the value for the length of a text string is the sum of the "advances" of the characters. The "advance" is the distance from the start of one character to the start of the next. In a nutshell this means that our lengths include a small amount of space after the last letter. This is by design so that strings can be appended based on that measurement.
I did some testing with your suggested text string to confirm that blf.dimensions is working as expected.
For example at this size it is correctly giving a length of 62, indicated between the blue lines:
Twice as large it is correctly giving a length of 123.
Three times as large and it gives an expected value of 185
So are you saying that the value from blf.dimensions is wrong or just different? Is it just an issue of placing that text caret (blue bar) correctly?
blf.dimensions
output not accurate, in 4.0/4.1 compare with 3.6. Especially when the font size is set to a small size.Thanks for listening, I've provided a test script, see top.
As mentioned, the font spacing is more accurate in 4.0/4.1
In your example script you are drawing "Modifier" but showing a box that is the width of the substring "Modifi":
You will notice that the width includes a space after the "i" that is approximately the same width as the width of the stroke of the "i". This is because this is how the "i" is constructed in that font (viewed in FontForge):
So the string length will include the space to the right of the "i". Make the text larger in your script and you will see that it maintains that distance as perfectly as possible, within a pixel.
By the comments, the new behavior is expected.
(And @Y.T-LAW no longer replied), so I'm closing the report.