Feature request: ASCII accented characters

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

Previous topic - Next topic

Radiant

- suggestion: when displaying a SCI-font, it would be easy to add support for extended characters (German and French accented letters, in particular). These correspond to ASCII codes 128-140 roughly. It seems to be easy to modify the WFN font format to support 140 characters rather than 128, or alternatively the game could use the characters 0-32 instead, which are currently unused (i.e. char % 128). Both SCI studio and Radiant FontEdit allow editing these. This would be helpful to all people making translations of games.

For instance I've added accented characters to this font file: agsfnt0

Pumaman

Sounds a reasonable enough request, I'm not sure why I never implemented this. I'll add it to my list.

rtf

I'd like to take a look at that... list... ;)
I fail at art.

Gilbert

#3
It's called FUTURE.TXT in the docs folder...

The docs folder is included only in final releases (ie, you don't find them in beta versions).

That list may not be updated though, but just read ALL of its content.

Also, you may check this.

strazer

Quotethe game could use the characters 0-32 instead

I'm in the middle of editing a font and I was wondering about these (mostly empty) characters.
What is/was their purpose? How will we be able to display them?

Btw, what is the naming convention for SCI font files? I don't get the numbering thing.

Radiant

They're control characters, actually, but obsolete in most applications.
For instance, character 13 = return, character 10 = line feed, char 27 = escape, 9 = tab, 8 = backspace.
Also they had funky graphics used in many dos-based ASCII games: 1 = smile, 2 = bright smile, 3-6 = clubs/spades/hearts/diamonds, etc.
Currently, AGS can display characters 1-31 with no problems, however the text editor used for scripting cannot really handle them well.

SCI font files are named FONT.### where ### is some number. I'm not sure why this convention was chosen, I would have named them ###.FNT myself. I believe AGS can import them regardless of name.


strazer

I see, the position of the characters in the SCI font correspond to a normal ASCII table. I've never noticed that... :P

QuoteCurrently, AGS can display characters 1-31 with no problems, however the text editor used for scripting cannot really handle them well.

So how do you use one of these at the moment? As you say, they are control characters so they aren't displayed in the script editor.

Gilbert

I never tried, but maybe it works in the "hard" way.

Like:

Display("%c is a special character", 12);

strazer


Gregjazz

By the way, does AGS support extended characters in TTF fonts? For example, if I import a Chinese TTF font into AGS, will it be able to display the characters?

strazer

I would say Yes.
The error message if you try to use extended characters with an SCI font reads:

"(Accented characters, for example the special French and German e/a/u/i letters cannot be used by default. You need to import a TTF font to do so)."

I don't know how hard it is to create a good-looking TTF with a proper accompanying outline font though.

Gilbert

No, I assure you.

AGS cannot display double-byted characters, and there won't be many people who would use it anyways.

strazer

#12
Ok, so I was going to write myself a function that replaces any special characters in the supplied string with characters 1-31 from my font.

This is what I have so far:

function StrCharConv(string buffer) {
  int charpos; // stores character position

  charpos = StrContains(buffer,"ä"); // search for special character Ã,, or ä in supplied string
  if (charpos > -1) { // special character found
   if (StrComp(xxx,"Ã,,") == 0) // special character is uppercase
      StrSetCharAt(buffer,charpos,3); // replace with character standing in for Ã,,
   else // special character is lowercase
      StrSetCharAt(buffer,charpos,4); // replace with character standing in for ä
   charpos = -1; // reset search result
  }

  // more replacements to come
}

xxx: How can I return one character as a string for this comparison?
StrGetCharAt(buffer,charpos) returns char format only.

Of course it would be easiest if there were a case-sensitive StrContains function.
I thought I'd ask first before I write a more complicated function that disassembles and later reassembles the string.

Gilbert

#13
Quote
xxx: How can I return one character as a string for this comparison?
Try the hard way:
StrFormat(tmpstr,"%c",StrGetCharAt(buffer,charpos);

So:

function StrCharConv(string buffer) {
  int charpos; // stores character position

  charpos = StrContains(buffer,"ä"); // search for special character Ã,, or ä in supplied string
  if (charpos > -1) { // special character found
  StrFormat(tmpstr,"%c",StrGetCharAt(buffer,charpos);
   if (StrComp(tmpstr,"Ã,,") == 0) // special character is uppercase
      StrSetCharAt(buffer,charpos,3); // replace with character standing in for Ã,,
   else // special character is lowercase
      StrSetCharAt(buffer,charpos,4); // replace with character standing in for ä
  }

  // more replacements to come
}



Quote
Of course it would be easiest if there were a case-sensitive StrContains function.
I'm not sure (as I never type accented characters and I don't know how anyways), but maybe the case-insensitiveness applies only to the standard A-Z alphabets, so accented characters in different cases maybe be considered different already, you may need to experiment though.


Ah there's a yet easier way (I won't write the full codes now, I think you understand it):
if (StrGetCharAt(buffer,charpos)=='Ã,,')  { blah bla bla

Note: A character is a one byte integer, so you can use = and == directly.

strazer

QuoteTry the hard way

Oh right, you had shown me already. I should have known that...Sorry. :-[

Quoteaccented characters in different cases maybe be considered different already

My, you're right. Why do I complicate things so much?

Ok, here's what I have now:

function StrCharConv(string buffer) {
  int charpos=-1; // stores character position
  
  charpos = StrContains(buffer,"Ã,,"); // search for uppercase character
  while (charpos != -1) { // start loop to replace ALL occurrences of this character
   StrSetCharAt(buffer,charpos,3); // replace with character standing in for Ã,,
   charpos = StrContains(buffer,"Ã,,"); // check for next occurrence
  } // exit loop if no further occurrences found

  // more replacements here
}


Thanks for your help, Gilbert!
If you don't have any further suggestions, I'll go with this one.

Gilbert

#15
Heh did you read my "easier" way after edit? ;)

Nice word for the much more compact codes.

strazer

Yes, I have. Thanks, I'll remember that. :)

But what do you mean by
QuoteA character is a one byte integer, so you can use = and == directly.
? Could you please give an example?

Gilbert

I just mean that unlike strings, you can manipulate char variables like integers, and use them ambigorously, like for example:

char tmpchar='A';



tmpchar+=2; //will make tmpchar into 'C'

Orieac

#18
This was a great help. I notice that letter 0 can't be used.
But if we have many cases to change this may not be easy to edit/read. I made a small chance to the code.



function StrCCAux(string bf, string letter, int cs) {Ã, 
int charpos=-1; // stores character position
//Ã,  Ã, 
charpos = StrContains(bf,letter); // search for uppercase characterÃ, 
while (charpos != -1) { // start loop to replace ALL occurrences of this characterÃ,  Ã, 
StrSetCharAt(bf,charpos,cs); // replace with character standing inÃ,  Ã, 
charpos = StrContains(bf,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
}

strazer

Good idea!

I've abandoned this since you can't use it with dialog scripts and I decided to just use a TTF font instead.
My main gripe with TTF fonts was that it's hard to find a font with a fitting accompanying outline font. I don't like the look of the automatic outlining feature so I'm in the process of making a fixed-size TTF font & outline myself. Works great so far.

SMF spam blocked by CleanTalk