Guard Freetype reference

This commit is contained in:
Joshua Granick
2014-07-15 22:42:20 -07:00
parent 22fa6ced55
commit de9260a619
4 changed files with 24 additions and 8 deletions

View File

@@ -10,7 +10,9 @@
#include <hx/CFFI.h>
#include <app/Application.h>
#include <app/UpdateEvent.h>
#ifdef LIME_FREETYPE
#include <graphics/Font.h>
#endif
#include <graphics/Image.h>
#include <graphics/PNG.h>
#include <graphics/JPEG.h>
@@ -75,22 +77,30 @@ namespace lime {
value lime_font_load (value fontFace) {
#ifdef LIME_FREETYPE
Font *font = new Font (val_string (fontFace));
return alloc_float ((intptr_t)font);
#else
return alloc_null ();
#endif
}
value lime_font_load_glyphs (value fontHandle, value size, value glyphs) {
#ifdef LIME_FREETYPE
Image image;
Font *font = (Font*)(intptr_t)val_float (fontHandle);
value data = alloc_empty_object ();
alloc_field (data, val_id ("glyphs"), font->LoadGlyphs (val_int (size), val_string (glyphs), &image));
alloc_field (data, val_id ("image"), image.Value ());
return data;
#else
return alloc_null ();
#endif
}

View File

@@ -1,4 +1,7 @@
#include <graphics/Font.h>
#include <ft2build.h>
#include FT_FREETYPE_H
typedef struct {
@@ -8,6 +11,7 @@ typedef struct {
} GlyphInfo;
namespace lime {