BASIC

Author Topic: bitmap Font resize?  (Read 5519 times)

Offline Jonás Perusquía

  • Mr. Polyvector
  • ***
  • Posts: 170
    • View Profile
    • Ditrabox
bitmap Font resize?
« on: 2013-Apr-11 »
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?
« Last Edit: 2013-Apr-11 by jonaspm »
<HTML><BASIC><EC>
Be free and do good things

Offline CW

  • Mr. Polyvector
  • ***
  • Posts: 155
    • View Profile
Re: bitmap Font resize?
« Reply #1 on: 2013-Apr-11 »
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
« Last Edit: 2013-Apr-11 by CW »

Offline CW

  • Mr. Polyvector
  • ***
  • Posts: 155
    • View Profile
Re: bitmap Font resize?
« Reply #2 on: 2013-Apr-11 »
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
« Last Edit: 2013-Apr-11 by CW »

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3611
    • View Profile
    • Space Fractal
Re: bitmap Font resize?
« Reply #3 on: 2013-Apr-11 »
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.
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline Jonás Perusquía

  • Mr. Polyvector
  • ***
  • Posts: 170
    • View Profile
    • Ditrabox
Re: bitmap Font resize?
« Reply #4 on: 2013-Apr-12 »
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

Offline spicypixel

  • Prof. Inline
  • *****
  • Posts: 646
  • Pixel Artist
    • View Profile
    • SpicyPixel.net
Re: bitmap Font resize?
« Reply #5 on: 2013-Apr-12 »
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.

Offline Brick Redux

  • Mr. Drawsprite
  • **
  • Posts: 60
    • View Profile
Re: bitmap Font resize?
« Reply #6 on: 2013-Sep-21 »
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!

Offline Jonás Perusquía

  • Mr. Polyvector
  • ***
  • Posts: 170
    • View Profile
    • Ditrabox
Re: bitmap Font resize?
« Reply #7 on: 2013-Sep-23 »
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

Offline Qedo

  • Mr. Polyvector
  • ***
  • Posts: 164
  • UNUS SED LEO
    • View Profile
Re: bitmap Font resize?
« Reply #8 on: 2013-Oct-20 »
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

Offline Wampus

  • Prof. Inline
  • *****
  • Posts: 1004
    • View Profile
Re: bitmap Font resize?
« Reply #9 on: 2013-Oct-20 »
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.

Offline kanonet

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1142
    • View Profile
    • My GLBasic code archiv
Re: bitmap Font resize?
« Reply #10 on: 2013-Oct-20 »
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

Offline Qedo

  • Mr. Polyvector
  • ***
  • Posts: 164
  • UNUS SED LEO
    • View Profile
Re: bitmap Font resize?
« Reply #11 on: 2013-Oct-21 »
as soon as I finish the conversion from FUNCTION to TYPE (for better style programming) i will send you the source,
Ciao
Qedo

Offline Wampus

  • Prof. Inline
  • *****
  • Posts: 1004
    • View Profile
Re: bitmap Font resize?
« Reply #12 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.

Offline Qedo

  • Mr. Polyvector
  • ***
  • Posts: 164
  • UNUS SED LEO
    • View Profile
Re: bitmap Font resize?
« Reply #13 on: 2013-Oct-25 »
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

Offline Qedo

  • Mr. Polyvector
  • ***
  • Posts: 164
  • UNUS SED LEO
    • View Profile
Re: bitmap Font resize?
« Reply #14 on: 2013-Oct-25 »
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]