[wasm] Add wasm shaper skeleton

This commit is contained in:
Behdad Esfahbod 2023-02-22 12:19:06 -07:00
parent 04a47932a3
commit 425fc7f3ee
7 changed files with 111 additions and 0 deletions

View File

@ -229,6 +229,8 @@ if chafa_dep.found()
conf.set('HAVE_CHAFA', 1) conf.set('HAVE_CHAFA', 1)
endif endif
conf.set('HAVE_WASM', 1)
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)
endif endif

View File

@ -255,6 +255,7 @@ HB_BASE_sources = \
hb-unicode.hh \ hb-unicode.hh \
hb-utf.hh \ hb-utf.hh \
hb-vector.hh \ hb-vector.hh \
hb-wasm-shape.cc \
hb-priority-queue.hh \ hb-priority-queue.hh \
hb.hh \ hb.hh \
$(NULL) $(NULL)

View File

@ -60,3 +60,4 @@
#include "hb-subset.cc" #include "hb-subset.cc"
#include "hb-ucd.cc" #include "hb-ucd.cc"
#include "hb-unicode.cc" #include "hb-unicode.cc"
#include "hb-wasm-shape.cc"

View File

@ -58,3 +58,4 @@
#include "hb-ucd.cc" #include "hb-ucd.cc"
#include "hb-unicode.cc" #include "hb-unicode.cc"
#include "hb-uniscribe.cc" #include "hb-uniscribe.cc"
#include "hb-wasm-shape.cc"

View File

@ -33,6 +33,11 @@
/* v--- Add new shapers in the right place here. */ /* v--- Add new shapers in the right place here. */
#ifdef HAVE_WASM
/* Only picks up fonts that have a "Wasm" table. */
HB_SHAPER_IMPLEMENT (wasm)
#endif
#ifdef HAVE_GRAPHITE2 #ifdef HAVE_GRAPHITE2
/* Only picks up fonts that have a "Silf" table. */ /* Only picks up fonts that have a "Silf" table. */
HB_SHAPER_IMPLEMENT (graphite2) HB_SHAPER_IMPLEMENT (graphite2)

100
src/hb-wasm-shape.cc Normal file
View File

@ -0,0 +1,100 @@
/*
* Copyright © 2011 Google, Inc.
*
* This is part of HarfBuzz, a text shaping library.
*
* Permission is hereby granted, without written agreement and without
* license or royalty fees, to use, copy, modify, and distribute this
* software and its documentation for any purpose, provided that the
* above copyright notice and the following two paragraphs appear in
* all copies of this software.
*
* IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
* IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
* Google Author(s): Behdad Esfahbod
*/
#include "hb-shaper-impl.hh"
#ifdef HAVE_WASM
/*
* shaper face data
*/
#define HB_WASM_TAG_WASM HB_TAG('W','a','s','m')
struct hb_wasm_face_data_t {
hb_blob_t *blob;
};
hb_wasm_face_data_t *
_hb_wasm_shaper_face_data_create (hb_face_t *face)
{
hb_blob_t *wasm_blob = hb_face_reference_table (face, HB_WASM_TAG_WASM);
if (!hb_blob_get_length (wasm_blob))
{
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));
if (unlikely (!data))
return nullptr;
data->blob = wasm_blob;
return data;
}
void
_hb_wasm_shaper_face_data_destroy (hb_wasm_face_data_t *data)
{
hb_blob_destroy (data->blob);
hb_free (data);
}
/*
* shaper font data
*/
struct hb_wasm_font_data_t {};
hb_wasm_font_data_t *
_hb_wasm_shaper_font_data_create (hb_font_t *font HB_UNUSED)
{
return (hb_wasm_font_data_t *) HB_SHAPER_DATA_SUCCEEDED;
}
void
_hb_wasm_shaper_font_data_destroy (hb_wasm_font_data_t *data HB_UNUSED)
{
}
/*
* shaper
*/
hb_bool_t
_hb_wasm_shape (hb_shape_plan_t *shape_plan,
hb_font_t *font,
hb_buffer_t *buffer,
const hb_feature_t *features,
unsigned int num_features)
{
return false;
}
#endif

View File

@ -256,6 +256,7 @@ 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',
) )