Welcome,
Guest
. Please
login
or
register
.
September 22, 2025, 01:19:20 PM
Home
Help
Search
Login
Register
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
ngui label: fallback to "default font" if character is not available.
« previous
next »
Print
Pages: [
1
]
Author
Topic: ngui label: fallback to "default font" if character is not available. (Read 5718 times)
Lotti
Newbie
Thank You
-Given: 5
-Receive: 0
Posts: 47
ngui label: fallback to "default font" if character is not available.
«
on:
July 01, 2014, 07:50:48 AM »
Hello Aaren!
I noticed that there is some sort of fallback on uilabel's font. Let me explain with an example.
If I use a font that has only the ascii charset on a uilabel that contains utf-8 character (chinese), the uilabel will show chinese text with a font that is different from mine ("fallback font"). Can you confirm this?
Plus, there is a way to force the fallback font with some method/hack? we need this to bypass our custom font only for certain languages. Thanks.
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: ngui label: fallback to "default font" if character is not available.
«
Reply #1 on:
July 02, 2014, 03:37:41 AM »
Assuming you are talking about dynamic fonts here, this is all Unity. NGUI merely requests characters from Unity. I'm not sure what happens inside and what "fallback" functionality is provided.
Logged
Lotti
Newbie
Thank You
-Given: 5
-Receive: 0
Posts: 47
Re: ngui label: fallback to "default font" if character is not available.
«
Reply #2 on:
July 02, 2014, 03:41:49 AM »
yes, it's dynamic font. thank you for your reply, i will investigate.
substantially, it prints characters in ARIAL instead of our setted font, when the character is not available.
Logged
Lotti
Newbie
Thank You
-Given: 5
-Receive: 0
Posts: 47
Re: ngui label: fallback to "default font" if character is not available.
«
Reply #3 on:
July 02, 2014, 06:04:05 AM »
Ok! i think i'm done.
Could you check if this is the "best place" to overwrite the setted font (on editor) on each UILabel? Thank you.
public
Font trueTypeFont
{
get
{
if
(
mTrueTypeFont
!=
null
)
return
mTrueTypeFont
;
return
(
mFont
!=
null
?
mFont
.
dynamicFont
:
null
)
;
}
set
{
if
(
mTrueTypeFont
!=
value
)
{
#if DYNAMIC_FONT
//FIX per cambiare font per le lingue non supportate - VALERIO
#if !UNITY_EDITOR
if
(
Translate
.
defaultFontLanguages
.
Contains
(
Localization
.
language
)
)
{
value
=
Translate
.
defaultFont
;
}
#endif
........
Logged
Lotti
Newbie
Thank You
-Given: 5
-Receive: 0
Posts: 47
Re: ngui label: fallback to "default font" if character is not available.
«
Reply #4 on:
July 02, 2014, 08:11:32 AM »
the previous snipper will not work on devices..
this one works.
UILabel.cs
public
Font trueTypeFont
{
get
{
//FIX set an alternative font for each languages that require it - Lotti
#if !UNITY_EDITOR
if
(
Translate
.
alternativeFontLanguages
.
Contains
(
Localization
.
language
)
&&
mTrueTypeFont
!=
Translate
.
alternativeFont
)
{
trueTypeFont
=
Translate
.
alternativeFont
;
}
#endif
//ENDFIX
if
(
mTrueTypeFont
!=
null
)
return
mTrueTypeFont
;
return
(
mFont
!=
null
?
mFont
.
dynamicFont
:
null
)
;
}
set
{
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: ngui label: fallback to "default font" if character is not available.
«
Reply #5 on:
July 03, 2014, 03:51:40 AM »
I wouldn't do it like this. NGUI's fonts can be set up as "reference fonts", where your labels use a dummy font that points to a real one. Then when you switch languages you can also switch the font your reference font is pointing to.
Logged
Lotti
Newbie
Thank You
-Given: 5
-Receive: 0
Posts: 47
Re: ngui label: fallback to "default font" if character is not available.
«
Reply #6 on:
July 03, 2014, 06:48:03 AM »
how to create a reference font? i don't find this option inside font maker
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: ngui label: fallback to "default font" if character is not available.
«
Reply #7 on:
July 04, 2014, 12:53:15 PM »
Create a game object, attach UIFont to it, save it as a prefab.
Logged
Print
Pages: [
1
]
« previous
next »
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
ngui label: fallback to "default font" if character is not available.