scaffold.libs_as.starling.text.MiniBitmapFont.as Maven / Gradle / Ivy
// =================================================================================================
//
// Starling Framework
// Copyright 2011-2015 Gamua. All Rights Reserved.
//
// This program is free software. You can redistribute and/or modify it
// in accordance with the terms of the accompanying license agreement.
//
// =================================================================================================
package starling.text
{
import flash.display.BitmapData;
import flash.geom.Rectangle;
import flash.utils.ByteArray;
import starling.textures.Texture;
/** @private
* This class contains constants for the 'MINI' bitmap font. It's done that way to avoid
* a dependency on the 'mx.core' library (which is required for the 'Embed' statement).
*
* The font is based on "uni05_53.ttf" from Craig Kroeger (http://www.miniml.com) and was
* converted to a Bitmap Font with "GlyphDesigner" from 71squared (http://www.71squared.com).
*
*/
internal class MiniBitmapFont
{
private static const BITMAP_WIDTH:int = 128;
private static const BITMAP_HEIGHT:int = 64;
private static const BITMAP_DATA:Array = [
2027613533, 3413039936, 202148514, 2266925598, 4206886452, 4286853117, 2034947,
3202703399, 352977282, 2957757964, 3113652880, 2158068882, 1468709156, 2268063717,
2779310143, 2101025806, 3416509055, 4215794539, 3602168838, 1038056207, 1932393374,
3182285627, 3086802234, 1741291262, 2017257123, 3395280843, 984074419, 3049693147,
3986077023, 1055013549, 1806563255, 1754714962, 1577746187, 1124058786, 3888759258,
2482229043, 2916583666, 3743065328, 866060213, 1695195001, 2401582068, 3113347901,
2616521596, 1053798161, 2093370968, 4229025683, 560451479, 854767518, 2610241322,
4279041348, 4181572480, 4031244973, 587139110, 1081376765, 962217926, 783603325,
3605526425, 4102001916, 289204733, 2635140255, 3453981695, 3487854373, 2132197241,
3164775074, 4257640328, 770238970, 144664537, 707141570, 2934433071, 871272893,
512964596, 808491899, 481894297, 3095982481, 3598364156, 1710636358, 2904016319,
1751040139, 596966466, 1363963692, 465815609, 315567311, 4290666159, 4086022551,
179721458, 2221734970, 3942224988, 1519355876, 3292323782, 3933427230, 3314199893,
3736227348, 3846038425, 603088884, 2677349227, 3207069327, 3555275967, 3063054283,
3064577213, 3412044179, 693642210, 4280513949, 762928717, 1802215333, 3774849674,
4221155330, 970959395, 557220237, 2107226136, 3509822982, 3403284788, 4265820019,
898597576, 991077243, 2091615904, 3334716888, 633599866, 4218780109, 2216000376,
834870947, 2118009742, 1362731961, 236280636, 1274945142, 1458729366, 797960805,
3289369720, 2103717340, 3946406003, 2676522889, 1624104606, 1156993903, 3186170404,
2254499071, 1204911924, 1314218830, 3307086392, 2824275959, 3839865679, 2073394964,
1873329433, 1754205930, 1528429545, 1631106062, 2263272465, 4220497047, 3522893765,
3641376303, 707451487, 3452496787, 1390653868, 2620555793, 1027328684, 3419683476,
3662193703, 765701986, 3808279132, 786403271, 3824435837, 713234896, 4261856399,
3471930731, 3993492879, 1447960461, 1398434593, 1914230187, 2398643285, 4156374464,
3859339207, 3220700061, 3373248762, 3186030434, 1315917060, 2809852481, 4008553903,
4105611953, 1599499652, 3513857591, 877854499, 4198259455, 3648560077, 2838035419,
3255594190, 2465578457, 4263505201, 534904657, 2889261598, 1358214576, 1069250354,
3870010557, 2628896583, 3448610878, 442343309, 1024736866, 4015119133, 3250867279,
1513359261, 2442089596, 1944476762, 735490552, 426990058, 4234106111, 1204305707,
3330995265, 2398649368, 4221048123, 1724669255, 3801115709, 3489328790, 3896402933,
3696936939, 2836983295, 3656750393, 3349724512, 3810416287, 3654997608, 4284455103,
2294939563, 4207697932, 642748805, 2476981639, 2319419898, 572956615, 3833238940,
964924880, 2081600351, 3572458416, 2056247513, 1951368808, 2133449703, 2783728628,
512866577, 913279200, 1678129016, 3488578991, 3373952929, 2562996951, 3666058925,
1664169178, 1943591935, 750675303, 154399903, 2571590890, 852654952, 4117307766,
1971649621, 4180195820, 1222535348, 4283953215, 2880662236, 2717410980, 1175907705,
1157322027, 505963121, 2631540616, 3661227656, 3591803353, 2624126821, 1948662907,
3596065103, 1147387734, 256773959, 1173572460, 2361957471, 4210876076, 3080180620,
3464801210, 3821654259, 1465302035, 2851185457, 3143266144, 3793180414, 3368833103,
4274670712, 3473819108, 3487569332, 773123355, 1618635668, 2570176190, 2075248691,
1740805534, 288646743, 1837597401, 603556968, 3182536872, 673184603, 3088757053,
2897054404, 3192651316, 2885335802, 1057233368, 1118437241, 4182126463, 3110464775,
3313191614, 2360987274, 735505357, 2992631425, 2360928811, 4187834527, 279183208,
1586420003, 1174008423, 4062987589, 1162167621, 1162167621, 1162167621, 1162167621,
1174119799, 787274608
];
private static const XML_DATA:XML =
;
public static function get texture():Texture
{
var bitmapData:BitmapData = getBitmapData();
var texture:Texture = Texture.fromBitmapData(bitmapData, false);
bitmapData.dispose();
bitmapData = null;
texture.root.onRestore = function():void
{
bitmapData = getBitmapData();
texture.root.uploadBitmapData(bitmapData);
bitmapData.dispose();
bitmapData = null;
};
return texture;
}
private static function getBitmapData():BitmapData
{
var bmpData:BitmapData = new BitmapData(BITMAP_WIDTH, BITMAP_HEIGHT);
var bmpBytes:ByteArray = new ByteArray();
var numBytes:int = BITMAP_DATA.length;
for (var i:int=0; i