BLF: Glyph Clipping Corrections #104679
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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#104679
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "Harley:BlfClipping"
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?
Improvements to how glyphs are tested against the font clipping rect.
Our code is testing each glyph against a bounding box that is incorrectly specified, so there are times when we will clip text contents unnecessarily.
However we only see this as a problem under very narrow circumstances. It does NOT occur at any size or with any settings using our current font.
But it does occur at some sizes with some other fonts if the Hinting is set to "Full". This is because "Full" hinting can change the glyphs horizontally. If this includes leftward change by even one pixel it will result in the glyph not being shown. This can even occur if the visible part of the glyph would fit because we don't consider the character's margins - specifically the left-side bearing.
The following is after setting the UI font to "Inter Regular", Hinting "Full", at size "1.5". You will see it toggle between current code (missing some initial letters) and patch (showing all letters):
This patch addresses issues regarding both horizontal and vertical clipping:
Horizontal Clipping
This patch corrects the testing of the left side of the glyph by considering the left-side bearing, but also adds one pixel for wriggle room to account for hinting movement. Therefore if the visible part of the glyph will fit it will pass.
This patch corrects the right side by considering the right-side bearing, the bitmap width, and also subtracts one pixel for wriggle room. Current code does not consider the bearing, but also uses the smallest of the width or advance, which is not correct.
Vertical Clipping
We are calculating the vertical tested bounds of the glyph very incorrectly, but in a way that passes tests. Best explained in the example I am staring at now:
The clipping rectangle is (just vertically) set to: ymin of 3 and ymax of 23. The current vertical pen position off the baseline is 9. Since the font size is the default 11 it makes sense that text can fit in there.
However the glyph rect this is tested against has the very wrong ymin of 9 and a ymax of 1. Yes, the values are backward and incorrect. But 9 is greater than 3 and 1 is less than 23 so it passes.
The glyph itself is 8 pixels high and has a top margin (distance from baseline to the top) of 8. So this is a 8-pixel high glyph sitting on the baseline without a descender. With this patch applied this uses the correct and sane value of ymin:9 and ymax:17. And still properly fits inside the clipping values of 3 and 23 as expected.
Does the text in buttons show any different with the current default font after? If so can you show it? For example when you make e.g. the properties editor narrow and a lot of clipping occurs?
Mark as requesting changes for question, if current font renders the same or better this is fine with me.
No, and I updated the original comment with a better description and better image illustrating the issue.
The problem fixed with this patch does not occur with our current font at any size or with any settings. The issue is only seen with some fonts at some sizes when "Full" hinting is turned on because that can alter glyphs horizontally.
This patch does not change the placement of any glyphs, so every glyph goes in the same place before and after this patch. This is only fixing that some initial characters are not displayed under these special conditions. Basically just allows users to select Full hinting with some fonts, or allow us to change our font to Inter or Roboto later.
Thanks for the explanation.
074541ef45
to3ded635e7c
@blender-bot build
Closing with Manual commit
54fa3b124f
Pull request closed