1. Kanji bit-mapped font
- Posted by Craig Welch <euphoria at welchaviation.org> Jul 02, 2004
- 613 views
I've written a little program to drill kanji characters as I learn them. It works just fine, and I've been pleased to see that EDS handles unicode just fine, and Tommy Carlier's unicode file handling was very useful. Matt Lewis' EDS browser has been invaluable as well. I'm using IDE and Win32Lib on Windoze 98. To display kanji characters, I use a third party program, from NJStar, which provides both an IME and a trapped display capability. Thus if I display "真", the relevant kanji will be displayed. The problem with that is that the 3P program uses its own fonts, and they don't scale up well. If I set the font size in the field into which I output the characters to a high size (24, say) I'll get a large character, but badly rendered. It doesn't matter what font I choose for the field, that's not what is used. I would like to use bitmap fonts, as many of the commercial programs of the same type do. An example font might be ftp://ftp.cc.monash.edu.au/pub/nihongo/asiya24.zip. But I'm at a loss as to how to do this in Euphoria/Windoze. These are not Windoze fonts, so it's not just a matter of doing a Windoze instal. I need to read the font, and render it into a field ... or straight onto the window, I guess. Any insights or suggestions? TIA, -- Craig
2. Re: Kanji bit-mapped font
- Posted by Tommy Carlier <tommy.carlier at pandora.be> Jul 02, 2004
- 575 views
Instead of using a bitmap font directly, you could create a bitmap-file (in MSPaint), type in all the characters there and save it to a BMP-file. In your program that needs to display the characters, just load the BMP-file and blit the appropriate region for a character to your window. -- tommy online: http://users.pandora.be/tommycarlier Euphoria Message Board: http://uboard.proboards32.com
3. Re: Kanji bit-mapped font
- Posted by Craig Welch <euphoria at welchaviation.org> Jul 02, 2004
- 570 views
Tommy Carlier wrote: > > Instead of using a bitmap font directly, you could create a bitmap-file (in > MSPaint), > type in all the characters there and save it to a BMP-file. In your program > that needs > to display the characters, just load the BMP-file and blit the appropriate > region for > a character to your window. That's a way I hadn't thought of, thanks. Only problem is, there are about 3,000 characters! -- Craig
4. Re: Kanji bit-mapped font
- Posted by rudy toews <rltoews at ilos.net> Jul 02, 2004
- 545 views
Hi Craig http://babel.uoregon.edu/yamada/fonts.html i keyed in "font library" in my search engine . the above is one of the results. it also has Klingon. there is some places that have free fonts too. divide the problem and conquer. 3000 / 10 chars/day = 300 days / 10 people = 30 days. look out : i am thinking again. how the characters are built? is there actually only 16 different pen strokes? save only the different strokes first and then have everybody chip in to build the characters. it would probably have to be local people who are looking at the same data (book?) you have. rudy
5. Re: Kanji bit-mapped font
- Posted by irv mullins <irvm at ellijay.com> Jul 02, 2004
- 563 views
Craig Welch wrote: > But I'm at a loss as to how to do this in Euphoria/Windoze. These are not > Windoze fonts, so it's not just a matter of doing a Windoze instal. I need > to read the font, and render it into a field ... or straight onto the > window, I guess. Take a look at: http://user.dtcc.edu/~berlin/font/japanese.htm These are TTF which look very good as big as 72 pt. The only drawback is if you are planning to sell your program, you'll need written permission to use the fonts. Regards, Irv
6. Re: Kanji bit-mapped font
- Posted by Craig Welch <euphoria at welchaviation.org> Jul 03, 2004
- 577 views
rudy toews wrote: > > > Hi Craig > > http://babel.uoregon.edu/yamada/fonts.html > > i keyed in "font library" in my search engine . > the above is one of the results. it also has Klingon. > there is some places that have free fonts too. Thanks Rudy, The issue for me is not availabilty of fonts. I have plenty of Japanese fonts. It's how to render a bitmap font in my Euphoria application. -- Craig
7. Re: Kanji bit-mapped font
- Posted by Craig Welch <euphoria at welchaviation.org> Jul 03, 2004
- 583 views
irv mullins wrote: > > Craig Welch wrote: > > > But I'm at a loss as to how to do this in Euphoria/Windoze. These are not > > Windoze fonts, so it's not just a matter of doing a Windoze instal. I need > > to read the font, and render it into a field ... or straight onto the > > window, I guess. > > Take a look at: > http://user.dtcc.edu/~berlin/font/japanese.htm > > These are TTF which look very good as big as 72 pt. > The only drawback is if you are planning to sell your program, > you'll need written permission to use the fonts. Thanks Irv, Truetype fonts don't work. They're fine in Microsoft applications such as Office, but won't work in my Euphoria application. Hence my search for a way to render a bitmap font. -- Craig
8. Re: Kanji bit-mapped font
- Posted by Derek Parnell <ddparnell at bigpond.com> Jul 03, 2004
- 562 views
Craig Welch wrote: > > irv mullins wrote: > > > > Craig Welch wrote: > > > > > But I'm at a loss as to how to do this in Euphoria/Windoze. These are not > > > Windoze fonts, so it's not just a matter of doing a Windoze instal. I need > > > to read the font, and render it into a field ... or straight onto the > > > window, I guess. > > > > Take a look at: > > <a > > href="http://user.dtcc.edu/~berlin/font/japanese.htm">http://user.dtcc.edu/~berlin/font/japanese.htm</a> > > > > These are TTF which look very good as big as 72 pt. > > The only drawback is if you are planning to sell your program, > > you'll need written permission to use the fonts. > > Thanks Irv, > > Truetype fonts don't work. They're fine in Microsoft applications such as > Office, but won't work in my Euphoria application. Hence my search for a > way to render a bitmap font. You can simply write a True-Type font to a bitmap in RAM and then render that on the screen. Here is starting point for you. It creates 26 bitmaps, from "A" to "Z" in Times New Roman font at 200 point. ---------------------- without warning include win32lib.ew constant pm = create(Pixmap, "", 0, 0,0, 1,1, 0) procedure DoLetter(sequence pText) sequence lTextRect -- printf(1, "%s\n", {pText}) lTextRect = getTextExtent(pm,pText) setCtlSize(pm, lTextRect[3], lTextRect[4]) setBackColor(pm, BrightWhite) setPenColor(pm,Black) wPuts({pm, 0, 0}, pText) VOID = copyToBitmapFile(pm, pText[1] & ".bmp", 0, 0, lTextRect[3], lTextRect[4]) end procedure setFont(pm, "Times New Roman", 200, 0) for i = 'A' to 'Z' do DoLetter({i}) end for ---------------------- -- Derek Parnell Melbourne, Australia
9. Re: Kanji bit-mapped font
- Posted by irv mullins <irvm at ellijay.com> Jul 03, 2004
- 585 views
Craig Welch wrote: > Truetype fonts don't work. They're fine in Microsoft applications such as > Office, but won't work in my Euphoria application. Hence my search for a > way to render a bitmap font. TT fonts work fine with Euphoria on Linux. I can't think of any reason they wouldn't also work with Windows. I don't know why you would need bitmaps. Maybe we need more details. Irv
10. Re: Kanji bit-mapped font
- Posted by Bernard Ryan <xotron at bluefrog.com> Jul 03, 2004
- 565 views
Craig: What format is the file asiya24.fnt using and how can it be viewed ? Bernie
11. Re: Kanji bit-mapped font
- Posted by Craig Welch <euphoria at welchaviation.org> Jul 04, 2004
- 589 views
Derek Parnell wrote: > > Truetype fonts don't work. They're fine in Microsoft applications such as > > Office, but won't work in my Euphoria application. Hence my search for a > > way to render a bitmap font. > > You can simply write a True-Type font to a bitmap in RAM and then render > that on the screen. Here is starting point for you. It creates 26 bitmaps, > from "A" to "Z" in Times New Roman font at 200 point. Thanks Derek, I'll have a play with that later today. It will be interesting to see if I can use that for double-byte fonts. Meanwhile, I found that there are a few kanji fonts available in bdf format, which is far easier to understand than the example to which I first referred. Here is one character, for example:
STARTCHAR CNS2-5071 ENCODING 17522 SWIDTH 985 0 DWIDTH 40 0 BBX 40 40 0 -3 BITMAP 0300018000 03e000c000 03c000e000 0380007000 038000700c 038000301e 0383ffffff 0388300180 039c1801e0 fffe0c01c0 03800e0380 0380070300 0780070618 0781830c3c 07c1fffffe 0fe1c0601e 0fb1c0781c 0fb9c0701c 1f9dc0701c 1b9dc0719c 1b8ddfffdc 3b81c0701c 3381c0701c 3381c0701c 6381c0701c 6381c7ff1c c381c7071c c381c7071c 8381c7071c 0381c7071c 0381c7071c 0381c7ff1c 0381c6061c 0381c0001c 0381c0001c 0381c0003c 0381c007fc 0381c00078 0381c00070 0301800060 ENDCHAR
The second number in 'BBX' (40) refers to the number of encoding lines to follow. Because that's so readable, it was a simple 10 minutes coding to turn 0381c007fc into the Euphoria required {0,0,0,0,0,0,1,1, etc} and display the character as a bitmap. Now I'll just write an indexing routine and all should be well. Thanks again for your help ... -- Craig
12. Re: Kanji bit-mapped font
- Posted by Craig Welch <euphoria at welchaviation.org> Jul 04, 2004
- 568 views
irv mullins wrote: > > Truetype fonts don't work. They're fine in Microsoft applications such as > > Office, but won't work in my Euphoria application. Hence my search for a > > way to render a bitmap font. > > TT fonts work fine with Euphoria on Linux. I can't think of any reason > they wouldn't also work with Windows. Because, as I understand it, Linux has underlying support for double-byte characters. Not all versions of Windows do. Windows 98, as I mentioned I'm using, doesn't. You can install add-ons that provide that support, but only in Office applications, so that excludes anything written in Euphoria. > I don't know why you would need bitmaps. Maybe we need more details. See above ... and bitmaps work, so I'm only seeking a working solution. -- Craig
13. Re: Kanji bit-mapped font
- Posted by Craig Welch <euphoria at welchaviation.org> Jul 04, 2004
- 583 views
Bernard Ryan wrote: > > Craig: > What format is the file asiya24.fnt using and > how can it be viewed ? Heh. If I knew enough about font file formats to answer that question, I would probably know enough to have written the code to render it! I used a hex editor to view it, but nothing of what I saw provided any patterns that would help me decode it. As you will see from another post though, I've found a font (several, in fact) in a format that is quite readable by humans, and easily rendered in Euphoria. I'm using this font: ftp://ftp.cc.monash.edu.au/pub/nihongo/jisksp40.bdf.gz -- Craig
14. Re: Kanji bit-mapped font
- Posted by Bernard Ryan <xotron at bluefrog.com> Jul 04, 2004
- 577 views
Craig: This code that will create xpm constants for the bdf files. It comments out the other file lines. so you can keep the comments for the copyright and other wanted information by editing the file and removing what you don't want. This code will genertae the code to allow you to use the win32lib or my w32engin.ew library. Bernie
-------------- CODE FOR BDF2XPM.EX -- include wildcard.e -- atom fi, fo, k integer flag, ctr object line sequence infile, outfile, xpm infile = {} outfile = {} xpm = {} -- constant cmdline = command_line(), bin = {"x,x,x,x","x,x,x, ","x,x, ,x","x,x, , ", "x, ,x,x","x, ,x, ","x, , ,x","x, , , ", " ,x,x,x"," ,x,x, "," ,x, ,x"," ,x, , ", " , ,x,x"," , ,x, "," , , ,x"," , , , "} -- function cvt2seq(integer c) -- if find(c,"0123456789") then return bin[ c - '0' + 1 ] -- [0-9] else return bin[ lower(c) - 'a' + 10 + 1 ] -- [A-Fa-f] end if -- end function -- if length(cmdline) >= 3 then infile = cmdline[3] if length(cmdline) >= 4 then outfile = cmdline[4] end if else puts(1, "\n Enter the name of the input bdf file : ") infile = gets(0) infile = infile[1..length(infile)-1] puts(1,"\n\n") end if -- if find('.', infile) then outfile = infile[1..find('.', infile)-1]&".exf" else infile = infile&".bdf" outfile = infile[1..find('.', infile)-1]&".exf" end if -- open the input bdf file fi = open(infile, "rb") if fi = -1 then puts(1, " Can not open "&infile&" the bdf input file\n") abort(1) end if -- see if it already exists fo = open(outfile, "rb") if fo != -1 then close(fo) -- don't destroy an existing include file - let user delete himself puts(1, "\n A file "&outfile&" already exists !"& "\n Over-write the existing file ?"& "\n (y/n) or (q to quit) : ") while 1 do k = lower(get_key()) if k = 'n' or k = 'q' then close(fi) close(fo) abort(0) elsif k = 'y' then close(fo) puts(1, "\n\n ") exit end if end while end if -- open the output bdf file fo = open(outfile, "w") if fo = -1 then puts(1, " Can not open "&outfile&" the bdf output file.\n") close(fi) abort(1) end if -- flag = 0 ctr = 0 puts(1,"Processing the file.\n Please Wait : ") while 1 do if get_key() != -1 then exit end if line = gets(fi) if atom(line) then exit -- -1 is returned at end of file else if match("STARTCHAR ",line) then xpm &= "constant "&line[11..length(line)-1]&" = textToBitmap( {"&10 puts(fo,"-- "&line) elsif match("BITMAP",line) then flag = 1 puts(fo,"-- "&line) elsif match("ENDCHAR",line) then puts(fo,"-- "&line) xpm = xpm[1..length(xpm)-2] xpm &= "})\n" puts(fo,xpm) xpm = {} flag = 0 end if if flag and not match("BITMAP",line) then xpm &= "\"" for i = 1 to length(line)-1 do xpm &= cvt2seq(line[i])&"," end for xpm = xpm[1..length(xpm)-1] xpm &= "\",\n" puts(fo,"-- "&line) end if if ctr = 5000 then puts(1,"*") ctr = 0 else ctr += 1 end if end if end while -- close(fi) close(fo) puts(1,"\nProcessing complete !") --
Bernie
15. Re: Kanji bit-mapped font
- Posted by Craig Welch <euphoria at welchaviation.org> Jul 22, 2004
- 564 views
Bernard Ryan wrote: > Craig: > > This code that will create xpm constants for > the bdf files. It comments out the other file lines. > so you can keep the comments for the copyright and > other wanted information by editing the file and > removing what you don't want. This code will genertae > the code to allow you to use the win32lib or my w32engin.ew > library. > Thanks for going to the trouble, Bernie. One problem (easily fixed) with that was that Euphoria didn't like that the name of each constant was a number. The other problem was that the size of the include file was around 40MBytes, which took a while to load on my fast server, but *minutes* on my laptop. This made it unworkable. I've now gone to inline processing. I read in the font file as is, do a lookup and expand/process it as required. It's quite fast enough. Thanks, -- Craig