Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Mehrdad on Fri 10/03/2017 15:57:02

Title: Please improve and increase slots from preview font pane [Solved]
Post by: Mehrdad on Fri 10/03/2017 15:57:02
Hi

I finally success to solved TTF Persian fonts for AGS . It works perfect now . All slots is OK but i need more slot after red oval in below picture for add other symbols . How can I increase slot ?

(http://uupload.ir/files/pcpy_farsifont.png) (http://uupload.ir/)
Title: Re: Improve one slot from font page
Post by: Gurok on Fri 10/03/2017 17:33:22
AFAIK, you can't, Mehrdad.

Perhaps you could write a print function that combined glyphs from two fonts.

Other than that, you might try limiting your use of Persian to < 127 glyphs.


Ignore this. I forgot about the sprite font plugin.
Title: Re: Improve one slot from font page
Post by: Mehrdad on Fri 10/03/2017 17:47:19
Hi Gurok

127 symbol is enough for Persian fonts but font page in AGS show less than this . It's 10X10 = 100 and show 95 slot only. Doesn't it?
Title: Re: Improve one slot from font page
Post by: Gurok on Fri 10/03/2017 18:55:32
Oh, I'm sorry. My mistake. < 95 characters then.

Thinking about this, you could use a sprite font, which would remove this restriction.

http://www.adventuregamestudio.co.uk/forums/index.php?topic=44359.0
Title: Re: Improve one slot from font page
Post by: Crimson Wizard on Fri 10/03/2017 19:00:07
TBH I do not quite understand what the problem is. Is it that you cannot edit these letters, or they don't show up in the game, or they do not show up in the Editor's preview panel?

AGS is supposed to support all 256 letters in TTF font since 3.0 and in WFN font too since 3.4.0.

But for some reason Editor does not show all letters of the font in that window. Probably it is programmed that way. So the question is, do the missing letters show up in game.

EDIT: I just looked into the Editor code, and it literally tells to draw only first 96 letters of the font on that preview.
Title: Re: Improve one slot from font page
Post by: Mehrdad on Sat 11/03/2017 05:55:06
Quote from: Crimson Wizard on Fri 10/03/2017 19:00:07
TBH I do not quite understand what the problem is. Is it that you cannot edit these letters, or they don't show up in the game, or they do not show up in the Editor's preview panel?

AGS is supposed to support all 256 letters in TTF font since 3.0 and in WFN font too since 3.4.0.

But for some reason Editor does not show all letters of the font in that window. Probably it is programmed that way. So the question is, do the missing letters show up in game.

EDIT: I just looked into the Editor code, and it literally tells to draw only first 96 letters of the font on that preview.

Letters didn't show in the game and window font . It only show until red oval that I showed it in picture.
When I import TTF fonts It only show 95 item in window font an miss other words and into the game is show this 95 letters only.

I can only use TTF font for Persian letters and can't use any WFN , SCI , PNG,.. or others . Because our alphabet is not separate like yours. They stick together sometimes . 127 letters is enough and 256 is great . 

Can you increase it ? I was glad that I can solved Farsi font for AGS after a long time but now I have this problem .  It's so important for me . Otherwise I can't make my native language for my game.
Title: Re: Improve one slot from font page
Post by: Crimson Wizard on Sat 11/03/2017 12:29:26
There are two different and unrelated problems:

1) Letters not showing in the game
2) Letters not showing in the preview pane.

Increasing number of letters in preview may not be difficult, but I doubt it has anything to do with letters not showing in game.
So the question is, why do not they show in the game.

Can you tell:
- Which version of AGS are you using;
- How do you type strings in your game that are supposed to be printed with your font;
- Can you upload your TTF font;
Title: Re: Improve one slot from font page
Post by: Mehrdad on Sat 11/03/2017 13:24:54



- Latest version 3.4.0.15

