Re: Kanji bit-mapped font
- Posted by Bernard Ryan <xotron at bluefrog.com> Jul 04, 2004
- 544 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