Repository navigation
Expand file tree
/
Copy pathBitmapFontTextFormat.as
More file actions
93 lines (83 loc) · 2.13 KB
/
Copy pathBitmapFontTextFormat.as
File metadata and controls
93 lines (83 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
Feathers
Copyright 2012-2013 Joshua Tynjala. 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 feathers.text
{
import flash.text.TextFormatAlign;
import starling.text.BitmapFont;
import starling.text.TextField;
/**
* Customizes a bitmap font for use by a <code>BitmapFontTextRenderer</code>.
*
* @see feathers.controls.text.BitmapFontTextRenderer
*/
public class BitmapFontTextFormat
{
/**
* Constructor.
*/
public function BitmapFontTextFormat(font:Object, size:Number = NaN, color:uint = 0xffffff, align:String = TextFormatAlign.LEFT)
{
if(font is String)
{
font = TextField.getBitmapFont(font as String);
}
if(!(font is BitmapFont))
{
throw new ArgumentError("BitmapFontTextFormat font must be a BitmapFont instance or a String representing the name of a registered bitmap font.");
}
this.font = BitmapFont(font);
this.size = size;
this.color = color;
this.align = align;
}
/**
* The name of the font.
*/
public function get fontName():String
{
return this.font ? this.font.name : null;
}
/**
* The BitmapFont instance to use.
*/
public var font:BitmapFont;
/**
* The multiply color.
*
* @default 0xffffff
*/
public var color:uint;
/**
* The size at which to display the bitmap font. Set to <code>NaN</code>
* to use the default size in the BitmapFont instance.
*
* @default NaN
*/
public var size:Number;
/**
* The number of extra pixels between characters. May be positive or
* negative.
*
* @default 0
*/
public var letterSpacing:Number = 0;
[Inspectable(type="String",enumeration="left,center,right")]
/**
* Determines the alignment of the text, either left, center, or right.
*
* @default flash.text.TextFormatAlign.LEFT
*/
public var align:String = TextFormatAlign.LEFT;
/**
* Determines if the kerning values defined in the BitmapFont instance
* will be used for layout.
*
* @default true
*/
public var isKerningEnabled:Boolean = true;
}
}