|
From: Tom on 18 Jun 2008 00:05 In article <48560116$1(a)clear.net.nz>, Jim Granville <no.spam(a)designtools.maps.co.nz> wrote: >rickman wrote: >> On Jun 15, 6:18 pm, Jim Granville <no.s...(a)designtools.maps.co.nz> >>>We already use a fixed 8x8 and (8x16)(7x14) font, but that does not >>>scale too well, so something a step up from a single stroke, small pixel >>>count looked to be better. The problem was, fonts such as those above >>>did not have enough info to easily calculate a ROM size, or an obvious >>>ROM pathway. >> >> I don't get what you mean about scaling. Fixed size fonts *don't* >> scale. That is why they invented the TrueType and other scalable >> fonts. > > Our use is less common: We want to have smaller fonts (8x16 is ok here) >for close reading, and then scale that x2, x3, x4, x5 etc, for >more distant reading of few critical variables. >This works now by scaling the 8x16 - and it is 100% functional, but gets >a tad 'chunky'..... > > So, we need a Pixel Font, but with a larger 'tile', that 'looks nicer', >but we do not have as many pixels, ROM space, (or rendering power) as a >Windows PC. > I think a 24x16 tile, with a soft-define on dX,dY should give good >results. > My guess is that most of the fonts on >http://www.minifonts.com/samples.html will be inside this. > > I did find FontForge, which looks possible, but it is not a native >windows application - > > Has anyone every used FontForge ? I've tried using FontForge, it's a bit of a pain to use under Windows since you have to download several megs worth of Cygwin stuff before it will even run. Also, FontForge is mainly designed for editing scalable fonts like TrueType or OpenType. If you just want to edit bitmapped fonts, try a simpler freeware editor like Fony. If you want to use an existing font, here is a program that will display the raw pixels of any installed font (either bitmapped or TrueType or Type1, etc.) at any size. Right now it's set to do "Tahoma" at 21 pixels cell size with uppercase characters from A to Z. What I've done in the past is drawn my font in Fony (the "import" feature works well) and then saved it as a .FON file, copied it into the Windows Fonts folder, and previewed it in Paint inside a rectangle that has the same number of pixels as my LCD panel. I can mock up several sample screens this way. Once I'm happy with the results, I use the attached program to generate a ROM table for the font. I can also get bold or italic versions of the same font just by changing the arguments to the CreateFont function. #include <windows.h> #include <stdio.h> typedef unsigned char U8; typedef unsigned long U32; #define MAXSIZE (96) /* MAXSIZE must be a multiple of 8 */ void displayfont(HDC h, U8 *bits, char* name, U32 cellheight, U8 first, U8 last) { HFONT fnt; U32 i,j,width,row,col; U8 glyphbuff[MAXSIZE][MAXSIZE],txt[2]; U8 firstchar,numchar,currchar,c,v; if (cellheight>MAXSIZE) {printf("Can't display font, the requested cell height is %u but MAXSIZE is only %d.\n",cellheight,MAXSIZE); return;} firstchar=first; numchar =last-first+1; fnt=CreateFont(cellheight,0,0,0,0,FALSE,FALSE,FALSE,DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE,name); SelectObject(h,fnt); for (currchar=firstchar; currchar<firstchar+numchar; currchar++) { GetCharWidth32(h,currchar,currchar+1,&width); printf("Character %c width %d\n",currchar,width); sprintf(txt,"%c",currchar); TextOut(h,0,0,txt,1); col=0; row=-1; for (i=0; i<(MAXSIZE*MAXSIZE/8); i++) { if (!(i%(MAXSIZE/8))) {row++; col=0;} c=bits[i]; for (j=0; j<8; j++) { if (c&0x80) v=1; else v=0; glyphbuff[row][col]=v; col++; c<<=1; } } for (row=0; row<cellheight; row++) { for (col=0; col<width; col++) { printf("%c",glyphbuff[row][col]?'*':'-'); } printf("\n"); } printf("\n"); } DeleteObject(fnt); } void create_dib(HDC *dctx, U8 **bits) { BITMAPINFO *bi; HBITMAP bmp; HGDIOBJ prev; HDC h; U8 *bit; h=CreateCompatibleDC(NULL); bi=malloc(sizeof(bi->bmiHeader)+sizeof(bi->bmiColors)*2); bi->bmiHeader.biSize =sizeof(bi->bmiHeader); bi->bmiHeader.biWidth =MAXSIZE; bi->bmiHeader.biHeight =-MAXSIZE; bi->bmiHeader.biPlanes =1; bi->bmiHeader.biBitCount =1; bi->bmiHeader.biCompression =BI_RGB; bi->bmiHeader.biSizeImage =0; bi->bmiHeader.biXPelsPerMeter =0; bi->bmiHeader.biYPelsPerMeter =0; bi->bmiHeader.biClrUsed =0; bi->bmiHeader.biClrImportant =0; bi->bmiColors[0].rgbBlue =0; bi->bmiColors[0].rgbGreen =255; bi->bmiColors[0].rgbRed =255; bi->bmiColors[0].rgbReserved =0; bi->bmiColors[1].rgbBlue =255; bi->bmiColors[1].rgbGreen =0; bi->bmiColors[1].rgbRed =0; bi->bmiColors[1].rgbReserved =0; bmp=CreateDIBSection(h,bi,DIB_RGB_COLORS,(void*)&bit,NULL,0); free(bi); prev=SelectObject(h,bmp); *dctx=h; *bits=bit; } void destroy_dib(HDC h) { HGDIOBJ bmp; if (!h) return; bmp=GetCurrentObject(h,OBJ_BITMAP); DeleteObject(bmp); DeleteDC(h); } void main() { HDC h; U8 *bits; create_dib(&h,&bits); displayfont(h,bits,"Tahoma",21,'A','Z'); destroy_dib(h); }
|
Pages: 1 Prev: Sample DOSFS disk image file for testing Next: mips-linux-g++ |