News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

fonts

Started by ragdog, October 26, 2007, 08:49:14 PM

Previous topic - Next topic

ragdog

hi guys

how can i create such png fonts and do i have to observe the distances if i work with a photoprogramm?
i have found a source in masm32 wich uses these kind of fonts

can your help me

ragdog

[attachment deleted by admin]

Mark Jones

Hi ragdog. What is probably happening here is the .png is treated as a bitmap, and each "character" is copied into a representative bitmap of a character of the alphabet. These then, are placed and moved around the screen using calls to BitBlt or a related function, which basically moves these bitmaps around the screen. This is a graphics function, and has very little to do with an actual font. Do a Win32.hlp search (or MSDN) for BitBlt, PlgBlt, StretchBlt, or similar. The bitmap is probably made using a bitmap font creation program... google for "bitmap font creator" or "sprite font" or similar.

I'm sure some of us would like to see this code. Could you share the link?
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

ragdog

hi

here is the source

.data
CHAR_W EQU 8
CHAR_H EQU 14

fTable db '!"#$% `()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]',0
     
t_sz =$-fTable 

pText db "test xyz",0
     

char_w_f REAL4 8.0

Yline REAL4 14.0


srcRect RECT <0,0,0,CHAR_H>
start_pos REAL4 10.0f
start_y_pos REAL4 130.0
fontPosition   D3DXVECTOR3 <10.0f, 130.0f, 0.0f>
.code
font3d proc
                pushad
               
                    mov esi,offset pText
       next_char:
                    lodsb
                    or al,al
                    jz _ok
                    cmp al,13
                    jne @F
                    fld Yline
                    fadd fontPosition.y
                    fstp fontPosition.y
                   
                    fld start_pos
                    fstp fontPosition.x
                   
                    jmp next_char
                   
                    @@:
                    mov edi,offset fTable
                    mov edx,edi
                    mov ecx,t_sz
                    repne scasb
                    jne _ok
                    dec edi
                    sub edi,edx
                    mov eax,CHAR_W
                    mul edi
                    mov srcRect.left,eax
                    mov srcRect.right,eax
                    add srcRect.right,CHAR_W
     
     
                   d3dxspr Begin,mSprite,D3DXSPRITE_ALPHABLEND
                   d3dxspr Draw,mSprite,d3font,addr srcRect,0,addr fontPosition,-1
                   d3dxspr End1,mSprite
     
                   fld fontPosition.x
                   fadd char_w_f
                   fstp fontPosition.x
     
     
                   jmp next_char
                   
                    _ok:
     
     
                    fld start_pos
                    fstp fontPosition.x   
                    fld start_y_pos
                    fstp fontPosition.y
                    popad
                    ret
font3d endp

Mark Jones

Oh, this is Direct3D. MASM32 currently does not contain the prototypes or libraries for the "d3dxspr" function, however, Siekmanski has posted a DX9 package which does (in this thread.) Are you using something like this? Just curious, only a few people here have experimented with D3D.
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

hoverlees

If each character has the same width,may be we can use  ImageList.

[attachment deleted by admin]

Mark Jones

"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

ragdog

hi

thanks

that was not my problem!
my problem like I these create png fonts png


greets

ragdog

ramguru

It's a matter of few seconds to create such fonts.


PNG is an image, so you have to use an image editor. F.e. I use FireWorks (my favorite) it has built-in styles for text, so all you have to do - is to paste an alphabet and apply style you want to it. Of course that final font will be based on some already existing, such as Lucida Console.

ragdog


ragdog

#9
ok works

greets
ragdog

ragdog

hi

can the bitmap font draw with BitBlt?

and how does it work multi line text?

db "test1",13,10
db "test2",13,10
db "test3",0


DrawFontTest proc uses esi,hdc:DWORD,hImageListp:DWORD,lpText:DWORD,xpos:DWORD,ypos:DWORD
local paintX,paintY,counter
local tempChar:BYTE
push xpos
pop paintX
push ypos
pop paintY
cld
mov counter,0
mov esi,lpText
lodsb
mov tempChar,al
.while tempChar!=0
mov edi,offset fTable
assume edi:ptr BYTE
mov counter,0
.while TRUE
.break .if [edi]==0
mov al,tempChar
.break .if [edi]==al
inc counter
inc edi
.endw
.if [edi]==0
mov counter,-1
.endif
; invoke ImageList_Draw,hImageListp,counter,hdc,paintX,paintY,ILD_NORMAL
    invoke BitBlt, hdc,20,20,paintX,paintY,hDCBmp,0,0,SRCCOPY   
add paintX,8
lodsb
mov tempChar,al
.endw
ret
DrawFontTest endp


can your help me please

ragdog

ramguru

Here is how I would do it...(no ImageList, using BiltBlt & PatBlt)


[attachment deleted by admin]

ragdog

this very nice ramguru this is perfect :U

greets ragdog

u

I always treat custom bitmap fonts as one whole bitmap, and do BitBlt-like functions.

ImgFont1_CharWid db 15,14,17,10,11,11,14,17,........ ; width of each displayable character from <space> to the last character.
ImgFont1_CharPos dw 0,15,29,46,56,67,78,92,109,....; X-position of each displayable character.

You can make a tool to automatically compute the above arrays, for this you should have one empty pixel-column after each character. You can prepare the bitmap by either using MS Paint (or GIMP) to draw the 32..128 range of characters with a given font, or make a tool to draw that stuff into an offscreen HDC/HBITMAP and save the result (after optionally computing the above arrays).
Please use a smaller graphic in your signature.