Lens = glyphs.getBounds2D().getWidth() + interchar Vectorize(glyphs = new Path2D.Float(), chars, tx, 0f) This code: TTFFile file įile ttf = new File("C:\\Windows\\Fonts\\calibri.ttf" ) Ĭatch (IOException e) But there are two TTFFile classes in this parser. I also eliminated the directory jaredrummler because it was a bit too long (I kept the copyright comments in the beginning of the files, though). If anyone wants to do it, one needs to use Rectangle instead of Rect. If (charLocation.x + char.I was willing to use the parser described above using standard Java on Windows. So, probably it doesn't make sense to explain everything, and is tedious to read, so, I'll go to the point. Var numCharsToRemove:int = lastWhiteSpace = -1 ? 1 : i - lastWhiteSpace remove characters and add them again to next line So, if u see the next line: it creates a new line, removing "exceeded" chars from the current line, and offseting the i-=numCharsToRemove to loop through them again.
And adjust everything to the specified width/height. (if the current char position exceeds the width then.)īitmapFont automatically thinks that the TextField is multiline=true by default. Line 283 - // this is the key of your issue. This will happen until the entire text reaches the specific width/height.
So, this will start another while loop with the fontSize 1pt smaller. If (autoScale & !finished & fontSize > 3) fontSize -= 1 Line 233 - while (!finished) // the intimidating part ?Īs far as finished=false, it'll loop over and over through the logic.Īnd here's when the NEW SIZE is applied on each while when using autoSize=true. The "magic" of autoScale, is playing with this ratio: When u divide both, u get a ratio of the scale ( a percentage ), that's applied to the final image to match the size u want. xml, and the real fontSize of the textures in the atlas) and a fontSize that u specify in the params. U have a native fontSize (the one present in the. * If u want to "fix" that issue that u have u need to pass more info into it, that's why I suggested a new param called multiline:BooleanĪnyway, the function is long, so it's hard to explain in detail. Basically, this is the "core" of the logic for a Bitmap TextField. This method populates a collection of CharLocations to generate later the DisplayObjects (in createSprite). there's no need to splice or delete chars at that stage.Īnyway, I'll go through it for u (using the current version fom 1.4.1) : Maybe u can find something useful in the code. Is funny cause I've been creating my custom BitmapText implementation for Genome2D, and my first versions were based on this class.
Line 219 (only add a new line if u're using multiline.) Var numCharsToRemove:int = multiline ? 1 : lastWhiteSpace = -1 ? 1 : i - lastWhiteSpace Line 206 (if multiline remove only 1 char at a time.) Kerning:Boolean=true, multiline:Boolean=true):DisplayObject HAlign:String="center", vAlign:String="center", Public function createDisplayObject(width:Number, height:Number, text:String, I'm just guessing based on the old version I have of the BitmapFont class: