Font Size Question

Previous topic - Next topic

vetie

Hello everyone,

I'm testing out GLBasic with just basic stuff and trying to understand the usage of Fonts. I understand that we can create BMP fonts with the included editor and have done that successfully. I have been able to load and see the created font.

My question is this, Do I have to create each font "Size" as a separate BMP file or can I create one font and re-size it within the program? (i.e SETFONTSIZE)

Thanks for any information

ampos

A font/file per size :(

Slydog

#2
If you write your own font system you could add a 'scale' attribute, and use polyvectors to draw and resize them.
But any scale other than 1.0 would stretch or shrink your font, and it may look blurry.

But it may still be useful if that doesn't matter, such as zooming a font for effects such as receiving points, you could zoom the font to twice its size over a second then fade it away.

However, the built in font system doesn't allow font scaling, as ampos mentioned.

Here's a post from PeeJay about his font system:
http://www.glbasic.com/forum/index.php?topic=1521.0

I think there is a more current font system in these forums somewhere if you want to search.  It may allow font scaling.
Someday I may post mine (it has scaling), but that would be quite involved as it is dependent on my other libraries such my sprite, file, and vector libraries, etc.

[Edit] Or I could just post my entire library!  (But it is getting huge, and not all parts are 'clean' as they all seem to be WIP!)
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Minion

Heres a quick and nasty print routine I sometimes use. Has text scalling and recolouring. Shouldn`t be hard to add left/right justification as well. Not perfect, but does the job.


Code (glbasic) Select

FUNCTION Prontsc:a$,x,y,cl,cl2,scx,scy

// x,y     - Center point of text
// cl      - top colour of text
// cl2     - bottom colour of text
// scx,scy - Scaling factor for text (1 = normal, 2 = double size, 0.5 = half size etc)

// Needs bitmap font loaded into sprite id 1000 (Use GLBs Font creator to make, or use other bitmap font)
// size of font needs to be 32x32, 16 chars accross, 8 down

LOCAL xx,yy,a,Nm
LOCAL nx,ny,nx2,ny2

Nm=LEN(a$)-1
STARTPOLY 1000,2
FOR m=0 TO Nm

a=ASC(MID$(a$,m,1))

yy= INTEGER((a/16))*32
xx= MOD(a,16)*32


nx=(((m*2)-Nm)-1)*(16*scx)
nx2=((((m+1)*2)-Nm)-1)*(16*scx)
ny=16*scy
ny2=16*scy

POLYVECTOR x+nx,y-ny,   xx,yy,       cl
POLYVECTOR x+nx,y+ny,   xx,yy+32,    cl2
POLYVECTOR x+nx2,y-ny,  xx+32,yy,    cl
POLYVECTOR x+nx2,y+ny,  xx+32,yy+32, cl2

NEXT
ENDPOLY

ENDFUNCTION