parent
425fc7f3ee
commit
fcc8be409b
|
@ -114,6 +114,7 @@ glib_dep = dependency('glib-2.0', required: get_option('glib'))
|
||||||
gobject_dep = dependency('gobject-2.0', required: get_option('gobject'))
|
gobject_dep = dependency('gobject-2.0', required: get_option('gobject'))
|
||||||
graphite2_dep = dependency('graphite2', required: get_option('graphite2'))
|
graphite2_dep = dependency('graphite2', required: get_option('graphite2'))
|
||||||
graphite_dep = dependency('graphite2', required: get_option('graphite'))
|
graphite_dep = dependency('graphite2', required: get_option('graphite'))
|
||||||
|
wasm_dep = cpp.find_library('iwasm', required: get_option('wasm'))
|
||||||
|
|
||||||
if meson.version().version_compare('>=0.60.0')
|
if meson.version().version_compare('>=0.60.0')
|
||||||
# pkg-config: icu-uc, cmake: ICU but with components
|
# pkg-config: icu-uc, cmake: ICU but with components
|
||||||
|
@ -229,7 +230,9 @@ if chafa_dep.found()
|
||||||
conf.set('HAVE_CHAFA', 1)
|
conf.set('HAVE_CHAFA', 1)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if wasm_dep.found()
|
||||||
conf.set('HAVE_WASM', 1)
|
conf.set('HAVE_WASM', 1)
|
||||||
|
endif
|
||||||
|
|
||||||
if graphite2_dep.found() or graphite_dep.found()
|
if graphite2_dep.found() or graphite_dep.found()
|
||||||
conf.set('HAVE_GRAPHITE2', 1)
|
conf.set('HAVE_GRAPHITE2', 1)
|
||||||
|
|
|
@ -21,6 +21,8 @@ option('directwrite', type: 'feature', value: 'disabled',
|
||||||
description: 'Enable DirectWrite shaper backend on Windows (experimental)')
|
description: 'Enable DirectWrite shaper backend on Windows (experimental)')
|
||||||
option('coretext', type: 'feature', value: 'disabled',
|
option('coretext', type: 'feature', value: 'disabled',
|
||||||
description: 'Enable CoreText shaper backend on macOS')
|
description: 'Enable CoreText shaper backend on macOS')
|
||||||
|
option('wasm', type: 'feature', value: 'disabled',
|
||||||
|
description: 'Enable WebAssembly shaper backend')
|
||||||
|
|
||||||
# Common feature options
|
# Common feature options
|
||||||
option('tests', type: 'feature', value: 'enabled', yield: true,
|
option('tests', type: 'feature', value: 'enabled', yield: true,
|
||||||
|
|
|
@ -28,6 +28,25 @@
|
||||||
|
|
||||||
#ifdef HAVE_WASM
|
#ifdef HAVE_WASM
|
||||||
|
|
||||||
|
#include <wasm_c_api.h>
|
||||||
|
|
||||||
|
#define own // wasm-micro-runtime wasm-c-api/hello.c example has this; no idea why :))
|
||||||
|
|
||||||
|
static wasm_store_t *
|
||||||
|
get_wasm_store ()
|
||||||
|
{
|
||||||
|
|
||||||
|
static wasm_store_t *store;
|
||||||
|
if (!store)
|
||||||
|
{
|
||||||
|
static wasm_engine_t *engine = wasm_engine_new();
|
||||||
|
store = wasm_store_new (engine);
|
||||||
|
}
|
||||||
|
|
||||||
|
return store;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* shaper face data
|
* shaper face data
|
||||||
*/
|
*/
|
||||||
|
@ -36,30 +55,50 @@
|
||||||
|
|
||||||
struct hb_wasm_face_data_t {
|
struct hb_wasm_face_data_t {
|
||||||
hb_blob_t *blob;
|
hb_blob_t *blob;
|
||||||
|
wasm_module_t *mod;
|
||||||
};
|
};
|
||||||
|
|
||||||
hb_wasm_face_data_t *
|
hb_wasm_face_data_t *
|
||||||
_hb_wasm_shaper_face_data_create (hb_face_t *face)
|
_hb_wasm_shaper_face_data_create (hb_face_t *face)
|
||||||
{
|
{
|
||||||
hb_blob_t *wasm_blob = hb_face_reference_table (face, HB_WASM_TAG_WASM);
|
hb_blob_t *wasm_blob = nullptr;
|
||||||
if (!hb_blob_get_length (wasm_blob))
|
own wasm_module_t *wasm_module = nullptr;
|
||||||
{
|
hb_wasm_face_data_t *data = nullptr;
|
||||||
hb_blob_destroy (wasm_blob);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
hb_wasm_face_data_t *data = (hb_wasm_face_data_t *) hb_calloc (1, sizeof (hb_wasm_face_data_t));
|
wasm_blob = hb_face_reference_table (face, HB_WASM_TAG_WASM);
|
||||||
|
unsigned length = hb_blob_get_length (wasm_blob);
|
||||||
|
if (!length)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
wasm_byte_vec_t binary;
|
||||||
|
wasm_byte_vec_new_uninitialized (&binary, length);
|
||||||
|
memcpy (binary.data, hb_blob_get_data (wasm_blob, nullptr), length);
|
||||||
|
wasm_module = wasm_module_new (get_wasm_store (), &binary);
|
||||||
|
if (!wasm_module)
|
||||||
|
goto fail;
|
||||||
|
wasm_byte_vec_delete(&binary);
|
||||||
|
|
||||||
|
data = (hb_wasm_face_data_t *) hb_calloc (1, sizeof (hb_wasm_face_data_t));
|
||||||
if (unlikely (!data))
|
if (unlikely (!data))
|
||||||
return nullptr;
|
goto fail;
|
||||||
|
|
||||||
data->blob = wasm_blob;
|
data->blob = wasm_blob;
|
||||||
|
data->mod = wasm_module;
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
if (wasm_module)
|
||||||
|
wasm_module_delete (wasm_module);
|
||||||
|
hb_blob_destroy (wasm_blob);
|
||||||
|
hb_free (data);
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_hb_wasm_shaper_face_data_destroy (hb_wasm_face_data_t *data)
|
_hb_wasm_shaper_face_data_destroy (hb_wasm_face_data_t *data)
|
||||||
{
|
{
|
||||||
|
wasm_module_delete (data->mod);
|
||||||
hb_blob_destroy (data->blob);
|
hb_blob_destroy (data->blob);
|
||||||
hb_free (data);
|
hb_free (data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -256,7 +256,6 @@ hb_base_sources = files(
|
||||||
'hb-unicode.hh',
|
'hb-unicode.hh',
|
||||||
'hb-utf.hh',
|
'hb-utf.hh',
|
||||||
'hb-vector.hh',
|
'hb-vector.hh',
|
||||||
'hb-wasm-shape.cc',
|
|
||||||
'hb.hh',
|
'hb.hh',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -325,6 +324,9 @@ hb_glib_headers = files('hb-glib.h')
|
||||||
hb_graphite2_sources = files('hb-graphite2.cc')
|
hb_graphite2_sources = files('hb-graphite2.cc')
|
||||||
hb_graphite2_headers = files('hb-graphite2.h')
|
hb_graphite2_headers = files('hb-graphite2.h')
|
||||||
|
|
||||||
|
hb_wasm_sources = files('hb-wasm-shape.cc')
|
||||||
|
hb_wasm_headers = files()
|
||||||
|
|
||||||
# System-dependent sources and headers
|
# System-dependent sources and headers
|
||||||
|
|
||||||
hb_coretext_sources = files('hb-coretext.cc')
|
hb_coretext_sources = files('hb-coretext.cc')
|
||||||
|
@ -460,6 +462,12 @@ if conf.get('HAVE_GRAPHITE2', 0) == 1
|
||||||
harfbuzz_deps += [graphite2_dep, graphite_dep]
|
harfbuzz_deps += [graphite2_dep, graphite_dep]
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if conf.get('HAVE_WASM', 0) == 1
|
||||||
|
hb_sources += hb_wasm_sources
|
||||||
|
hb_headers += hb_wasm_headers
|
||||||
|
harfbuzz_deps += wasm_dep
|
||||||
|
endif
|
||||||
|
|
||||||
if conf.get('HAVE_UNISCRIBE', 0) == 1
|
if conf.get('HAVE_UNISCRIBE', 0) == 1
|
||||||
hb_sources += hb_uniscribe_sources
|
hb_sources += hb_uniscribe_sources
|
||||||
hb_headers += hb_uniscribe_headers
|
hb_headers += hb_uniscribe_headers
|
||||||
|
|
Loading…
Reference in New Issue