String fixes
This commit is contained in:
@@ -1109,7 +1109,12 @@ namespace lime {
|
|||||||
#ifdef LIME_FREETYPE
|
#ifdef LIME_FREETYPE
|
||||||
Font *font = (Font*)fontHandle->ptr;
|
Font *font = (Font*)fontHandle->ptr;
|
||||||
wchar_t *name = font->GetFamilyName ();
|
wchar_t *name = font->GetFamilyName ();
|
||||||
return (vbyte*)name;
|
int size = std::wcslen (name);
|
||||||
|
char* result = (char*)malloc (size + 1);
|
||||||
|
std::wcstombs (result, name, size);
|
||||||
|
result[size] = '\0';
|
||||||
|
delete name;
|
||||||
|
return (vbyte*)result;
|
||||||
#else
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2272,7 +2272,6 @@ namespace lime {
|
|||||||
int length = strlen (version);
|
int length = strlen (version);
|
||||||
char* _version = (char*)malloc (length + 1);
|
char* _version = (char*)malloc (length + 1);
|
||||||
strcpy (_version, version);
|
strcpy (_version, version);
|
||||||
_version[length] = '\0';
|
|
||||||
return (vbyte*)_version;
|
return (vbyte*)_version;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2207,7 +2207,6 @@ namespace lime {
|
|||||||
int length = strlen (result);
|
int length = strlen (result);
|
||||||
char* _result = (char*)malloc (length + 1);
|
char* _result = (char*)malloc (length + 1);
|
||||||
strcpy (_result, result);
|
strcpy (_result, result);
|
||||||
_result[length] = '\0';
|
|
||||||
return (vbyte*)_result;
|
return (vbyte*)_result;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -3389,7 +3388,6 @@ namespace lime {
|
|||||||
int length = strlen (result);
|
int length = strlen (result);
|
||||||
char* _result = (char*)malloc (length + 1);
|
char* _result = (char*)malloc (length + 1);
|
||||||
strcpy (_result, result);
|
strcpy (_result, result);
|
||||||
_result[length] = '\0';
|
|
||||||
return (vbyte*)_result;
|
return (vbyte*)_result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2191,7 +2191,6 @@ namespace lime {
|
|||||||
int length = strlen (result);
|
int length = strlen (result);
|
||||||
char* _result = (char*)malloc (length + 1);
|
char* _result = (char*)malloc (length + 1);
|
||||||
strcpy (_result, result);
|
strcpy (_result, result);
|
||||||
_result[length] = '\0';
|
|
||||||
return (vbyte*)_result;
|
return (vbyte*)_result;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2211,7 +2210,6 @@ namespace lime {
|
|||||||
int length = strlen (result);
|
int length = strlen (result);
|
||||||
char* _result = (char*)malloc (length + 1);
|
char* _result = (char*)malloc (length + 1);
|
||||||
strcpy (_result, result);
|
strcpy (_result, result);
|
||||||
_result[length] = '\0';
|
|
||||||
return (vbyte*)_result;
|
return (vbyte*)_result;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2762,7 +2760,6 @@ namespace lime {
|
|||||||
int length = strlen (result);
|
int length = strlen (result);
|
||||||
char* _result = (char*)malloc (length + 1);
|
char* _result = (char*)malloc (length + 1);
|
||||||
strcpy (_result, result);
|
strcpy (_result, result);
|
||||||
_result[length] = '\0';
|
|
||||||
return (vbyte*)_result;
|
return (vbyte*)_result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -622,11 +622,28 @@ namespace lime {
|
|||||||
hl_dyn_seti (ret, hl_hash_utf8 ("is_bold"), &hlt_bool, ((FT_Face)face)->style_flags & FT_STYLE_FLAG_BOLD);
|
hl_dyn_seti (ret, hl_hash_utf8 ("is_bold"), &hlt_bool, ((FT_Face)face)->style_flags & FT_STYLE_FLAG_BOLD);
|
||||||
hl_dyn_seti (ret, hl_hash_utf8 ("num_glyphs"), &hlt_i32, num_glyphs);
|
hl_dyn_seti (ret, hl_hash_utf8 ("num_glyphs"), &hlt_i32, num_glyphs);
|
||||||
|
|
||||||
// TODO: if family_name is null, convert to wide string
|
char* _family_name = NULL;
|
||||||
|
|
||||||
|
if (family_name != NULL) {
|
||||||
|
|
||||||
|
int length = std::wcslen (family_name);
|
||||||
|
char* result = (char*)malloc (length + 1);
|
||||||
|
std::wcstombs (result, family_name, length);
|
||||||
|
result[length] = '\0';
|
||||||
|
delete family_name;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
int length = strlen (((FT_Face)face)->family_name);
|
||||||
|
_family_name = (char*)malloc (length + 1);
|
||||||
|
strcpy (_family_name, ((FT_Face)face)->family_name);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
char* style_name = (char*)malloc(strlen(((FT_Face)face)->style_name) + 1);
|
char* style_name = (char*)malloc(strlen(((FT_Face)face)->style_name) + 1);
|
||||||
strcpy(style_name, ((FT_Face)face)->style_name);
|
strcpy(style_name, ((FT_Face)face)->style_name);
|
||||||
|
|
||||||
hl_dyn_setp (ret, hl_hash_utf8 ("family_name"), &hlt_bytes, family_name);
|
hl_dyn_setp (ret, hl_hash_utf8 ("family_name"), &hlt_bytes, _family_name);
|
||||||
hl_dyn_setp (ret, hl_hash_utf8 ("style_name"), &hlt_bytes, style_name);
|
hl_dyn_setp (ret, hl_hash_utf8 ("style_name"), &hlt_bytes, style_name);
|
||||||
hl_dyn_seti (ret, hl_hash_utf8 ("em_size"), &hlt_i32, ((FT_Face)face)->units_per_EM);
|
hl_dyn_seti (ret, hl_hash_utf8 ("em_size"), &hlt_i32, ((FT_Face)face)->units_per_EM);
|
||||||
hl_dyn_seti (ret, hl_hash_utf8 ("ascend"), &hlt_i32, ((FT_Face)face)->ascender);
|
hl_dyn_seti (ret, hl_hash_utf8 ("ascend"), &hlt_i32, ((FT_Face)face)->ascender);
|
||||||
|
|||||||
@@ -727,7 +727,6 @@ namespace lime {
|
|||||||
int length = strlen (result);
|
int length = strlen (result);
|
||||||
char* _result = (char*)malloc (length + 1);
|
char* _result = (char*)malloc (length + 1);
|
||||||
strcpy (_result, result);
|
strcpy (_result, result);
|
||||||
_result[length] = '\0';
|
|
||||||
return (vbyte*)_result;
|
return (vbyte*)_result;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1149,7 +1148,6 @@ namespace lime {
|
|||||||
int length = strlen (result);
|
int length = strlen (result);
|
||||||
char* _result = (char*)malloc (length + 1);
|
char* _result = (char*)malloc (length + 1);
|
||||||
strcpy (_result, result);
|
strcpy (_result, result);
|
||||||
_result[length] = '\0';
|
|
||||||
return (vbyte*)_result;
|
return (vbyte*)_result;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1419,7 +1417,6 @@ namespace lime {
|
|||||||
int length = strlen (result);
|
int length = strlen (result);
|
||||||
char* _result = (char*)malloc (length + 1);
|
char* _result = (char*)malloc (length + 1);
|
||||||
strcpy (_result, result);
|
strcpy (_result, result);
|
||||||
_result[length] = '\0';
|
|
||||||
return (vbyte*)_result;
|
return (vbyte*)_result;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1608,7 +1605,6 @@ namespace lime {
|
|||||||
int length = strlen (result);
|
int length = strlen (result);
|
||||||
char* _result = (char*)malloc (length + 1);
|
char* _result = (char*)malloc (length + 1);
|
||||||
strcpy (_result, result);
|
strcpy (_result, result);
|
||||||
_result[length] = '\0';
|
|
||||||
return (vbyte*)_result;
|
return (vbyte*)_result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -472,7 +472,7 @@ class Font
|
|||||||
if (name == null)
|
if (name == null)
|
||||||
{
|
{
|
||||||
#if hl
|
#if hl
|
||||||
name = @:privateAccess String.fromUCS2(NativeCFFI.lime_font_get_family_name(src));
|
name = @:privateAccess String.fromUTF8(NativeCFFI.lime_font_get_family_name(src));
|
||||||
#else
|
#else
|
||||||
name = cast NativeCFFI.lime_font_get_family_name(src);
|
name = cast NativeCFFI.lime_font_get_family_name(src);
|
||||||
#end
|
#end
|
||||||
|
|||||||
Reference in New Issue
Block a user