Feature request: ASCII accented characters

Started by Radiant, Mon 19/04/2004 13:49:40

Previous topic - Next topic

monkey0506

It could work if someone wrote their own dialog system... ::)


Orieac

#22
I thought i had the problem solved but i was not right. I can replace accented characters with ASCII 1-31 if the text is in the script. If i use a traslation file this doesn't work anymore. I think AGS only changes the string with the translated one when showed on screen. Every other functions use the original string.


I have a question for Chris Jones: Is it possible to increase the priority of the suggestion, http://www.adventuregamestudio.co.uk/tracker.php?action=detail&id=119
If not is it possible to change the way AGS uses translated text? Because if i want to display the text centered i can't get the translated text width.

Thanks in advance
orieac

Edit: I would like to remake an old game and i would like to keep the original bitmap font.
Edit2: I will try GetTranslation (string original).
Edit3: I found the error. AGS was complaining about accents, but the problem was an empty string.

Pumaman

Does Radiant FontEdit allow creating SCI fonts with more than 128 characters? It's all very well if I was to add support for it to AGS, but if nobody could create the fonts then there'd be no point.

Traveler

I just tried it, and it doesn't seem to. It shows 128 characters when opening a file (unless I missed something on its UI.)

Just an idea: how hard would it be to implement characters by using sprites? One could load all character sprites and in AGS specify a sprite-character mapping table. So I'd say:

'm' -> Sprite 109
'B' -> Sprite 110
'A' -> Sprite 111
etc.

in any order. Then during runtime, the engine would just lookup each sprite for each character or draw a default black rectangle if there is no sprite associated for a character. This would allow for effects on each letter (like different colors, etc.) of a character and everyone could use any graphics in place of each character.

I don't know, if this would be hard to implement, or if even anyone would use it. Just an idea :)


Radiant

Quote from: Pumaman on Sun 24/04/2005 12:37:25
Does Radiant FontEdit allow creating SCI fonts with more than 128 characters? It's all very well if I was to add support for it to AGS, but if nobody could create the fonts then there'd be no point.

Not presently, but it would be trivial to modify it so.

Orieac

Quote from: Radiant on Mon 25/04/2005 11:21:05

Not presently, but it would be trivial to modify it so.



Could it be possible to open the new sci fonts. i think some of then already have accents.

http://freesci.linuxgames.com/scihtml/x2345.html#AEN2349
Quote from: Freesci_doc

The SCI font resource
SCI font resources remained unchanged during the SCI revisions and were still used in SCI32. Their format is relatively straightforward and completely sufficient for any 8 or even 16 bit character table:


Table 3-1. The SCI font resource data structure

Offset Type Meaning
0 16 bit integer, little endian encoding Always zero (?)
2 16 bit integer, little endian encoding NUMCHAR: Number of characters
4 16 bit integer, little endian encoding HEIGHT: Number of pixel lines per text line
6 + NR * 2 16 bit integer, little endian encoding Absolute offset of the character #NR, where 0 <= NR < NUMCHAR


HEIGHT does not affect the height of a character, though- it only tells the interpreter how far to move downwards when displaying a line of text. The characters referenced to starting at offset 6 are encoded as follows:

Table 3-2. The SCI font resource character data structure

Offset Type Meaning
0 unsigned 8 bit integer character HEIGHT
1 unsigned 8 bit integer character WIDTH
2... bitmask, size HEIGHT * round_up(WIDTH / 8) Bitmask for the character

The bitmap consists of HEIGHT lines of n bytes, where n equals the number of bytes required for storing WIDTH bits. Data is stored with the MSB first, in little-endian encoding (first byte describes the 8 leftmost pixels), where a pixel is drawn iff the bit it corresponds to is set.

Orieac

Quote from: Pumaman on Sun 24/04/2005 12:37:25
Does Radiant FontEdit allow creating SCI fonts with more than 128 characters? It's all very well if I was to add support for it to AGS, but if nobody could create the fonts then there'd be no point.

So Radiant can improve fontedit. Can we see this feature after the final release of AGS 2.7?

Pumaman

I will certainly consider it for a future version.

Radiant

Quote from: Orieac on Mon 25/04/2005 16:05:10
Could it be possible to open the new sci fonts. i think some of then already have accents.

I've seen SCI fonts with accents, but they tend to use the first 32 characters for that. I've never come across a 256-char SCI font, if you have one please send it to me. Reading it would be easy.

Orieac

Quote from: Radiant on Thu 28/04/2005 08:05:53

I've seen SCI fonts with accents, but they tend to use the first 32 characters for that. I've never come across a 256-char SCI font, if you have one please send it to me. Reading it would be easy.


I have some sci fonts with accents. But since fontedit can't open then i really can't say if the font has 256 char.  But have a look at the ones from the french version of SQ5, http://www.geocities.com/orieac/FontSQ5FREN.zip

Orieac

