Add Cairo showGlyphs
This commit is contained in:
@@ -5,6 +5,7 @@ import lime.math.Matrix3;
|
||||
import lime.math.Vector2;
|
||||
import lime.system.CFFI;
|
||||
import lime.system.CFFIPointer;
|
||||
import lime.text.Glyph;
|
||||
|
||||
#if !macro
|
||||
@:build(lime.system.CFFI.build())
|
||||
@@ -402,6 +403,15 @@ class Cairo {
|
||||
}
|
||||
|
||||
|
||||
public function showGlyphs (glyphs:Array<CairoGlyph>):Void {
|
||||
|
||||
#if (lime_cairo && !macro)
|
||||
lime_cairo_show_glyphs (handle, glyphs);
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function showPage ():Void {
|
||||
|
||||
#if (lime_cairo && !macro)
|
||||
@@ -946,6 +956,7 @@ class Cairo {
|
||||
@:cffi private static function lime_cairo_set_source_rgba (handle:CFFIPointer, r:Float, g:Float, b:Float, a:Float):Void;
|
||||
@:cffi private static function lime_cairo_set_source_surface (handle:CFFIPointer, surface:CFFIPointer, x:Float, y:Float):Void;
|
||||
@:cffi private static function lime_cairo_set_tolerance (handle:CFFIPointer, tolerance:Float):Void;
|
||||
@:cffi private static function lime_cairo_show_glyphs (handle:CFFIPointer, glyphs:Dynamic):Void;
|
||||
@:cffi private static function lime_cairo_show_page (handle:CFFIPointer):Void;
|
||||
@:cffi private static function lime_cairo_show_text (handle:CFFIPointer, text:String):Void;
|
||||
@:cffi private static function lime_cairo_status (handle:CFFIPointer):Int;
|
||||
|
||||
21
lime/graphics/cairo/CairoGlyph.hx
Normal file
21
lime/graphics/cairo/CairoGlyph.hx
Normal file
@@ -0,0 +1,21 @@
|
||||
package lime.graphics.cairo;
|
||||
|
||||
|
||||
class CairoGlyph {
|
||||
|
||||
|
||||
public var index:Int;
|
||||
public var x:Float;
|
||||
public var y:Float;
|
||||
|
||||
|
||||
public function new (index:Int, x:Float = 0, y:Float = 0) {
|
||||
|
||||
this.index = index;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -11,6 +11,10 @@
|
||||
namespace lime {
|
||||
|
||||
|
||||
static int id_index;
|
||||
static int id_x;
|
||||
static int id_y;
|
||||
static bool init = false;
|
||||
cairo_user_data_key_t userData;
|
||||
|
||||
|
||||
@@ -902,6 +906,36 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
void lime_cairo_show_glyphs (value handle, value glyphs) {
|
||||
|
||||
if (!init) {
|
||||
|
||||
id_index = val_id ("index");
|
||||
id_x = val_id ("x");
|
||||
id_y = val_id ("y");
|
||||
|
||||
}
|
||||
|
||||
int length = val_array_size (glyphs);
|
||||
cairo_glyph_t* _glyphs = cairo_glyph_allocate (length);
|
||||
|
||||
value glyph;
|
||||
|
||||
for (int i = 0; i < length; i++) {
|
||||
|
||||
glyph = val_array_i (glyphs, i);
|
||||
_glyphs[i].index = val_int (val_field (glyph, id_index));
|
||||
_glyphs[i].x = val_number (val_field (glyph, id_x));
|
||||
_glyphs[i].y = val_number (val_field (glyph, id_y));
|
||||
|
||||
}
|
||||
|
||||
cairo_show_glyphs ((cairo_t*)val_data (handle), _glyphs, length);
|
||||
cairo_glyph_free (_glyphs);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void lime_cairo_show_page (value handle) {
|
||||
|
||||
cairo_show_page ((cairo_t*)val_data (handle));
|
||||
@@ -1088,6 +1122,7 @@ namespace lime {
|
||||
DEFINE_PRIME5v (lime_cairo_set_source_rgba);
|
||||
DEFINE_PRIME4v (lime_cairo_set_source_surface);
|
||||
DEFINE_PRIME2v (lime_cairo_set_tolerance);
|
||||
DEFINE_PRIME2v (lime_cairo_show_glyphs);
|
||||
DEFINE_PRIME1v (lime_cairo_show_page);
|
||||
DEFINE_PRIME2v (lime_cairo_show_text);
|
||||
DEFINE_PRIME1 (lime_cairo_status);
|
||||
|
||||
Reference in New Issue
Block a user