[OT] calling non-numbered Unicode glyphs

Mark Schonewille m.schonewille at economy-x-talk.com
Fri Jul 15 18:29:07 EDT 2011


Hi Richmond,

I think that Fontographer will show you the UTF8 values of the font values. You can take those values and convert them to binary using the binaryEncode function. Convert the binary value to UTF8.

It is probably easier to use Mac OS X's Character Viewer. This palette will allowyou to view the code tables. You can look up unicode character 31f0 for example. On intel machines, you need to reverse this hex number before you can use it. 31f0 becomes f031, e201 becomes 01e2 etc. I believe you don't need to do this on a PowerMac. 

If you use these functions, you can just enter a sequence of hex numbers and set the unicodetext of a field to the value returned.

function hexToUnicode theHex
     put binaryEncode("H*",theHex) into myUnicode
     if the processor contains "x86" then
          repeat with x = 1 to the number of bytes of myUnicode step 2
               put char x+1 of myUnicode & char x of myUnicode after myNewUnicode
          end repeat
          return myNewUnicode
     else
          return myUnicode
     end if
end hexToUnicode

function unicodeToHex theUnicode
     if the processor contains "x86" then
          repeat with x = 1 to the number of bytes of theUnicode step 2
               put char x+1 of theUnicode & char x of theUnicode after myNewUnicode
          end repeat
          if binaryDecode("H*",myNewUnicode,myHex) is 1 then
               return myHex
          end if
     else
          if binaryDecode("H*",theUnicode,myHex) is 1 then
               return myHex
          end if
     end if
     return empty
end unicodeToHex

Here's an example you might like:

on mouseUp
     put empty into fld 1
     set the textFont of fld 1 to empty
     set the traversalOn of fld 1 to true
     put hexToUnicode("041f044004380432043504423000042004380449043c044e043d0434") into myUnicode
     lock screen
     set the unicodeText of fld 1 to myUnicode
     set the textFont of fld 1 to ",Cyrillic"
     select the text of fld 1
     set the textSize of the selection to 18
     select empty
     unlock screen
end mouseUp

Unfortunately, Unicode in LiveCode is a very, very dirty thing. Hence all those hacks, such as put empty into fld 1, select the text of fld 1, etc.

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
KvK: 50277553

New: Download the Installer Maker Plugin 1.6 for LiveCode here http://qery.us/ce

On 15 jul 2011, at 22:47, Richmond Mathewson wrote:

> Normally if one wants to put a unicode char into a field one does something
> like this:
> 
> set the unicodeText of fld "MyBigFatUnicodeTextFld" to numToChat(2327) & numToChar(9745)
> 
> or
> 
> set the unicodeText of fld "MyBigFatUnicodeTextFld" to the unicodeText of fld "MyBigFatUnicodeTextFld" & numToChar(67234)
> 
> and that works reasonably well . . .
> 
> HOWEVER; if one cracks open a Unicode font with a font editing program such as
> Fontographer
> 
> [the best way to see this is to use the LastResort font from the Unicode consortium]
> 
> one finds that there are glyphs/chars that belong to font families that have names
> such as "kannada_31" but no hex address that is required for LiveCode to call it.
> 
> Now one CAN generate Unicode addresses for those chars: but the big and burning question is if those ARE the real Unicode addresses or just locally assigned values.
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list