Page 1 of 1

FONTS

Posted: Tue Oct 26, 2004 1:13 pm
by Vladaz
Hello,
can someone help me with fonts?
I have vesa driver installed and now i want to print some text to screen, but I need to create fonts and my print function. Can someone help me with this? Maybe someone know a good manual or tutorial or smth?
Thanks in advance.

Re:FONTS

Posted: Tue Oct 26, 2004 2:07 pm
by mystran
I'd take a look at freetype. IIRC it doesn't really need much from the OS it's running under, and it reads and renders truetype fonts, optionally with antialiasing for you. There's also a nice tutorial for it on the freetype site http://www.freetype.org/

That said, the basic idea is to somehow render a glyph, then advance "position", then render another glyph, and so on, until you have rendered the whole string.

The most simple possible font-format is simply a bitmap containing fixed-width glyphs. More advanced formats also store data about the width of the individual glyphs, scaled fonts use vector-data (or something similar) instead of bitmaps, and possibly also have some "hints" for fitting the glyphs into pixel grid to get better shapes with small fonts. Finally, many formats also allow fonts to speficy that some letters should be rendered closer to the previous letters if they follow some other letter. Example would be rendering "fi" a bit closer together than two letters normally.

In any case, whether you decide to use freetype or not, you might want to check out the tutorials anyway, so you get an idea of what's involved.

Re:FONTS

Posted: Tue Oct 26, 2004 4:07 pm
by ASHLEY4
Here is how i do font's in vesa

Code: Select all

;***********************************
; Draws text.
;***********************************
DrawImage:
      mov   edi,[ModeInfo_PhysBasePtr]
      add   edi,270*4+640*4*148
      xor   edx,edx
      mov   dl,7
      cld
GetData:
      lodsd
      MOV     ebx,eax
      MOV     CL,32
CheckBit:
      test    ebx,80000000h
      JZ      ZeroBit

      xor    eax,eax
      stosd
      jmp     Skip
ZeroBit:
      mov     eax,0xffa6ffff
      stosd
Skip:
      shl     ebx,1
      loop    CheckBit
      add     edi,640*4-32*4
      dec     edx
      jne     GetData
      ret
Here are the fonts

Code: Select all

Play:
db     44h,38h,40h,78h
db     44h,44h,40h,44h
db     28h,44h,40h,44h
db     10h,7ch,40h,78h
db     10h,44h,40h,40h
db     10h,44h,40h,40h
db     10h,44h,7ch,40h
play:

Stop:
db     78h,38h,7ch,38h
db     44h,44h,10h,44h
db     44h,44h,10h,40h
db     78h,44h,10h,38h
db     40h,44h,10h,04h
db     40h,44h,10h,44h
db     40h,38h,10h,38h
stop:
You call it like this:

Code: Select all

        mov   si,Stop
        call  DrawImage
What it does is loads a dword in to ebx from the fonts and test each bit if its a 1 it put a pixel of one color and if its a 0 another color, normal it just inc edi by one pixel, but i need a block background, for CdPod from which this is a example.
Than it loads another dword from the fonts, and so on untill its done 7 dwords, this prints Stop and Play.

For this code to work with your vesa you need to make shore, your vesa is 32bits and instead of 640 put your vesa X size in, where you see 640.

This is just to give a demo, if you want the full fonts let me know.
Also you can get the full asm code for CdPod here:
http://board.flatassembler.net/viewtopi ... 4&start=50
Screenshot here:
http://www.falconrybells.co.uk/page2.htm
Vesa pmode cdplayer vesa fonts atapi driver keyboard input 24bit graphic, all in just 510 bytes, try doing that in C ;-).

\\\\||////
(@@)
ASHLEY4.

Re:FONTS

Posted: Tue Oct 26, 2004 11:57 pm
by Brendan
Hi,

Probably the easiest way is to use the font data from the BIOS ROM - int 0x10; ax=0x1130, bh = 3 for 8*8 fonts or bh = 4 for 8*16 fonts. This saves boot image/disk/memory, and also means you don't have to care about any font data copyrights. My OS uses this so that graphics modes look exactly the same as text mode during boot :).

The problem with BIOS fonts is that they aren't useful for unicode or variable width spacing.


Cheers,

Brendan