Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Resizable Custom Fonts
#1
I am trying to create a resisable custom font, curently reading data statements from a file to create the text like such:

Code:
0,0,1,1,0,0
0,1,0,0,1,0
0,1,1,1,1,0
0,1,0,0,1,0
0,1,0,0,1,0
0,1,0,0,1,0

Reading it from a file allows me to have multiple types of fonts which is nice, but the whole process is pointless if I can't resize the letters in the code, so I loaded the data into a 2d array and tried something like this:

Code:
If Mid$(Text,1,1)="A" then
  For Count=1 to 6:For Count2=1 to 6
    If FontSetArray(Count2,Count)=1 then Line (x*count,y*count)-((x*count)+textsize),(y*count2)+textsize),colour,bf
  Next:Next

Which i thought would have enlarged the letter to be the same as 1 pixel except each pixel would = the textsize....but instead it is either making the squares too big, or the text too small. the whole thing works fine if I leave I dont try to enlarge but as I said that would make the whole routine pointless...
url=http://www.smithcosoft.com]SmithcoSoft Creations[/url]
"If you make it idiot proof, someone will make a better idiot" - Murphy's Law
Reply
#2
Maybe you could use vector fonts; describe the features of the letters as vectors. For curves, you could base them on an ellipse with a start angle and end angle to draw from...

The advantage of using this method would be that scaling the fonts would be as simple as scaling the vectors. Also, you have instant transparency, as only the required details of the letters are drawn.

A simple example I can think of would be describing a capital T.

Classic representation (8x8):

1,1,1,1,1,1,1,0
0,0,0,1,0,0,0,0
0,0,0,1,0,0,0,0
0,0,0,1,0,0,0,0
0,0,0,1,0,0,0,0
0,0,0,1,0,0,0,0
0,0,0,1,0,0,0,0
0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0

Vector representation:

LINE:0,0:7,0
LINE:4,1:0,6

Your font-drawing routine should just accept a structure containing the descriptive vectors and draw them according to the instructions similar to above.

A curve may be represented as something like this:

ELLIPSE:4,4:4,3:50,60

Where the second parameter (delimited by colons) represents the centre of the ellipse, the 4 and 3 represent the scale of the ellipse in the X and Y plane (e.g. (4sint, 3cost)) and 50,60 is the angle to draw between, written in degrees for the sake of simplicity.

The idea is that all of these parameters (apart from the angles to draw between) can be scaled by some fixed amount to change the size of the font.

Just some thoughts.

-shiftLynx
img]http://www.cdsoft.co.uk/misc/shiftlynx.png[/img]
Reply
#3
There is an utility for QB at:
http://www.philipz.com/qb/files/ypfv1-0.zip

I have not tested it, though.
ean Debord
----------------
Math library for FreeBasic:
http://www.unilim.fr/pages_perso/jean.de...fbmath.zip
Reply
#4
You could use ttf fonts with SDL, they are normal windows fonts if i believe?
Reply
#5
yeah but the whole poing of me making this is so that I can make custom fonts and store them in files to be used as i please...any ideas abhout why it isnt resizing?
url=http://www.smithcosoft.com]SmithcoSoft Creations[/url]
"If you make it idiot proof, someone will make a better idiot" - Murphy's Law
Reply
#6
You could do something like this. You'll just have to change it to read from a file, instead of getting the font with point. Wink


Code:
Screen 13

Const False = 0, True = Not False


DECLARE Sub PrintS( Text as String, Lx as Integer, Ly as Integer, Col as Integer, Scale as Integer, FontSetArray() as Integer )
DECLARE SUB BuildFont( FontSetArray() as Integer )


Dim FontSetArray(0 to 255,0 to 8,0 to 8) as Integer




BuildFont FontSetArray()

PrintS "Super Size", 0, 80, 1, 1, FontSetArray()


Sleep


Sub PrintS( Text as String, Lx as Integer, Ly as Integer, Col as Integer, Scale as Integer, FontSetArray() as Integer)
   COLOR(31)
   For i = 1 to Len(Text)
      AscVal = ASC(Mid$(Text,i))
      For Y = 0 to 8
         For X = 0 to 8            
            If FontSetArray(AscVal,X,Y) then                
               LINE( (Lx+(X*Scale))+((i-1)*Scale*8),(Ly+(Y*Scale))) _
               -Step(Scale-1,Scale-1 ),Col ,Bf
            End If
         Next        
      Next      
   Next
End Sub



Sub BuildFont( FontSetArray() as Integer )
   For i = 0 to 255
      Locate 1,1
      Color(1)
      Print CHR$(i)
      For Y = 0 to 8
         For X = 0 to 8
            FontSetArray(i,X,Y) = Point(X,Y)
         Next        
      Next      
   Next  
End Sub
Reply
#7
yeah, ttf fonts both support your needs: they come in files and you can create your own Wink.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)