Antti wrote:Have you added support for bi-directional text?
Not in my operating system, but I've dealt with i11n issues before.
Antti wrote:I tried but it ended up going too complicated at this point. Had it worked somehow, the implementation would have been a hack. I will try it again later but it requires more research and study. One of the problem is the lack of knowledge of any language written right-to-left. Another problem is to decide the proper internal presentation of text, i.e. whether to use the logical sequence of characters or the correct visual presentation. There are other problems too.
The internal representation is exactly the same. The characters in a word or sentence should still be stored in reading order (if it's a five character word, store the first character first, second character next, third character, fourth character, fifth character, etc.), the only difference is when you go to print you start at the right and decrease X until you reach the end of the line.
The real kicker here is when you try to deal with
Bi-directional text. If the text is rendered separately (e.g. imagine a GUI with two text labels), you could probably set one to render left-to-right and the other to render right-to-left, and because each one is being drawn separately, it should work.
But what if you tried to mix the two? For example, having Arabic text yet inserting an English word or vice versa? Two solutions:
1. Insert the quoted backwards.
2. Handle Unicode characters U+200E and U+200F to switch printing direction mid character, but this complicates your printing functionality slightly - when you encounter the control code to switch direction, you'll need to read ahead to find the opposite control code, then print the part of the string enclosed in those Unicode characters backwards.
Antti wrote:It is sure that I will not have a glyph for every character but I would like to have replacement characters ordered like they should.
Unicode is pretty much the universal standard for encoding data. (UTF-8 for storage and transmission, and perhaps UTF-32 internally.) Because there are too many glyphs in Unicode for you to probably want to make your own font, you're going to want to find a font you can already use.
Here's a monospaced bitmap Unicode font, but most fonts you find online are in a vector format like TrueType (and the complex topic of
Font rasterization. If a font is missing a glyph, then usually a '□' or '?' will be printed instead.
I'm not sure what you mean by:
Antti wrote:have replacement characters ordered
Do you mean that Unicode is so large that you don't want all characters loaded into memory at once? Your font rasterizer will probably only want to load and store recently used glyphs. You could probably get away with a glyph cache that only stores about 1000 rasterized characters, and every time a glyph is used it's either loaded in and added to the front or if it's already in the cache just bumped to the front. If you're trying to load a glyph when there's already 1000 characters in the glyph cache, unload the one at the very end.