- I typed all of them in the separate program and paste in AGS . Into the AGS showed like this :  player.Say ("Svàâ,¬ Æ'Ho† "); And into the game is OK. All of characters that you see in preview pane supported into the game even rectangles is same (That seems don't support by AGS) . Preview pane is complete equal with show game . It have 95 slot ready and missed others . AFAIK 110 it's enough for Farsi font .

- Here You are:
https://www.dropbox.com/s/lpa90uykzj895b1/LMN%20Sam.ttf?dl=0
Title: Re: Improve one slot from font page
Post by: Crimson Wizard on Sat 11/03/2017 13:40:37
Can you tell how could I get some text that has letters over 95th slot?
Title: Re: Improve one slot from font page
Post by: Mehrdad on Sat 11/03/2017 14:44:01
Quote from: Crimson Wizard on Sat 11/03/2017 13:40:37
Can you tell how could I get some text that has letters over 95th slot?

OK 95th slot is  ﺻ
Some other missed letters is       Ã˜Â¸ Ø· ع غ ف Ù‚ Ú© ....

I ready all persian letters with unicode numbers .Please get it here:
https://www.dropbox.com/s/l7m7nvt7yfb5419/PersianAndUnicode.rar?dl=0

Title: Re: Improve one slot from font page
Post by: Crimson Wizard on Sat 11/03/2017 15:08:04
Hmm... actually I was wrong. That editor preview shows 96 letters but not slots 0-95, it shows slots 32-127. It does not show first 32 slots, because these are special non-printable symbols.
Although this makes preview more logical, this does not explain why characters do not work in game, since AGS is supposed to support up to 256 characters.



EDIT: I opened your font in the FontForge editor, and what I can see there:

The last letter from preview is at the slot 126.
After that you have NO LETTERS until slot 160.
Title: Re: Improve one slot from font page
Post by: Mehrdad on Sat 11/03/2017 15:21:16
Oh wait ... Sorry  . It show some other missed letters into the game that aren't in preview pane . Did you want  all missed letters ? And does it help to you for fix it ?
Title: Re: Improve one slot from font page
Post by: Crimson Wizard on Sat 11/03/2017 15:28:47
Quote from: Mehrdad on Sat 11/03/2017 15:21:16
Oh wait ... Sorry  . It show some other missed letters into the game that aren't in preview pane . Did you want  all missed letters ? And does it help to you for fix it ?

Merhdad, you are asking me to fix something, but I cannot understand what exactly.

Is it just the preview pane that you need to get fixed? Or letters displayed in game?
As I said, the preview pane is simply limited to slots 32-127. But it does not mean that other letters do not exist, it simply does not show them.
So, the question is, are those letters shown in game?
If they are shown, then it is just the preview pane that needs to be expanded.
Title: Re: Improve one slot from font page
Post by: Mehrdad on Sat 11/03/2017 15:40:09
Quote from: Crimson Wizard on Sat 11/03/2017 15:28:47
Merhdad, you are asking me to fix something, but I cannot understand what exactly.

Is it just the preview pane that you need to get fixed? Or letters displayed in game?
As I said, the preview pane is simply limited to slots 32-127. But it does not mean that other letters do not exist, it simply does not show them.
So, the question is, are those letters shown in game?
If they are shown, then it is just the preview pane that needs to be expanded.

Actually I want letters displayed in game.

Quote
So, the question is, are those letters shown in game?
Some letters show in the game

Maybe  expand preview pane is will be good for start and even fix . Because i can see which letters are rectangle and unknown for AGS .
Title: Re: Improve one slot from font page
Post by: Crimson Wizard on Sat 11/03/2017 15:48:28
Quote from: Mehrdad on Sat 11/03/2017 15:40:09Actually I want letters displayed in game.
Maybe  expand preview pane is will be good for start and even fix . Because i can see which letters are rectangle and unknown for AGS .

Alright, that's good point.

I made a very quick fix just to resize the preview box, and here is what I see with your font:
(http://i.imgur.com/l52g0jR.png)

I noticed that some letters look weird, like only small piece of them is visible. I cannot tell if this is how they are supposed to be, but I guess you know better.

Title: Re: Please improve and increase slots from preview font pane
Post by: Mehrdad on Sat 11/03/2017 15:51:05
Great . Thanks a lot . Please let me find them ... It takes a some minutes....
Title: Re: Please improve and increase slots from preview font pane
Post by: Crimson Wizard on Sat 11/03/2017 15:59:01
Also, I do not know why, but this font looks more "blocky" on my computer than on your screenshot... :/
Title: Re: Please improve and increase slots from preview font pane
Post by: Mehrdad on Sat 11/03/2017 16:28:01
There is missed 25 letters :
https://www.dropbox.com/s/01ztse8pdf3tdv1/PersianMissedAGS.docx?dl=0

I know fix it is difficult for you .  If slots was editable I could fix it manually .
CW , can you send for me this version of AGS as expand preview fonts ? I want test other ttf Persian fonts and see result.

Title: Re: Please improve and increase slots from preview font pane
Post by: Crimson Wizard on Sat 11/03/2017 18:19:48
Ok, this preview issue is an annoying one, so I decided to fix it properly. Now it displays all supported slots (0-255), uses all available window space and has vertical scrollbar if the font does not fit in visible area.

http://www.mediafire.com/file/wiht24y0231kd4t/AGS.Editor.3.4.0.15--improv-font-pane.zip
Title: Re: Please improve and increase slots from preview font pane
Post by: Mehrdad on Sun 12/03/2017 15:36:00
Sorry for answer late

Thanks a lot for patch . I'm glad that you want fix it. I'm appreciate too much.
I'll try more than 40 fonts and result was same .Exactly Same slots is unknown for AGS . I think best solution is slot editable . So we can replace rectangle with letters as copy / paste .
Title: Re: Please improve and increase slots from preview font pane
Post by: Crimson Wizard on Sun 12/03/2017 15:44:15
Quote from: Mehrdad on Sun 12/03/2017 15:36:00
I'll try more than 40 fonts and result was same .Exactly Same slots is unknown for AGS . I think best solution is slot editable . So we can replace rectangle with letters as copy / paste .

We cannot make the slot editable so simply, because TTF are vector fonts, they require a real font editor with complex functionality, which knows how to deal with TTF data.
Also, AGS is not really meant to be a resource editor. Similarily like putting an image editor in it not likely is a good idea.
If someone makes a plugin that edits TTF fonts - that will be another story (there is already a font editor plugin that edits bitmap fonts).

Anyway, there is number of TTF editors around that let you do that. For example, download FontForge, open your font in it and copy letters to the slots you need:
https://fontforge.github.io
Title: Re: Please improve and increase slots from preview font pane
Post by: Mehrdad on Sun 12/03/2017 16:28:21
OK . unfortunately I only can use TTF font for AGS . No bitmap and so on

I have some TTF editor too but It's just matter is unknown for AGS .
Title: Re: Please improve and increase slots from preview font pane
Post by: Crimson Wizard on Sun 12/03/2017 16:42:25
Quote from: Mehrdad on Sun 12/03/2017 16:28:21
I have some TTF editor too but It's just matter is unknown for AGS .

Well, I have to admit that I am again not exactly sure what you mean.

Are you saying there an actual letter in the font between slots 0 and 255, that is not visible on preview and not working in game?
Could you post a font you have such problem with and point out which slot does not work? (If it is a font you already posted, then simply tell which slot is that.)

Title: Re: Please improve and increase slots from preview font pane
Post by: Mehrdad on Sun 12/03/2017 17:00:52
Quote from: Crimson Wizard on Sun 12/03/2017 16:42:25
Are you saying there an actual letter in the font between slots 0 and 255, that is not visible on preview and not working in game?
Yes . Your shot showed them as rectangle . And it's happen for other fonts in exactly same slots.

Quote from: Crimson Wizard on Sun 12/03/2017 16:42:25
Could you post a font you have such problem with and point out which slot does not work? (If it is a font you already posted, then simply tell which slot is that.)

Sorry I don't understand what's you mean . I tried many fonts and it occur exactly in same slots . First rectangle slot want  :   Ã¯ÂºÂ»     U+FEBB &#65211



Title: Re: Please improve and increase slots from preview font pane
Post by: Crimson Wizard on Sun 12/03/2017 17:04:30
Quote from: Mehrdad on Sun 12/03/2017 17:00:52
Quote from: Crimson Wizard on Sun 12/03/2017 16:42:25
Are you saying there an actual letter in the font between slots 0 and 255, that is not visible on preview and not working in game?
Yes . Your shot showed them as rectangle . And it's happen for other fonts in exactly same slots.

I opened the TTF font you posted in the FontForge editor, and it also had NO LETTERS in these slots. There were just no letters, at all.

AGS works only with slots #0-255. If the font ITSELF does not have any letters there, then AGS obviously won't know them.

If you want to have particular letter in exactly these slots (where you see rectangles), then you need to open the font in a font editor, and copy/paste this letter to such slot.

Title: Re: Please improve and increase slots from preview font pane
Post by: Mehrdad on Sun 12/03/2017 17:16:14
Quote

I opened the TTF font you posted in the FontForge editor, and it also had NO LETTERS in these slots. There were just no letters, at all.

Really ? ? ? ? . But I could find all of them in bottom list . Maybe I don't familiar with this program because it show me many China words too . I use 'High logic Font creator' and show all of them .
Title: Re: Please improve and increase slots from preview font pane
Post by: Crimson Wizard on Sun 12/03/2017 17:23:36
Mehrdad, I am not sure what you are trying to do exactly, and how do you want to use your fonts. But I am coming to a thought that either we do not understand each other, or you are doing it wrong.

So, just in case, I feel the need to explain following.

There was a big page in the wiki explaining how to use fonts of other languages in AGS. You can read it here:
http://www.adventuregamestudio.co.uk/wiki/Fonts
But that could be a long read.

In very short, the idea is that AGS only sees FIRST 256 slots from any font.
This means: if your letters are located in slots after #255, then AGS won't see them no matter what you do.
This means that you need a font where all of the letters you want to use are located in slots in the range between 0 and 255.

Such letters layout is called "ANSI codepage", Windows uses same thing, which is a long story. But important part is that you can use ANSI table to know where to paste your letters.

I am not very well acquianted with the alphabet you are using, but for example, I found this table for persian language:
https://en.wikipedia.org/wiki/Iran_System_encoding
EDIT: sorry, nevermind that, this seem to be the correct page:
https://en.wikipedia.org/wiki/Windows-1256

Basically, if you copy&paste letters to the slots as shown in this table, then not only AGS will be able to see that, but also you will be able to type texts in your own language in AGS using native language mode, and AGS should correctly convert these texts to use in game.

This is how, for example, we made Russian, and some other languages to work within AGS.
Title: Re: Please improve and increase slots from preview font pane
Post by: Mehrdad on Sun 12/03/2017 17:40:51
How can I put letters in FIRST 256 ? Can you help me for one example? Please see this image in comparison with your shot in AGS . It's in 'High logic Font creator' program

(http://uupload.ir/files/ie0m_font.png) (http://uupload.ir/)
Title: Re: Please improve and increase slots from preview font pane
Post by: Crimson Wizard on Sun 12/03/2017 17:44:23
Quote from: Mehrdad on Sun 12/03/2017 17:40:51
How can I put letters in FIRST 256 ? Can you help me for one example . Please see this image in comparison with your shot in AGS . It's in 'High logic Font creator' program


Hmm... I can see that FontCreator displays the font differently from FontForge. I will try to install FontCreator and check that out.
Title: Re: Please improve and increase slots from preview font pane
Post by: Crimson Wizard on Sun 12/03/2017 18:23:14
Alright, I think I got it. There is a big misunderstanding here.

The font "slots" I was speaking about, are symbol "codes". As I mentioned, AGS only works with codes 0-255.

Font Creator does not show letters in the order of codes by default. It shows them in the order of alphabet, it seems. What you see in the program window is not what AGS "sees".

Do following: on the toolbar, where the glyph sorting is being set up, near "Default Grouping" text, choose following sort order:
- Codepoint
and following hints type:
- Codepoints

Then you will see which actual slots these letters occupy.

For example, in the font "LMN Sam.ttf", which you posted earlier, letters go from slot 32 to 126, then from 160 to 255, then from 338 to 376 and some letter has even code number 8729.
This is why they are not working in AGS (you need them all inside numbers 0-255).


I do not know how you do that in FontCreator exactly, but the idea is to change the codes of these letters to bring them into the range of 0-255.

The biggest question, though, is what codes each letter should have.

Normally I'd recommend trying to match the ANSI table shown at this page in wikipedia, and then type texts having your native language selected in Windows:
https://en.wikipedia.org/wiki/Windows-1256
Windows uses this codetable for Arabic and some non-Arabic languages like Persian (sorry if I am mistaken at something).

The problem there is that it looks like not all letters from your alphabet are on that page. So it may not work for you.

The only other solution I know at this point is to use some program that would translate real text in Farsi to the "pseudo-language" with letters in code range 0-255.
You have mentioned that you use some program to type texts already. I do not know what program that is and what it does exactly, but maybe it will help you in this case too.
Title: Re: Please improve and increase slots from preview font pane
Post by: Mehrdad on Mon 13/03/2017 14:15:56
Sorry but I couldn't find sorting as codpoints . Would you mind a shot ? My version of this program is so old (2007) .

After success in sorting by code , Can I improve manually slots and export to AGS?


I use LeoMoon ParsiNegar software for type and export texts to AGS . Only this software is almost match with AGS .
https://leomoon.com/downloads/desktop-apps/leomoon-parsinegar/


Edit: I grab new version and find codpoints . Now how can I fill it for AGS ?
Title: Re: Please improve and increase slots from preview font pane
Post by: Crimson Wizard on Mon 13/03/2017 17:53:45
You need to assign codes to letters in such a way that they will fit into range of code #0 to code #255.
I do not know how to change letter's code, or do copy/paste letter in FontCreator, but I guess that is possible to find out. That is not the most important thing though.

More important question here, is which codes to assign to which letters. You cannot do that randomly, because this is connected to how your real text in Persian will be translated in to "pseudo-text" to work with this new font.

In other words, even more importantly, is first to find out how you will translate your text from one form into another.

You need some program that can take a text in Persian and change the letter codes so that real persian letter become the code of such letter in your font.

ORIGINAL LETTER CODE (XXX) == converted to ==> LETTER's CODE (YYY) IN AGS FONT.


I never used ParsiNegar, so I cannot tell if that may help. I can take a look, but I don't have much free time right now, so this may take a while.


EDIT: I tried ParsiNegar, and I understand how it works better now. For example, I can see that if I type something in ParsiNegar, I can then convert & copy "weird" text into FontCreator's "preview" window and see proper Persian letters.

With that, I realize that ParsiNegar won't be enough on its own to solve this problem, but I have some thoughts about what can be done here. Unfortunately I am too tired today, so I will explain my idea tomorrow.
Title: Re: Please improve and increase slots from preview font pane
Post by: Mehrdad on Tue 14/03/2017 06:56:15
New version of Font creator is commerical and don't export fonts. So I migrate to FontForge and tried similar slots as Name,Unicode,.. and export to AGS  many times . But don't get any success .  My knowledge is is poor for it.

Thanks so much for try ParsiNegar . If you can find a way for fix it you save me a lot.
I really appreciate your generous help.
Title: Re: Please improve and increase slots from preview font pane
Post by: Mehrdad on Wed 15/03/2017 12:08:52
Today I tested another Farsi maker that was similar to ParsiNegar . With Roya name . I import new TTF (made for Roya only)  and I had exactly same missed slots . I don't know how can I arrange slots for AGS .
CW can you get any success in ParsiNegar ?   I know you are busy for 3.4.1 and thanks for this great updates .
Title: Re: Please improve and increase slots from preview font pane
Post by: Crimson Wizard on Wed 15/03/2017 12:41:42
Quote from: Mehrdad on Wed 15/03/2017 12:08:52
Today I tested another Farsi maker that was similar to ParsiNegar . With Roya name . I import new TTF (made for Roya only)  and I had exactly same missed slots . I don't know how can I arrange slots for AGS .
CW can you get any success in ParsiNegar ?   I know you are busy for 3.4.1 and thanks for this great updates .

I was taking a break to think this over, but in reality, there are just two possible ways to solve this problem (except for upgrading AGS to support Unicode, which is a big task).
It's just that I do not know which one you should take.

First of all, it does not matter which program do you use to type text and export fonts, because in either case you will get Unicode font and Unicode text. So just use the one you like more.
In either case you will have to create an ANSI font from your Unicode one, and you will need to have your Unicode text converted into ANSI text in such way that will make letter match codes in new font.

I will try to explain how this works, but that may be a little difficult for me to make good explanation.

----------------------------------------------------------------

You may already know, that there is a Unicode encoding for text, which allows letter codes up to #65535, and therefore Unicode fonts may have a very big range of letters.
There are ANSI encodings, which allow letter codes up to only #255, and therefore ANSI texts allow much smaller range of letters.
AGS only supports ANSI at the moment.

When you put Unicode text in AGS (for example, in the script), and then compile your game, this text will be converted into ANSI text. When this conversion is done, letters from Unicode have their codes changed to similar letters of particular ANSI table.
There are numerous ANSI tables: standard (latin only) table, cyrillic table, arabic table, and so forth. If wrong table is chosen, some native (non-latin) letters may get lost.

So, how AGS choses which table to use? It takes it from the system locale settings. Specifically, the option called "Language for non-Unicode programs". Here is a quick info on how to find this option in your Windows: https://www.java.com/en/download/help/locale.xml (don't mind the Java reference).

After this conversion, the resulting text's letters have codes in the range of #0-#255, so you cannot any longer use real Unicode font to display them (AGS wont be able to find correct letters). Instead, you need ANSI font, that has these letters in new slots (0 - 255), arranged according to the current system locale.

****************
EDIT: I had to rewrite following part, because I first wrote something not related to your situation.
****************

What I explained above is the standart way. However, you are using different method of typing: you first type Persian letters in your program (ParsiNegar, or other one), which converts them into some other letters ("special letters"), and then you put these, different letters, into AGS. We need to know how AGS will convert "special letters" into ANSI.

1. So, the first question really is, what is the "Language for non-Unicode programs" you are using, and what ANSI table does it use to convert text.
You'll need to check out what is set in your system (use above link to find it).
2. When we find out what table is used, we need to find what codes these "special" letters have there.
3. And then we would need to make a chart of our own:

Native Persian letter =>Letter created by ParsiNegar =>Code of the final letter in ANSI text

When we have such table, you will need to create a font, where Persian letters are put in the codes, which correspond to respective "special letters" in the ANSI table.

I am sorry if last thing sounds confusing. When we find out which ANSI table is being used, I can make a more "visual" example.
Title: Re: Please improve and increase slots from preview font pane
Post by: Mehrdad on Wed 15/03/2017 14:58:43
OK. Thanks a lot for great answer. So we need a convertor from ParsiNegar to ANSI . I sent a massage to Amin ( ParsiNegar author ) for this problem and also sent your last answer too. Maybe he can find a solution for it .
I'm searching for convert to ANSI at the moment .   
Title: Re: Please improve and increase slots from preview font pane
Post by: Crimson Wizard on Wed 15/03/2017 15:40:40
Quote from: Mehrdad on Wed 15/03/2017 14:58:43
I'm searching for convert to ANSI at the moment .   

Notepad++ text editor can simply convert Unicode text files into ANSI using selected character set.
https://notepad-plus-plus.org/


To clarify something, I modified my previous post after writing it. Did you read first or modified variant (with "EDIT" line in it)?
Title: Re: Please improve and increase slots from preview font pane
Post by: Mehrdad on Wed 15/03/2017 16:51:00
Quote from: Crimson Wizard on Wed 15/03/2017 15:40:40
To clarify something, I modified my previous post after writing it. Did you read first or modified variant (with "EDIT" line in it)?

Yes I read it. "Language for non-Unicode programs" was English and now I changed it to Persian (Iran)
But I don't know what ANSI table use to convert text .
Title: Re: Please improve and increase slots from preview font pane
Post by: Monsieur OUXX on Wed 15/03/2017 17:07:54
EDIT: bad reading through thread

I think your issue is a combination of two issues :
1) Your TTF font doesn't have all the characters. Yep, CW guessed correctly : it's perfectly possible for a font not to have all the characters. But most of the times you don't notice it because Windows replaces the missing characters with the same character from a similar-looking font. For example, as a French, how many times have I been using a cool font, only to realize that all the instances of character é appear in Arial? windows knows how to do that. But AGS obviously can't do that.
2) You don't know how to render your TTF font to WFN and how to move the characters you need to the first 256 slots.


I'd follow this process :
1) Read the Font wiki page : http://www.adventuregamestudio.co.uk/wiki/Fonts
2) Use rulaman's tool to turn your TTF font into WFN : look for the "Rulaman's TtfWfnSci" section in the wiki page
3) Use Rulaman's other tool ("Rulaman's WFN-FontEditor" - see dedicated section of the wiki page) to edit that WFN font and draw the (potentially missing) required characters into the first 256 slots.



