Welcome,
Guest
. Please
login
or
register
.
April 24, 2026, 09:50:29 PM
Home
Help
Search
Login
Register
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
dynamic font not centered
« previous
next »
Print
Pages: [
1
]
Author
Topic: dynamic font not centered (Read 4300 times)
beermoney
Jr. Member
Thank You
-Given: 0
-Receive: 2
Posts: 80
dynamic font not centered
«
on:
December 28, 2013, 06:59:40 AM »
creating a button with a dynamic font centered in the middle, the text appears un-centered
repro:
drag NGUI button prefab into scene
change font to dynamic and then to using "oliver's barney" font from the free square pack font pack (
https://www.assetstore.unity3d.com/#/content/4235
)
change the font size to 50 to exaggerate the displacement
this is using NGUI 3.0.8, (previous versions 3.0.7 f3, worked fine with this font)
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: dynamic font not centered
«
Reply #1 on:
December 28, 2013, 04:44:05 PM »
Unity doesn't provide any clear way of properly retrieving the baseline for the character, so all ways of doing so manually are, pretty much -- hacks. Can you send me the font itself to support at tasharen.com? I'll have a look.
Logged
beermoney
Jr. Member
Thank You
-Given: 0
-Receive: 2
Posts: 80
Re: dynamic font not centered
«
Reply #2 on:
December 30, 2013, 05:50:16 AM »
hope it's ok to attach here
Logged
beermoney
Jr. Member
Thank You
-Given: 0
-Receive: 2
Posts: 80
Re: dynamic font not centered
«
Reply #3 on:
March 10, 2014, 01:55:31 PM »
Hey Aren,
I'm seeing this issue again with NGUI 3.5.3 and Bitmap/NGUI fonts!
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: dynamic font not centered
«
Reply #4 on:
March 10, 2014, 07:49:37 PM »
In case of the font you posted the issue occurs because of the vast difference between how characters "_" and "`" are positioned in the font. Try drawing them. The "`" in particular is way higher than it should be. The creator of the font didn't respect the bounds at all.
P.S. I've modified the freetype parsing logic to calculate the offset a little differently in 3.5.4 though:
int
baseline
=
size
+
min
;
baseline
+=
(
(
max
-
min
-
size
)
>>
1
)
;
// Offset all glyphs so that they are not using the baseline
for
(
int
i
=
0
;
i
<
entries
.
size
;
++
i
)
{
BMGlyph glyph
=
font
.
GetGlyph
(
entries
[
i
]
,
true
)
;
glyph
.
offsetY
+=
baseline
;
}
«
Last Edit: March 10, 2014, 08:05:30 PM by ArenMook
»
Logged
Print
Pages: [
1
]
« previous
next »
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
dynamic font not centered