Update license, fixes for harfbuzz

This commit is contained in:
Joshua Granick
2014-08-04 11:03:56 -07:00
parent 35b8ffc87a
commit 850ce2f269
6 changed files with 145 additions and 127 deletions

2
.gitmodules vendored
View File

@@ -30,4 +30,4 @@
url = https://github.com/native-toolkit/freetype url = https://github.com/native-toolkit/freetype
[submodule "project/lib/harfbuzz"] [submodule "project/lib/harfbuzz"]
path = project/lib/harfbuzz path = project/lib/harfbuzz
url = https://github.com/MattTuttle/harfbuzz url = https://github.com/native-toolkit/harfbuzz

View File

@@ -3,7 +3,7 @@ License
The MIT License (MIT) The MIT License (MIT)
Copyright (c) 2007-2014 OpenFL Technologies, LLC, underscorediscovery and contributors Copyright (c) 2013-2014 OpenFL Technologies and contributors
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@@ -22,3 +22,21 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
-------
Portions of other MIT-license projects are also used, including content that is
Copyright (c) 2007-2014 NME contributors
Copyright (c) 2013-2014 Mathew Groves
Copyright (c) 2013-2014 James Simpson and GoldFire Studios, Inc.
-------
Native dependencies include unrestrictive licenses, such as the Zlib, MIT, or BSD
license. The full text of each license is included in each sub-repository. The
notable exception is OpenAL Soft, which is LGPL-licensed.
When Lime is compiled to a shared binary, the LGPL "copy-left" clause will apply
to Lime's C++ source-code, but not to other aspects of a project. When Lime
is statically linked to project code, OpenAL Soft is not included.

View File