Oh, and when you're done, UPLOAD the font you made, to make it available to the Persian/Iranian/Farsi AGS community ;)

Title: Re: Please improve and increase slots from preview font pane
Post by: Crimson Wizard on Wed 15/03/2017 18:06:21
Quote from: Mehrdad on Wed 15/03/2017 16:51:00
Quote from: Crimson Wizard on Wed 15/03/2017 15:40:40
To clarify something, I modified my previous post after writing it. Did you read first or modified variant (with "EDIT" line in it)?

Yes I read it. "Language for non-Unicode programs" was English and now I changed it to Persian (Iran)
But I don't know what ANSI table use to convert text .
Please, return it back for now.... I did not mean to force you to change it (you may have problems with that in some programs), I just needed to know what you are working with, because I wanted to make some experiments.



@ Monsieur OUXX, it seems like you have not read this the discussion thoroughly, because what you said cannot not really apply here.

1) I did not "guess" that TTF font does not have something. I opened posted TTF font in the editor to see its contents, and it did not miss anything, it had all letters it need; problem was they had codes > #255.
There was a big misunderstanding with Mehrdad thinking that he has letters at certain slots, while AGS did not see them, because font editor displayed these letters in different order.

2,3) Mehrdad did not want, and cannot use WFN, for the reason he explained in one of this posts above (and something you learn as soon as you try to write in Persian with the program Mehrdad referenced). The thing is that Persian letters are combined with each other when printed. One spot in text can have 2 symbols placed one upon another. TTF renderers can do that, because their font parameters describe these rules. But you cannot do that with WFN - you would have to make distinct letters for all possible combinations, thus significantly increasing their numbers.
Besides, what's the point of converting to WFN (and loosing ability to e.g. resize font and antialias text) when you can just edit TTF and put necessary letters in the first 256 slots?

