diff --git a/lime/text/Font.hx b/lime/text/Font.hx index 8dbe2c8ea..60a1bfb50 100644 --- a/lime/text/Font.hx +++ b/lime/text/Font.hx @@ -73,7 +73,7 @@ class Font { } - public function getGlyphIndex (character:String):Int { + public function getGlyph (character:String):Glyph { #if (cpp || neko || nodejs) return lime_font_get_glyph_index (__handle, character); @@ -84,7 +84,7 @@ class Font { } - public function getGlyphIndices (characters:String):Array { + public function getGlyphs (characters:String):Array { #if (cpp || neko || nodejs) return lime_font_get_glyph_indices (__handle, characters); @@ -95,10 +95,10 @@ class Font { } - public function getGlyphMetrics (index:Int):GlyphMetrics { + public function getGlyphMetrics (glyph:Glyph):GlyphMetrics { #if (cpp || neko || nodejs) - var value = lime_font_get_glyph_metrics (__handle, index); + var value = lime_font_get_glyph_metrics (__handle, glyph); var metrics = new GlyphMetrics (); metrics.height = value.height; @@ -117,7 +117,7 @@ class Font { } - public function renderGlyph (index:Int, fontSize:Int):Image { + public function renderGlyph (glyph:Glyph, fontSize:Int):Image { #if (cpp || neko || nodejs) @@ -126,7 +126,7 @@ class Font { var bytes = new ByteArray (); bytes.bigEndian = false; - if (lime_font_render_glyph (__handle, index, bytes)) { + if (lime_font_render_glyph (__handle, glyph, bytes)) { bytes.position = 0; @@ -155,16 +155,32 @@ class Font { } - public function renderGlyphs (indices:Array, fontSize:Int):Map { + public function renderGlyphs (glyphs:Array, fontSize:Int):Map { #if (cpp || neko || nodejs) + var uniqueGlyphs = new Map (); + + for (glyph in glyphs) { + + uniqueGlyphs.set (glyph, true); + + } + + var glyphList = []; + + for (key in uniqueGlyphs.keys ()) { + + glyphList.push (key); + + } + lime_font_set_size (__handle, fontSize); var bytes = new ByteArray (); bytes.bigEndian = false; - if (lime_font_render_glyphs (__handle, indices, bytes)) { + if (lime_font_render_glyphs (__handle, glyphList, bytes)) { bytes.position = 0; @@ -230,7 +246,7 @@ class Font { } - var map = new Map (); + var map = new Map (); var buffer = new ImageBuffer (null, bufferWidth, bufferHeight, 1); var data = new ByteArray (bufferWidth * bufferHeight); diff --git a/lime/text/Glyph.hx b/lime/text/Glyph.hx new file mode 100644 index 000000000..e406cb471 --- /dev/null +++ b/lime/text/Glyph.hx @@ -0,0 +1,15 @@ +package lime.text; + + +abstract Glyph(Int) from Int to Int { + + + public function new (i:Int) { + + this = i; + + + } + + +} \ No newline at end of file