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

Wrong text positioning? #113

Open
sdelaysam opened this issue Dec 4, 2017 · 6 comments
Open

Wrong text positioning? #113

sdelaysam opened this issue Dec 4, 2017 · 6 comments

Comments

@sdelaysam
Copy link

Hi, @frankinshtein

Working with TTF fonts in Oxygine.
Looks like text positioning is wrong, but text rect calculation is correct.
I'd say that font's descent is ignored.
Please look at screenshot.

screen shot 2017-12-04 at 21 55 01

Code for drawing text and red rectangle:

_textfield->setSize(getSize()); // <-- size of white background

const Rect& rect = _textfield->getTextRect(); // <-- rect of red overlay
_textrect->setPosition(rect.pos);
_textrect->setSize(rect.size);
@frankinshtein
Copy link
Contributor

  1. it is not related with TTF
  2. check
    oxygine examples/Demo/Text
    it has all possible combinations demo
  3. Do you know about TextField::setVerticalAlign?

@sdelaysam
Copy link
Author

  1. I'm afraid it is related with how you work with metrics provided by freetype library
  2. i did it
  3. yes, sure. i'm using VALIGN_MIDDLE. Otherwise red rect won't be vertically aligned.

@sdelaysam
Copy link
Author

sdelaysam commented Dec 4, 2017

  1. White rect - size of TextField.
  2. Rect red - bounds of text itself.

Problem: Glyphs are out of text bounds.

@frankinshtein
Copy link
Contributor

At this moment I don't know what metrick should be used from TTF. Do you know?

in your case could help for example
TextField::setBaselineScale (0.65); it will align text like in your screenshot

@sdelaysam
Copy link
Author

Yep, with TextField::setBaselineScale (0.65); works fine!
Not sure about glyph metrics, will let you know if find something.

@sdelaysam
Copy link
Author

#115 works fine for me
(together with oxygine/oxygine-freetype#5)

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

2 participants