Glaiel-Gamer
Guest
|
|
« Reply #9 on: November 12, 2009, 02:43:28 PM » |
|
I'll write a little pseudo of my method, Aquin. This is at least a simple way to do it, might not be the fastest but it doesn't matter that much as it's probably precalculated to an array anyways.
i wrote a flash program that outputs c++ code for me flash code: (bitmap font placed on the stage and named "clip") var a:BitmapData = new BitmapData(32, 32, true, 0x00000000);
var str:String = "static const float widths[] = {";
for(var i:int = 0; i<16; i++){ for(var j:int = 0; j<16; j++){ var m:Matrix = new Matrix(); m.translate(-j*32, -i*32); a.draw(clip, m); var n:Number = a.getColorBoundsRect(0xFFFFFFFF, 0xFFFFFFFF).width/32; if(n == 0) n = .35; str += (n) + ((j==15&&i==15)?"};":", "); } } trace(str);
output: static const float widths[] = {0.4375, 0.4375, 0.4375, 0.4375, 0.4375, 0.4375, 0.4375, 0.4375, 0.4375, 0.35, 0.35, 0.4375, 0.4375, 0.35, 0.4375, 0.4375, 0.4375, 0.4375, 0.4375, 0.4375, 0.4375, 0.4375, 0.4375, 0.4375, 0.4375, 0.4375, 0.4375, 0.4375, 0.4375, 0.4375, 0.4375, 0.4375, 0.35, 0.09375, 0.21875, 0.5, 0.375, 0.46875, 0.46875, 0.0625, 0.15625, 0.15625, 0.3125, 0.4375, 0.09375, 0.21875, 0.09375, 0.34375, 0.40625, 0.34375, 0.40625, 0.40625, 0.4375, 0.40625, 0.40625, 0.40625, 0.40625, 0.40625, 0.09375, 0.09375, 0.4375, 0.4375, 0.4375, 0.34375, 0.46875, 0.40625, 0.40625, 0.375, 0.40625, 0.375, 0.375, 0.40625, 0.40625, 0.34375, 0.34375, 0.4375, 0.375, 0.4375, 0.40625, 0.40625, 0.40625, 0.40625, 0.40625, 0.40625, 0.46875, 0.375, 0.40625, 0.4375, 0.4375, 0.40625, 0.40625, 0.1875, 0.34375, 0.1875, 0.375, 0.4375, 0.125, 0.40625, 0.40625, 0.34375, 0.40625, 0.40625, 0.375, 0.40625, 0.34375, 0.40625, 0.40625, 0.375, 0.40625, 0.46875, 0.34375, 0.40625, 0.40625, 0.40625, 0.3125, 0.34375, 0.40625, 0.34375, 0.375, 0.4375, 0.375, 0.375, 0.34375, 0.34375, 0.0625, 0.34375, 0.4375, 0.4375, 0.375, 0.4375, 0.09375, 0.5, 0.28125, 0.40625, 0.375, 0.375, 0.125, 0.53125, 0.40625, 0.15625, 0.46875, 0.4375, 0.40625, 0.4375, 0.4375, 0.09375, 0.09375, 0.28125, 0.28125, 0.25, 0.5, 0.5, 0.28125, 0.4375, 0.34375, 0.15625, 0.5, 0.4375, 0.34375, 0.40625, 0.35, 0.09375, 0.34375, 0.40625, 0.28125, 0.40625, 0.0625, 0.34375, 0.25, 0.5, 0.3125, 0.34375, 0.4375, 0.21875, 0.5, 0.25, 0.25, 0.4375, 0.21875, 0.1875, 0.125, 0.40625, 0.375, 0.09375, 0.1875, 0.25, 0.3125, 0.34375, 0.4375, 0.40625, 0.375, 0.34375, 0.40625, 0.40625, 0.40625, 0.40625, 0.40625, 0.40625, 0.4375, 0.375, 0.375, 0.375, 0.375, 0.375, 0.34375, 0.34375, 0.34375, 0.34375, 0.46875, 0.40625, 0.40625, 0.40625, 0.40625, 0.40625, 0.40625, 0.3125, 0.4375, 0.375, 0.375, 0.375, 0.375, 0.40625, 0.40625, 0.40625, 0.40625, 0.40625, 0.40625, 0.40625, 0.40625, 0.40625, 0.46875, 0.34375, 0.40625, 0.40625, 0.40625, 0.40625, 0.40625, 0.40625, 0.40625, 0.40625, 0.40625, 0.34375, 0.40625, 0.40625, 0.40625, 0.40625, 0.40625, 0.40625, 0.40625, 0.34375, 0.34375, 0.34375, 0.34375, 0.375, 0.40625, 0.375};
|
|
|
Logged
|
|
|
|