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

Feature request: allow change char offsets #8

Open
Maligan opened this issue Sep 7, 2017 · 8 comments
Open

Feature request: allow change char offsets #8

Maligan opened this issue Sep 7, 2017 · 8 comments
Assignees
Labels

Comments

@Maligan
Copy link

Maligan commented Sep 7, 2017

Hello, soimy!
In first let me express my gratitude for your work!

Several otf/ttf fonts output incorrect char offsets, for example attached font have huge yoffset, all characters are shifted down. Usually, I run script which fix offsetY values on all char.

This is not a bug of your utility, this is font's peculiarity.

It will be cool if msdf-bmfont-xml can change offsetX / offsetY by custom value.

@soimy soimy added the Feature label Sep 7, 2017
@soimy
Copy link
Owner

soimy commented Sep 7, 2017

I'll look into that next week. Maybe add both letter spacing & baseline offset modifiers. What do you think?

@soimy soimy self-assigned this Sep 7, 2017
@Maligan
Copy link
Author

Maligan commented Sep 7, 2017

I'm nether faced with baseline in my projects - and can't make useful comment.
Custom letter spacing may be useful in case font with large stroke for avoid char overlapping.

@soimy
Copy link
Owner

soimy commented Sep 7, 2017

Just tested your font, looks great. I didn't find any offsetY issue for now @Maligan
qq20170908-075113 2x

@Maligan
Copy link
Author

Maligan commented Sep 8, 2017

Wow, yesterday I was ready to swear that there is this problem.
But today I reassemble bitmap font and all is ok.

However I understand why I confused, if try to use custrom distance range then offsets appears:
msdf-bmfont -m 1024,1024 -r 8 Marvin.otf

There is one important note: in starling if text field use autoSize = TextFieldAutoSize.BOTH_DIRECTIONS then it trim offsets from text, but if autoSize = TextFieldAutoSize.NONE it doesn't do it.

@Maligan
Copy link
Author

Maligan commented Sep 8, 2017

Khm... I try another my font - FiraSans.zip, and it produce bad y-offset:

With autoSize = TextFieldAutoSize.NONE:

With autoSize = TextFieldAutoSize.BOTH_DIRECTIONS offsets is trimmed in starling text filed:

@soimy
Copy link
Owner

soimy commented Sep 8, 2017

From your image every thing looks fine to me. For the first image, what is your textField.horizontalAlign and textField.verticalAlign ? If I guess right, they are left and top.

@Maligan
Copy link
Author

Maligan commented Sep 11, 2017

Sorry for my late reply, I restored spaces in my typography understanding.

As I read there are next font metrics:

In bmfont file format next two metrics are available:

  • lineHeight (13)
  • baseline (4)

What I called an excess yoffset is shoulders (14). It is no excess, I misunderstanded this moment.


Look on this case there are two starling text fields - top with autoSize = NONE (and height equals font's lineHeight), bottom with autoSize = BOTH_DIRECTIONS:

diff

Simple toggle autoSize to NONE make starling ignore any free spaces around letters and gives such an unobvious result. Change chars offsetY in output file cut top shoulder. This allow place text field in UI independed their autoSize mode - font's shoulders will be ignored.

@soimy
Copy link
Owner

soimy commented Sep 12, 2017

Great explanation on font metric graph! And I've tested the autoSize settings. You are right, when set to autoSize = BOTH_DIRECTIONS, textField's height is cropped to bodyHeight and lineGap(shoulder) is ignored.
For your case:

  • fontSize: 42
  • lineHeight: 50
  • baseline: 32

Case 1: autoSize = NONE

Smallest Textfield's height is lineHeight (50), smaller height will remove all text render.

Case 2: autoSize = BOTH_DIRECTION

Textfield's height is fontSize+1 (43)

For packing efficiency all glyph is rendered and packed in smallest bounding-box, all font metrics is in bmfont .fnt file and rely on bitmap render framework to place them properly. There's nothing I can do for now. (Hard fix in rendered glyph is not a good approach, will break metrics computing)
I should let Daniel take a look at this.

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

No branches or pull requests

2 participants