Hello all
I am trying to display Arabic words, like the Arabic names for the stars but I just don't know how, I know I have to use UTF-8 encoded characters but it is not working when I substitute the Arabic word with its UTF-8 encoded characters
Can you help me please with an example of displaying UTF-8 encoded characters using the print or the flash method?
Cheers
How to display Arabic word using print method?
Forum rules
Please help to make this forum more useful by checking the FAQs before posting! Keep it clean, keep it civil, keep it truthful, stay on topic, be responsible, share your knowledge.
Please help to make this forum more useful by checking the FAQs before posting! Keep it clean, keep it civil, keep it truthful, stay on topic, be responsible, share your knowledge.
-
Topic authorahmedbahgat
- Posts: 1
- Joined: 25.03.2017
- With us: 7 years 8 months
Hi,
It looks like arabic fonts in .txf format are missing in the celestia\fonts directories.
Maybe you can rebuild them following the method described here.
https://en.wikibooks.org/wiki/Celestia/Internationalization
(see "Building .txf font texture files" )
Change the "font_bold.ttf" in the description with a ttf police containing arabic characters.
celestia:print() uses the font "TitleFond" as declared in the celestia.cfg file.
I can't help too much because I am unable to write with this set of characters. (No arabic keyboard and above all zero knowledge of the language itself).
But I can test if you post a utf-8 encoded celx script with a valid celestia:print() statement containing arabic words.
- Please precise the default language of your computer and the language displayed in Celestia when you launch Celestia.
I fear there is also a problem in Celestia concerning the right to left management of the scripting.
In this case maybe you will have to write your text in reverse order
.
It looks like arabic fonts in .txf format are missing in the celestia\fonts directories.
Maybe you can rebuild them following the method described here.
https://en.wikibooks.org/wiki/Celestia/Internationalization
(see "Building .txf font texture files" )
Change the "font_bold.ttf" in the description with a ttf police containing arabic characters.
celestia:print() uses the font "TitleFond" as declared in the celestia.cfg file.
I can't help too much because I am unable to write with this set of characters. (No arabic keyboard and above all zero knowledge of the language itself).
But I can test if you post a utf-8 encoded celx script with a valid celestia:print() statement containing arabic words.
- Please precise the default language of your computer and the language displayed in Celestia when you launch Celestia.
I fear there is also a problem in Celestia concerning the right to left management of the scripting.
In this case maybe you will have to write your text in reverse order
.
.
Definitively, the arabic fonts are missing.
Here is a workaround to display arabic words in Celestia.
This is not the only way to do it, but maybe you find it useful.
1) Building the font for Celestia.
I have built a txf font with arabic characters (and also the latin ones, so you can use it to write any kind of text including special west-europeans letters with accents.
The base font is the simpo.ttf font that I found here.
https://cooltext.com/Fonts-Unicode-Arabic
I choosed this font because the latin characters in it match well withe the usual celestia fonts.
Of course another font is maybe better for arabic characters. Please tell me.
I gave the name simpo24_ar.txf to this font.
I got it withe this command :
ttf2txf -w 1048 -h 1048 -f codepoints_ar.txt -s 24 -o simpo24_ar.txf simpo.ttf
I join this font to this message.
2) copy this font in the fonts directory of Celestia.
3) In the celestia.cfg file, replace the sansbold20.txf with simpo24_ar.txf as TitleFont
Now you shoud be able to print arabic text using the celestia:print() or celestia:flash() functions.
But there is still a problem :
As I guessed, these functions don't manage the right to left order of arabic scripture and the text is written in reverse order.
To fix this issue, I have created a little lua function that reverse the order of a utf-8 text.
Here is a minimal script as exemple.
And a screen copy of the result.
(click for a bigger view)
I Hope it make sense I used google to translate from French to Arab.
Download the font from here:
Definitively, the arabic fonts are missing.
Here is a workaround to display arabic words in Celestia.
This is not the only way to do it, but maybe you find it useful.
1) Building the font for Celestia.
I have built a txf font with arabic characters (and also the latin ones, so you can use it to write any kind of text including special west-europeans letters with accents.
The base font is the simpo.ttf font that I found here.
https://cooltext.com/Fonts-Unicode-Arabic
I choosed this font because the latin characters in it match well withe the usual celestia fonts.
Of course another font is maybe better for arabic characters. Please tell me.
I gave the name simpo24_ar.txf to this font.
I got it withe this command :
ttf2txf -w 1048 -h 1048 -f codepoints_ar.txt -s 24 -o simpo24_ar.txf simpo.ttf
I join this font to this message.
2) copy this font in the fonts directory of Celestia.
3) In the celestia.cfg file, replace the sansbold20.txf with simpo24_ar.txf as TitleFont
Code: Select all
Font "sans12.txf"
LabelFont "sans12.txf"
# TitleFont "sansbold20.txf"
TitleFont "simpo24_ar.txf"
Now you shoud be able to print arabic text using the celestia:print() or celestia:flash() functions.
But there is still a problem :
As I guessed, these functions don't manage the right to left order of arabic scripture and the text is written in reverse order.
To fix this issue, I have created a little lua function that reverse the order of a utf-8 text.
Here is a minimal script as exemple.
Code: Select all
local function utf8inverse(s)
local inverse="";
local i=1
while (i <= string.len(s)) do
local car,b
b=string.byte(s,i)
if b<128 then
car = string.char(b);
i=i+1
elseif b<224 then
car = string.sub(s,i,i+1)
i=i+2
elseif b<240 then
car = string.sub(s,i,i+2)
i=i+3
else
car = string.sub(s,i,i+3)
i=i+4
end
inverse = car..inverse
end
return inverse
end
celestia:print(utf8inverse("هذا النجم الدبران") , 60,0,0,-12,-3)
And a screen copy of the result.
(click for a bigger view)
I Hope it make sense I used google to translate from French to Arab.
Download the font from here:
- Attachments
-
- simpo24_ar.zip
- (13.05 KiB) Downloaded 275 times