Skip to content
This repository

Padding size has no effect #18

Closed
gbirke opened this Issue · 9 comments

3 participants

Gabriel Birke Jason Davies Artur Bodera
Gabriel Birke
gbirke commented

Regardless of what .padding is set to, the Words are always relatively tightly packed.

I expected more whitespace when I called .padding(10). Is the padding a true/false setting or is there something missing. I don't see the padding value added anywhere in the code, just a check if it is set. If this is intentional, please clarify in the documentation/example.

Jason Davies
Owner

Apologies for the lack of documentation. The padding option is indeed a boolean. It simply extends the word silhouettes by one pixel in all directions. If you need arbitrary padding, you can achieve this by simply using a smaller font size when rendering the words. I have found that a font size of 1px smaller works well for the output.

Artur Bodera

Just stumbled upon that and tried to work around it, but failed.

Unfortunately the font size trick doesn't work too well, because of apostrophes, smaller words being put inside empty spaces of bigger words and other effects of the layout algo. Using font difference more than 1px will produce a broken layout with overlapping words :-(

Jason Davies
Owner

Works fine for me. Are you sure you are positioning the words correctly? Perhaps you could post an example.

Artur Bodera

Here's an example with 5px difference. Notice the business mixer phrase - you can clearly see that the b character would fit in the gap left to talent word. Unfortunately, after decreasing font size and after it re-centers and reduces it's size proportionally, the distances between letters also decrease proportionally, thus making the word more "compact" (and also shorter).

image

Artur Bodera

And here's an example without font size manipulation:
screen shot 2013-06-18 at 6 04 37 pm

Artur Bodera

Oh jolly! You're the best Jason! :-)
I'll test it out in a few minutes...

I'll give back by PR-ing some of my enhancements, including deterministic cloud generation ;-)

Jason Davies
Owner

Excellent. :)

Artur Bodera

That stroke trick was ingenius ;-) Congratulations on the idea...

However there's noticeable performance hit after enabling padding... I can't benchmark it further but I'd say about 20% performance loss as compared to stroke-less bitmap+layout generation.

Jason Davies
Owner

This will only impact the performance of the initial sprite grab, which is not a bottleneck. If you are comparing padding=0 with something like padding=5, then it will of course take longer to find a layout because the text is bigger; a better comparison would be (padding=0, font-size=X) and (padding=5, font-size=X-5). The layout algorithm itself is unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.