Font of field won't change

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
larryh
Posts: 32
Joined: Sat Mar 22, 2008 6:02 pm

Font of field won't change

Post by larryh » Sat Nov 22, 2008 10:11 pm

Me again : )

I have a multiline field with text in it. I am trying to change the font on it to a different font but no matter what I do, the font remains the same. If I use the property inspector or message command line box, a change in font still retains the old font. I imagine this has to do with the custom property shown below.

I populate this field using:

put field "Gloss" & uniEncode(comma & space) & field "Vernacular" & \
uniEncode(comma & space) & UniEncode(id of this card) into tEnglishCardName

set the EnglishCardName of this card to tEnglishCardName --THIS IS ALREADY IN UTF16

put the EnglishCardName of this card & UniEncode(return) into line (the number of this card) of fld "listEnglish"

Thanks,

Larry

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Sat Nov 22, 2008 11:50 pm

Hi Larry,

Unicode text often doesn't adhere to the owner's font. Instead, try this.

First, you need to build the complete index in unicode. You can't put unicodeText into a field. You can only set the unicodeText property. Once you have built the complete index, you can set the unicodeText to a variable, e.g. myUCIndex

Code: Select all

set the unicodeText of fld "listEnglish" to myUCIndex
set the textFont of char 1 to -1 of fld "listEnglish" to "ValidFont,UTF16"
Note that ValidFont needs to be a font with the necessary glyphs. Otherwise, you may see a lot of meaningless symbols, usually Chinese glyphs. You may need to replace UTF16 with a different value, but I think it will work for you.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

larryh
Posts: 32
Joined: Sat Mar 22, 2008 6:02 pm

Post by larryh » Sun Nov 23, 2008 5:24 am

Cool, that works! Thank you :D

Post Reply