1 decade ago by eLouai
Needed to add scaling to fonts independently of the current system font.
So I made changes to the font class to accomodate.
It should really be something added to the main code set.
Usage is simple.
Just call the created font file to set the scale
It just sets the state of the font scale. Maybe I need to cap it so its more obvious.
So I made changes to the font class to accomodate.
It should really be something added to the main code set.
...
letterSpacing: 1,
lineSpacing: 0,
// >>> added
scaleFont: 1,
startChar: {x:0,y:0},
// <<< end
...
...
for( var i = 0; i < text.length; i++ )
{
// >>> added
if (i == 0)
{
this.startChar.x = ig.system.getDrawPos(x);
this.startChar.y = ig.system.getDrawPos(y);
}
// <<< end
...
...
// >>> replaced context drawImage
ig.system.context.drawImage(
this.data,
charX, charY,
charWidth, charHeight,
this.startChar.x+((ig.system.getDrawPos(targetX)-this.startChar.x)*this.scaleFont),
ig.system.getDrawPos(targetY),
charWidth*this.scaleFont, charHeight*this.scaleFont
);
// <<< end
Usage is simple.
Just call the created font file to set the scale
font.scalefont = 4;
font.draw('some text',x,y,Font.ALIGN.CENTER);
font.scalefont = 2;
otherfont.draw('some text',x,y+20,Font.ALIGN.CENTER); // also gets changed
It just sets the state of the font scale. Maybe I need to cap it so its more obvious.
