Page MenuHome

Fixes for font vertical alignment
ClosedPublic

Authored by Dalai Felinto (dfelinto) on Aug 31 2018, 3:13 PM.

Details

Summary

They way Blender handles vertical alignment is very buggy:

  • Top-Base: It works perfectly.
  • Bottom: It is actually bottom-baseline,a nd it fails when line size is != 1.0 when working with text boxes.
  • Top: Poorly implemented, it should use font's ascent (recommended distance from baseline), so it has room for accents, but it's not one line distance far from the origin (as it is now).
  • Center: Poorly implemented. This is tricky since there is no silver bullet.

To clear this situation I created a new option (Bottom-Baseline), and addressed
the issues above. I'm getting the ascent and descent from freetype2, and use
this for padding above/below the text. Also for vertically centering the text.

Diff Detail

Repository
rB Blender
Branch
FONT-alignment (branched from blender2.8)
Build Status
Buildable 2014
Build 2014: arc lint + arc unit

Event Timeline

  • Fallback for incomplete fonts
Brecht Van Lommel (brecht) requested changes to this revision.Sep 3 2018, 8:13 PM

Seems to work well, minor comments.

source/blender/blenkernel/intern/font.c
651

This macro seems rather pointless.

651–653

Put () around expressions in macros, just to be sure.

1045

Could just use const float textbox_y_origin = 1.0f;, no need for a macro.

source/blender/blenlib/intern/freetypefont.c
368

Would check to avoid division by zero here.

source/blender/makesrna/intern/rna_curve.c
967–974

In the UI we should stop expanding the enum, there's just not enough space. Might as well do it for both enums in the Alignment panel also then.

This revision now requires changes to proceed.Sep 3 2018, 8:13 PM
  • From review: Macros changes
  • From review: Avoid division by zero
  • From review: UI - leave enums unexpanded.
This revision is now accepted and ready to land.Sep 4 2018, 1:50 PM
Campbell Barton (campbellbarton) accepted this revision.EditedSep 5 2018, 3:26 AM

Looks good, lib/tests/modeling/text-regression.blend remains unchanged.

Committed rB312af01fb4faa7d1ff0dea4d2ef936caa9af4c67 (added args to ASCENT/DESCENT, minor comment)

Thank you Campbell :) It's always a good surprise to see the review process expedited and the committed done already.

Looks good, lib/tests/modeling/text-regression.blend remains unchanged.

That would be because I never updated it for the vertical alignment. But better this way, it adds regression but I consider them fixes.