Adding offset and advance
This commit is contained in:
@@ -11,8 +11,11 @@ import js.html.CanvasRenderingContext2D;
|
||||
typedef GlyphRect = {
|
||||
var x:Float;
|
||||
var y:Float;
|
||||
var advance:Int;
|
||||
var width:Float;
|
||||
var height:Float;
|
||||
var xOffset:Int;
|
||||
var yOffset:Int;
|
||||
}
|
||||
|
||||
typedef GlyphData = {
|
||||
@@ -115,6 +118,9 @@ class Font {
|
||||
glyphRects.set(c, {
|
||||
x: x,
|
||||
y: y,
|
||||
xOffset: 0,
|
||||
yOffset: 0,
|
||||
advance: Std.int(width),
|
||||
width: width,
|
||||
height: height
|
||||
});
|
||||
@@ -180,6 +186,9 @@ class Font {
|
||||
glyphRects.set(c, {
|
||||
x: x,
|
||||
y: y,
|
||||
xOffset: 0,
|
||||
yOffset: 0,
|
||||
advance: Std.int(tf.textWidth + 2),
|
||||
width: tf.textWidth + 2,
|
||||
height: tf.textHeight + 2
|
||||
});
|
||||
@@ -214,6 +223,9 @@ class Font {
|
||||
glyphRects.set (glyph.char, {
|
||||
x: glyph.x,
|
||||
y: glyph.y,
|
||||
xOffset: glyph.xOffset,
|
||||
yOffset: glyph.yOffset,
|
||||
advance: glyph.advance,
|
||||
width: glyph.width,
|
||||
height: glyph.height,
|
||||
});
|
||||
|
||||
@@ -13,6 +13,9 @@ namespace lime {
|
||||
|
||||
static int id_x;
|
||||
static int id_y;
|
||||
static int id_x_offset;
|
||||
static int id_y_offset;
|
||||
static int id_advance;
|
||||
static int id_width;
|
||||
static int id_height;
|
||||
static int id_char;
|
||||
@@ -62,6 +65,9 @@ namespace lime {
|
||||
id_height = val_id ("height");
|
||||
id_x = val_id ("x");
|
||||
id_y = val_id ("y");
|
||||
id_x_offset = val_id ("xOffset");
|
||||
id_y_offset = val_id ("yOffset");
|
||||
id_advance = val_id ("advance");
|
||||
id_char = val_id ("char");
|
||||
init = true;
|
||||
|
||||
@@ -162,6 +168,9 @@ namespace lime {
|
||||
value v = alloc_empty_object ();
|
||||
alloc_field (v, id_x, alloc_int (x));
|
||||
alloc_field (v, id_y, alloc_int (y));
|
||||
alloc_field (v, id_x_offset, alloc_int (face->glyph->metrics.horiBearingX / 64));
|
||||
alloc_field (v, id_y_offset, alloc_int (face->glyph->metrics.horiBearingY / 64));
|
||||
alloc_field (v, id_advance, alloc_int (face->glyph->metrics.horiAdvance / 64));
|
||||
alloc_field (v, id_width, alloc_int (bitmap.width));
|
||||
alloc_field (v, id_height, alloc_int (bitmap.rows));
|
||||
alloc_field (v, id_char, alloc_string (c));
|
||||
|
||||
Reference in New Issue
Block a user