Quote from: Pumaman on Sun 24/04/2005 12:37:25
Does Radiant FontEdit allow creating SCI fonts with more than 128 characters? It's all very well if I was to add support for it to AGS, but if nobody could create the fonts then there'd be no point.

Sorry to come back with this but i had another sugestion. In AGS we can use an outline font with another one (two fonts). I think an easy way to support the other 128 caracters could be using another font. I think this don't require too many changes in AGS engine, and we can use the available version of fontedit.

Orieac

Orieac

I was updating some functions to ags 2.71rc1 but found one problem. How can i change a String with a custom function? I've made the following changes:


function StrCCAux(String bf, const string letter, int cs) {Ã, 
int charpos=-1; // stores character position
//Ã,  Ã, 
charpos = bf.Contains(letter); // search for uppercase characterÃ, 
while (charpos != -1) { // start loop to replace ALL occurrences of this characterÃ,  Ã, 
st=st.ReplaceCharAt(charpos,cs); // replace with character standing inÃ,  Ã, 
charpos = bf.Contains(letter); // check for next occurrenceÃ, 
} // exit loop if no further occurrences foundÃ, 
}

function StrCharConv(String buffer) {
StrCCAux(buffer, "á", 1);
StrCCAux(buffer, "à ", 2);
StrCCAux(buffer, "ã", 3);
StrCCAux(buffer, "â", 4);
// more cases
StrCCAux(buffer, "à", 12);
StrCCAux(buffer, "àâ,¬", 13);
StrCCAux(buffer, "àÆ'", 14);
StrCCAux(buffer, "àÆ'", 15);
// more cases
}

My problem is that when StrCCAux ends, StrCCAux returns the same String. How don't know how do they work in Java/C#. Who can StrCCAux change the String?

strazer

Quote
st = st.ReplaceCharAt(charpos,cs); // replace with character standing in   

Where does "st" come from? Shouldn't it be "bf"?

If

Code: ags

bf = bf.ReplaceCharAt(charpos,cs); // replace with character standing in   


doesn't work, try:

Code: ags

String changed = bf.ReplaceCharAt(charpos,cs); // replace with character standing in  
bf = changed;

Orieac

This is what i have now:

Quote
function StrCCAux(String st,const string letter, int cs) {Ã, 
int charpos=-1; // stores character position
charpos = st.Contains(letter); // search for characterÃ, 
while (charpos != -1) { // start loop to replace ALL occurrences of this characterÃ,  Ã, 
Ã,  Ã,  Ã,  String changed=st.ReplaceCharAt(charpos,cs); // replace with character standing in
Ã,  Ã,  Ã,  st = changed;Ã,  Ã, 
Ã,  Ã,  Ã,  charpos = st.Contains(letter); // check for next occurrenceÃ, 
} // exit loop if no further occurrences foundÃ, 
Display(st);
}


Display(st) shows that the String st has changed. But when the function ends the changes aren't saved (i get the old String). This worked with the old strings, but now i don't know where is the problem.Ã,  ???

Scorpiorus

#36
Yes, the problem has to do with a way the new Strings are handled. Since a String is a constant and can't be changed the .ReplaceCharAt() function creates a new instance of String instead. You catch the string with the "st" pointer variable but it's declared as a local one (ie. within the function body). When function ends "st" is discared along with the changed String as well.

Therefore, you can either set up a global pointer to changed String (I would not recommend this) or, what is much clearer, have the function do actually return modified String:

String StrCCAux(String st,const string letter, int cs) {
   int charpos=-1;
   charpos = st.Contains(letter);
   while (charpos != -1) {
      st=st.ReplaceCharAt(charpos,cs);
      charpos = st.Contains(letter);
   }

   return st;
}


Then you can catch it from within the caller function as follows:

function StrCharConv(String buffer) {

   buffer = StrCCAux(buffer, "á", 1);
   ...
}


EDIT:

Oh by the way, if StrCharConv is also supposed to change and then return String buffer it has to be altered in the very same way, ie...

String StrCharConv(String buffer) {

   buffer = StrCCAux(buffer, "á", 1);
   ...

   return buffer;
}

So that its caller could in turn receive changes too.

Orieac

Quote from: Scorpiorus on Thu 06/10/2005 17:21:02
String StrCCAux(String st,const string letter, int cs) {

This doen'st work. The problem is the String before the function name.
I have now the error: The variable 'int' is already defined

I thought that in AGS a function could only return an integer.

Scorpiorus

#38
Just replace "function" with "String". By the way in AGS "function" stands for "int" ;)

[Edit]: And if you have the import declaration in the header script it needs to be changed too:

import String StrCCAux(String st,const string letter, int cs);

So "String" instead of "function".

Orieac

Quote from: Scorpiorus on Thu 06/10/2005 18:17:17
Just replace "function" with "String". By the way in AGS "function" stands for "int" ;)
That was the error. I added String before function  ;D  ;D Thanks.
It's now working again.

SMF spam blocked by CleanTalk