At last but not least, from what I gathered up to this point, it seems that there is no direct way to convert Persian text from Unicode to ANSI, because there is no compatible ANSI table that would keep all required letters.


EDIT:
To elaborate further, Persian language does not have a proper ANSI codepage to use in MS Windows, like they do with, for example, French, Russian, etc languages. The closest available is codepage 1256, used for Arabic languages, but it has only small part of necessary letters.
I am not an expert here, but searching around the web, I found this article that gives some insight in this issue:
http://archives.miloush.net/michkap/archive/2010/05/11/10009925.html

judging on that explanation, this may related mainly to legal issues (US sanctions against Iran, and Microsoft being US-based company).

So, what Mehrdad does, he uses a special program called "ParsiNegar", where he is typing Persian texts using virtual on-screen keyboard. That program then takes that persian text and converts it into "pseudo-text", consisting of all kinds of extended characters. This pseudo-text, when used in combination with very special types of Unicode fonts, produces correct Persian visual output.

The only viable solution I have at this point is to make another step, and find out, how does this "pseudo-text" converts into ANSI, using, for example, standard (English) table, and then modify these Persian fonts accordingly to match the conversion result.
Title: Re: Please improve and increase slots from preview font pane
Post by: Mehrdad on Thu 16/03/2017 07:59:50
Quote from: Crimson Wizard on Wed 15/03/2017 18:06:21
Please, return it back for now.... I did not mean to force you to change it (you may have problems with that in some programs), I just needed to know what you are working with, because I wanted to make some experiments.

You mean is what is my work with ParsiNegar ? Sorry for bad English .
I used ParsiNegar for Farsi type in Photoshop , Premiere , .... And haven't any problem with it .  Only AGS have some issue with it that you know better than me.
If I don't understand your question please let me know
Title: Re: Please improve and increase slots from preview font pane
Post by: Crimson Wizard on Thu 16/03/2017 08:26:31
Quote from: Mehrdad on Thu 16/03/2017 07:59:50
Quote from: Crimson Wizard on Wed 15/03/2017 18:06:21
Please, return it back for now.... I did not mean to force you to change it (you may have problems with that in some programs), I just needed to know what you are working with, because I wanted to make some experiments.

You mean is what is my work with ParsiNegar ? Sorry for bad English .
I used ParsiNegar for Farsi type in Photoshop , Premiere , .... And haven't any problem with it .  Only AGS have some issue with it that you know better than me.
If I don't understand your question please let me know

No, I mean  "Language for non-Unicode programs". Better return it to what you had before, because it can affect how some old programs, including AGS, work with text.


Regarding how to change the font. I would try following:

1. Create a text file (normal text file, not something like Word document).
2. Type every possible Persian letter (converted using ParsiNegar) from your font in that file to create some sort of "alphabet".
3. Save that text file in Unicode format.

What happens then, but probably I would have to do that:
4. Pick out unique symbols and sort the list by the order of letter codes.
5a. Use the standart ANSI character set (English) to know the codes of these letters in ANSI.
OR, if that won't work for some reason -
5b. Save a copy of that file, converting to ANSI format, and check the resulting codes there.
6. Write down a table of two columns:
Code of letter in UnicodeCode of letter in ANSI

Back to you:
7. Make a modification of your Persian font by moving letters to new codes.
8. Test in AGS.
Title: Re: Please improve and increase slots from preview font pane
Post by: Mehrdad on Thu 16/03/2017 08:47:40
I don't see any different between last situation and now in  "Language for non-Unicode programs" .

There is great way .  Thanks a lot  . If you want any help for Persian language please let me know . ( It's similar to Arabic font but with a few more letters)

p.s : I get first post from Amin ( ParsiNegar author ) . That he said what is your font . I replied and ask Is it possible convert to ANSI or other trick in your program . I'm waiting to answer.
Title: Re: Please improve and increase slots from preview font pane
Post by: Snarky on Thu 16/03/2017 09:14:36
Man, CW, you're going far above and beyond here!

One thing that puzzles me a little: even if Mehrdad moves the character glyphs to other slots in the font, won't the font coding that combines different glyphs to make up a full character still refer to the old slots, so that as soon as you get into compound characters or ligatures, the whole thing will break?
Title: Re: Please improve and increase slots from preview font pane
Post by: Crimson Wizard on Thu 16/03/2017 09:23:16
Quote from: Snarky on Thu 16/03/2017 09:14:36
One thing that puzzles me a little: even if Mehrdad moves the character glyphs to other slots in the font, won't the font coding that combines different glyphs to make up a full character still refer to the old slots, so that as soon as you get into compound characters or ligatures, the whole thing will break?

That is a good question. I am not a big expert in TTFs, although I probably learnt a little more while researching this issue.

How these special Persian fonts work: they require you to type 2 characters for 1 letter, first character corresponding to "modification" symbol, and second character corresponding to "base" symbol.
(That special typing program converts some Persian letters to combinations of 2 characters)
"Modification" symbols in font are given offset properties, that actually make them overlap following character. They do not have exact reference to what chars they need to overlap, I guess that could be anything (even incorrect combinations).
Hope my explanation makes sense; I am not really aware of proper terminology for all this.
Title: Re: Please improve and increase slots from preview font pane
Post by: Crimson Wizard on Fri 17/03/2017 08:50:25
Just to make a little update, I decided to write a tiny utility program which will create a table of conversion between unicode font codes and ansi font codes. Because making such table by hand would be a chore.

My idea is to make a program that will analyze Unicode text, and converted ANSI text, and then write a table of correspondence between letter codes. This table is then used to modify letter codes in the font.

I guess this won't take long, but I need to find some free time.
Title: Re: Please improve and increase slots from preview font pane
Post by: Mehrdad on Fri 17/03/2017 12:22:38
Great news CW . Thanks a lot for this plan . I'm waiting for your good news  ;-D
Title: Re: Please improve and increase slots from preview font pane
Post by: Snarky on Fri 17/03/2017 14:59:53
So many hoops to jump through just because AGS doesn't support Unicode... :~(
Title: Re: Please improve and increase slots from preview font pane
Post by: Crimson Wizard on Fri 17/03/2017 15:50:33
Alright, here is the program.
https://www.dropbox.com/s/ua0jdrd9xlgshcl/TextConvMapMaker_Build.zip?dl=0

I do not think I will be able to do much more to it.

Instructions:
1. Type all the Persian letters (whole alphabet) in the ParsiNegar, and convert text to use for you font, as usual.
2. Copy resulting text into my program, in the big field.
3. Click "Create map". You will see the table of letter codes, first column is letter (in your case that would be "pseudo-letter" from ParsiNegar), second - original Unicode codepoint, third - codepoint in the ANSI encoding of your system.
4. For convenience you may click "Save table" - that will print this table into simple text file.

5. Use this table to modify Persian font in your favorite TTF editor. What you need to do is to change each letter's code, according to this table. For example, if table sais like:
some letter123445
Then you need to find a letter with code 1234, and change that code to 45 (or make a copy of letter and paste it into slot 45).
Title: Re: Please improve and increase slots from preview font pane
Post by: Mehrdad on Fri 17/03/2017 17:08:32
AWESOME !!!! . It seems works perfect . I replaced some letters in correct slots and now I have right words without any problem  ;-D
I only must improve all slots for start Farsi typing as 2th language after English in my game.

Many thanks, in advance, for your help and your great program

Mehrdad
Title: Re: Please improve and increase slots from preview font pane [Solved]
Post by: Mehrdad on Sat 18/03/2017 07:37:27
A little problem . I have equal number for different original codepoints . Where is my wrong ?

I think problem is choose Arabian unicode .  I can't see Persian unicode in list .

(http://uupload.ir/files/2zaw_similar.png) (http://uupload.ir/)
Title: Re: Please improve and increase slots from preview font pane [Solved]
Post by: Crimson Wizard on Sat 18/03/2017 13:14:42
Quote from: Mehrdad on Sat 18/03/2017 07:37:27
A little problem . I have equal number for different original codepoints . Where is my wrong ?
Not every Unicode letter can be converted to unique letters in ANSI automatically. If you have such letters, you would need to deal with them specially.

Quote from: Mehrdad on Sat 18/03/2017 07:37:27
I think problem is choose Arabian unicode .  I can't see Persian unicode in list .
As I was saying earlier, there is no ANSI codeset for Persian language in Windows.

That was the reason why I suggested to return your "Language for non-Unicode applications" to what you had before (English?). This setting is also used when you build your game in AGS.
Of course if you do that now, some codes may change and you need to edit font again.
Title: Re: Please improve and increase slots from preview font pane [Solved]
Post by: Mehrdad on Sat 18/03/2017 13:38:33
Quote from: Crimson Wizard on Sat 18/03/2017 13:14:42
Not every Unicode letter can be converted to unique letters in ANSI automatically. If you have such letters, you would need to deal with them specially.
But it's will be so hard by typing .Please see it :
   Ã Æ'   195    63
   Ã Å'   204    63
   Âº   186    63
   Ã¶   246    63
Quote
As I was saying earlier, there is no ANSI codeset for Persian language in Windows.

That was the reason why I suggested to return your "Language for non-Unicode applications" to what you had before (English?). This setting is also used when you build your game in AGS.
Of course if you do that now, some codes may change and you need to edit font again.

English is one of language my game and it's OK . Second is Persian . Sorry I don't understand . Did you mean I ignore it ? Or made a custom alphabet keyboard for Farsi ?
Title: Re: Please improve and increase slots from preview font pane [Solved]
Post by: Crimson Wizard on Sat 18/03/2017 14:02:42

Quote from: Mehrdad on Sat 18/03/2017 13:38:33
But it's will be so hard by typing .
Yes, it will be difficult. That is a problem with putting Unicode text into non-Unicode program, such as AGS.

The only thing I can suggest here is to first deal with simple letters, and then see how many free slots are there remaining in the font. If you still have free slots, you may use them for missing letters.
But if you do that, you will also have to change these letters in Parsi-Negar's texts.


Quote from: Mehrdad on Sat 18/03/2017 13:38:33
Quote from: Crimson Wizard on Sat 18/03/2017 13:14:42
As I was saying earlier, there is no ANSI codeset for Persian language in Windows.

That was the reason why I suggested to return your "Language for non-Unicode applications" to what you had before (English?). This setting is also used when you build your game in AGS.
Of course if you do that now, some codes may change and you need to edit font again.

English is one of language my game and it's OK . Second is Persian . Sorry I don't understand . Did you mean I ignore it ? Or made a custom alphabet keyboard for Farsi ?

No, that's not what I mean.
This setting "language for non-Unicode programs" is used when Unicode text is converted to non-Unicode. This is what AGS does, for example, when you put ParsiNegar's text in there, and then compile the game.
What I mean, is that different options may produce different results. I am suggesting to try changing it back to English and see if that reduces the number of letters that have same code.
I do not know if it will, but I think it's worth trying.
Title: Re: Please improve and increase slots from preview font pane [Solved]
Post by: Mehrdad on Sat 18/03/2017 18:07:54
OK . Finally done.

Your right CW . I back to English , Arabic ,.... and English was best result for "language for non-Unicode programs" option  . I improved all slots but 3 letters was complete missed without any rectangle slot even. So replaced to another slots that I don't need to them .

It seems works perfect now and ready to typing.

Thanks a lot for great advises.
Title: Re: Please improve and increase slots from preview font pane [Solved]
Post by: Mehrdad on Thu 23/03/2017 07:51:46
I have an issue with line break Farsi fonts for long words .Please see this example :
player.Say("!kLvaà‚¶ Iµ{ ¾M Iàâ,¬Â·A à‚ThL{¼i , kàÆ'¹¨à‚¶ à‚ºI¶jI{ pHoMH o«Ã,,j o#º ¦Ã,, à‚ThL{¼i pH à‚T¤» .ànA");

After run game it show :  o«Ã,,j o#º ¦Ã,, à‚ThL{¼i pH à‚T¤» .ànA    under    ¾M Iàâ,¬Â·A à‚ThL{¼i , kàÆ'¹¨à‚¶ à‚ºI¶jI{ pHoMH

I changed place two words and result was worse .

How AGS do it ? Is it any way for manually set break long words ?
Title: Re: Please improve and increase slots from preview font pane [Solved]
Post by: Crimson Wizard on Thu 23/03/2017 08:04:57
Quote from: Mehrdad on Thu 23/03/2017 07:51:46
How AGS do it ? Is it any way for manually set break long words ?

This is a common issue with autobreak, AFAIK AGS is breaking at nearest space character. But you can use '[' character to set line break.
Title: Re: Please improve and increase slots from preview font pane [Solved]
Post by: Mehrdad on Thu 23/03/2017 11:58:34
Quote from: Crimson Wizard on Thu 23/03/2017 08:04:57
This is a common issue with autobreak, AFAIK AGS is breaking at nearest space character. But you can use '[' character to set line break.

OK. Thanks. It's seems good when player stand on middle screen but in edges I have a messy words  :(