Pages: « 1 2
  Print  
Author Topic: Unicode Fonts  (Read 3968 times)
Offline (Unknown gender) TheExDeus
Reply #15 Posted on: April 13, 2014, 07:04:52 AM

Developer
Joined: Apr 2008
Posts: 1872

View Profile
Quote
No, they all work fine including the new string_length_utf8, GM Studio's on the other hand is still not working as of v1.3
If by that you are implying to make a different function just for UTF-8, then that is exactly what I am afraid of. We DON'T need several functions for that. We should use UTF-8 everywhere and use one.

Quote
For the same reason we currently offer two overloads of string_length: one accepts const char*, the other accepts std::string. If all you have is const char*, then length is O(N), but does not necessarily entail a copy. If we only accept std::string, a copy becomes necessary, so now we're N in complexity and memory.
And const char* is only possible in ENIGMA if explicitly used right? Like "char array[20]; string_length(array);"? Even though the code for "string_length(const char* str)" seems a little fishy. It doesn't seem to check end of line characters or anything like that. It just checks if the value is not null.

Quote
In order to have a utf8_string whose complexity is the same as std::string (which is completely possible), I must keep TWO strings. The first is a string of at most 4N characters, where N is the length in characters of the string; this translates to N bytes. The second string is of size_ts and denotes the byte of each character. So it'll usually look like ⟨0, 1, 2, 3, ...⟩ or ⟨0, 2, 4, 6, ...⟩ but will often be much uglier. Primarily where other languages use English (ASCII) punctuation.
My idea was just to use UTF-16 or something which apparently has the best memory/speed tradeoff for most of earth's languages. But I guess it doesn't really matter. Most of the time (i.e. English) the complexity won't be large enough to cause real slowdowns. Maybe we could figure out a way to optimize that getUnicodeCharacter() though.

Quote
For your interest, I'll write the class. But I am disclaiming liability for slowdown from you two constructing one or more strings in addition to the simple ASCII strings you are usually asked to operate on.
I guess there is no need for that. I just wanted a way to differentiate that all std::string's in our code is actually UTF-8 encoded. Because by default str::string isn't meant to be. Just the same way I don't want two versions of all string manipulation functions.
Logged
Offline (Male) Rusky
Reply #16 Posted on: April 13, 2014, 09:49:43 AM

Resident Troll
Joined: Feb 2008
Posts: 955
MSN Messenger - rpjohnst@gmail.com
View Profile WWW Email
UTF-16 is a terrible idea. string_length on UTF-8 is slow and extremely complicated to write correctly. The majority of GM and ENIGMA games don't need Unicode for anything but random symbols. If you do want to use Unicode for other languages, GM's string interface is not the way to do it. An i18n interface would be better.
Logged
Offline (Unknown gender) TheExDeus
Reply #17 Posted on: April 13, 2014, 10:54:30 AM

Developer
Joined: Apr 2008
Posts: 1872

View Profile
Quote
string_length on UTF-8 is slow and extremely complicated to write correctly.
Not any slower than actually drawing the text. Another reason I thought we should use classes is because then we could just add a .length member to the string and calculate it once when creating/assigning the string. It wouldn't make the "string_length("This is a string!");" any faster, but it would make faster cases when using variables.

Quote
The majority of GM and ENIGMA games don't need Unicode for anything but random symbols.
And localizations.. you know, the main reason Unicode exists.

Quote
If you do want to use Unicode for other languages, GM's string interface is not the way to do it. An i18n interface would be better.
How would i18n be of any benefit here? We need a way not only to store the strings, but to also draw them. Either way we need some kind of UTF encoding. We could include additional functions for easier localization of course. But that is besides the topic here.
Logged
Offline (Male) Goombert
Reply #18 Posted on: April 13, 2014, 04:47:35 PM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3110

View Profile
After my last commit it is now working perfect, TKG's infinity symbol is also working now. After a few more improvements to LGM and stuff we can look to getting this release rolled out to everyone.
« Last Edit: April 14, 2014, 07:03:53 PM by Robert B Colton » Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Pages: « 1 2
  Print