Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

text, btt/ttb settings make certain fonts not horizontal align correctly #4266

Open
jglauche opened this issue May 23, 2022 · 3 comments
Open

Comments

@jglauche
Copy link

jglauche commented May 23, 2022

I don't know the bug is with the fonts or in openscad; however if you try to align a text going in Y direction (btt or ttb) you may get a different horizontal alignment depending on the font.

text(text="Meow",valign="top",halign="left",direction="btt");
This seems to be a problem with all Liberation fonts on my system. halign = left pretty much centers the font.

Another test case for me is:
text(text="Meow",valign="top",halign="center",direction="btt", font="Liberation Sans");
This puts the font at the Y center (towards -Y direction)

Not all fonts have issues with this, for example Helvetica works as I expect:
text(text="Meow",valign="top",halign="left",direction="btt", font="Helvetica");


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@t-paul
Copy link
Member

t-paul commented May 23, 2022

Oh, I have not seen this type of extreme result, but it seems to be fixed with the alignment changes that came with #3684. With the nightly build it looks ok on my system (Debian/Testing).
The overall alignment looks quite different now, I guess that needs another review if there's not more/other issues.

Note that the alignment is still based on font information, not geometry. With the new (experimental feature) textmetrics() (docu) it's possible to query that font information giving more options for alignment.

@jordanbrown0
Copy link
Contributor

As Torsten says, I looked into this and fixed a number of issues as part of the textmetrics work.

https://forum.openscad.org/several-variations-on-text-ttb-btt-and-valign-and-halign-seem-wrong-td31310.html is, I believe, a discussion of the issues raised here.

https://forum.openscad.org/More-on-text-alignment-td31315.html discusses a few more issues, and https://forum.openscad.org/text-the-2-4-problem-td31425.html is a few more.


I did not address all text alignment / spacing issues.

  • spacing yields unobvious behavior in all but the most trivial cases. I don't think it can be salvaged. (See the "More on text alignment" thread above.)
  • There's an argument that horizontal alignment in RTL text is wrong. The general idea is that in the default case the origin should be where your pen starts, and you should draw from there as is natural for the text. Thus for LTR text you would draw to the right of the origin, but for LTR text you would draw to the left of the origin.

@jordanbrown0
Copy link
Contributor

Also note that you have said valign="top" and what you get has the origin at the bottom of the text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants