Sprite Font Spacing Format?

Post » Fri May 19, 2017 5:38 am

Just verifying something: the correct format for doing Sprite Font spacing seems to be:

[[9, "Il"],[10, "i.,'("],[11, ";:!-)[\\/"],[12, "J]<>"],[14, "1"],[15, "j"],[16, "frt*"],[17, "?"],[18, "FLacs_\\"+="],[19, "ESehnz27"],[20, "NPUbdquv358$"],[21, "BCDHZop069"],[22, "Gky4#£"],[23, "KOQRTgx"],[24, "AVX€"],[25, "Y"],[27, "Mw&%"],[30, "m"],[31, "@"],[32, "W"]]

I tried both of the below in the Spacing Data property of the Sprite Font object, however the spacing is not changing, I imagine it's the incorrect format.

{"data": [[9, "Il"],[10, "i.,'("],[11, ";:!-)[\/"],[12, "J]<>"],[14, "1"],[15, "j"],[16, "frt*"],[17, "?"],[18, "FLacs_\"+="],[19, "ESehnz27"],[20, "NPUbdquv358$"],[21, "BCDHZop069"],[22, "Gky4#£"],[23, "KOQRTgx"],[24, "AVX€"],[25, "Y"],[27, "Mw&%"],[30, "m"],[31, "@"],[32, "W"]]}

{""c2array"":true,""size"":[20,2,1],""data"":[[9, ""Il""],[10, ""i.,'(""],[11, "";:!-)[\/""],[12, ""J]<>""],[14, ""1""],[15, ""j""],[16, ""frt*""],[17, ""?""],[18, ""FLacs_\"+=""],[19, ""ESehnz27""],[20, ""NPUbdquv358$""],[21, ""BCDHZop069""],[22, ""Gky4#£""],[23, ""KOQRTgx""],[24, ""AVX€""],[25, ""Y""],[27, ""Mw&%""],[30, ""m""],[31, ""@""],[32, ""W""]]}

i was referring to this blog post for info:
Now there's a new 'Spacing data' property that accepts a JSON array of character widths. This is simply an array of a width in pixels, and a string of the characters with that width. For example [6, "il"] means the characters "i" and "l" will appear at six pixels wide instead of the default character width.

https://www.scirra.com/blog/203/some-bo ... onstruct-3
B
31
S
10
G
3
Posts: 59
Reputation: 3,556

Post » Fri May 19, 2017 6:12 am

The top example is correct. It does work. If I create a default spritefont and use this data, the spacing does change (it's wrong of course), but it does change.
ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494

Post » Fri May 19, 2017 6:02 pm

Thanks, experimenting with an appropriate font and it looks it now works.

I hope folks update their assets to include this, would be even better if it could be embedded in the font data itself. Then the spacing could be loaded automatically. I wonder if there is enough space in PNG metadata to include a long string like this.

@Ashley thoughts?
B
31
S
10
G
3
Posts: 59
Reputation: 3,556


Return to General Discussion

Who is online

Users browsing this forum: blackhornet, Jackriduk and 1 guest