|
Post by jaloman on Dec 8, 2015 17:41:20 GMT -8
Hi, great to member of gameduino community.
I want to design a user interface with 480x272 in portrait and show chinese font. but the asset tool can not convert chinese font, so maybe i can use font like sprite. gd2 do not have tool for convert sprite, what can i do ?
anyone have experience on this ?
|
|
|
Post by jamesbowman on Dec 9, 2015 6:28:38 GMT -8
Hi Jaloman, welcome! Yes, you are correct. The "font" tools are only suitable for font with ASCII characters 32-127. For Chinese and Japanese the best way would be to load each character as it is required, just like sprites. This thread talks about the way to load sprites: gameduino2.proboards.com/thread/127/bitmap-cells-frustrationSo I am thinking of an "Xf" package to handle e xtended fonts. The character data would be on SDcard. Then a single method "Xf.text()" translates from UTF-8 characters to unicode, and loads the unicode characters as sprites from SDcard. #include <EEPROM.h> #include <SPI.h> #include <GD2.h>
void setup() { GD.begin(); Xf.begin("cn-24x24"); // Chinese 24x24 }
void loop() { GD.ClearColorRGB(0x103000); GD.Clear(); GD.cmd_text(240, 136, Xf.font, OPT_CENTER, Xf.text("你好,世界")); GD.swap(); } I think this would be an excellent demo -- I would be very happy to work with you on this. Do you have a Chinese or Japanese bitmap set in mind?
|
|
|
Post by jaloman on Dec 9, 2015 12:25:21 GMT -8
Dear James, Thanks for your kindly advice, it would be great with unicode support on gd2. there are a lot of font extractor tools(dot matrix)out there help to get even a full unicode font.bin. by now, with the sprite support will fullfill me request. but I can not make asset python or sprite tool work.
IOError: cannot identify image file 'G:\\Gameduino2\\gd2asset\\sprite.png'
|
|
|
Post by jaloman on Dec 9, 2015 19:35:34 GMT -8
IOError issue resolved by change "import Image" to "from PIL import Image"
here is the modified py
from PIL import Image import gameduino2 as gd2
class Walk(gd2.prep.AssetBin):
def addall(self): walk = gd2.prep.split(32, 32, Image.open("walk.png"))[1:] self.load_handle("WALK", walk, gd2.ARGB1555)
if __name__ == '__main__': Walk().make()
but can I rotate clockwise 90 degree on each sprite when convert ?
|
|
|
Post by jaloman on Dec 15, 2015 1:38:09 GMT -8
modify walk.py for my font.png which is 22x24 per character in serial, ARGB2, transparent color set to background
------------------------------------------------------------------------------- from PIL import Image import gameduino2 as gd2
class Walk(gd2.prep.AssetBin):
def addall(self): walk = gd2.prep.split(22, 24, Image.open("FONT.png"))[0:] self.load_handle("FONT", walk, gd2.ARGB2)
if __name__ == '__main__': Walk().make()
------------------------------------------------------------------------------- and add rotate to split(tw, th, im) in prep.py for my portrait screen layout
------------------------------------------------------------------------------- def split(tw, th, im): tiles = [] for y in range(0, im.size[1], th): for x in range(0, im.size[0], tw): nim = im.crop((x, y, x + tw, y + th)); nim2 = nim.transpose( Image.ROTATE_270 ) tiles.append(nim2) return tiles -------------------------------------------------------------------------------
|
|
|
Post by jaloman on Dec 15, 2015 1:42:41 GMT -8
please find attached font.png for reference simply use it as sprite to show japan font in portrait GD.Begin(BITMAPS); GD.Vertex2ii(420, 67, FONT_HANDLE, 39); Attachments:
|
|
BrewBot
Junior Member
busy
Posts: 21
|
Post by BrewBot on Sept 25, 2019 8:33:35 GMT -8
Hello Everyone
Can you comment whether any improvements on the above methods have been made? Looking to translate an English program I have written into Japanese and want to do so in the most efficient manner possible.
Jason
|
|