[SOLVED] Android and Unicode

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

egolombek
Posts: 59
Joined: Thu Jan 30, 2020 2:11 pm

Re: Android and Unicode

Post by egolombek » Tue Jun 30, 2020 6:16 am

I believe fontLanguage is a function. I cannot figure out how you set the fontLanguage.

When I call on the function, it tells me that all of my fonts except one are ANSI. Which I guess should be fine? But just to see what would happen, I changed the font to a weird Hebrew font. No luck. Even odder- when I call on fontLanguage on the computer, it says the font is Hebrew. But, on the Android it says that the same font is ANSI.

Feeling very frustrated. There are gazillion apps in Hebrew and LiveCode supports Hebrew amazingly except for this major problem. Ahhhh.....

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 4717
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Android and Unicode

Post by richmond62 » Tue Jun 30, 2020 8:41 am

I have a feeling that you must make sure:

1. Your font is Unicode compliant. [ANSI is seriously "old hat"]

2. The font you use to prepare your stack on a desktop computer is
the SAME font the standalone will use on the Android device.

You can embed fonts in LC standalones: but whether that works when
moving to Android or iOS I just don't know.

https://home.unicode.org/

Hebrew: https://www.unicode.org/charts/PDF/U0590.pdf

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 4717
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Android and Unicode

Post by richmond62 » Tue Jun 30, 2020 9:51 am

https://en.wikipedia.org/wiki/ANSI_character_set

"The phrase ANSI character set has no well-defined meaning"

Which is not much use.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 4717
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Android and Unicode

Post by richmond62 » Tue Jun 30, 2020 10:08 am

I believe fontLanguage is a function.
-
Screenshot 2020-06-30 at 11.53.09.png
Screenshot 2020-06-30 at 11.53.09.png (20.64 KiB) Viewed 291 times
-
No feelings about it. 8)

AND returning 'ansi' is not helpful at all.

Just installed a font called "Ezra SIL SR" and the fontLanguage returned 'ansi'.

Very peculiar website: https://opensiddur.org/help/fonts/

Having downloaded a font called "Shlomo semistam" it actually put "Ezra SIL SR" into my system and I got "hot and sweaty"
scrolling through the font list looking for 'Shlomo'.

I think that they are being naughty by repackaging a SIL font without giving credit.

[This could be, of course, because the 'Summer Institute of Linguistics' is effectively a Fundamentalist Christian cult, and their
values are somewhat different to opensiddur, which is a website for Jewish prayers.]

So: obviously before you go any further you will have to get hold of a font
that returns "Hebrew" for fontLanguage:
-
Screenshot 2020-06-30 at 12.06.27.png

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 4717
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Android and Unicode

Post by richmond62 » Tue Jun 30, 2020 2:54 pm

Actually it turns out that fontLanguages is essentially rubbish.

I quote from the Use-List"

"On 6/30/2020 5:18 AM, Richmond via use-livecode wrote:
> Why does fontLanguage return ANSI for English language fonts instead of romething like 'Roman'?
>
> There is a fundamental mismatch between 'ANSI' and Unicode.
>
> Richmond.
>
> _______________________________________________
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

I asked a similar question back on June 5th under the subject "Unicode and languages" and Mark Waddingham provided the following answer (essentially the fontLanguages function no longer applies)

----------------------
Unicode doesn't deal in languages but 'scripts' e.g. English and French are both written in the Latin script, whereas Ukrainian can be written in either the Latin or Cyrillic script.

LiveCode gives you access to the unicode properties of all codepoints (as held by ICU) via the 'codepointProperty(codepoint, property)' function.

e.g. codepointProperty("A", "Script") => "Latin"
codepointProperty(numToCodepoint(0x03B1), "Script") => "Greek"

This might at least help to cut out trying to spellcheck things which are definitely not the languages you do have dictionaries for.
----------------------
. . ."

egolombek
Posts: 59
Joined: Thu Jan 30, 2020 2:11 pm

Re: Android and Unicode

Post by egolombek » Wed Jul 01, 2020 6:12 am

Well, after help from this forum and a lot of trial and error, I have solved the Hebrew problem!

For anyone who wishes to know what you need to do:

1. Find the original font file (.ttf). Do not take the file from C:\Windows\fonts because for some reason, even though the fonts look like they are stored there, they are not (or at least that did not work for me). Instead, search for the font and find where it is buried. For example, I needed to find the following file to use the Arial font:

amd64_microsoft-windows-font-truetype-arial_31bf3856ad364e35_10.0.18362.1_none_44e0e02b2a9382cc/arial.rtf

2. In Standalone settings, copy the file. Copy all variations of it you wish to use.

3. In preOpenStack, you must specify all of the fonts you are using. For example:
start using font file (specialFolderPath("resources") & "/arial.ttf")
start using font file (specialFolderPath("resources") & "/arialbd.ttf")
start using font file (specialFolderPath("resources") & "/arialbi.ttf")
start using font file (specialFolderPath("resources") & "/ariali.ttf")
4. Use trial and error to find which fonts display Hebrew and which do not. More popular ones like Arial seem to work. Less popular ones like Georgia do not. I have not found a successful method other than trial and error.

5. If you are saving and retrieving Hebrew from a database or the like, you must use Encode and Decode functions. UTF-8 is working for me, although I am told it's outdated. I tried other encodings and they work too, but I stuck to UTF-8 because that is how I had already set up my database and didn't see any need to change things. BTW, I have been using Clever Cloud for MySQL hosting and it is excellent! They offer a free version as you are developing and very inexpensive monthly plans as well. (And no, I do not work for them in any way!)

I hope this is helpful. It was many hours of hair pulling and going down dead ends. Thank you to the people of this forum for the help!

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”