Resolve issues in Font.renderGlyph(s)
This commit is contained in:
@@ -1454,51 +1454,66 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
bool lime_font_render_glyph (value fontHandle, int index, value data) {
|
||||
value lime_font_render_glyph (value fontHandle, int index, value data) {
|
||||
|
||||
#ifdef LIME_FREETYPE
|
||||
Font *font = (Font*)val_data (fontHandle);
|
||||
Bytes bytes (data);
|
||||
return font->RenderGlyph (index, &bytes);
|
||||
#else
|
||||
return false;
|
||||
|
||||
if (font->RenderGlyph (index, &bytes)) {
|
||||
|
||||
return bytes.Value (data);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
HL_PRIM bool hl_lime_font_render_glyph (HL_CFFIPointer* fontHandle, int index, Bytes* data) {
|
||||
HL_PRIM Bytes* hl_lime_font_render_glyph (HL_CFFIPointer* fontHandle, int index, Bytes* data) {
|
||||
|
||||
#ifdef LIME_FREETYPE
|
||||
Font *font = (Font*)fontHandle->ptr;
|
||||
return font->RenderGlyph (index, data);
|
||||
#else
|
||||
return false;
|
||||
|
||||
if (font->RenderGlyph (index, data)) {
|
||||
|
||||
return data;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool lime_font_render_glyphs (value fontHandle, value indices, value data) {
|
||||
value lime_font_render_glyphs (value fontHandle, value indices, value data) {
|
||||
|
||||
#ifdef LIME_FREETYPE
|
||||
Font *font = (Font*)val_data (fontHandle);
|
||||
Bytes bytes (data);
|
||||
return font->RenderGlyphs (indices, &bytes);
|
||||
#else
|
||||
return false;
|
||||
|
||||
if (font->RenderGlyphs (indices, &bytes)) {
|
||||
|
||||
return bytes.Value (data);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
HL_PRIM bool hl_lime_font_render_glyphs (HL_CFFIPointer* fontHandle, hl_varray* indices, Bytes* data) {
|
||||
HL_PRIM Bytes* hl_lime_font_render_glyphs (HL_CFFIPointer* fontHandle, hl_varray* indices, Bytes* data) {
|
||||
|
||||
// #ifdef LIME_FREETYPE
|
||||
// Font *font = (Font*)fontHandle->ptr;
|
||||
// return font->RenderGlyphs (indices, &bytes);
|
||||
// #else
|
||||
return false;
|
||||
return NULL;
|
||||
// #endif
|
||||
|
||||
}
|
||||
@@ -3983,8 +3998,8 @@ namespace lime {
|
||||
DEFINE_HL_PRIM (_TCFFIPOINTER, lime_font_load_bytes, _TBYTES);
|
||||
DEFINE_HL_PRIM (_TCFFIPOINTER, lime_font_load_file, _STRING);
|
||||
DEFINE_HL_PRIM (_DYN, lime_font_outline_decompose, _TCFFIPOINTER _I32);
|
||||
DEFINE_HL_PRIM (_BOOL, lime_font_render_glyph, _TCFFIPOINTER _I32 _TBYTES);
|
||||
DEFINE_HL_PRIM (_BOOL, lime_font_render_glyphs, _TCFFIPOINTER _ARR _TBYTES);
|
||||
DEFINE_HL_PRIM (_TBYTES, lime_font_render_glyph, _TCFFIPOINTER _I32 _TBYTES);
|
||||
DEFINE_HL_PRIM (_TBYTES, lime_font_render_glyphs, _TCFFIPOINTER _ARR _TBYTES);
|
||||
DEFINE_HL_PRIM (_VOID, lime_font_set_size, _TCFFIPOINTER _I32);
|
||||
DEFINE_HL_PRIM (_VOID, lime_gamepad_add_mappings, _ARR);
|
||||
DEFINE_HL_PRIM (_VOID, lime_gamepad_event_manager_register, _FUN(_VOID, _NO_ARG) _TGAMEPAD_EVENT);
|
||||
|
||||
@@ -111,8 +111,8 @@ class NativeCFFI {
|
||||
@:cffi private static function lime_font_load_bytes (data:Dynamic):Dynamic;
|
||||
@:cffi private static function lime_font_load_file (path:Dynamic):Dynamic;
|
||||
@:cffi private static function lime_font_outline_decompose (handle:Dynamic, size:Int):Dynamic;
|
||||
@:cffi private static function lime_font_render_glyph (handle:Dynamic, index:Int, data:Dynamic):Bool;
|
||||
@:cffi private static function lime_font_render_glyphs (handle:Dynamic, indices:Dynamic, data:Dynamic):Bool;
|
||||
@:cffi private static function lime_font_render_glyph (handle:Dynamic, index:Int, data:Dynamic):Dynamic;
|
||||
@:cffi private static function lime_font_render_glyphs (handle:Dynamic, indices:Dynamic, data:Dynamic):Dynamic;
|
||||
@:cffi private static function lime_font_set_size (handle:Dynamic, size:Int):Void;
|
||||
@:cffi private static function lime_gamepad_add_mappings (mappings:Dynamic):Void;
|
||||
@:cffi private static function lime_gamepad_get_device_guid (id:Int):Dynamic;
|
||||
@@ -258,8 +258,8 @@ class NativeCFFI {
|
||||
private static var lime_font_load_bytes = new cpp.Callable<cpp.Object->cpp.Object> (cpp.Prime._loadPrime ("lime", "lime_font_load_bytes", "oo", false));
|
||||
private static var lime_font_load_file = new cpp.Callable<cpp.Object->cpp.Object> (cpp.Prime._loadPrime ("lime", "lime_font_load_file", "oo", false));
|
||||
private static var lime_font_outline_decompose = new cpp.Callable<cpp.Object->Int->cpp.Object> (cpp.Prime._loadPrime ("lime", "lime_font_outline_decompose", "oio", false));
|
||||
private static var lime_font_render_glyph = new cpp.Callable<cpp.Object->Int->cpp.Object->Bool> (cpp.Prime._loadPrime ("lime", "lime_font_render_glyph", "oiob", false));
|
||||
private static var lime_font_render_glyphs = new cpp.Callable<cpp.Object->cpp.Object->cpp.Object->Bool> (cpp.Prime._loadPrime ("lime", "lime_font_render_glyphs", "ooob", false));
|
||||
private static var lime_font_render_glyph = new cpp.Callable<cpp.Object->Int->cpp.Object->cpp.Object> (cpp.Prime._loadPrime ("lime", "lime_font_render_glyph", "oioo", false));
|
||||
private static var lime_font_render_glyphs = new cpp.Callable<cpp.Object->cpp.Object->cpp.Object->cpp.Object> (cpp.Prime._loadPrime ("lime", "lime_font_render_glyphs", "oooo", false));
|
||||
private static var lime_font_set_size = new cpp.Callable<cpp.Object->Int->cpp.Void> (cpp.Prime._loadPrime ("lime", "lime_font_set_size", "oiv", false));
|
||||
private static var lime_gamepad_add_mappings = new cpp.Callable<cpp.Object->cpp.Void> (cpp.Prime._loadPrime ("lime", "lime_gamepad_add_mappings", "ov", false));
|
||||
private static var lime_gamepad_get_device_guid = new cpp.Callable<Int->cpp.Object> (cpp.Prime._loadPrime ("lime", "lime_gamepad_get_device_guid", "io", false));
|
||||
@@ -557,8 +557,8 @@ class NativeCFFI {
|
||||
@:hlNative("lime", "lime_font_load_bytes") private static function lime_font_load_bytes (data:Bytes):CFFIPointer { return null; }
|
||||
@:hlNative("lime", "lime_font_load_file") private static function lime_font_load_file (path:String):CFFIPointer { return null; }
|
||||
@:hlNative("lime", "lime_font_outline_decompose") private static function lime_font_outline_decompose (handle:CFFIPointer, size:Int):Dynamic { return null; }
|
||||
@:hlNative("lime", "lime_font_render_glyph") private static function lime_font_render_glyph (handle:CFFIPointer, index:Int, data:Bytes):Bool { return false; }
|
||||
@:hlNative("lime", "lime_font_render_glyphs") private static function lime_font_render_glyphs (handle:CFFIPointer, indices:hl.NativeArray<Int>, data:Bytes):Bool { return false; }
|
||||
@:hlNative("lime", "lime_font_render_glyph") private static function lime_font_render_glyph (handle:CFFIPointer, index:Int, data:Bytes):Bytes { return null; }
|
||||
@:hlNative("lime", "lime_font_render_glyphs") private static function lime_font_render_glyphs (handle:CFFIPointer, indices:hl.NativeArray<Int>, data:Bytes):Bytes { return null; }
|
||||
@:hlNative("lime", "lime_font_set_size") private static function lime_font_set_size (handle:CFFIPointer, size:Int):Void {}
|
||||
@:hlNative("lime", "lime_gamepad_add_mappings") private static function lime_gamepad_add_mappings (mappings:hl.NativeArray<String>):Void {}
|
||||
@:hlNative("lime", "lime_gamepad_get_device_guid") private static function lime_gamepad_get_device_guid (id:Int):hl.Bytes { return null; }
|
||||
|
||||
@@ -235,8 +235,9 @@ class Font {
|
||||
//bytes.endian = (System.endianness == BIG_ENDIAN ? "bigEndian" : "littleEndian");
|
||||
|
||||
var dataPosition = 0;
|
||||
bytes = NativeCFFI.lime_font_render_glyph (src, glyph, bytes);
|
||||
|
||||
if (NativeCFFI.lime_font_render_glyph (src, glyph, bytes)) {
|
||||
if (bytes != null && bytes.length > 0) {
|
||||
|
||||
var index = bytes.getInt32 (dataPosition); dataPosition += 4;
|
||||
var width = bytes.getInt32 (dataPosition); dataPosition += 4;
|
||||
@@ -298,8 +299,9 @@ class Font {
|
||||
NativeCFFI.lime_font_set_size (src, fontSize);
|
||||
|
||||
var bytes = Bytes.alloc (0);
|
||||
bytes = NativeCFFI.lime_font_render_glyphs (src, glyphList, bytes);
|
||||
|
||||
if (NativeCFFI.lime_font_render_glyphs (src, glyphList, bytes)) {
|
||||
if (bytes != null && bytes.length > 0) {
|
||||
|
||||
var bytesPosition = 0;
|
||||
var count = bytes.getInt32 (bytesPosition); bytesPosition += 4;
|
||||
|
||||
Reference in New Issue
Block a user