Skip to content
This repository has been archived by the owner on Jun 28, 2021. It is now read-only.

Support for letterSpacing possible? #39

Closed
ArronFerguson opened this issue Jan 20, 2017 · 11 comments
Closed

Support for letterSpacing possible? #39

ArronFerguson opened this issue Jan 20, 2017 · 11 comments

Comments

@ArronFerguson
Copy link

Hey guys,

I was wondering if there's the possibility of supporting the letterSpacing property of the multistyle-text object? I imagine it may be fairly complicated since the width needs to be calculated by each individual tag and this may affect word wrap and its size.

Anyways, figured I'd put that out there.

Thanks again for taking care of the updating with the setTagStyle method, that really is useful!

Arron

@bluepichu
Copy link
Collaborator

I should have a bit of extra time tomorrow, so I'll try to take a look.

@bluepichu bluepichu self-assigned this Jan 20, 2017
@ArronFerguson
Copy link
Author

Thanks for looking into it!

@bluepichu
Copy link
Collaborator

Is this for a bitmap font? If not, it's not possible since text objects are backed by a canvas, which doesn't support character spacing. (See pixijs/pixijs#1748.)

The bahvior of character spacing at the edges between styles is also a bit interesting. For example, suppose wide has a large letterSpacing, and narrow has it set to 0. How should <narrow>abc<wide>def</wide>ghi</narrow> be rendered? abcd e fghi or abc d e f ghi?

@ArronFerguson
Copy link
Author

Matthew,

It's for outline fonts, not bitmap. Yeah, I was thinking probably not. No worries, you can close it. Figured I'd check with the experts though.

:)

@bluepichu
Copy link
Collaborator

I'll leave this open, since letterSpacing probably should work for bitmap fonts at least.

I might also be able to make it work for non-bitmaps by simply drawing one character at a time - which would probably be a performance hit and might cause some fonts to do strange things, but would only kick in if letterSpacing is non-zero. The only way to find out is to try. 😄

Of course, we'd still need to decide on abcd e fghi vs. abc d e f ghi. Another possibility I just thought of is to have the letterSpacing be evenly divided on both sides of a character - which would give abc-d e f-ghi, where - is half the width of a space.

@bluepichu
Copy link
Collaborator

Never mind about bitmap fonts - I didn't realize that there was a separate class for those in Pixi. We'd need to add any support for bitmap fonts before we could think of adding this feature for them, and I currently don't see any need to unless there's a particular interest in bitmap fonts.

Anyway, I'll see if drawing one character at a time works for non-bitmaps.

bluepichu added a commit to bluepichu/pixi-multistyle-text that referenced this issue Jan 20, 2017
@bluepichu
Copy link
Collaborator

bluepichu commented Jan 20, 2017

Turns out it was surprisingly straightforward.

As for my earlier question, I went with the third option - abc-d e f-ghi.

Edit:

screenshot 2017-01-20 13 47 19

That has letterSpacing set to -1 for "multiline" and to 5 for "multistyle".

@bluepichu
Copy link
Collaborator

PR filed: #40.

@ArronFerguson
Copy link
Author

OMG wow, that was fast! Thank you so much!

@tleunen
Copy link
Owner

tleunen commented Jan 20, 2017

@bluepichu What's the value of letterSpacing actually? What does represent a letterSpacing of 0 and a letter spacing of 5? Is it an offset in pixels?

@bluepichu
Copy link
Collaborator

Yes.

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

No branches or pull requests

3 participants