@@ -18,7 +18,7 @@
#include <graphics/Font.h> #include <graphics/Font.h>
#ifdef LIME_HARFBUZZ #ifdef LIME_HARFBUZZ
#include <graphics/Text.h> #include <graphics/Text.h>
#endif // LIME_HARFBUZZ #endif
#include <graphics/ImageBuffer.h> #include <graphics/ImageBuffer.h>
#include <graphics/Renderer.h> #include <graphics/Renderer.h>
#include <graphics/RenderEvent.h> #include <graphics/RenderEvent.h>
@@ -93,39 +93,18 @@ namespace lime {
} }
value lime_image_load (value data) { value lime_font_create_image (value fontHandle) {
ImageBuffer imageBuffer;
Resource resource;
if (val_is_string (data)) {
resource = Resource (val_string (data));
} else {
ByteArray bytes (data);
resource = Resource (&bytes);
}
#ifdef LIME_PNG
if (PNG::Decode (&resource, &imageBuffer)) {
return imageBuffer.Value ();
}
#endif
#ifdef LIME_JPEG
if (JPEG::Decode (&resource, &imageBuffer)) {
return imageBuffer.Value ();
}
#endif
#ifdef LIME_FREETYPE
ImageBuffer image;
Font *font = (Font*)(intptr_t)val_float (fontHandle);
value data = alloc_empty_object ();
alloc_field (data, val_id ("glyphs"), font->RenderToImage (&image));
alloc_field (data, val_id ("image"), image.Value ());
return data;
#else
return alloc_null (); return alloc_null ();
#endif
} }
@@ -179,55 +158,40 @@ namespace lime {
} }
value lime_font_create_image (value fontHandle) { value lime_image_load (value data) {
#ifdef LIME_FREETYPE ImageBuffer imageBuffer;
ImageBuffer image; Resource resource;
Font *font = (Font*)(intptr_t)val_float (fontHandle);
value data = alloc_empty_object (); if (val_is_string (data)) {
alloc_field (data, val_id ("glyphs"), font->RenderToImage (&image));
alloc_field (data, val_id ("image"), image.Value ()); resource = Resource (val_string (data));
return data;
#else } else {
return alloc_null ();
#endif ByteArray bytes (data);
resource = Resource (&bytes);
} }
#ifdef LIME_PNG
if (PNG::Decode (&resource, &imageBuffer)) {
void lime_text_destroy (value textHandle) { return imageBuffer.Value ();
Text *text = (Text*)(intptr_t)val_float (textHandle);
delete text;
text = 0;
} }
value lime_text_create (value direction, value script, value language) {
#if defined(LIME_FREETYPE) && defined(LIME_HARFBUZZ)
Text *text = new Text (val_int (direction), val_string (script), val_string (language));
value v = alloc_float ((intptr_t)text);
val_gc (v, lime_text_destroy);
return v;
#else
return alloc_null ();
#endif #endif
#ifdef LIME_JPEG
if (JPEG::Decode (&resource, &imageBuffer)) {
return imageBuffer.Value ();
} }
value lime_text_from_string (value textHandle, value fontHandle, value size, value textString) {
#if defined(LIME_FREETYPE) && defined(LIME_HARFBUZZ)
Text *text = (Text*)(intptr_t)val_float (textHandle);
Font *font = (Font*)(intptr_t)val_float (fontHandle);
return text->FromString(font, val_int (size), val_string (textString));
#else
return alloc_null ();
#endif #endif
return alloc_null ();
} }
@@ -317,6 +281,42 @@ namespace lime {
} }
void lime_text_destroy (value textHandle) {
Text *text = (Text*)(intptr_t)val_float (textHandle);
delete text;
text = 0;
}
value lime_text_create (value direction, value script, value language) {
#if defined(LIME_FREETYPE) && defined(LIME_HARFBUZZ)
Text *text = new Text (val_int (direction), val_string (script), val_string (language));
value v = alloc_float ((intptr_t)text);
val_gc (v, lime_text_destroy);
return v;
#else
return alloc_null ();
#endif
}
value lime_text_from_string (value textHandle, value fontHandle, value size, value textString) {
#if defined(LIME_FREETYPE) && defined(LIME_HARFBUZZ)
Text *text = (Text*)(intptr_t)val_float (textHandle);
Font *font = (Font*)(intptr_t)val_float (fontHandle);
return text->FromString(font, val_int (size), val_string (textString));
#else
return alloc_null ();
#endif
}
value lime_touch_event_manager_register (value callback, value eventObject) { value lime_touch_event_manager_register (value callback, value eventObject) {
TouchEvent::callback = new AutoGCRoot (callback); TouchEvent::callback = new AutoGCRoot (callback);
@@ -374,13 +374,11 @@ namespace lime {
DEFINE_PRIM (lime_application_exec, 1); DEFINE_PRIM (lime_application_exec, 1);
DEFINE_PRIM (lime_application_get_ticks, 0); DEFINE_PRIM (lime_application_get_ticks, 0);
DEFINE_PRIM (lime_audio_load, 1); DEFINE_PRIM (lime_audio_load, 1);
DEFINE_PRIM (lime_image_load, 1); DEFINE_PRIM (lime_font_create_image, 1);
DEFINE_PRIM (lime_font_load, 1); DEFINE_PRIM (lime_font_load, 1);
DEFINE_PRIM (lime_font_load_glyphs, 3); DEFINE_PRIM (lime_font_load_glyphs, 3);
DEFINE_PRIM (lime_font_load_range, 4); DEFINE_PRIM (lime_font_load_range, 4);
DEFINE_PRIM (lime_font_create_image, 1); DEFINE_PRIM (lime_image_load, 1);
DEFINE_PRIM (lime_text_create, 3);
DEFINE_PRIM (lime_text_from_string, 4);
DEFINE_PRIM (lime_key_event_manager_register, 2); DEFINE_PRIM (lime_key_event_manager_register, 2);
DEFINE_PRIM (lime_lzma_encode, 1); DEFINE_PRIM (lime_lzma_encode, 1);
DEFINE_PRIM (lime_lzma_decode, 1); DEFINE_PRIM (lime_lzma_decode, 1);
@@ -390,6 +388,8 @@ namespace lime {
DEFINE_PRIM (lime_renderer_flip, 1); DEFINE_PRIM (lime_renderer_flip, 1);
DEFINE_PRIM (lime_render_event_manager_register, 2); DEFINE_PRIM (lime_render_event_manager_register, 2);
DEFINE_PRIM (lime_system_get_timestamp, 0); DEFINE_PRIM (lime_system_get_timestamp, 0);
DEFINE_PRIM (lime_text_create, 3);
DEFINE_PRIM (lime_text_from_string, 4);
DEFINE_PRIM (lime_touch_event_manager_register, 2); DEFINE_PRIM (lime_touch_event_manager_register, 2);
DEFINE_PRIM (lime_update_event_manager_register, 2); DEFINE_PRIM (lime_update_event_manager_register, 2);
DEFINE_PRIM (lime_window_create, 5); DEFINE_PRIM (lime_window_create, 5);