bitmap Font resize?

Previous topic - Next topic

Jonás Perusquía

Hello all of you :), i just wanted to ask you if it was posible to resize a Font using for example using GETFONTSIZE command?

Thanks in advance :)

I would like to create a big Font file and resize the characters at any size, depending on screen resolution :)

maybe something like this?

Code (glbasic) Select
GETSCREENSIZE sx, sy
GETFONTSIZE tx, ty
tx = sx/99
ty = tx * 1.2


what about using X_PRINT?
<HTML><BASIC><EC>
Be free and do good things

CW

#1
Hi Jonaspm.

Resizing fonts is not native to GLbasic, neither is setting font colors, because the fonts are based on static images.
The easiest work-around which most people go with is to create a hand full of custom fonts using the Create Font utility built into GLbasic, and call them as needed.

A couple of programers have written custom font routines which are sizable, after a fashion, and they are available on this website. I'll poke around and see what I can find.
(Does anyone have a handy link?)

GLbasic has its strengths and its weaknesses. The strengths make some hard things ridiculously easy. For the other sort, we either devise work-arounds or learn to live with them. All in all, the strengths far outshine the weaknesses.

-CW

CW

#2
Hi Jonaspm,

A quick search turned up these two programs which may meet your need.

Check out this link: http://www.glbasic.com/forum/index.php?topic=2223.0
Or this link: http://www.glbasic.com/forum/index.php?topic=8207.0

There may be others.

-CW

spacefractal

except grapsprite can been muddy on some Android devices. Anyways there is no colors as well size on the glbasic font system. Howover its pretty easy to do you own, but its depend how you will use the font.

In my own im wrote a DrawImage function, which did the Polyvectors drawing from a regular bitmap, which can been colored too. Howover colored vectors can slowdown on some iOS devices.

Yes the first link did my self used, until im created my own.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

Jonás Perusquía

thank you for your replies, can't X_PRINT work also? it has a #scale property...

The game where i would like to resize the text and sprites (i see it's posible to resize sprites) it's in 2D mode, but i think 3D mode allos scaling of sprites and text, anyway i will keep looking and thank you for the links! they will be very very handy
<HTML><BASIC><EC>
Be free and do good things

spicypixel

Use PV's or sprites for your font and scale away :D
http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.

Brick Redux

Just come across this thread and realised I had a method of enlarging the current font that is quick and very simple.

Code (glbasic) Select
/// Quick and simple enlarged font method.
/// Coded by Mark Cooper AKA BRICK REDUX
/// Could be handy for text adventures etc?


/// Define the bits needed for the moving title and scaling quit request.
y1=50 ; y1dir=1 ; factorx=1 ; factory=1 ; fdirx=1 ; fdiry=1

WHILE TRUE

text$="Enlarged Font demo!"
largefont(text$,120,y1,3,4,0,RGB(255,0,0))

text$="By displaying the text on a virtual screen"
largefont(text$,70,120,1.5,3,0,RGB(0,0,150))

text$="( CREATESCREEN ) you then ZOOM that Sprite"
largefont(text$,70,140,1.5,3,0,RGB(0,150,0))

text$="after a USESCREEN -1 call."
largefont(text$,100,170,1.5,3,0,RGB(150,0,0))

text$="Press <ESCAPE> to exit."
largefont(text$,110,300,factorx,factory,1,RGB(RND(255),RND(255),RND(255)))

text$="Brick Redux, 2013"
largefont(text$,120,400,2,3,1,0)

GOSUB FX


SHOWSCREEN

WEND



// A$=text / xpos/ ypos / zoomfactor X / zoomfactor Y / Smoothshading on/off / background RGB

FUNCTION largefont:a$,x,y,scalex,scaley,shading,background

SMOOTHSHADING shading

LOCAL size=LEN(a$)

CREATESCREEN 4,2,size*8,9 // Sprite 2

USESCREEN 4 // Use an hidden screen

DRAWRECT 0,0,size*8,9,background // Fill the background with a colour.

PRINT a$,0,0 // Now print the text

USESCREEN -1 // Back to reality!

ZOOMSPRITE 2,x*2,y,scalex,scaley // Scale the text!

ENDFUNCTION

SUB FX: /// Only needed here for the moving and scaling text.

INC y1,y1dir
IF y1<40 OR y1>80
y1dir=-y1dir
ENDIF


INC timer

IF timer=4

timer=0

INC factorx,fdirx;INC factory,fdiry

IF factorx<0 OR factorx>5

fdirx=-fdirx

ENDIF

IF factory<0 OR factory>5

fdiry=-fdiry

ENDIF

ENDIF
ENDSUB


And with alittle tweaking, you could use my former selfs :) colour alteration routine: http://www.glbasic.com/forum/index.php?topic=8207.msg69270#msg69270 too. :)
A mournful owner of a HP HDX18 Laptop that has died...FECK!

Jonás Perusquía

Oh! Brick Redux, thanks a lot for helping me and all the GLBasic community :)

I will try your method as fast as i can, again, THANK YOU! :D
<HTML><BASIC><EC>
Be free and do good things

Qedo

Hi
attached my work ( thanks to the community of GLBasic) about resize font.
If interesting i will send source and istruction.
Ciao
Qedo

http://web.tiscali.it/edoardobianchi/STUFF/font/Animation_Font.app.zip

Wampus

Oooh. That's great Qedo.

I wrote something to use GLBasic style fonts with kerning and justification using polyvector commands for speed but its basic. Your routine is wayyyy better. For sure source would be appreciated by me. Instruction too, if you have the time.

kanonet

Yeah looks very good, i want to see the soure too.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

Qedo

as soon as I finish the conversion from FUNCTION to TYPE (for better style programming) i will send you the source,
Ciao
Qedo

Wampus

Quote from: Ocean on 2013-Oct-24
on another note: has anybody ever done vector fonts for GLB ?

Well, there is this routine to draw SVG and DXF objects with Polyvectors.

Qedo

sorry for the delay (source program) but in GLBasic 11.559 the program don't work. see picture.
I dont know if is a bug. I'm working.
Ciao
Qedo

Qedo

Send the source (without comment, sorry)
Solved moving the command USESCREEN 5 from outside NEXT loop to inside.
I don't Know if it is a bug, but GLBasic 11 seems reset to  USESCREEN -1 at every cycle of the loop.

OK on Windows. On Android OK on BlueStack but don't work on my Sony  :(.
Can you try?
Thank you
Qedo

http://web.tiscali.it/edoardobianchi/STUFF/font/Animation_Font_source.zip

Code (glbasic) Select
CREATESCREEN 5, single_id_sprite, w,h
//USESCREEN 5  // work in GLBasic 10, NOT in GLBasic 11.559
FOR i=32 TO n_car
USESCREEN 5 // work in GLBasic 10 and in GLBasic 11.559
CLEARSCREEN RGB(0,0,0)
DRAWANIM self.id_sprite% , i, 0, 0 // stampa il carattere i dello sprite
ok% = SPRITE2MEM(pix[], single_id_sprite)
.....
.....
.....
NEXT
USESCREEN -1/code]