Change Font.getChar* to Font.getGlyph* (makes more sense) and remove unused Glyph/GlyphIndex classes
This commit is contained in:
@@ -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<Int> {
|
||||
public function getGlyphIndices (characters:String):Array<Int> {
|
||||
|
||||
#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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
package lime.text;
|
||||
|
||||
|
||||
class GlyphSet {
|
||||
|
||||
|
||||
public var glyphs:String;
|
||||
public var ranges:Array<GlyphRange>;
|
||||
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -8,6 +8,10 @@
|
||||
#include <utils/Resource.h>
|
||||
#include <hx/CFFI.h>
|
||||
|
||||
#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 ();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 ();
|
||||
|
||||
Reference in New Issue
Block a user