Improve handling of font family name, move AssetHelper.processLibraries and fix a couple colors

This commit is contained in:
Joshua Granick
2014-10-22 21:40:38 -07:00
parent 33d25eaf16
commit 58e70d4b76
4 changed files with 40 additions and 44 deletions

View File

@@ -291,56 +291,54 @@ namespace lime {
}
wchar_t *get_familyname_from_sfnt_name(FT_Face face)
{
wchar_t *get_familyname_from_sfnt_name (FT_Face face) {
wchar_t *family_name = NULL;
FT_SfntName sfnt_name;
FT_UInt num_sfnt_names, sfnt_name_index;
int len, i;
if (FT_IS_SFNT(face))
{
num_sfnt_names = FT_Get_Sfnt_Name_Count(face);
if (FT_IS_SFNT (face)) {
num_sfnt_names = FT_Get_Sfnt_Name_Count (face);
sfnt_name_index = 0;
while (sfnt_name_index < num_sfnt_names)
{
if (!FT_Get_Sfnt_Name(face, sfnt_name_index++, (FT_SfntName *)&sfnt_name))
{
//if((sfnt_name.name_id == TT_NAME_ID_FONT_FAMILY) &&
if((sfnt_name.name_id == 4) &&
//(sfnt_name.language_id == GetUserDefaultLCID()) &&
(sfnt_name.platform_id == TT_PLATFORM_MICROSOFT) &&
(sfnt_name.encoding_id == TT_MS_ID_UNICODE_CS))
{
/* Note that most fonts contains a Unicode charmap using
TT_PLATFORM_MICROSOFT, TT_MS_ID_UNICODE_CS.
*/
while (sfnt_name_index < num_sfnt_names) {
if (!FT_Get_Sfnt_Name (face, sfnt_name_index++, (FT_SfntName *)&sfnt_name) && sfnt_name.name_id == TT_NAME_ID_FULL_NAME) {
if (sfnt_name.platform_id == TT_PLATFORM_MACINTOSH) {
/* .string :
Note that its format differs depending on the
(platform,encoding) pair. It can be a Pascal String,
a UTF-16 one, etc..
Generally speaking, the string is "not" zero-terminated.
Please refer to the TrueType specification for details..
.string_len :
The length of `string' in bytes.
*/
len = sfnt_name.string_len;
family_name = new wchar_t[len + 1];
mbstowcs (&family_name[0], &reinterpret_cast<const char*>(sfnt_name.string)[0], len);
family_name[len] = L'\0';
return family_name;
} else if ((sfnt_name.platform_id == TT_PLATFORM_MICROSOFT) && (sfnt_name.encoding_id == TT_MS_ID_UNICODE_CS)) {
len = sfnt_name.string_len / 2;
family_name = (wchar_t*)malloc((len + 1) * sizeof(wchar_t));
for(i = 0; i < len; i++)
{
family_name[i] = ((wchar_t)sfnt_name.string[i*2 + 1]) | (((wchar_t)sfnt_name.string[i*2]) << 8);
family_name = (wchar_t*)malloc ((len + 1) * sizeof (wchar_t));
for (i = 0; i < len; i++) {
family_name[i] = ((wchar_t)sfnt_name.string[i * 2 + 1]) | (((wchar_t)sfnt_name.string[i * 2]) << 8);
}
family_name[len] = 0;
family_name[len] = L'\0';
return family_name;
}
}
}
}
return NULL;
}
@@ -442,6 +440,8 @@ namespace lime {
alloc_field (ret, val_id ("descend"), alloc_int (face->descender));
alloc_field (ret, val_id ("height"), alloc_int (face->height));
delete family_name;
// 'glyphs' field
value neko_glyphs = alloc_array (num_glyphs);
for (i = 0; i < glyphs.size (); i++) {

View File

@@ -469,15 +469,9 @@ class CommandLineTools {
}
if (command == "update" || command == "build" || command == "test") {
AssetHelper.processLibraries (project);
}
if (project.targetHandlers.exists (Std.string (project.target))) {
LogHelper.info ("", "\x1b[32;1mUsing target platform: " + Std.string (project.target).toUpperCase () + "\x1b[0m");
LogHelper.info ("", LogHelper.accentColor + "Using target platform: " + Std.string (project.target).toUpperCase () + "\x1b[0m");
var handler = project.targetHandlers.get (Std.string (project.target));
var projectData = Serializer.run (project);
@@ -593,7 +587,7 @@ class CommandLineTools {
private function createTemplate () {
LogHelper.info ("", "\x1b[32;1mRunning command: CREATE\x1b[0m");
LogHelper.info ("", LogHelper.accentColor + "Running command: CREATE\x1b[0m");
if (words.length > 0) {

View File

@@ -295,11 +295,11 @@ class FlashHelper {
// More code ripped off from "samhaxe"
var src = name;
var font_name = Path.withoutExtension (name);
//var font_name = Path.withoutExtension (name);
var face = new Font (src);
var font = face.decompose ();
font_name = font.family_name;
var font_name = font.family_name;
var glyphs = new Array <Font2GlyphData> ();
var glyph_layout = new Array <FontLayoutGlyphData> ();
@@ -316,7 +316,7 @@ class FlashHelper {
var shapeRecords = new Array <ShapeRecord> ();
var i:Int = 0;
var styleChanged:Bool = false;
while (i < native_glyph.points.length) {
var type = native_glyph.points[i++];

View File

@@ -2,6 +2,7 @@ package project;
import haxe.rtti.Meta;
import helpers.AssetHelper;
import helpers.LogHelper;
@@ -53,6 +54,7 @@ class PlatformTarget {
if (!Reflect.hasField (metaFields.update, "ignore") && (command == "update" || command == "build" || command == "test")) {
LogHelper.info ("", "\n" + LogHelper.accentColor + "Running command: UPDATE" + LogHelper.resetColor);
AssetHelper.processLibraries (project);
update ();
}