Displaying japanese characters in homebrews
Displaying japanese characters in homebrews
Hi all,
does exist a way to display japanese language in homebrew ? i would like to make a japanese version of my homebrew...
thanx for your help
Pacopad
does exist a way to display japanese language in homebrew ? i would like to make a japanese version of my homebrew...
thanx for your help
Pacopad
For inputing you could just use the built-in input dialog. If you are interested I figured out which "unknown" option you need to set to 1 to get the input method working (so you can type kanji).
As for displaying Japanese text, you could always use a character map texture for hiragana and/or katakana like you would for normal ASCII. If you want anything more complex I would say you have to use freetype (method I used) or SDL_ttf with a Japanese ttf font. I was able to pass it each Japanese character in UTF-16/UCS2 encoding which ended up the same value as the unicode code point. As a side effect, if you use UTF-16/UCS2 for encoding, you can pass it directly to the built-in input dialog and back again. The last method would be static images for all your text but I doubt that is what you wanted.
As for displaying Japanese text, you could always use a character map texture for hiragana and/or katakana like you would for normal ASCII. If you want anything more complex I would say you have to use freetype (method I used) or SDL_ttf with a Japanese ttf font. I was able to pass it each Japanese character in UTF-16/UCS2 encoding which ended up the same value as the unicode code point. As a side effect, if you use UTF-16/UCS2 for encoding, you can pass it directly to the built-in input dialog and back again. The last method would be static images for all your text but I doubt that is what you wanted.
Hi plebihan,
I'm just about to finish a little library (called intraFont) which let's you use the PSPs internal fonts:
As you can see it can also render japanese characters (these are random, I do not know what they mean!). Before I finalize it maybe you or somebody else can help me:
How do you program a japanese string in C (using UCS-2)? As an array of unsigned short? What would a typical "Hello World" string in japanese look like?
Thanks, BenHur
Edit: updated screenshot (thanks to CpuWhiz the Japanese text now has a meaning)
I'm just about to finish a little library (called intraFont) which let's you use the PSPs internal fonts:
As you can see it can also render japanese characters (these are random, I do not know what they mean!). Before I finalize it maybe you or somebody else can help me:
How do you program a japanese string in C (using UCS-2)? As an array of unsigned short? What would a typical "Hello World" string in japanese look like?
Thanks, BenHur
Edit: updated screenshot (thanks to CpuWhiz the Japanese text now has a meaning)
Last edited by BenHur on Wed Nov 14, 2007 9:16 am, edited 2 times in total.
-
- Posts: 328
- Joined: Sun Jun 03, 2007 10:05 pm
Nice..BenHur wrote:Hi plebihan,
I'm just about to finish a little library (called intraFont) which let's you use the PSPs internal fonts:
As you can see it can also render japanese characters (these are random, I do not know what they mean!). Before I finalize it maybe you or somebody else can help me:
How do you program a japanese string in C (using UCS-2)? As an array of unsigned short? What would a typical "Hello World" string in japanese look like?
Thanks, BenHur
But How can we verify the authenticity, my eyes hint at P.S. :(?
[seeing it's a publically available font]
Intrigued by PSP system Since December 2006.
Use it more for Development than for Gaming.
Use it more for Development than for Gaming.
Sorry, I don't understand (my first language isn't Enlish):KickinAezz wrote: Nice..
But How can we verify the authenticity, my eyes hint at P.S. :(?
[seeing it's a publically available font]
- what authenticity? what's a P.S. ?
- do you mean the PSPs internal font is publically available? I thought some japanese company and Sony own the rights to it.
BenHur
That looks nice, hope you release it soon :)BenHur wrote:Hi plebihan,
I'm just about to finish a little library (called intraFont) which let's you use the PSPs internal fonts:
As you can see it can also render japanese characters (these are random, I do not know what they mean!). Before I finalize it maybe you or somebody else can help me:
How do you program a japanese string in C (using UCS-2)? As an array of unsigned short? What would a typical "Hello World" string in japanese look like?
Thanks, BenHur
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki
Alexander Berl
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki
Alexander Berl
An array of unsigned shorts encoded with UTF-16LE works good. I have been using libxml2 and iconv to parse xml files into a simple binary file with UTF-16LE strings that I load into an array. I load a different file per language. It's working for what I need.
You could use this for "Hello World": こんにちは世界
For those who don't have Japanese fonts:
Here is how it would be encoded in hex (I just used recode and hexdump on the command line):
This is what I mean:
When you start typing hiragana/katakana and press triangle, it underlines the word and you get a selection of possible kanji for that word. I noticed this feature when I was entering a character name from the Japanese version of Tales of the World: Radiant Mythology. Anyway, to make a long story short, I used a memory dump of the game, searched for the string displayed in the dialog, and used a little math to figure out how they enabled it:
If you want my modified dialog sample: http://www.revworld.org/~cpuwhiz/psp/oskdialog.tar.gz
You could use this for "Hello World": こんにちは世界
For those who don't have Japanese fonts:
Here is how it would be encoded in hex (I just used recode and hexdump on the command line):
Code: Select all
3053 3093 306b 3061 306f 4e16 754c 0000
When you start typing hiragana/katakana and press triangle, it underlines the word and you get a selection of possible kanji for that word. I noticed this feature when I was entering a character name from the Japanese version of Tales of the World: Radiant Mythology. Anyway, to make a long story short, I used a memory dump of the game, searched for the string displayed in the dialog, and used a little math to figure out how they enabled it:
Code: Select all
osk.unk_00 = 1; // Enable IME
Here it is: intraFont - version 0.1Raphael wrote:That looks nice, hope you release it soon :)
http://rapidshare.com/files/69530117/in ... 1.zip.html
It's still in an early stage (not everything implemented and probably a few bugs), but it works. The archive contains samples for GU and graphics.h - just look at them to see how to use intraFont and read the readme.
(If you used pgeFont by InsertWittyName (http://insomniac.0x89.org) before: you'll feel right at home since intraFont uses parts of pgeFont - but intraFont doesn't need the freetype library!)
Have fun and let me know your comments,
BenHur
@CpuWhiz: Thank you for your nice explanation. It's exciting to write something in a language I have no clue whatsoever! :-)
Wow! This REALLY works well! I've already put it in my app and it looks fantastic - night and day difference. One thing, it's not as useful without the text width function, so I went ahead and implemented and tested it for you. :)BenHur wrote:Here it is: intraFont - version 0.1Raphael wrote:That looks nice, hope you release it soon :)
http://rapidshare.com/files/69530117/in ... 1.zip.html
It's still in an early stage (not everything implemented and probably a few bugs), but it works. The archive contains samples for GU and graphics.h - just look at them to see how to use intraFont and read the readme.
(If you used pgeFont by InsertWittyName (http://insomniac.0x89.org) before: you'll feel right at home since intraFont uses parts of pgeFont - but intraFont doesn't need the freetype library!)
Have fun and let me know your comments,
BenHur
@CpuWhiz: Thank you for your nice explanation. It's exciting to write something in a language I have no clue whatsoever! :-)
Code: Select all
int intraFontMeasureText(intraFont *font, const char *text) {
if (!text || strlen(text) == 0 || !font) return 0;
unsigned short* ucs2_text = (unsigned short*)malloc((strlen(text)+1)*sizeof(unsigned short));
if (!ucs2_text) return 0;
int i;
for (i = 0; i < strlen(text); i++) ucs2_text[i] = text[i];
ucs2_text[i] = 0;
i = intraFontMeasureTextUCS2(font, ucs2_text);
free(ucs2_text);
return i;
}
int intraFontMeasureTextUCS2(intraFont *font, const unsigned short *text) {
if(!font) return 0;
int i;
int length = 0;
int x = 0;
float glyphscale = font->size;
while (text[length] > 0) length++;
if (length == 0) return 0;
for(i = 0; i < length; i++) {
unsigned short char_id = intraFontGetID(font,text[i]);
if (char_id >= font->n_chars) char_id = 0;
Glyph *glyph = &(font->glyph[char_id]);
if (!(glyph->flags & PGF_CACHED)) {
intraFontGetBMP(font,char_id,PGF_CHARGLYPH);
}
x += ((font->options & INTRAFONT_FIXEDWIDTH) ? font->advancex*0.5f : glyph->advance) * glyphscale / 4.0;
}
return x;
}
-
- Posts: 328
- Joined: Sun Jun 03, 2007 10:05 pm