diff --git a/lime/text/Font.hx b/lime/text/Font.hx index ce116e6ce..8dbe2c8ea 100644 --- a/lime/text/Font.hx +++ b/lime/text/Font.hx @@ -3,8 +3,6 @@ package lime.text; import lime.graphics.Image; import lime.graphics.ImageBuffer; -import lime.math.Vector2; -import lime.text.Glyph; import lime.utils.ByteArray; import lime.utils.UInt8Array; import lime.system.System; @@ -75,10 +73,10 @@ class Font { } - public function getCharIndex (character:String):Int { + public function getGlyphIndex (character:String):Int { #if (cpp || neko || nodejs) - return lime_font_get_char_index (__handle, character); + return lime_font_get_glyph_index (__handle, character); #else return -1; #end @@ -86,10 +84,10 @@ class Font { } - public function getCharIndices (characters:String):Array { + public function getGlyphIndices (characters:String):Array { #if (cpp || neko || nodejs) - return lime_font_get_char_indices (__handle, characters); + return lime_font_get_glyph_indices (__handle, characters); #else return null; #end @@ -433,10 +431,10 @@ class Font { #if (cpp || neko || nodejs) private static var lime_font_get_ascender = System.load ("lime", "lime_font_get_ascender", 1); - private static var lime_font_get_char_index = System.load ("lime", "lime_font_get_char_index", 2); - private static var lime_font_get_char_indices = System.load ("lime", "lime_font_get_char_indices", 2); private static var lime_font_get_descender = System.load ("lime", "lime_font_get_descender", 1); private static var lime_font_get_family_name = System.load ("lime", "lime_font_get_family_name", 1); + private static var lime_font_get_glyph_index = System.load ("lime", "lime_font_get_glyph_index", 2); + private static var lime_font_get_glyph_indices = System.load ("lime", "lime_font_get_glyph_indices", 2); private static var lime_font_get_glyph_metrics = System.load ("lime", "lime_font_get_glyph_metrics", 2); private static var lime_font_get_height = System.load ("lime", "lime_font_get_height", 1); private static var lime_font_get_num_glyphs = System.load ("lime", "lime_font_get_num_glyphs", 1); diff --git a/lime/text/Glyph.hx b/lime/text/Glyph.hx deleted file mode 100644 index ef5aa1992..000000000 --- a/lime/text/Glyph.hx +++ /dev/null @@ -1,26 +0,0 @@ -package lime.text; - - -import lime.graphics.Image; - - -class Glyph { - - - public var charCode:Int; - public var image:Image; - public var index:Int; - public var metrics:GlyphMetrics; - public var x:Int; - public var y:Int; - - - public function new (charCode:Int = -1, index:Int = -1) { - - this.charCode = charCode; - this.index = index; - - } - - -} \ No newline at end of file diff --git a/lime/text/GlyphSet.hx b/lime/text/GlyphSet.hx deleted file mode 100644 index 306ea3fd1..000000000 --- a/lime/text/GlyphSet.hx +++ /dev/null @@ -1,62 +0,0 @@ -package lime.text; - - -class GlyphSet { - - - public var glyphs:String; - public var ranges:Array; - - - public function new (glyphs:String = null, rangeStart:Int = -1, rangeEnd:Int = -1) { - - ranges = new Array (); - - if (glyphs != null) { - - addGlyphs (glyphs); - - } - - if (rangeStart > -1) { - - addRange (rangeStart, rangeEnd); - - } - - } - - - public function addGlyphs (glyphs:String):Void { - - this.glyphs += glyphs; - - } - - - public function addRange (start:Int = 0, end:Int = -1) { - - ranges.push (new GlyphRange (start, end)); - - } - - -} - - -private class GlyphRange { - - - public var end:Int; - public var start:Int; - - - public function new (start:Int, end:Int) { - - this.start = start; - this.end = end; - - } - - -} \ No newline at end of file diff --git a/project/include/text/Font.h b/project/include/text/Font.h index d8a3e8733..a48e5a5c7 100644 --- a/project/include/text/Font.h +++ b/project/include/text/Font.h @@ -8,6 +8,10 @@ #include #include +#ifdef HX_WINDOWS +#undef GetGlyphIndices +#endif + namespace lime { @@ -45,10 +49,10 @@ namespace lime { value Decompose (int em); int GetAscender (); - int GetCharIndex (char* character); - value GetCharIndices (char* characters); int GetDescender (); wchar_t *GetFamilyName (); + int GetGlyphIndex (char* character); + value GetGlyphIndices (char* characters); value GetGlyphMetrics (int index); int GetHeight (); int GetNumGlyphs (); diff --git a/project/src/ExternalInterface.cpp b/project/src/ExternalInterface.cpp index e66a479aa..e0eb61df1 100644 --- a/project/src/ExternalInterface.cpp +++ b/project/src/ExternalInterface.cpp @@ -141,30 +141,6 @@ namespace lime { } - value lime_font_get_char_index (value fontHandle, value character) { - - #ifdef LIME_FREETYPE - Font *font = (Font*)(intptr_t)val_float (fontHandle); - return alloc_int (font->GetCharIndex ((char*)val_string (character))); - #else - return alloc_int (-1); - #endif - - } - - - value lime_font_get_char_indices (value fontHandle, value characters) { - - #ifdef LIME_FREETYPE - Font *font = (Font*)(intptr_t)val_float (fontHandle); - return font->GetCharIndices ((char*)val_string (characters)); - #else - return alloc_null (); - #endif - - } - - value lime_font_get_descender (value fontHandle) { #ifdef LIME_FREETYPE @@ -189,6 +165,30 @@ namespace lime { } + value lime_font_get_glyph_index (value fontHandle, value character) { + + #ifdef LIME_FREETYPE + Font *font = (Font*)(intptr_t)val_float (fontHandle); + return alloc_int (font->GetGlyphIndex ((char*)val_string (character))); + #else + return alloc_int (-1); + #endif + + } + + + value lime_font_get_glyph_indices (value fontHandle, value characters) { + + #ifdef LIME_FREETYPE + Font *font = (Font*)(intptr_t)val_float (fontHandle); + return font->GetGlyphIndices ((char*)val_string (characters)); + #else + return alloc_null (); + #endif + + } + + value lime_font_get_glyph_metrics (value fontHandle, value index) { #ifdef LIME_FREETYPE @@ -669,10 +669,10 @@ namespace lime { DEFINE_PRIM (lime_application_update, 1); DEFINE_PRIM (lime_audio_load, 1); DEFINE_PRIM (lime_font_get_ascender, 1); - DEFINE_PRIM (lime_font_get_char_index, 2); - DEFINE_PRIM (lime_font_get_char_indices, 2); DEFINE_PRIM (lime_font_get_descender, 1); DEFINE_PRIM (lime_font_get_family_name, 1); + DEFINE_PRIM (lime_font_get_glyph_index, 2); + DEFINE_PRIM (lime_font_get_glyph_indices, 2); DEFINE_PRIM (lime_font_get_glyph_metrics, 2); DEFINE_PRIM (lime_font_get_height, 1); DEFINE_PRIM (lime_font_get_num_glyphs, 1); diff --git a/project/src/text/Font.cpp b/project/src/text/Font.cpp index 4590eca73..f4e43f050 100644 --- a/project/src/text/Font.cpp +++ b/project/src/text/Font.cpp @@ -631,34 +631,6 @@ namespace lime { } - int Font::GetCharIndex (char* character) { - - long charCode = readNextChar (character); - - return FT_Get_Char_Index ((FT_Face)face, charCode); - - } - - - value Font::GetCharIndices (char* characters) { - - value indices = alloc_array (0); - unsigned long character; - int index; - - while (*characters != 0) { - - character = readNextChar (characters); - index = FT_Get_Char_Index ((FT_Face)face, character); - val_array_push (indices, alloc_int (index)); - - } - - return indices; - - } - - int Font::GetDescender () { return ((FT_Face)face)->descender; @@ -721,6 +693,34 @@ namespace lime { } + int Font::GetGlyphIndex (char* character) { + + long charCode = readNextChar (character); + + return FT_Get_Char_Index ((FT_Face)face, charCode); + + } + + + value Font::GetGlyphIndices (char* characters) { + + value indices = alloc_array (0); + unsigned long character; + int index; + + while (*characters != 0) { + + character = readNextChar (characters); + index = FT_Get_Char_Index ((FT_Face)face, character); + val_array_push (indices, alloc_int (index)); + + } + + return indices; + + } + + value Font::GetGlyphMetrics (int index) { initialize ();