Merge branch 'master' into cff-subset

Renamed cff "private" source/headers without the suffix
This commit is contained in:
Michiharu Ariza 2018-08-29 13:26:17 -07:00
commit 8af9690ac7
192 changed files with 1515 additions and 1149 deletions

View File

@ -170,6 +170,7 @@ hb_coretext_font_get_ct_font
<SECTION>
<FILE>hb-face</FILE>
hb_face_count
hb_face_t
hb_face_create
hb_face_create_for_tables
hb_face_destroy
@ -188,7 +189,11 @@ hb_face_set_glyph_count
hb_face_set_index
hb_face_set_upem
hb_face_set_user_data
hb_face_t
hb_face_collect_unicodes
hb_face_collect_variation_selectors
hb_face_collect_variation_unicodes
hb_face_builder_create
hb_face_builder_add_table
</SECTION>
<SECTION>
@ -226,6 +231,7 @@ hb_font_get_glyph
hb_font_get_glyph_advance_for_direction
hb_font_get_glyph_advance_func_t
hb_font_get_glyph_advances_for_direction
hb_font_get_glyph_advances_func_t
hb_font_get_glyph_contour_point
hb_font_get_glyph_contour_point_for_origin
hb_font_get_glyph_contour_point_func_t
@ -602,6 +608,7 @@ hb_shape_plan_t
<SECTION>
<FILE>hb-unicode</FILE>
HB_UNICODE_MAX
HB_UNICODE_MAX_DECOMPOSITION_LEN
hb_unicode_combining_class
hb_unicode_combining_class_func_t

View File

@ -1,28 +1,28 @@
# Base and default-included sources and headers
HB_BASE_sources = \
hb-atomic-private.hh \
hb-blob-private.hh \
hb-atomic.hh \
hb-blob.hh \
hb-blob.cc \
hb-buffer-private.hh \
hb-buffer.hh \
hb-buffer-serialize.cc \
hb-buffer.cc \
hb-common.cc \
hb-debug.hh \
hb-dsalgs.hh \
hb-face-private.hh \
hb-face.hh \
hb-face.cc \
hb-font-private.hh \
hb-font.hh \
hb-font.cc \
hb-iter-private.hh \
hb-map-private.hh \
hb-iter.hh \
hb-map.hh \
hb-map.cc \
hb-machinery-private.hh \
hb-mutex-private.hh \
hb-machinery.hh \
hb-mutex.hh \
hb-null.hh \
hb-object-private.hh \
hb-open-file-private.hh \
hb-open-type-private.hh \
hb-object.hh \
hb-open-file.hh \
hb-open-type.hh \
hb-ot-color-cbdt-table.hh \
hb-ot-cmap-table.hh \
hb-ot-glyf-table.hh \
@ -40,23 +40,23 @@ HB_BASE_sources = \
hb-ot-post-macroman.hh \
hb-ot-post-table.hh \
hb-ot-tag.cc \
hb-private.hh \
hb-set-digest-private.hh \
hb-set-private.hh \
hb.hh \
hb-set-digest.hh \
hb-set.hh \
hb-set.cc \
hb-shape.cc \
hb-shape-plan-private.hh \
hb-shape-plan.hh \
hb-shape-plan.cc \
hb-shaper-list.hh \
hb-shaper-impl-private.hh \
hb-shaper-private.hh \
hb-shaper-impl.hh \
hb-shaper.hh \
hb-shaper.cc \
hb-static.cc \
hb-string-array.hh \
hb-unicode-private.hh \
hb-unicode.hh \
hb-unicode.cc \
hb-vector-private.hh \
hb-utf-private.hh \
hb-vector.hh \
hb-utf.hh \
hb-warning.cc \
$(NULL)
@ -91,72 +91,74 @@ HB_FALLBACK_sources = \
HB_OT_sources = \
hb-aat-layout.cc \
hb-aat-layout-common-private.hh \
hb-aat-layout-common.hh \
hb-aat-layout-ankr-table.hh \
hb-aat-layout-bsln-table.hh \
hb-aat-layout-feat-table.hh \
hb-aat-layout-kerx-table.hh \
hb-aat-layout-morx-table.hh \
hb-aat-layout-trak-table.hh \
hb-aat-layout-private.hh \
hb-aat-layout.hh \
hb-aat-ltag-table.hh \
hb-ot-face.hh \
hb-ot-face.cc \
hb-ot-font.cc \
hb-ot-layout.cc \
hb-ot-layout-base-table.hh \
hb-ot-layout-common-private.hh \
hb-ot-layout-common.hh \
hb-ot-layout-gdef-table.hh \
hb-ot-layout-gpos-table.hh \
hb-ot-layout-gsubgpos-private.hh \
hb-ot-layout-gsubgpos.hh \
hb-ot-layout-gsub-table.hh \
hb-ot-layout-jstf-table.hh \
hb-ot-layout-private.hh \
hb-ot-layout.hh \
hb-ot-color.cc \
hb-ot-color-colr-table.hh \
hb-ot-color-cpal-table.hh \
hb-ot-color-sbix-table.hh \
hb-ot-color-svg-table.hh \
hb-ot-map.cc \
hb-ot-map-private.hh \
hb-ot-map.hh \
hb-ot-math.cc \
hb-ot-math-table.hh \
hb-ot-shape.cc \
hb-ot-shape-complex-arabic.cc \
hb-ot-shape-complex-arabic-fallback.hh \
hb-ot-shape-complex-arabic-private.hh \
hb-ot-shape-complex-arabic.hh \
hb-ot-shape-complex-arabic-table.hh \
hb-ot-shape-complex-arabic-win1256.hh \
hb-ot-shape-complex-default.cc \
hb-ot-shape-complex-hangul.cc \
hb-ot-shape-complex-hebrew.cc \
hb-ot-shape-complex-indic.cc \
hb-ot-shape-complex-indic-private.hh \
hb-ot-shape-complex-indic.hh \
hb-ot-shape-complex-indic-table.cc \
hb-ot-shape-complex-khmer-private.hh \
hb-ot-shape-complex-khmer.hh \
hb-ot-shape-complex-khmer.cc \
hb-ot-shape-complex-myanmar-private.hh \
hb-ot-shape-complex-myanmar.hh \
hb-ot-shape-complex-myanmar.cc \
hb-ot-shape-complex-thai.cc \
hb-ot-shape-complex-tibetan.cc \
hb-ot-shape-complex-use.cc \
hb-ot-shape-complex-use-private.hh \
hb-ot-shape-complex-use.hh \
hb-ot-shape-complex-use-table.cc \
hb-ot-shape-complex-private.hh \
hb-ot-shape-normalize-private.hh \
hb-ot-shape-complex.hh \
hb-ot-shape-normalize.hh \
hb-ot-shape-normalize.cc \
hb-ot-shape-fallback-private.hh \
hb-ot-shape-fallback.hh \
hb-ot-shape-fallback.cc \
hb-ot-shape-private.hh \
hb-ot-cff-common-private.hh \
hb-ot-shape.hh \
hb-ot-var.cc \
hb-ot-var-avar-table.hh \
hb-ot-var-fvar-table.hh \
hb-ot-var-hvar-table.hh \
hb-ot-var-mvar-table.hh \
hb-cff-interp-common-private.hh \
hb-cff-interp-cs-common-private.hh \
hb-ot-cff-common.hh \
hb-cff-interp-common.hh \
hb-cff-interp-cs-common.hh \
hb-cff1-interp-cs.hh \
hb-cff2-interp-cs.hh \
hb-cff-interp-dict-common-private.hh \
hb-cff-interp-dict-common.hh \
$(NULL)
HB_OT_RAGEL_GENERATED_sources = \
@ -215,22 +217,25 @@ HB_ICU_headers = hb-icu.h
HB_SUBSET_sources = \
hb-static.cc \
hb-subset.cc \
hb-subset.hh \
hb-subset-glyf.cc \
hb-subset-cff1.cc \
hb-subset-cff2.cc \
hb-subset-cff-common-private.cc \
hb-subset-glyf.hh \
hb-subset-cff1.cc \
hb-subset-cff2.cc \
hb-subset-cff-common.cc \
hb-subset-input.cc \
hb-subset-plan.cc \
hb-subset-plan.hh \
$(NULL)
HB_SUBSET_headers = \
hb-subset.h \
hb-subset-glyf.hh \
hb-subset-cff1.hh \
hb-subset-cff2.hh \
hb-subset-cff-common-private.hh \
hb-subset-cff1.hh \
hb-subset-cff2.hh \
hb-subset-cff-common.hh \
hb-subset-plan.hh \
hb-subset-private.hh \
hb-subset.hh \
$(NULL)
HB_GOBJECT_DIST_sources = hb-gobject-structs.cc

View File

@ -23,14 +23,14 @@ grep -v 'hb[.]h:' |
grep . >&2 && stat=1
echo 'Checking that source files #include "hb-*private.hh" first (or none)'
echo 'Checking that source files #include a private header first (or none)'
for x in $HBSOURCES; do
test -f "$srcdir/$x" -a ! -f "$x" && x="$srcdir/$x"
grep '#.*\<include\>' "$x" /dev/null | grep -v 'include _' | head -n 1
grep '#.*\<include\>' "$x" /dev/null | head -n 1
done |
grep -v '"hb-.*private[.]hh"' |
grep -v 'hb-private[.]hh:' |
grep -v '"hb-.*[.]hh"' |
grep -v 'hb[.]hh' |
grep . >&2 && stat=1

View File

@ -24,7 +24,7 @@
* Google Author(s): Behdad Esfahbod
*/
#include "hb-ot-shape-complex-indic-private.hh"
#include "hb-ot-shape-complex-indic.hh"
int
main (void)

View File

@ -24,7 +24,7 @@
* Google Author(s): Behdad Esfahbod
*/
#include "hb-ot-shape-complex-khmer-private.hh"
#include "hb-ot-shape-complex-khmer.hh"
int
main (void)

View File

@ -24,7 +24,7 @@
* Google Author(s): Behdad Esfahbod
*/
#include "hb-ot-shape-complex-myanmar-private.hh"
#include "hb-ot-shape-complex-myanmar.hh"
int
main (void)

View File

@ -24,7 +24,7 @@
* Google Author(s): Behdad Esfahbod
*/
#include "hb-ot-shape-complex-use-private.hh"
#include "hb-ot-shape-complex-use.hh"
int
main (void)

View File

@ -102,7 +102,7 @@ for h in headers:
print (" * %s" % (l.strip()))
print (" */")
print ()
print ('#include "hb-ot-shape-complex-indic-private.hh"')
print ('#include "hb-ot-shape-complex-indic.hh"')
print ()
# Shorten values

View File

@ -394,7 +394,7 @@ for h in headers:
print (" * %s" % (l.strip()))
print (" */")
print ()
print ('#include "hb-ot-shape-complex-use-private.hh"')
print ('#include "hb-ot-shape-complex-use.hh"')
print ()
total = 0

View File

@ -25,7 +25,7 @@
#ifndef HB_AAT_LAYOUT_ANKR_TABLE_HH
#define HB_AAT_LAYOUT_ANKR_TABLE_HH
#include "hb-aat-layout-common-private.hh"
#include "hb-aat-layout-common.hh"
/*
* ankr -- Anchor Point

View File

@ -25,7 +25,7 @@
#ifndef HB_AAT_LAYOUT_BSLN_TABLE_HH
#define HB_AAT_LAYOUT_BSLN_TABLE_HH
#include "hb-aat-layout-common-private.hh"
#include "hb-aat-layout-common.hh"
/*
* bsln -- Baseline

View File

@ -24,10 +24,10 @@
* Google Author(s): Behdad Esfahbod
*/
#ifndef HB_AAT_LAYOUT_COMMON_PRIVATE_HH
#define HB_AAT_LAYOUT_COMMON_PRIVATE_HH
#ifndef HB_AAT_LAYOUT_COMMON_HH
#define HB_AAT_LAYOUT_COMMON_HH
#include "hb-aat-layout-private.hh"
#include "hb-aat-layout.hh"
namespace AAT {
@ -641,4 +641,4 @@ struct hb_aat_apply_context_t :
} /* namespace AAT */
#endif /* HB_AAT_LAYOUT_COMMON_PRIVATE_HH */
#endif /* HB_AAT_LAYOUT_COMMON_HH */

View File

@ -25,7 +25,7 @@
#ifndef HB_AAT_LAYOUT_FEAT_TABLE_HH
#define HB_AAT_LAYOUT_FEAT_TABLE_HH
#include "hb-aat-layout-common-private.hh"
#include "hb-aat-layout-common.hh"
/*
* feat -- Feature Name

View File

@ -28,8 +28,8 @@
#ifndef HB_AAT_LAYOUT_KERX_TABLE_HH
#define HB_AAT_LAYOUT_KERX_TABLE_HH
#include "hb-open-type-private.hh"
#include "hb-aat-layout-common-private.hh"
#include "hb-open-type.hh"
#include "hb-aat-layout-common.hh"
#include "hb-aat-layout-ankr-table.hh"
/*

View File

@ -27,9 +27,9 @@
#ifndef HB_AAT_LAYOUT_MORX_TABLE_HH
#define HB_AAT_LAYOUT_MORX_TABLE_HH
#include "hb-open-type-private.hh"
#include "hb-aat-layout-common-private.hh"
#include "hb-ot-layout-common-private.hh"
#include "hb-open-type.hh"
#include "hb-aat-layout-common.hh"
#include "hb-ot-layout-common.hh"
/*
* morx -- Extended Glyph Metamorphosis

View File

@ -28,9 +28,9 @@
#ifndef HB_AAT_LAYOUT_TRAK_TABLE_HH
#define HB_AAT_LAYOUT_TRAK_TABLE_HH
#include "hb-aat-layout-common-private.hh"
#include "hb-ot-layout-private.hh"
#include "hb-open-type-private.hh"
#include "hb-aat-layout-common.hh"
#include "hb-ot-layout.hh"
#include "hb-open-type.hh"
/*
* trak -- Tracking

View File

@ -24,12 +24,10 @@
* Google Author(s): Behdad Esfahbod
*/
#include "hb-open-type-private.hh"
#include "hb-open-type.hh"
#include "hb-ot-layout-private.hh"
#include "hb-ot-layout-gsubgpos-private.hh"
#include "hb-aat-layout-private.hh"
#include "hb-ot-face.hh"
#include "hb-aat-layout.hh"
#include "hb-aat-layout-ankr-table.hh"
#include "hb-aat-layout-bsln-table.hh" // Just so we compile it; unused otherwise.
#include "hb-aat-layout-feat-table.hh" // Just so we compile it; unused otherwise.
@ -51,25 +49,12 @@ _get_morx (hb_face_t *face, hb_blob_t **blob = nullptr)
*blob = hb_blob_get_empty ();
return Null(AAT::morx);
}
hb_ot_layout_t * layout = hb_ot_layout_from_face (face);
const AAT::morx& morx = *(layout->table.morx.get ());
const AAT::morx& morx = *(hb_ot_face_data (face)->morx.get ());
if (blob)
*blob = layout->table.morx.get_blob ();
*blob = hb_ot_face_data (face)->morx.get_blob ();
return morx;
}
// static inline void
// _hb_aat_layout_create (hb_face_t *face)
// {
// hb_blob_t *morx_blob = hb_sanitize_context_t ().reference_table<AAT::morx> (face);
// morx_blob->as<AAT::morx> ();
// if (0)
// {
// morx_blob->as<AAT::Lookup<OT::GlyphID> > ()->get_value (1, face->get_num_glyphs ());
// }
// }
void
hb_aat_layout_substitute (hb_font_t *font, hb_buffer_t *buffer)
{

View File

@ -24,14 +24,14 @@
* Google Author(s): Behdad Esfahbod
*/
#ifndef HB_AAT_LAYOUT_PRIVATE_HH
#define HB_AAT_LAYOUT_PRIVATE_HH
#ifndef HB_AAT_LAYOUT_HH
#define HB_AAT_LAYOUT_HH
#include "hb-private.hh"
#include "hb.hh"
#include "hb-font-private.hh"
#include "hb-buffer-private.hh"
#include "hb-open-type-private.hh"
#include "hb-font.hh"
#include "hb-buffer.hh"
#include "hb-open-type.hh"
HB_INTERNAL void
@ -40,4 +40,4 @@ hb_aat_layout_substitute (hb_font_t *font, hb_buffer_t *buffer);
HB_INTERNAL void
hb_aat_layout_position (hb_font_t *font, hb_buffer_t *buffer);
#endif /* HB_AAT_LAYOUT_PRIVATE_HH */
#endif /* HB_AAT_LAYOUT_HH */

View File

@ -25,7 +25,7 @@
#ifndef HB_AAT_LTAG_TABLE_HH
#define HB_AAT_LTAG_TABLE_HH
#include "hb-aat-layout-common-private.hh"
#include "hb-aat-layout-common.hh"
/*
* ltag -- Language Tag

View File

@ -29,10 +29,10 @@
* Google Author(s): Behdad Esfahbod
*/
#ifndef HB_ATOMIC_PRIVATE_HH
#define HB_ATOMIC_PRIVATE_HH
#ifndef HB_ATOMIC_HH
#define HB_ATOMIC_HH
#include "hb-private.hh"
#include "hb.hh"
/*
@ -278,4 +278,4 @@ struct hb_atomic_ptr_t
};
#endif /* HB_ATOMIC_PRIVATE_HH */
#endif /* HB_ATOMIC_HH */

View File

@ -30,8 +30,8 @@
#define _POSIX_C_SOURCE 200809L
#endif
#include "hb-private.hh"
#include "hb-blob-private.hh"
#include "hb.hh"
#include "hb-blob.hh"
#ifdef HAVE_SYS_MMAN_H
#ifdef HAVE_UNISTD_H

View File

@ -26,10 +26,10 @@
* Google Author(s): Behdad Esfahbod
*/
#ifndef HB_BLOB_PRIVATE_HH
#define HB_BLOB_PRIVATE_HH
#ifndef HB_BLOB_HH
#define HB_BLOB_HH
#include "hb-private.hh"
#include "hb.hh"
/*
@ -62,6 +62,10 @@ struct hb_blob_t
{
return unlikely (!data) ? &Null(Type) : reinterpret_cast<const Type *> (data);
}
inline hb_bytes_t as_bytes (void) const
{
return hb_bytes_t (data, length);
}
public:
hb_object_header_t header;
@ -79,4 +83,4 @@ struct hb_blob_t
DECLARE_NULL_INSTANCE (hb_blob_t);
#endif /* HB_BLOB_PRIVATE_HH */
#endif /* HB_BLOB_HH */

View File

@ -29,7 +29,7 @@
#ifndef HB_BUFFER_DESERIALIZE_JSON_HH
#define HB_BUFFER_DESERIALIZE_JSON_HH
#include "hb-private.hh"
#include "hb.hh"
#line 36 "hb-buffer-deserialize-json.hh"

View File

@ -27,7 +27,7 @@
#ifndef HB_BUFFER_DESERIALIZE_JSON_HH
#define HB_BUFFER_DESERIALIZE_JSON_HH
#include "hb-private.hh"
#include "hb.hh"
%%{

View File

@ -29,7 +29,7 @@
#ifndef HB_BUFFER_DESERIALIZE_TEXT_HH
#define HB_BUFFER_DESERIALIZE_TEXT_HH
#include "hb-private.hh"
#include "hb.hh"
#line 36 "hb-buffer-deserialize-text.hh"

View File

@ -27,7 +27,7 @@
#ifndef HB_BUFFER_DESERIALIZE_TEXT_HH
#define HB_BUFFER_DESERIALIZE_TEXT_HH
#include "hb-private.hh"
#include "hb.hh"
%%{

View File

@ -24,7 +24,7 @@
* Google Author(s): Behdad Esfahbod
*/
#include "hb-buffer-private.hh"
#include "hb-buffer.hh"
static const char *serialize_formats[] = {

View File

@ -27,8 +27,8 @@
* Google Author(s): Behdad Esfahbod
*/
#include "hb-buffer-private.hh"
#include "hb-utf-private.hh"
#include "hb-buffer.hh"
#include "hb-utf.hh"
/**

View File

@ -27,11 +27,11 @@
* Google Author(s): Behdad Esfahbod
*/
#ifndef HB_BUFFER_PRIVATE_HH
#define HB_BUFFER_PRIVATE_HH
#ifndef HB_BUFFER_HH
#define HB_BUFFER_HH
#include "hb-private.hh"
#include "hb-unicode-private.hh"
#include "hb.hh"
#include "hb-unicode.hh"
#ifndef HB_BUFFER_MAX_LEN_FACTOR
@ -386,4 +386,4 @@ _next_cluster (hb_buffer_t *buffer, unsigned int start)
#define HB_BUFFER_ASSERT_VAR(b, var) HB_BUFFER_XALLOCATE_VAR (b, assert_var, var ())
#endif /* HB_BUFFER_PRIVATE_HH */
#endif /* HB_BUFFER_HH */

View File

@ -26,8 +26,8 @@
#ifndef HB_CFF_INTERP_CS_COMMON_PRIVATE_HH
#define HB_CFF_INTERP_CS_COMMON_PRIVATE_HH
#include "hb-private.hh"
#include "hb-cff-interp-common-private.hh"
#include "hb.hh"
#include "hb-cff-interp-common.hh"
namespace CFF {

View File

@ -26,7 +26,7 @@
#ifndef HB_CFF_INTERP_DICT_COMMON_PRIVATE_HH
#define HB_CFF_INTERP_DICT_COMMON_PRIVATE_HH
#include "hb-cff-interp-common-private.hh"
#include "hb-cff-interp-common.hh"
namespace CFF {

View File

@ -26,8 +26,8 @@
#ifndef HB_CFF1_INTERP_CS_HH
#define HB_CFF1_INTERP_CS_HH
#include "hb-private.hh"
#include "hb-cff-interp-cs-common-private.hh"
#include "hb.hh"
#include "hb-cff-interp-cs-common.hh"
namespace CFF {

View File

@ -26,8 +26,8 @@
#ifndef HB_CFF2_INTERP_CS_HH
#define HB_CFF2_INTERP_CS_HH
#include "hb-private.hh"
#include "hb-cff-interp-cs-common-private.hh"
#include "hb.hh"
#include "hb-cff-interp-cs-common.hh"
namespace CFF {

View File

@ -26,9 +26,9 @@
* Google Author(s): Behdad Esfahbod
*/
#include "hb-private.hh"
#include "hb.hh"
#include "hb-machinery-private.hh"
#include "hb-machinery.hh"
#include <locale.h>
#ifdef HAVE_XLOCALE_H

View File

@ -28,8 +28,8 @@
#define HB_SHAPER coretext
#include "hb-private.hh"
#include "hb-shaper-impl-private.hh"
#include "hb.hh"
#include "hb-shaper-impl.hh"
#include "hb-coretext.h"
#include <math.h>

View File

@ -27,8 +27,8 @@
#ifndef HB_DEBUG_HH
#define HB_DEBUG_HH
#include "hb-private.hh"
#include "hb-atomic-private.hh"
#include "hb.hh"
#include "hb-atomic.hh"
#include "hb-dsalgs.hh"

View File

@ -22,9 +22,9 @@
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*/
#include "hb-private.hh"
#include "hb.hh"
#define HB_SHAPER directwrite
#include "hb-shaper-impl-private.hh"
#include "hb-shaper-impl.hh"
#include <DWrite_1.h>

View File

@ -27,7 +27,7 @@
#ifndef HB_DSALGS_HH
#define HB_DSALGS_HH
#include "hb-private.hh"
#include "hb.hh"
/* Void! For when we need a expression-type of void. */
@ -492,6 +492,15 @@ template <typename Type>
struct hb_auto_t : Type
{
hb_auto_t (void) { Type::init (); }
/* Explicitly allow the following only for pointer and references,
* to avoid any accidental copies.
*
* Apparently if we template for all types, then gcc seems to
* capture a reference argument in the type, but clang doesn't,
* causing unwanted copies and bugs that come with it. Ideally
* we should use C++11-style rvalue reference &&t1. */
template <typename T1> explicit hb_auto_t (T1 *t1) { Type::init (t1); }
template <typename T1> explicit hb_auto_t (T1 &t1) { Type::init (t1); }
~hb_auto_t (void) { Type::fini (); }
private: /* Hide */
void init (void) {}
@ -502,6 +511,9 @@ struct hb_bytes_t
{
inline hb_bytes_t (void) : bytes (nullptr), len (0) {}
inline hb_bytes_t (const char *bytes_, unsigned int len_) : bytes (bytes_), len (len_) {}
inline hb_bytes_t (const void *bytes_, unsigned int len_) : bytes ((const char *) bytes_), len (len_) {}
inline void free (void) { ::free ((void *) bytes); bytes = nullptr; len = 0; }
inline int cmp (const hb_bytes_t &a) const
{

View File

@ -26,11 +26,13 @@
* Google Author(s): Behdad Esfahbod
*/
#include "hb-private.hh"
#include "hb.hh"
#include "hb-face-private.hh"
#include "hb-blob-private.hh"
#include "hb-open-file-private.hh"
#include "hb-face.hh"
#include "hb-blob.hh"
#include "hb-open-file.hh"
#include "hb-ot-face.hh"
#include "hb-ot-cmap-table.hh"
/**
@ -512,3 +514,208 @@ hb_face_get_table_tags (const hb_face_t *face,
return ot_face.get_table_tags (start_offset, table_count, table_tags);
}
/*
* Character set.
*/
/**
* hb_face_collect_unicodes:
* @face: font face.
* @out: set to add Unicode characters covered by @face to.
*
* Since: REPLACEME
*/
void
hb_face_collect_unicodes (hb_face_t *face,
hb_set_t *out)
{
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return;
hb_ot_face_data (face)->cmap->collect_unicodes (out);
}
/**
* hb_face_collect_variation_selectors:
* @face: font face.
* @out: set to add Variation Selector characters covered by @face to.
*
*
*
* Since: REPLACEME
*/
void
hb_face_collect_variation_selectors (hb_face_t *face,
hb_set_t *out)
{
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return;
hb_ot_face_data (face)->cmap->collect_variation_selectors (out);
}
/**
* hb_face_collect_variation_unicodes:
* @face: font face.
* @out: set to add Unicode characters for @variation_selector covered by @face to.
*
*
*
* Since: REPLACEME
*/
void
hb_face_collect_variation_unicodes (hb_face_t *face,
hb_codepoint_t variation_selector,
hb_set_t *out)
{
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return;
hb_ot_face_data (face)->cmap->collect_variation_unicodes (variation_selector, out);
}
/*
* face-builder: A face that has add_table().
*/
struct hb_face_builder_data_t
{
struct table_entry_t
{
inline int cmp (const hb_tag_t *t) const
{
if (*t < tag) return -1;
if (*t > tag) return -1;
return 0;
}
hb_tag_t tag;
hb_blob_t *blob;
};
hb_vector_t<table_entry_t, 32> tables;
};
static hb_face_builder_data_t *
_hb_face_builder_data_create (void)
{
hb_face_builder_data_t *data = (hb_face_builder_data_t *) calloc (1, sizeof (hb_face_builder_data_t));
if (unlikely (!data))
return nullptr;
data->tables.init ();
return data;
}
static void
_hb_face_builder_data_destroy (void *user_data)
{
hb_face_builder_data_t *data = (hb_face_builder_data_t *) user_data;
for (unsigned int i = 0; i < data->tables.len; i++)
hb_blob_destroy (data->tables[i].blob);
data->tables.fini ();
free (data);
}
static hb_blob_t *
_hb_face_builder_data_reference_blob (hb_face_builder_data_t *data)
{
unsigned int table_count = data->tables.len;
unsigned int face_length = table_count * 16 + 12;
for (unsigned int i = 0; i < table_count; i++)
face_length += hb_ceil_to_4 (hb_blob_get_length (data->tables.arrayZ[i].blob));
char *buf = (char *) malloc (face_length);
if (unlikely (!buf))
return nullptr;
hb_serialize_context_t c (buf, face_length);
OT::OpenTypeFontFile *f = c.start_serialize<OT::OpenTypeFontFile> ();
bool is_cff = data->tables.lsearch (HB_TAG ('C','F','F',' ')) || data->tables.lsearch (HB_TAG ('C','F','F','2'));
hb_tag_t sfnt_tag = is_cff ? OT::OpenTypeFontFile::CFFTag : OT::OpenTypeFontFile::TrueTypeTag;
Supplier<hb_tag_t> tags_supplier (&data->tables[0].tag, table_count, sizeof (data->tables[0]));
Supplier<hb_blob_t *> blobs_supplier (&data->tables[0].blob, table_count, sizeof (data->tables[0]));
bool ret = f->serialize_single (&c,
sfnt_tag,
tags_supplier,
blobs_supplier,
table_count);
c.end_serialize ();
if (unlikely (!ret))
{
free (buf);
return nullptr;
}
return hb_blob_create (buf, face_length, HB_MEMORY_MODE_WRITABLE, buf, free);
}
static hb_blob_t *
_hb_face_builder_reference_table (hb_face_t *face, hb_tag_t tag, void *user_data)
{
hb_face_builder_data_t *data = (hb_face_builder_data_t *) user_data;
if (!tag)
return _hb_face_builder_data_reference_blob (data);
hb_face_builder_data_t::table_entry_t *entry = data->tables.lsearch (tag);
if (entry)
return hb_blob_reference (entry->blob);
return nullptr;
}
/**
* hb_face_builder_create:
*
* Creates a #hb_face_t that can be used with hb_face_builder_add_table().
* After tables are added to the face, it can be compiled to a binary
* font file by calling hb_face_reference_blob().
*
* Return value: (transfer full) New face.
*
* Since: REPLACEME
**/
hb_face_t *
hb_face_builder_create (void)
{
hb_face_builder_data_t *data = _hb_face_builder_data_create ();
if (unlikely (!data)) return hb_face_get_empty ();
return hb_face_create_for_tables (_hb_face_builder_reference_table,
data,
_hb_face_builder_data_destroy);
}
/**
* hb_face_builder_add_table:
*
* Add table for @tag with data provided by @blob to the face. @face must
* be created using hb_face_builder_create().
*
* Since: REPLACEME
**/
hb_bool_t
hb_face_builder_add_table (hb_face_t *face, hb_tag_t tag, hb_blob_t *blob)
{
if (unlikely (face->destroy != (hb_destroy_func_t) _hb_face_builder_data_destroy))
return false;
hb_face_builder_data_t *data = (hb_face_builder_data_t *) face->user_data;
hb_face_builder_data_t::table_entry_t *entry = data->tables.push ();
entry->tag = tag;
entry->blob = hb_blob_reference (blob);
return true;
}

View File

@ -33,6 +33,7 @@
#include "hb-common.h"
#include "hb-blob.h"
#include "hb-set.h"
HB_BEGIN_DECLS
@ -120,6 +121,38 @@ hb_face_get_table_tags (const hb_face_t *face,
unsigned int *table_count, /* IN/OUT */
hb_tag_t *table_tags /* OUT */);
/*
* Character set.
*/
HB_EXTERN void
hb_face_collect_unicodes (hb_face_t *face,
hb_set_t *out);
HB_EXTERN void
hb_face_collect_variation_selectors (hb_face_t *face,
hb_set_t *out);
HB_EXTERN void
hb_face_collect_variation_unicodes (hb_face_t *face,
hb_codepoint_t variation_selector,
hb_set_t *out);
/*
* Builder face.
*/
HB_EXTERN hb_face_t *
hb_face_builder_create (void);
HB_EXTERN hb_bool_t
hb_face_builder_add_table (hb_face_t *face,
hb_tag_t tag,
hb_blob_t *blob);
HB_END_DECLS
#endif /* HB_FACE_H */

View File

@ -26,13 +26,13 @@
* Google Author(s): Behdad Esfahbod
*/
#ifndef HB_FACE_PRIVATE_HH
#define HB_FACE_PRIVATE_HH
#ifndef HB_FACE_HH
#define HB_FACE_HH
#include "hb-private.hh"
#include "hb.hh"
#include "hb-shaper-private.hh"
#include "hb-shape-plan-private.hh"
#include "hb-shaper.hh"
#include "hb-shape-plan.hh"
/*
@ -105,4 +105,4 @@ DECLARE_NULL_INSTANCE (hb_face_t);
#undef HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS
#endif /* HB_FACE_PRIVATE_HH */
#endif /* HB_FACE_HH */

View File

@ -25,7 +25,7 @@
*/
#define HB_SHAPER fallback
#include "hb-shaper-impl-private.hh"
#include "hb-shaper-impl.hh"
HB_SHAPER_DATA_ENSURE_DEFINE(fallback, face)

View File

@ -26,10 +26,10 @@
* Google Author(s): Behdad Esfahbod
*/
#include "hb-private.hh"
#include "hb.hh"
#include "hb-font-private.hh"
#include "hb-machinery-private.hh"
#include "hb-font.hh"
#include "hb-machinery.hh"
/*

View File

@ -26,13 +26,13 @@
* Google Author(s): Behdad Esfahbod
*/
#ifndef HB_FONT_PRIVATE_HH
#define HB_FONT_PRIVATE_HH
#ifndef HB_FONT_HH
#define HB_FONT_HH
#include "hb-private.hh"
#include "hb.hh"
#include "hb-face-private.hh"
#include "hb-shaper-private.hh"
#include "hb-face.hh"
#include "hb-shaper.hh"
/*
@ -601,4 +601,4 @@ DECLARE_NULL_INSTANCE (hb_font_t);
#undef HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS
#endif /* HB_FONT_PRIVATE_HH */
#endif /* HB_FONT_HH */

View File

@ -27,12 +27,12 @@
* Google Author(s): Behdad Esfahbod
*/
#include "hb-private.hh"
#include "hb.hh"
#include "hb-ft.h"
#include "hb-font-private.hh"
#include "hb-machinery-private.hh"
#include "hb-font.hh"
#include "hb-machinery.hh"
#include FT_ADVANCES_H
#include FT_MULTIPLE_MASTERS_H

View File

@ -26,12 +26,12 @@
* Google Author(s): Behdad Esfahbod
*/
#include "hb-private.hh"
#include "hb.hh"
#include "hb-glib.h"
#include "hb-unicode-private.hh"
#include "hb-machinery-private.hh"
#include "hb-unicode.hh"
#include "hb-machinery.hh"
#if !GLIB_CHECK_VERSION(2,29,14)

View File

@ -25,7 +25,7 @@
* Google Author(s): Behdad Esfahbod
*/
#include "hb-private.hh"
#include "hb.hh"
/* g++ didn't like older gtype.h gcc-only code path. */
#include <glib.h>

View File

@ -24,7 +24,7 @@
* Google Author(s): Behdad Esfahbod
*/
#include "hb-private.hh"
#include "hb.hh"
/* g++ didn't like older gtype.h gcc-only code path. */
#include <glib.h>

View File

@ -27,7 +27,7 @@
*/
#define HB_SHAPER graphite2
#include "hb-shaper-impl-private.hh"
#include "hb-shaper-impl.hh"
#include "hb-graphite2.h"

View File

@ -27,12 +27,12 @@
* Google Author(s): Behdad Esfahbod
*/
#include "hb-private.hh"
#include "hb.hh"
#include "hb-icu.h"
#include "hb-unicode-private.hh"
#include "hb-machinery-private.hh"
#include "hb-unicode.hh"
#include "hb-machinery.hh"
#include <unicode/uchar.h>
#include <unicode/unorm2.h>

View File

@ -24,10 +24,10 @@
* Google Author(s): Behdad Esfahbod
*/
#ifndef HB_ITER_PRIVATE_HH
#define HB_ITER_PRIVATE_HH
#ifndef HB_ITER_HH
#define HB_ITER_HH
#include "hb-private.hh"
#include "hb.hh"
/* Unified iterator object.
@ -146,4 +146,4 @@ m (void)
}
}
#endif /* HB_ITER_PRIVATE_HH */
#endif /* HB_ITER_HH */

View File

@ -26,13 +26,13 @@
* Google Author(s): Behdad Esfahbod
*/
#ifndef HB_MACHINERY_PRIVATE_HH
#define HB_MACHINERY_PRIVATE_HH
#ifndef HB_MACHINERY_HH
#define HB_MACHINERY_HH
#include "hb-private.hh"
#include "hb-blob-private.hh"
#include "hb.hh"
#include "hb-blob.hh"
#include "hb-iter-private.hh"
#include "hb-iter.hh"
/*
@ -138,6 +138,68 @@ struct hb_dispatch_context_t
/*
* Sanitize
*
*
* === Introduction ===
*
* The sanitize machinery is at the core of our zero-cost font loading. We
* mmap() font file into memory and create a blob out of it. Font subtables
* are returned as a readonly sub-blob of the main font blob. These table
* blobs are then sanitized before use, to ensure invalid memory access does
* not happen. The toplevel sanitize API use is like, eg. to load the 'head'
* table:
*
* hb_blob_t *head_blob = hb_sanitize_context_t ().reference_table<OT::head> (face);
*
* The blob then can be converted to a head table struct with:
*
* const head *head_table = head_blob->as<head> ();
*
* What the reference_table does is, to call hb_face_reference_table() to load
* the table blob, sanitize it and return either the sanitized blob, or empty
* blob if sanitization failed. The blob->as() function returns the null
* object of its template type argument if the blob is empty. Otherwise, it
* just casts the blob contents to the desired type.
*
* Sanitizing a blob of data with a type T works as follows (with minor
* simplification):
*
* - Cast blob content to T*, call sanitize() method of it,
* - If sanitize succeeded, return blob.
* - Otherwise, if blob is not writable, try making it writable,
* or copy if cannot be made writable in-place,
* - Call sanitize() again. Return blob if sanitize succeeded.
* - Return empty blob otherwise.
*
*
* === The sanitize() contract ===
*
* The sanitize() method of each object type shall return true if it's safe to
* call other methods of the object, and false otherwise.
*
* Note that what sanitize() checks for might align with what the specification
* describes as valid table data, but does not have to be. In particular, we
* do NOT want to be pedantic and concern ourselves with validity checks that
* are irrelevant to our use of the table. On the contrary, we want to be
* lenient with error handling and accept invalid data to the extent that it
* does not impose extra burden on us.
*
* Based on the sanitize contract, one can see that what we check for depends
* on how we use the data in other table methods. Ie. if other table methods
* assume that offsets do NOT point out of the table data block, then that's
* something sanitize() must check for (GSUB/GPOS/GDEF/etc work this way). On
* the other hand, if other methods do such checks themselves, then sanitize()
* does not have to bother with them (glyf/local work this way). The choice
* depends on the table structure and sanitize() performance. For example, to
* check glyf/loca offsets in sanitize() would cost O(num-glyphs). We try hard
* to avoid such costs during font loading. By postponing such checks to the
* actual glyph loading, we reduce the sanitize cost to O(1) and total runtime
* cost to O(used-glyphs). As such, this is preferred.
*
* The same argument can be made re GSUB/GPOS/GDEF, but there, the table
* structure is so complicated that by checking all offsets at sanitize() time,
* we make the code much simpler in other methods, as offsets and referenced
* objectes do not need to be validated at each use site.
*/
/* This limits sanitizing time on really broken fonts. */
@ -402,7 +464,7 @@ struct hb_serialize_context_t
}
template <typename Type>
inline Type *copy (void)
inline Type *copy (void) const
{
assert (!this->ran_out_of_room);
unsigned int len = this->head - this->start;
@ -411,6 +473,25 @@ struct hb_serialize_context_t
memcpy (p, this->start, len);
return reinterpret_cast<Type *> (p);
}
inline hb_bytes_t copy_bytes (void) const
{
assert (!this->ran_out_of_room);
unsigned int len = this->head - this->start;
void *p = malloc (len);
if (p)
memcpy (p, this->start, len);
else
return hb_bytes_t ();
return hb_bytes_t (p, len);
}
inline hb_blob_t *copy_blob (void) const
{
assert (!this->ran_out_of_room);
return hb_blob_create (this->start,
this->head - this->start,
HB_MEMORY_MODE_DUPLICATE,
nullptr, nullptr);
}
template <typename Type>
inline Type *allocate_size (unsigned int size)
@ -682,6 +763,10 @@ struct hb_lazy_loader_t : hb_data_wrapper_t<Data, WheresData>
}
return p;
}
inline Stored * get_stored_relaxed (void) const
{
return this->instance.get_relaxed ();
}
inline void set_stored (Stored *instance_)
{
@ -695,6 +780,7 @@ struct hb_lazy_loader_t : hb_data_wrapper_t<Data, WheresData>
}
inline const Returned * get (void) const { return Funcs::convert (get_stored ()); }
inline const Returned * get_relaxed (void) const { return Funcs::convert (get_stored_relaxed ()); }
inline Returned * get_unconst (void) const { return const_cast<Returned *> (Funcs::convert (get_stored ())); }
/* To be possibly overloaded by subclasses. */
@ -729,9 +815,9 @@ struct hb_lazy_loader_t : hb_data_wrapper_t<Data, WheresData>
/* Specializations. */
template <unsigned int WheresFace, typename T>
template <typename T, unsigned int WheresFace>
struct hb_face_lazy_loader_t : hb_lazy_loader_t<T,
hb_face_lazy_loader_t<WheresFace, T>,
hb_face_lazy_loader_t<T, WheresFace>,
hb_face_t, WheresFace> {};
template <typename T, unsigned int WheresFace>
@ -789,4 +875,4 @@ struct hb_unicode_funcs_lazy_loader_t : hb_lazy_loader_t<hb_unicode_funcs_t, Sub
};
#endif /* HB_MACHINERY_PRIVATE_HH */
#endif /* HB_MACHINERY_HH */

View File

@ -24,7 +24,7 @@
* Google Author(s): Behdad Esfahbod
*/
#include "hb-map-private.hh"
#include "hb-map.hh"
/* Public API */

View File

@ -24,10 +24,10 @@
* Google Author(s): Behdad Esfahbod
*/
#ifndef HB_MAP_PRIVATE_HH
#define HB_MAP_PRIVATE_HH
#ifndef HB_MAP_HH
#define HB_MAP_HH
#include "hb-private.hh"
#include "hb.hh"
template <typename T>
@ -251,4 +251,4 @@ struct hb_map_t
};
#endif /* HB_MAP_PRIVATE_HH */
#endif /* HB_MAP_HH */

View File

@ -29,10 +29,10 @@
* Google Author(s): Behdad Esfahbod
*/
#ifndef HB_MUTEX_PRIVATE_HH
#define HB_MUTEX_PRIVATE_HH
#ifndef HB_MUTEX_HH
#define HB_MUTEX_HH
#include "hb-private.hh"
#include "hb.hh"
/* mutex */
@ -138,4 +138,4 @@ struct hb_mutex_t
};
#endif /* HB_MUTEX_PRIVATE_HH */
#endif /* HB_MUTEX_HH */

View File

@ -27,7 +27,7 @@
#ifndef HB_NULL_HH
#define HB_NULL_HH
#include "hb-private.hh"
#include "hb.hh"
/*

View File

@ -29,13 +29,13 @@
* Google Author(s): Behdad Esfahbod
*/
#ifndef HB_OBJECT_PRIVATE_HH
#define HB_OBJECT_PRIVATE_HH
#ifndef HB_OBJECT_HH
#define HB_OBJECT_HH
#include "hb-private.hh"
#include "hb-atomic-private.hh"
#include "hb-mutex-private.hh"
#include "hb-vector-private.hh"
#include "hb.hh"
#include "hb-atomic.hh"
#include "hb-mutex.hh"
#include "hb-vector.hh"
/*
@ -322,4 +322,4 @@ static inline void *hb_object_get_user_data (Type *obj,
}
#endif /* HB_OBJECT_PRIVATE_HH */
#endif /* HB_OBJECT_HH */

View File

@ -26,10 +26,10 @@
* Google Author(s): Behdad Esfahbod
*/
#ifndef HB_OPEN_FILE_PRIVATE_HH
#define HB_OPEN_FILE_PRIVATE_HH
#ifndef HB_OPEN_FILE_HH
#define HB_OPEN_FILE_HH
#include "hb-open-type-private.hh"
#include "hb-open-type.hh"
#include "hb-ot-head-table.hh"
@ -565,4 +565,4 @@ struct OpenTypeFontFile
} /* namespace OT */
#endif /* HB_OPEN_FILE_PRIVATE_HH */
#endif /* HB_OPEN_FILE_HH */

View File

@ -26,13 +26,13 @@
* Google Author(s): Behdad Esfahbod
*/
#ifndef HB_OPEN_TYPE_PRIVATE_HH
#define HB_OPEN_TYPE_PRIVATE_HH
#ifndef HB_OPEN_TYPE_HH
#define HB_OPEN_TYPE_HH
#include "hb-private.hh"
#include "hb-blob-private.hh"
#include "hb-face-private.hh"
#include "hb-machinery-private.hh"
#include "hb.hh"
#include "hb-blob.hh"
#include "hb-face.hh"
#include "hb-machinery.hh"
namespace OT {
@ -646,4 +646,4 @@ struct BinSearchArrayOf : SortedArrayOf<Type, BinSearchHeader> {};
} /* namespace OT */
#endif /* HB_OPEN_TYPE_PRIVATE_HH */
#endif /* HB_OPEN_TYPE_HH */

View File

@ -26,9 +26,9 @@
#ifndef HB_OT_CFF_COMMON_PRIVATE_HH
#define HB_OT_CFF_COMMON_PRIVATE_HH
#include "hb-open-type-private.hh"
#include "hb-ot-layout-common-private.hh"
#include "hb-cff-interp-dict-common-private.hh"
#include "hb-open-type.hh"
#include "hb-ot-layout-common.hh"
#include "hb-cff-interp-dict-common.hh"
#include "hb-subset-plan.hh"
namespace CFF {

View File

@ -27,7 +27,7 @@
#ifndef HB_OT_CFF1_TABLE_HH
#define HB_OT_CFF1_TABLE_HH
#include "hb-ot-cff-common-private.hh"
#include "hb-ot-cff-common.hh"
#include "hb-subset-cff1.hh"
namespace CFF {

View File

@ -27,7 +27,7 @@
#ifndef HB_OT_CFF2_TABLE_HH
#define HB_OT_CFF2_TABLE_HH
#include "hb-ot-cff-common-private.hh"
#include "hb-ot-cff-common.hh"
#include "hb-subset-cff2.hh"
namespace CFF {

View File

@ -27,8 +27,8 @@
#ifndef HB_OT_CMAP_TABLE_HH
#define HB_OT_CMAP_TABLE_HH
#include "hb-open-type-private.hh"
#include "hb-set-private.hh"
#include "hb-open-type.hh"
#include "hb-set.hh"
#include "hb-subset-plan.hh"
/*
@ -37,10 +37,6 @@
*/
#define HB_OT_TAG_cmap HB_TAG('c','m','a','p')
#ifndef HB_MAX_UNICODE_CODEPOINT_VALUE
#define HB_MAX_UNICODE_CODEPOINT_VALUE 0x10FFFF
#endif
namespace OT {
@ -52,7 +48,13 @@ struct CmapSubtableFormat0
if (!gid)
return false;
*glyph = gid;
return true;
return *glyph != 0;
}
inline void collect_unicodes (hb_set_t *out) const
{
for (unsigned int i = 0; i < 256; i++)
if (glyphIdArray[i])
out->add (i);
}
inline bool sanitize (hb_sanitize_context_t *c) const
@ -237,15 +239,14 @@ struct CmapSubtableFormat4
glyphIdArray = idRangeOffset + segCount;
glyphIdArrayLength = (subtable->length - 16 - 8 * segCount) / 2;
}
inline void fini (void) {}
static inline bool get_glyph_func (const void *obj, hb_codepoint_t codepoint, hb_codepoint_t *glyph)
inline bool get_glyph (hb_codepoint_t codepoint, hb_codepoint_t *glyph) const
{
const accelerator_t *thiz = (const accelerator_t *) obj;
/* Custom two-array bsearch. */
int min = 0, max = (int) thiz->segCount - 1;
const HBUINT16 *startCount = thiz->startCount;
const HBUINT16 *endCount = thiz->endCount;
int min = 0, max = (int) this->segCount - 1;
const HBUINT16 *startCount = this->startCount;
const HBUINT16 *endCount = this->endCount;
unsigned int i;
while (min <= max)
{
@ -264,33 +265,53 @@ struct CmapSubtableFormat4
found:
hb_codepoint_t gid;
unsigned int rangeOffset = thiz->idRangeOffset[i];
unsigned int rangeOffset = this->idRangeOffset[i];
if (rangeOffset == 0)
gid = codepoint + thiz->idDelta[i];
gid = codepoint + this->idDelta[i];
else
{
/* Somebody has been smoking... */
unsigned int index = rangeOffset / 2 + (codepoint - thiz->startCount[i]) + i - thiz->segCount;
if (unlikely (index >= thiz->glyphIdArrayLength))
unsigned int index = rangeOffset / 2 + (codepoint - this->startCount[i]) + i - this->segCount;
if (unlikely (index >= this->glyphIdArrayLength))
return false;
gid = thiz->glyphIdArray[index];
gid = this->glyphIdArray[index];
if (unlikely (!gid))
return false;
gid += thiz->idDelta[i];
gid += this->idDelta[i];
}
*glyph = gid & 0xFFFFu;
return true;
return *glyph != 0;
}
static inline void get_all_codepoints_func (const void *obj, hb_set_t *out)
static inline bool get_glyph_func (const void *obj, hb_codepoint_t codepoint, hb_codepoint_t *glyph)
{
const accelerator_t *thiz = (const accelerator_t *) obj;
for (unsigned int i = 0; i < thiz->segCount; i++)
return ((const accelerator_t *) obj)->get_glyph (codepoint, glyph);
}
inline void collect_unicodes (hb_set_t *out) const
{
unsigned int count = this->segCount;
if (count && this->startCount[count - 1] == 0xFFFFu)
count--; /* Skip sentinel segment. */
for (unsigned int i = 0; i < count; i++)
{
if (thiz->startCount[i] != 0xFFFFu
|| thiz->endCount[i] != 0xFFFFu) // Skip the last segment (0xFFFF)
hb_set_add_range (out, thiz->startCount[i], thiz->endCount[i]);
unsigned int rangeOffset = this->idRangeOffset[i];
if (rangeOffset == 0)
out->add_range (this->startCount[i], this->endCount[i]);
else
{
for (hb_codepoint_t codepoint = this->startCount[i];
codepoint <= this->endCount[i];
codepoint++)
{
unsigned int index = rangeOffset / 2 + (codepoint - this->startCount[i]) + i - this->segCount;
if (unlikely (index >= this->glyphIdArrayLength))
break;
hb_codepoint_t gid = this->glyphIdArray[index];
if (unlikely (!gid))
continue;
out->add (codepoint);
}
}
}
}
@ -305,10 +326,14 @@ struct CmapSubtableFormat4
inline bool get_glyph (hb_codepoint_t codepoint, hb_codepoint_t *glyph) const
{
accelerator_t accel;
accel.init (this);
hb_auto_t<accelerator_t> accel (this);
return accel.get_glyph_func (&accel, codepoint, glyph);
}
inline void collect_unicodes (hb_set_t *out) const
{
hb_auto_t<accelerator_t> accel (this);
accel.collect_unicodes (out);
}
inline bool sanitize (hb_sanitize_context_t *c) const
{
@ -383,7 +408,7 @@ struct CmapSubtableLongGroup
HBUINT32 startCharCode; /* First character code in this group. */
HBUINT32 endCharCode; /* Last character code in this group. */
HBUINT32 glyphID; /* Glyph index; interpretation depends on
* subtable format. */
* subtable format. */
public:
DEFINE_SIZE_STATIC (12);
};
@ -398,7 +423,15 @@ struct CmapSubtableTrimmed
if (!gid)
return false;
*glyph = gid;
return true;
return *glyph != 0;
}
inline void collect_unicodes (hb_set_t *out) const
{
hb_codepoint_t start = startCharCode;
unsigned int count = glyphIdArray.len;
for (unsigned int i = 0; i < count; i++)
if (glyphIdArray[i])
out->add (start + i);
}
inline bool sanitize (hb_sanitize_context_t *c) const
@ -433,17 +466,15 @@ struct CmapSubtableLongSegmented
if (i == -1)
return false;
*glyph = T::group_get_glyph (groups[i], codepoint);
return true;
return *glyph != 0;
}
inline void get_all_codepoints (hb_set_t *out) const
inline void collect_unicodes (hb_set_t *out) const
{
for (unsigned int i = 0; i < this->groups.len; i++) {
hb_set_add_range (out,
MIN ((unsigned int) this->groups[i].startCharCode,
(unsigned int) HB_MAX_UNICODE_CODEPOINT_VALUE),
MIN ((unsigned int) this->groups[i].endCharCode,
(unsigned int) HB_MAX_UNICODE_CODEPOINT_VALUE));
out->add_range (this->groups[i].startCharCode,
MIN ((hb_codepoint_t) this->groups[i].endCharCode,
(hb_codepoint_t) HB_UNICODE_MAX));
}
}
@ -574,13 +605,29 @@ struct UnicodeValueRange
}
HBUINT24 startUnicodeValue; /* First value in this range. */
HBUINT8 additionalCount; /* Number of additional values in this
HBUINT8 additionalCount; /* Number of additional values in this
* range. */
public:
DEFINE_SIZE_STATIC (4);
};
typedef SortedArrayOf<UnicodeValueRange, HBUINT32> DefaultUVS;
struct DefaultUVS : SortedArrayOf<UnicodeValueRange, HBUINT32>
{
inline void collect_unicodes (hb_set_t *out) const
{
unsigned int count = len;
for (unsigned int i = 0; i < count; i++)
{
hb_codepoint_t first = arrayZ[i].startUnicodeValue;
hb_codepoint_t last = MIN ((hb_codepoint_t) (first + arrayZ[i].additionalCount),
(hb_codepoint_t) HB_UNICODE_MAX);
out->add_range (first, last);
}
}
public:
DEFINE_SIZE_ARRAY (4, arrayZ);
};
struct UVSMapping
{
@ -601,7 +648,18 @@ struct UVSMapping
DEFINE_SIZE_STATIC (5);
};
typedef SortedArrayOf<UVSMapping, HBUINT32> NonDefaultUVS;
struct NonDefaultUVS : SortedArrayOf<UVSMapping, HBUINT32>
{
inline void collect_unicodes (hb_set_t *out) const
{
unsigned int count = len;
for (unsigned int i = 0; i < count; i++)
out->add (arrayZ[i].glyphID);
}
public:
DEFINE_SIZE_ARRAY (4, arrayZ);
};
struct VariationSelectorRecord
{
@ -624,6 +682,12 @@ struct VariationSelectorRecord
return GLYPH_VARIANT_NOT_FOUND;
}
inline void collect_unicodes (hb_set_t *out, const void *base) const
{
(base+defaultUVS).collect_unicodes (out);
(base+nonDefaultUVS).collect_unicodes (out);
}
inline int cmp (const hb_codepoint_t &variation_selector) const
{
return varSelector.cmp (variation_selector);
@ -652,7 +716,19 @@ struct CmapSubtableFormat14
hb_codepoint_t variation_selector,
hb_codepoint_t *glyph) const
{
return record[record.bsearch(variation_selector)].get_glyph (codepoint, glyph, this);
return record[record.bsearch (variation_selector)].get_glyph (codepoint, glyph, this);
}
inline void collect_variation_selectors (hb_set_t *out) const
{
unsigned int count = record.len;
for (unsigned int i = 0; i < count; i++)
out->add (record.arrayZ[i].varSelector);
}
inline void collect_variation_unicodes (hb_codepoint_t variation_selector,
hb_set_t *out) const
{
record[record.bsearch (variation_selector)].collect_unicodes (out, this);
}
inline bool sanitize (hb_sanitize_context_t *c) const
@ -690,6 +766,19 @@ struct CmapSubtable
default: return false;
}
}
inline void collect_unicodes (hb_set_t *out) const
{
switch (u.format) {
case 0: u.format0 .collect_unicodes (out); return;
case 4: u.format4 .collect_unicodes (out); return;
case 6: u.format6 .collect_unicodes (out); return;
case 10: u.format10.collect_unicodes (out); return;
case 12: u.format12.collect_unicodes (out); return;
case 13: u.format13.collect_unicodes (out); return;
case 14:
default: return;
}
}
inline bool sanitize (hb_sanitize_context_t *c) const
{
@ -754,7 +843,8 @@ struct cmap
{
static const hb_tag_t tableTag = HB_OT_TAG_cmap;
struct subset_plan {
struct subset_plan
{
subset_plan(void)
{
format4_segments.init();
@ -895,33 +985,44 @@ struct cmap
return result;
}
const CmapSubtable *find_best_subtable (bool *symbol = nullptr) const
{
if (symbol) *symbol = false;
const CmapSubtable *subtable;
/* 32-bit subtables. */
if ((subtable = this->find_subtable (3, 10))) return subtable;
if ((subtable = this->find_subtable (0, 6))) return subtable;
if ((subtable = this->find_subtable (0, 4))) return subtable;
/* 16-bit subtables. */
if ((subtable = this->find_subtable (3, 1))) return subtable;
if ((subtable = this->find_subtable (0, 3))) return subtable;
if ((subtable = this->find_subtable (0, 2))) return subtable;
if ((subtable = this->find_subtable (0, 1))) return subtable;
if ((subtable = this->find_subtable (0, 0))) return subtable;
/* Symbol subtable. */
if ((subtable = this->find_subtable (3, 0)))
{
if (symbol) *symbol = true;
return subtable;
}
/* Meh. */
return &Null(CmapSubtable);
}
struct accelerator_t
{
inline void init (hb_face_t *face)
{
this->blob = hb_sanitize_context_t().reference_table<cmap> (face);
const cmap *table = this->blob->as<cmap> ();
const CmapSubtable *subtable = nullptr;
const CmapSubtableFormat14 *subtable_uvs = nullptr;
bool symbol = false;
/* 32-bit subtables. */
if (!subtable) subtable = table->find_subtable (3, 10);
if (!subtable) subtable = table->find_subtable (0, 6);
if (!subtable) subtable = table->find_subtable (0, 4);
/* 16-bit subtables. */
if (!subtable) subtable = table->find_subtable (3, 1);
if (!subtable) subtable = table->find_subtable (0, 3);
if (!subtable) subtable = table->find_subtable (0, 2);
if (!subtable) subtable = table->find_subtable (0, 1);
if (!subtable) subtable = table->find_subtable (0, 0);
if (!subtable)
{
subtable = table->find_subtable (3, 0);
if (subtable) symbol = true;
}
/* Meh. */
if (!subtable) subtable = &Null(CmapSubtable);
bool symbol;
subtable = table->find_best_subtable (&symbol);
/* UVS subtable. */
if (!subtable_uvs)
@ -933,30 +1034,26 @@ struct cmap
/* Meh. */
if (!subtable_uvs) subtable_uvs = &Null(CmapSubtableFormat14);
this->uvs_table = subtable_uvs;
this->subtable_uvs = subtable_uvs;
this->get_glyph_data = subtable;
if (unlikely (symbol))
{
this->get_glyph_func = get_glyph_from_symbol<CmapSubtable>;
this->get_all_codepoints_func = null_get_all_codepoints_func;
} else {
switch (subtable->u.format) {
/* Accelerate format 4 and format 12. */
default:
this->get_glyph_func = get_glyph_from<CmapSubtable>;
this->get_all_codepoints_func = null_get_all_codepoints_func;
break;
case 12:
this->get_glyph_func = get_glyph_from<CmapSubtableFormat12>;
this->get_all_codepoints_func = get_all_codepoints_from<CmapSubtableFormat12>;
break;
case 4:
{
this->format4_accel.init (&subtable->u.format4);
this->get_glyph_data = &this->format4_accel;
this->get_glyph_func = this->format4_accel.get_glyph_func;
this->get_all_codepoints_func = this->format4_accel.get_all_codepoints_func;
}
break;
}
@ -978,7 +1075,7 @@ struct cmap
hb_codepoint_t variation_selector,
hb_codepoint_t *glyph) const
{
switch (this->uvs_table->get_glyph_variant (unicode,
switch (this->subtable_uvs->get_glyph_variant (unicode,
variation_selector,
glyph))
{
@ -990,22 +1087,24 @@ struct cmap
return get_nominal_glyph (unicode, glyph);
}
inline void get_all_codepoints (hb_set_t *out) const
inline void collect_unicodes (hb_set_t *out) const
{
this->get_all_codepoints_func (get_glyph_data, out);
subtable->collect_unicodes (out);
}
inline void collect_variation_selectors (hb_set_t *out) const
{
subtable_uvs->collect_variation_selectors (out);
}
inline void collect_variation_unicodes (hb_codepoint_t variation_selector,
hb_set_t *out) const
{
subtable_uvs->collect_variation_unicodes (variation_selector, out);
}
protected:
typedef bool (*hb_cmap_get_glyph_func_t) (const void *obj,
hb_codepoint_t codepoint,
hb_codepoint_t *glyph);
typedef void (*hb_cmap_get_all_codepoints_func_t) (const void *obj,
hb_set_t *out);
static inline void null_get_all_codepoints_func (const void *obj, hb_set_t *out)
{
// NOOP
}
template <typename Type>
static inline bool get_glyph_from (const void *obj,
@ -1016,14 +1115,6 @@ struct cmap
return typed_obj->get_glyph (codepoint, glyph);
}
template <typename Type>
static inline void get_all_codepoints_from (const void *obj,
hb_set_t *out)
{
const Type *typed_obj = (const Type *) obj;
typed_obj->get_all_codepoints (out);
}
template <typename Type>
static inline bool get_glyph_from_symbol (const void *obj,
hb_codepoint_t codepoint,
@ -1047,13 +1138,14 @@ struct cmap
}
private:
const CmapSubtable *subtable;
const CmapSubtableFormat14 *subtable_uvs;
hb_cmap_get_glyph_func_t get_glyph_func;
const void *get_glyph_data;
hb_cmap_get_all_codepoints_func_t get_all_codepoints_func;
CmapSubtableFormat4::accelerator_t format4_accel;
const CmapSubtableFormat14 *uvs_table;
hb_blob_t *blob;
};
@ -1066,10 +1158,7 @@ struct cmap
key.platformID.set (platform_id);
key.encodingID.set (encoding_id);
/* Note: We can use bsearch, but since it has no performance
* implications, we use lsearch and as such accept fonts with
* unsorted subtable list. */
int result = encodingRecord./*bsearch*/lsearch (key);
int result = encodingRecord.bsearch (key);
if (result == -1 || !encodingRecord[result].subtable)
return nullptr;
@ -1084,6 +1173,7 @@ struct cmap
DEFINE_SIZE_ARRAY (4, encodingRecord);
};
struct cmap_accelerator_t : cmap::accelerator_t {};
} /* namespace OT */

View File

@ -27,7 +27,7 @@
#ifndef HB_OT_COLOR_CBDT_TABLE_HH
#define HB_OT_COLOR_CBDT_TABLE_HH
#include "hb-open-type-private.hh"
#include "hb-open-type.hh"
/*
* CBLC -- Color Bitmap Location
@ -533,6 +533,8 @@ struct CBDT
DEFINE_SIZE_ARRAY(4, dataZ);
};
struct CBDT_accelerator_t : CBDT::accelerator_t {};
} /* namespace OT */
#endif /* HB_OT_COLOR_CBDT_TABLE_HH */

View File

@ -25,7 +25,7 @@
#ifndef HB_OT_COLOR_COLR_TABLE_HH
#define HB_OT_COLOR_COLR_TABLE_HH
#include "hb-open-type-private.hh"
#include "hb-open-type.hh"
/*
* COLR -- Color

View File

@ -28,7 +28,7 @@
#ifndef HB_OT_COLOR_CPAL_TABLE_HH
#define HB_OT_COLOR_CPAL_TABLE_HH
#include "hb-open-type-private.hh"
#include "hb-open-type.hh"
/*

View File

@ -25,7 +25,7 @@
#ifndef HB_OT_COLOR_SBIX_TABLE_HH
#define HB_OT_COLOR_SBIX_TABLE_HH
#include "hb-open-type-private.hh"
#include "hb-open-type.hh"
/*
* sbix -- Standard Bitmap Graphics

View File

@ -25,7 +25,7 @@
#ifndef HB_OT_COLOR_SVG_TABLE_HH
#define HB_OT_COLOR_SVG_TABLE_HH
#include "hb-open-type-private.hh"
#include "hb-open-type.hh"
/*
* SVG -- SVG (Scalable Vector Graphics)

View File

@ -25,7 +25,7 @@
* Google Author(s): Sascha Brawer
*/
#include "hb-open-type-private.hh"
#include "hb-open-type.hh"
#include "hb-ot-color-colr-table.hh"
#include "hb-ot-color-cpal-table.hh"
#include "hb-ot.h"
@ -33,8 +33,8 @@
#include <stdlib.h>
#include <string.h>
#include "hb-ot-layout-private.hh"
#include "hb-shaper-private.hh"
#include "hb-ot-layout.hh"
#include "hb-shaper.hh"
#if 0
HB_MARK_AS_FLAG_T (hb_ot_color_palette_flags_t)
@ -45,16 +45,14 @@ static inline const OT::COLR&
_get_colr (hb_face_t *face)
{
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::COLR);
hb_ot_layout_t * layout = hb_ot_layout_from_face (face);
return *(layout->colr.get ());
return *(hb_ot_face_data (face)->colr.get ());
}
static inline const OT::CPAL&
_get_cpal (hb_face_t *face)
{
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::CPAL);
hb_ot_layout_t * layout = hb_ot_layout_from_face (face);
return *(layout->cpal.get ());
return *(hb_ot_face_data (face)->cpal.get ());
}

76
src/hb-ot-face.cc Normal file
View File

@ -0,0 +1,76 @@
/*
* Copyright © 2018 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-ot-face.hh"
#include "hb-ot-cmap-table.hh"
#include "hb-ot-glyf-table.hh"
#include "hb-ot-hmtx-table.hh"
#include "hb-ot-kern-table.hh"
#include "hb-ot-post-table.hh"
#include "hb-ot-color-cbdt-table.hh"
#include "hb-ot-layout-gdef-table.hh"
#include "hb-ot-layout-gsub-table.hh"
#include "hb-ot-layout-gpos-table.hh"
void hb_ot_face_data_t::init0 (hb_face_t *face)
{
this->face = face;
#define HB_OT_LAYOUT_TABLE(Namespace, Type) Type.init0 ();
#define HB_OT_LAYOUT_ACCELERATOR(Namespace, Type) HB_OT_LAYOUT_TABLE (Namespace, Type)
HB_OT_LAYOUT_TABLES
#undef HB_OT_LAYOUT_ACCELERATOR
#undef HB_OT_LAYOUT_TABLE
}
void hb_ot_face_data_t::fini (void)
{
#define HB_OT_LAYOUT_TABLE(Namespace, Type) Type.fini ();
#define HB_OT_LAYOUT_ACCELERATOR(Namespace, Type) HB_OT_LAYOUT_TABLE (Namespace, Type)
HB_OT_LAYOUT_TABLES
#undef HB_OT_LAYOUT_ACCELERATOR
#undef HB_OT_LAYOUT_TABLE
}
hb_ot_face_data_t *
_hb_ot_face_data_create (hb_face_t *face)
{
hb_ot_face_data_t *data = (hb_ot_face_data_t *) calloc (1, sizeof (hb_ot_face_data_t));
if (unlikely (!data))
return nullptr;
data->init0 (face);
return data;
}
void
_hb_ot_face_data_destroy (hb_ot_face_data_t *data)
{
data->fini ();
free (data);
}

116
src/hb-ot-face.hh Normal file
View File

@ -0,0 +1,116 @@
/*
* Copyright © 2007,2008,2009 Red Hat, Inc.
* Copyright © 2012,2013 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.
*
* Red Hat Author(s): Behdad Esfahbod
* Google Author(s): Behdad Esfahbod
*/
#ifndef HB_OT_FACE_HH
#define HB_OT_FACE_HH
#include "hb.hh"
#include "hb-machinery.hh"
#define hb_ot_face_data(face) ((hb_ot_face_data_t *) face->shaper_data.ot.get_relaxed ())
/*
* hb_ot_face_data_t
*/
/* Most of these tables are NOT needed for shaping. But we need to hook them *somewhere*.
* This is as good as any place. */
#define HB_OT_LAYOUT_TABLES \
/* OpenType shaping. */ \
HB_OT_LAYOUT_TABLE(OT, JSTF) \
HB_OT_LAYOUT_TABLE(OT, BASE) \
/* AAT shaping. */ \
HB_OT_LAYOUT_TABLE(AAT, morx) \
HB_OT_LAYOUT_TABLE(AAT, kerx) \
HB_OT_LAYOUT_TABLE(AAT, ankr) \
HB_OT_LAYOUT_TABLE(AAT, trak) \
/* OpenType variations. */ \
HB_OT_LAYOUT_TABLE(OT, fvar) \
HB_OT_LAYOUT_TABLE(OT, avar) \
HB_OT_LAYOUT_TABLE(OT, MVAR) \
/* OpenType math. */ \
HB_OT_LAYOUT_TABLE(OT, MATH) \
/* OpenType fundamentals. */ \
HB_OT_LAYOUT_ACCELERATOR(OT, GDEF) \
HB_OT_LAYOUT_ACCELERATOR(OT, GSUB) \
HB_OT_LAYOUT_ACCELERATOR(OT, GPOS) \
HB_OT_LAYOUT_ACCELERATOR(OT, cmap) \
HB_OT_LAYOUT_ACCELERATOR(OT, hmtx) \
HB_OT_LAYOUT_ACCELERATOR(OT, vmtx) \
HB_OT_LAYOUT_ACCELERATOR(OT, post) \
HB_OT_LAYOUT_ACCELERATOR(OT, kern) \
HB_OT_LAYOUT_ACCELERATOR(OT, glyf) \
HB_OT_LAYOUT_ACCELERATOR(OT, CBDT) \
/* */
/* Declare tables. */
#define HB_OT_LAYOUT_TABLE(Namespace, Type) namespace Namespace { struct Type; }
#define HB_OT_LAYOUT_ACCELERATOR(Namespace, Type) HB_OT_LAYOUT_TABLE (Namespace, Type##_accelerator_t)
HB_OT_LAYOUT_TABLES
#undef HB_OT_LAYOUT_ACCELERATOR
#undef HB_OT_LAYOUT_TABLE
struct hb_ot_face_data_t
{
HB_INTERNAL void init0 (hb_face_t *face);
HB_INTERNAL void fini (void);
#define HB_OT_LAYOUT_TABLE_ORDER(Namespace, Type) \
HB_PASTE (ORDER_, HB_PASTE (Namespace, HB_PASTE (_, Type)))
enum order_t
{
ORDER_ZERO,
#define HB_OT_LAYOUT_TABLE(Namespace, Type) HB_OT_LAYOUT_TABLE_ORDER (Namespace, Type),
#define HB_OT_LAYOUT_ACCELERATOR(Namespace, Type) HB_OT_LAYOUT_TABLE (Namespace, Type)
HB_OT_LAYOUT_TABLES
#undef HB_OT_LAYOUT_ACCELERATOR
#undef HB_OT_LAYOUT_TABLE
};
hb_face_t *face; /* MUST be JUST before the lazy loaders. */
#define HB_OT_LAYOUT_TABLE(Namespace, Type) \
hb_table_lazy_loader_t<Namespace::Type, HB_OT_LAYOUT_TABLE_ORDER (Namespace, Type)> Type;
#define HB_OT_LAYOUT_ACCELERATOR(Namespace, Type) \
hb_face_lazy_loader_t<Namespace::Type##_accelerator_t, HB_OT_LAYOUT_TABLE_ORDER (Namespace, Type)> Type;
HB_OT_LAYOUT_TABLES
#undef HB_OT_LAYOUT_ACCELERATOR
#undef HB_OT_LAYOUT_TABLE
};
HB_INTERNAL hb_ot_face_data_t *
_hb_ot_face_data_create (hb_face_t *face);
HB_INTERNAL void
_hb_ot_face_data_destroy (hb_ot_face_data_t *data);
#endif /* HB_OT_FACE_HH */

View File

@ -24,86 +24,24 @@
* Google Author(s): Behdad Esfahbod, Roozbeh Pournader
*/
#include "hb-private.hh"
#include "hb.hh"
#include "hb-ot.h"
#include "hb-font-private.hh"
#include "hb-machinery-private.hh"
#include "hb-font.hh"
#include "hb-machinery.hh"
#include "hb-ot-face.hh"
#include "hb-ot-cmap-table.hh"
#include "hb-ot-glyf-table.hh"
#include "hb-ot-cff1-table.hh"
#include "hb-ot-cff2-table.hh"
#include "hb-ot-hmtx-table.hh"
#include "hb-ot-kern-table.hh"
#include "hb-ot-post-table.hh"
#include "hb-ot-glyf-table.hh"
#include "hb-ot-cff1-table.hh"
#include "hb-ot-cff2-table.hh"
#include "hb-ot-color-cbdt-table.hh"
struct hb_ot_font_t
{
inline void init (hb_face_t *face)
{
cmap.init (face);
h_metrics.init (face);
v_metrics.init (face, h_metrics.ascender - h_metrics.descender); /* TODO Can we do this lazily? */
this->face = face;
glyf.init ();
cbdt.init ();
post.init ();
kern.init ();
}
inline void fini (void)
{
cmap.fini ();
h_metrics.fini ();
v_metrics.fini ();
glyf.fini ();
cbdt.fini ();
post.fini ();
kern.fini ();
}
OT::cmap::accelerator_t cmap;
OT::hmtx::accelerator_t h_metrics;
OT::vmtx::accelerator_t v_metrics;
hb_face_t *face; /* MUST be JUST before the lazy loaders. */
hb_face_lazy_loader_t<1, OT::glyf::accelerator_t> glyf;
hb_face_lazy_loader_t<2, OT::CBDT::accelerator_t> cbdt;
hb_face_lazy_loader_t<3, OT::post::accelerator_t> post;
hb_face_lazy_loader_t<4, OT::kern::accelerator_t> kern;
};
static hb_ot_font_t *
_hb_ot_font_create (hb_face_t *face)
{
hb_ot_font_t *ot_font = (hb_ot_font_t *) calloc (1, sizeof (hb_ot_font_t));
if (unlikely (!ot_font))
return nullptr;
ot_font->init (face);
return ot_font;
}
static void
_hb_ot_font_destroy (void *data)
{
hb_ot_font_t *ot_font = (hb_ot_font_t *) data;
ot_font->fini ();
free (ot_font);
}
static hb_bool_t
hb_ot_get_nominal_glyph (hb_font_t *font HB_UNUSED,
void *font_data,
@ -112,8 +50,8 @@ hb_ot_get_nominal_glyph (hb_font_t *font HB_UNUSED,
void *user_data HB_UNUSED)
{
const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data;
return ot_font->cmap.get_nominal_glyph (unicode, glyph);
const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data;
return ot_font->cmap.get_relaxed()->get_nominal_glyph (unicode, glyph);
}
static hb_bool_t
@ -124,8 +62,8 @@ hb_ot_get_variation_glyph (hb_font_t *font HB_UNUSED,
hb_codepoint_t *glyph,
void *user_data HB_UNUSED)
{
const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data;
return ot_font->cmap.get_variation_glyph (unicode, variation_selector, glyph);
const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data;
return ot_font->cmap.get_relaxed ()->get_variation_glyph (unicode, variation_selector, glyph);
}
static hb_position_t
@ -134,8 +72,8 @@ hb_ot_get_glyph_h_advance (hb_font_t *font,
hb_codepoint_t glyph,
void *user_data HB_UNUSED)
{
const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data;
return font->em_scale_x (ot_font->h_metrics.get_advance (glyph, font));
const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data;
return font->em_scale_x (ot_font->hmtx.get_relaxed ()->get_advance (glyph, font));
}
static hb_position_t
@ -144,8 +82,8 @@ hb_ot_get_glyph_v_advance (hb_font_t *font,
hb_codepoint_t glyph,
void *user_data HB_UNUSED)
{
const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data;
return font->em_scale_y (-(int) ot_font->v_metrics.get_advance (glyph, font));
const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data;
return font->em_scale_y (-(int) ot_font->vmtx.get_relaxed ()->get_advance (glyph, font));
}
static hb_position_t
@ -155,7 +93,7 @@ hb_ot_get_glyph_h_kerning (hb_font_t *font,
hb_codepoint_t right_glyph,
void *user_data HB_UNUSED)
{
const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data;
const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data;
return font->em_scale_x (ot_font->kern->get_h_kerning (left_glyph, right_glyph));
}
@ -166,10 +104,10 @@ hb_ot_get_glyph_extents (hb_font_t *font,
hb_glyph_extents_t *extents,
void *user_data HB_UNUSED)
{
const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data;
const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data;
bool ret = ot_font->glyf->get_extents (glyph, extents);
if (!ret)
ret = ot_font->cbdt->get_extents (glyph, extents);
ret = ot_font->CBDT->get_extents (glyph, extents);
// TODO Hook up side-bearings variations.
extents->x_bearing = font->em_scale_x (extents->x_bearing);
extents->y_bearing = font->em_scale_y (extents->y_bearing);
@ -185,7 +123,7 @@ hb_ot_get_glyph_name (hb_font_t *font HB_UNUSED,
char *name, unsigned int size,
void *user_data HB_UNUSED)
{
const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data;
const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data;
return ot_font->post->get_glyph_name (glyph, name, size);
}
@ -196,7 +134,7 @@ hb_ot_get_glyph_from_name (hb_font_t *font HB_UNUSED,
hb_codepoint_t *glyph,
void *user_data HB_UNUSED)
{
const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data;
const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data;
return ot_font->post->get_glyph_from_name (name, len, glyph);
}
@ -206,12 +144,12 @@ hb_ot_get_font_h_extents (hb_font_t *font,
hb_font_extents_t *metrics,
void *user_data HB_UNUSED)
{
const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data;
metrics->ascender = font->em_scale_y (ot_font->h_metrics.ascender);
metrics->descender = font->em_scale_y (ot_font->h_metrics.descender);
metrics->line_gap = font->em_scale_y (ot_font->h_metrics.line_gap);
const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data;
metrics->ascender = font->em_scale_y (ot_font->hmtx.get_relaxed ()->ascender);
metrics->descender = font->em_scale_y (ot_font->hmtx.get_relaxed ()->descender);
metrics->line_gap = font->em_scale_y (ot_font->hmtx.get_relaxed ()->line_gap);
// TODO Hook up variations.
return ot_font->h_metrics.has_font_extents;
return ot_font->hmtx.get_relaxed ()->has_font_extents;
}
static hb_bool_t
@ -220,12 +158,12 @@ hb_ot_get_font_v_extents (hb_font_t *font,
hb_font_extents_t *metrics,
void *user_data HB_UNUSED)
{
const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data;
metrics->ascender = font->em_scale_x (ot_font->v_metrics.ascender);
metrics->descender = font->em_scale_x (ot_font->v_metrics.descender);
metrics->line_gap = font->em_scale_x (ot_font->v_metrics.line_gap);
const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data;
metrics->ascender = font->em_scale_x (ot_font->vmtx.get_relaxed ()->ascender);
metrics->descender = font->em_scale_x (ot_font->vmtx.get_relaxed ()->descender);
metrics->line_gap = font->em_scale_x (ot_font->vmtx.get_relaxed ()->line_gap);
// TODO Hook up variations.
return ot_font->v_metrics.has_font_extents;
return ot_font->vmtx.get_relaxed ()->has_font_extents;
}
#ifdef HB_USE_ATEXIT
@ -286,12 +224,16 @@ _hb_ot_get_font_funcs (void)
void
hb_ot_font_set_funcs (hb_font_t *font)
{
hb_ot_font_t *ot_font = _hb_ot_font_create (font->face);
if (unlikely (!ot_font))
return;
if (unlikely (!hb_ot_shaper_face_data_ensure (font->face))) return;
hb_ot_face_data_t *ot_font = hb_ot_face_data (font->face);
/* Load them lazies. We access them with get_relaxed() for performance. */
ot_font->cmap.get ();
ot_font->hmtx.get ();
ot_font->vmtx.get ();
hb_font_set_funcs (font,
_hb_ot_get_font_funcs (),
ot_font,
_hb_ot_font_destroy);
nullptr);
}

View File

@ -27,11 +27,11 @@
#ifndef HB_OT_GLYF_TABLE_HH
#define HB_OT_GLYF_TABLE_HH
#include "hb-open-type-private.hh"
#include "hb-open-type.hh"
#include "hb-ot-head-table.hh"
#include "hb-subset-glyf.hh"
#include "hb-subset-plan.hh"
#include "hb-subset-private.hh"
#include "hb-subset.hh"
namespace OT {
@ -490,6 +490,8 @@ struct glyf
DEFINE_SIZE_ARRAY (0, dataZ);
};
struct glyf_accelerator_t : glyf::accelerator_t {};
} /* namespace OT */

View File

@ -27,7 +27,7 @@
#ifndef HB_OT_HDMX_TABLE_HH
#define HB_OT_HDMX_TABLE_HH
#include "hb-open-type-private.hh"
#include "hb-open-type.hh"
#include "hb-subset-plan.hh"
/*

View File

@ -29,7 +29,7 @@
#ifndef HB_OT_HEAD_TABLE_HH
#define HB_OT_HEAD_TABLE_HH
#include "hb-open-type-private.hh"
#include "hb-open-type.hh"
/*
* head -- Font Header

View File

@ -27,7 +27,7 @@
#ifndef HB_OT_HHEA_TABLE_HH
#define HB_OT_HHEA_TABLE_HH
#include "hb-open-type-private.hh"
#include "hb-open-type.hh"
/*
* hhea -- Horizontal Header

View File

@ -27,7 +27,7 @@
#ifndef HB_OT_HMTX_TABLE_HH
#define HB_OT_HMTX_TABLE_HH
#include "hb-open-type-private.hh"
#include "hb-open-type.hh"
#include "hb-ot-hhea-table.hh"
#include "hb-ot-os2-table.hh"
#include "hb-ot-var-hvar-table.hh"
@ -332,6 +332,9 @@ struct vmtx : hmtxvmtx<vmtx, vhea> {
static const hb_tag_t os2Tag = HB_TAG_NONE;
};
struct hmtx_accelerator_t : hmtx::accelerator_t {};
struct vmtx_accelerator_t : vmtx::accelerator_t {};
} /* namespace OT */

View File

@ -27,7 +27,7 @@
#ifndef HB_OT_KERN_TABLE_HH
#define HB_OT_KERN_TABLE_HH
#include "hb-open-type-private.hh"
#include "hb-open-type.hh"
/*
* kern -- Kerning
@ -390,6 +390,8 @@ struct kern
DEFINE_SIZE_UNION (2, major);
};
struct kern_accelerator_t : kern::accelerator_t {};
} /* namespace OT */

View File

@ -28,8 +28,8 @@
#ifndef HB_OT_LAYOUT_BASE_TABLE_HH
#define HB_OT_LAYOUT_BASE_TABLE_HH
#include "hb-open-type-private.hh"
#include "hb-ot-layout-common-private.hh"
#include "hb-open-type.hh"
#include "hb-ot-layout-common.hh"
namespace OT {

View File

@ -26,13 +26,13 @@
* Google Author(s): Behdad Esfahbod
*/
#ifndef HB_OT_LAYOUT_COMMON_PRIVATE_HH
#define HB_OT_LAYOUT_COMMON_PRIVATE_HH
#ifndef HB_OT_LAYOUT_COMMON_HH
#define HB_OT_LAYOUT_COMMON_HH
#include "hb-private.hh"
#include "hb-ot-layout-private.hh"
#include "hb-open-type-private.hh"
#include "hb-set-private.hh"
#include "hb.hh"
#include "hb-ot-layout.hh"
#include "hb-open-type.hh"
#include "hb-set.hh"
#ifndef HB_MAX_NESTING_LEVEL
@ -743,6 +743,7 @@ struct CoverageFormat1
/* Older compilers need this to be public. */
struct Iter {
inline void init (const struct CoverageFormat1 &c_) { c = &c_; i = 0; };
inline void fini (void) {};
inline bool more (void) { return i < c->glyphArray.len; }
inline void next (void) { i++; }
inline hb_codepoint_t get_glyph (void) { return c->glyphArray[i]; }
@ -859,6 +860,7 @@ struct CoverageFormat2
i = c->rangeRecord.len;
}
}
inline void fini (void) {};
inline bool more (void) { return i < c->rangeRecord.len; }
inline void next (void)
{
@ -924,7 +926,8 @@ struct Coverage
if (glyphs[i - 1] + 1 != glyphs[i])
num_ranges++;
u.format.set (num_glyphs * 2 < num_ranges * 3 ? 1 : 2);
switch (u.format) {
switch (u.format)
{
case 1: return_trace (u.format1.serialize (c, glyphs, num_glyphs));
case 2: return_trace (u.format2.serialize (c, glyphs, num_glyphs));
default:return_trace (false);
@ -935,25 +938,27 @@ struct Coverage
{
TRACE_SANITIZE (this);
if (!u.format.sanitize (c)) return_trace (false);
switch (u.format) {
switch (u.format)
{
case 1: return_trace (u.format1.sanitize (c));
case 2: return_trace (u.format2.sanitize (c));
default:return_trace (true);
}
}
inline bool intersects (const hb_set_t *glyphs) const {
inline bool intersects (const hb_set_t *glyphs) const
{
/* TODO speed this up */
Coverage::Iter iter;
for (iter.init (*this); iter.more (); iter.next ()) {
for (hb_auto_t<Coverage::Iter> iter (*this); iter.more (); iter.next ())
if (glyphs->has (iter.get_glyph ()))
return true;
}
return false;
}
inline bool intersects_coverage (const hb_set_t *glyphs, unsigned int index) const {
switch (u.format) {
inline bool intersects_coverage (const hb_set_t *glyphs, unsigned int index) const
{
switch (u.format)
{
case 1: return u.format1.intersects_coverage (glyphs, index);
case 2: return u.format2.intersects_coverage (glyphs, index);
default:return false;
@ -963,47 +968,61 @@ struct Coverage
/* Might return false if array looks unsorted.
* Used for faster rejection of corrupt data. */
template <typename set_t>
inline bool add_coverage (set_t *glyphs) const {
switch (u.format) {
inline bool add_coverage (set_t *glyphs) const
{
switch (u.format)
{
case 1: return u.format1.add_coverage (glyphs);
case 2: return u.format2.add_coverage (glyphs);
default:return false;
}
}
struct Iter {
struct Iter
{
Iter (void) : format (0), u () {};
inline void init (const Coverage &c_) {
inline void init (const Coverage &c_)
{
format = c_.u.format;
switch (format) {
switch (format)
{
case 1: u.format1.init (c_.u.format1); return;
case 2: u.format2.init (c_.u.format2); return;
default: return;
default: return;
}
}
inline bool more (void) {
switch (format) {
inline void fini (void) {}
inline bool more (void)
{
switch (format)
{
case 1: return u.format1.more ();
case 2: return u.format2.more ();
default:return false;
}
}
inline void next (void) {
switch (format) {
inline void next (void)
{
switch (format)
{
case 1: u.format1.next (); break;
case 2: u.format2.next (); break;
default: break;
default: break;
}
}
inline hb_codepoint_t get_glyph (void) {
switch (format) {
inline hb_codepoint_t get_glyph (void)
{
switch (format)
{
case 1: return u.format1.get_glyph ();
case 2: return u.format2.get_glyph ();
default:return 0;
}
}
inline unsigned int get_coverage (void) {
switch (format) {
inline unsigned int get_coverage (void)
{
switch (format)
{
case 1: return u.format1.get_coverage ();
case 2: return u.format2.get_coverage ();
default:return -1;
@ -1803,4 +1822,4 @@ struct Device
} /* namespace OT */
#endif /* HB_OT_LAYOUT_COMMON_PRIVATE_HH */
#endif /* HB_OT_LAYOUT_COMMON_HH */

View File

@ -29,9 +29,9 @@
#ifndef HB_OT_LAYOUT_GDEF_TABLE_HH
#define HB_OT_LAYOUT_GDEF_TABLE_HH
#include "hb-ot-layout-common-private.hh"
#include "hb-ot-layout-common.hh"
#include "hb-font-private.hh"
#include "hb-font.hh"
namespace OT {
@ -337,6 +337,7 @@ struct MarkGlyphSets
* https://docs.microsoft.com/en-us/typography/opentype/spec/gdef
*/
struct GDEF
{
static const hb_tag_t tableTag = HB_OT_TAG_GDEF;
@ -420,6 +421,18 @@ struct GDEF
}
}
struct accelerator_t
{
HB_INTERNAL inline void init (hb_face_t *face);
inline void fini (void)
{
hb_blob_destroy (this->blob);
}
hb_blob_t *blob;
const GDEF *table;
};
protected:
FixedVersion<>version; /* Version of the GDEF table--currently
@ -454,6 +467,7 @@ struct GDEF
DEFINE_SIZE_MIN (12);
};
struct GDEF_accelerator_t : GDEF::accelerator_t {};
} /* namespace OT */

View File

@ -29,7 +29,7 @@
#ifndef HB_OT_LAYOUT_GPOS_TABLE_HH
#define HB_OT_LAYOUT_GPOS_TABLE_HH
#include "hb-ot-layout-gsubgpos-private.hh"
#include "hb-ot-layout-gsubgpos.hh"
namespace OT {
@ -1522,6 +1522,8 @@ struct GPOS : GSUBGPOS
const OffsetTo<PosLookupList> &list = CastR<OffsetTo<PosLookupList> > (lookupList);
return_trace (list.sanitize (c, this));
}
typedef GSUBGPOS::accelerator_t<GPOS> accelerator_t;
};
@ -1628,15 +1630,13 @@ GPOS::position_finish_offsets (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer)
template <typename context_t>
/*static*/ inline typename context_t::return_t PosLookup::dispatch_recurse_func (context_t *c, unsigned int lookup_index)
{
const GPOS &gpos = *(hb_ot_layout_from_face (c->face)->table.GPOS);
const PosLookup &l = gpos.get_lookup (lookup_index);
const PosLookup &l = _get_gpos_relaxed (c->face)->get_lookup (lookup_index);
return l.dispatch (c);
}
/*static*/ inline bool PosLookup::apply_recurse_func (hb_ot_apply_context_t *c, unsigned int lookup_index)
{
const GPOS &gpos = *(hb_ot_layout_from_face (c->face)->table.GPOS);
const PosLookup &l = gpos.get_lookup (lookup_index);
const PosLookup &l = _get_gpos_relaxed (c->face).get_lookup (lookup_index);
unsigned int saved_lookup_props = c->lookup_props;
unsigned int saved_lookup_index = c->lookup_index;
c->set_lookup_index (lookup_index);
@ -1647,6 +1647,8 @@ template <typename context_t>
return ret;
}
struct GPOS_accelerator_t : GPOS::accelerator_t {};
#undef attach_chain
#undef attach_type

View File

@ -29,7 +29,7 @@
#ifndef HB_OT_LAYOUT_GSUB_TABLE_HH
#define HB_OT_LAYOUT_GSUB_TABLE_HH
#include "hb-ot-layout-gsubgpos-private.hh"
#include "hb-ot-layout-gsubgpos.hh"
namespace OT {
@ -40,8 +40,7 @@ struct SingleSubstFormat1
inline void closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE (this);
Coverage::Iter iter;
for (iter.init (this+coverage); iter.more (); iter.next ())
for (hb_auto_t<Coverage::Iter> iter (this+coverage); iter.more (); iter.next ())
{
/* TODO Switch to range-based API to work around malicious fonts.
* https://github.com/harfbuzz/harfbuzz/issues/363 */
@ -55,8 +54,7 @@ struct SingleSubstFormat1
{
TRACE_COLLECT_GLYPHS (this);
if (unlikely (!(this+coverage).add_coverage (c->input))) return;
Coverage::Iter iter;
for (iter.init (this+coverage); iter.more (); iter.next ())
for (hb_auto_t<Coverage::Iter> iter (this+coverage); iter.more (); iter.next ())
{
/* TODO Switch to range-based API to work around malicious fonts.
* https://github.com/harfbuzz/harfbuzz/issues/363 */
@ -125,9 +123,8 @@ struct SingleSubstFormat2
inline void closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE (this);
Coverage::Iter iter;
unsigned int count = substitute.len;
for (iter.init (this+coverage); iter.more (); iter.next ())
for (hb_auto_t<Coverage::Iter> iter (this+coverage); iter.more (); iter.next ())
{
if (unlikely (iter.get_coverage () >= count))
break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
@ -140,9 +137,8 @@ struct SingleSubstFormat2
{
TRACE_COLLECT_GLYPHS (this);
if (unlikely (!(this+coverage).add_coverage (c->input))) return;
Coverage::Iter iter;
unsigned int count = substitute.len;
for (iter.init (this+coverage); iter.more (); iter.next ())
for (hb_auto_t<Coverage::Iter> iter (this+coverage); iter.more (); iter.next ())
{
if (unlikely (iter.get_coverage () >= count))
break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
@ -332,9 +328,8 @@ struct MultipleSubstFormat1
inline void closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE (this);
Coverage::Iter iter;
unsigned int count = sequence.len;
for (iter.init (this+coverage); iter.more (); iter.next ())
for (hb_auto_t<Coverage::Iter> iter (this+coverage); iter.more (); iter.next ())
{
if (unlikely (iter.get_coverage () >= count))
break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
@ -454,9 +449,8 @@ struct AlternateSubstFormat1
inline void closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE (this);
Coverage::Iter iter;
unsigned int count = alternateSet.len;
for (iter.init (this+coverage); iter.more (); iter.next ())
for (hb_auto_t<Coverage::Iter> iter (this+coverage); iter.more (); iter.next ())
{
if (unlikely (iter.get_coverage () >= count))
break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
@ -473,9 +467,8 @@ struct AlternateSubstFormat1
{
TRACE_COLLECT_GLYPHS (this);
if (unlikely (!(this+coverage).add_coverage (c->input))) return;
Coverage::Iter iter;
unsigned int count = alternateSet.len;
for (iter.init (this+coverage); iter.more (); iter.next ())
for (hb_auto_t<Coverage::Iter> iter (this+coverage); iter.more (); iter.next ())
{
if (unlikely (iter.get_coverage () >= count))
break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
@ -781,9 +774,8 @@ struct LigatureSubstFormat1
inline void closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE (this);
Coverage::Iter iter;
unsigned int count = ligatureSet.len;
for (iter.init (this+coverage); iter.more (); iter.next ())
for (hb_auto_t<Coverage::Iter> iter (this+coverage); iter.more (); iter.next ())
{
if (unlikely (iter.get_coverage () >= count))
break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
@ -796,9 +788,8 @@ struct LigatureSubstFormat1
{
TRACE_COLLECT_GLYPHS (this);
if (unlikely (!(this+coverage).add_coverage (c->input))) return;
Coverage::Iter iter;
unsigned int count = ligatureSet.len;
for (iter.init (this+coverage); iter.more (); iter.next ())
for (hb_auto_t<Coverage::Iter> iter (this+coverage); iter.more (); iter.next ())
{
if (unlikely (iter.get_coverage () >= count))
break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
@ -950,9 +941,8 @@ struct ReverseChainSingleSubstFormat1
return;
const ArrayOf<GlyphID> &substitute = StructAfter<ArrayOf<GlyphID> > (lookahead);
Coverage::Iter iter;
count = substitute.len;
for (iter.init (this+coverage); iter.more (); iter.next ())
for (hb_auto_t<Coverage::Iter> iter (this+coverage); iter.more (); iter.next ())
{
if (unlikely (iter.get_coverage () >= count))
break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
@ -1318,8 +1308,6 @@ struct GSUB : GSUBGPOS
inline const SubstLookup& get_lookup (unsigned int i) const
{ return CastR<SubstLookup> (GSUBGPOS::get_lookup (i)); }
static inline void substitute_start (hb_font_t *font, hb_buffer_t *buffer);
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
@ -1327,25 +1315,11 @@ struct GSUB : GSUBGPOS
const OffsetTo<SubstLookupList> &list = CastR<OffsetTo<SubstLookupList> > (lookupList);
return_trace (list.sanitize (c, this));
}
typedef GSUBGPOS::accelerator_t<GSUB> accelerator_t;
};
void
GSUB::substitute_start (hb_font_t *font, hb_buffer_t *buffer)
{
_hb_buffer_assert_gsubgpos_vars (buffer);
const GDEF &gdef = *hb_ot_layout_from_face (font->face)->table.GDEF;
unsigned int count = buffer->len;
for (unsigned int i = 0; i < count; i++)
{
_hb_glyph_info_set_glyph_props (&buffer->info[i], gdef.get_glyph_props (buffer->info[i].codepoint));
_hb_glyph_info_clear_lig_props (&buffer->info[i]);
buffer->info[i].syllable() = 0;
}
}
/* Out-of-class implementation for methods recursing */
/*static*/ inline bool ExtensionSubst::is_reverse (void) const
@ -1359,15 +1333,13 @@ GSUB::substitute_start (hb_font_t *font, hb_buffer_t *buffer)
template <typename context_t>
/*static*/ inline typename context_t::return_t SubstLookup::dispatch_recurse_func (context_t *c, unsigned int lookup_index)
{
const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->table.GSUB);
const SubstLookup &l = gsub.get_lookup (lookup_index);
const SubstLookup &l = _get_gsub_relaxed (c->face).get_lookup (lookup_index);
return l.dispatch (c);
}
/*static*/ inline bool SubstLookup::apply_recurse_func (hb_ot_apply_context_t *c, unsigned int lookup_index)
{
const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->table.GSUB);
const SubstLookup &l = gsub.get_lookup (lookup_index);
const SubstLookup &l = _get_gsub_relaxed (c->face).get_lookup (lookup_index);
unsigned int saved_lookup_props = c->lookup_props;
unsigned int saved_lookup_index = c->lookup_index;
c->set_lookup_index (lookup_index);
@ -1378,6 +1350,7 @@ template <typename context_t>
return ret;
}
struct GSUB_accelerator_t : GSUB::accelerator_t {};
} /* namespace OT */

View File

@ -26,14 +26,15 @@
* Google Author(s): Behdad Esfahbod
*/
#ifndef HB_OT_LAYOUT_GSUBGPOS_PRIVATE_HH
#define HB_OT_LAYOUT_GSUBGPOS_PRIVATE_HH
#ifndef HB_OT_LAYOUT_GSUBGPOS_HH
#define HB_OT_LAYOUT_GSUBGPOS_HH
#include "hb-private.hh"
#include "hb-buffer-private.hh"
#include "hb-map-private.hh"
#include "hb.hh"
#include "hb-buffer.hh"
#include "hb-map.hh"
#include "hb-set.hh"
#include "hb-ot-layout-common.hh"
#include "hb-ot-layout-gdef-table.hh"
#include "hb-set-private.hh"
namespace OT {
@ -480,7 +481,7 @@ struct hb_ot_apply_context_t :
iter_input (), iter_context (),
font (font_), face (font->face), buffer (buffer_),
recurse_func (nullptr),
gdef (*hb_ot_layout_from_face (face)->table.GDEF),
gdef (_get_gdef (face)),
var_store (gdef.get_var_store ()),
direction (buffer_->props.direction),
lookup_mask (1),
@ -987,7 +988,6 @@ struct LookupRecord
DEFINE_SIZE_STATIC (4);
};
template <typename context_t>
static inline void recurse_lookups (context_t *c,
unsigned int lookupCount,
@ -2381,6 +2381,38 @@ struct GSUBGPOS
(version.to_int () < 0x00010001u || featureVars.sanitize (c, this)));
}
template <typename T>
struct accelerator_t
{
inline void init (hb_face_t *face)
{
this->blob = hb_sanitize_context_t().reference_table<T> (face);
table = this->blob->template as<T> ();
this->lookup_count = table->get_lookup_count ();
this->accels = (hb_ot_layout_lookup_accelerator_t *) calloc (this->lookup_count, sizeof (hb_ot_layout_lookup_accelerator_t));
if (unlikely (!this->accels))
this->lookup_count = 0;
for (unsigned int i = 0; i < this->lookup_count; i++)
this->accels[i].init (table->get_lookup (i));
}
inline void fini (void)
{
for (unsigned int i = 0; i < this->lookup_count; i++)
this->accels[i].fini ();
free (this->accels);
hb_blob_destroy (this->blob);
}
hb_blob_t *blob;
const T *table;
unsigned int lookup_count;
hb_ot_layout_lookup_accelerator_t *accels;
};
protected:
FixedVersion<>version; /* Version of the GSUB/GPOS table--initially set
* to 0x00010000u */
@ -2403,4 +2435,4 @@ struct GSUBGPOS
} /* namespace OT */
#endif /* HB_OT_LAYOUT_GSUBGPOS_PRIVATE_HH */
#endif /* HB_OT_LAYOUT_GSUBGPOS_HH */

View File

@ -27,7 +27,7 @@
#ifndef HB_OT_LAYOUT_JSTF_TABLE_HH
#define HB_OT_LAYOUT_JSTF_TABLE_HH
#include "hb-open-type-private.hh"
#include "hb-open-type.hh"
#include "hb-ot-layout-gpos-table.hh"

View File

@ -28,10 +28,11 @@
* Google Author(s): Behdad Esfahbod
*/
#include "hb-open-type-private.hh"
#include "hb-ot-layout-private.hh"
#include "hb-ot-map-private.hh"
#include "hb-map-private.hh"
#include "hb-open-type.hh"
#include "hb-ot-layout.hh"
#include "hb-ot-face.hh"
#include "hb-ot-map.hh"
#include "hb-map.hh"
#include "hb-ot-layout-gdef-table.hh"
#include "hb-ot-layout-gsub-table.hh"
@ -47,6 +48,53 @@
#include "hb-ot-name-table.hh"
// static inline const OT::BASE&
// _get_base (hb_face_t *face)
// {
// if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::BASE);
// hb_ot_face_data_t *data = hb_ot_face_data (face);
// return *(data->base.get ());
// }
const OT::GDEF& _get_gdef (hb_face_t *face)
{
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GDEF);
return *hb_ot_face_data (face)->GDEF->table;
}
static hb_blob_t * _get_gsub_blob (hb_face_t *face)
{
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return hb_blob_get_empty ();
return hb_ot_face_data (face)->GSUB->blob;
}
static inline const OT::GSUB& _get_gsub (hb_face_t *face)
{
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GSUB);
return *hb_ot_face_data (face)->GSUB->table;
}
const OT::GSUB& _get_gsub_relaxed (hb_face_t *face)
{
return *hb_ot_face_data (face)->GSUB.get_relaxed ()->table;
}
static hb_blob_t * _get_gpos_blob (hb_face_t *face)
{
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return hb_blob_get_empty ();
return hb_ot_face_data (face)->GPOS->blob;
}
static inline const OT::GPOS& _get_gpos (hb_face_t *face)
{
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GPOS);
return *hb_ot_face_data (face)->GPOS->table;
}
const OT::GPOS& _get_gpos_relaxed (hb_face_t *face)
{
return *hb_ot_face_data (face)->GPOS.get_relaxed ()->table;
}
/*
* GDEF
*/
static bool
_hb_ot_blacklist_gdef (unsigned int gdef_len,
unsigned int gsub_len,
@ -149,106 +197,39 @@ _hb_ot_blacklist_gdef (unsigned int gdef_len,
return false;
}
void hb_ot_layout_t::tables_t::init0 (hb_face_t *face)
inline void
OT::GDEF::accelerator_t::init (hb_face_t *face)
{
this->face = face;
#define HB_OT_LAYOUT_TABLE(Namespace, Type) Type.init0 ();
HB_OT_LAYOUT_TABLES
#undef HB_OT_LAYOUT_TABLE
}
void hb_ot_layout_t::tables_t::fini (void)
{
#define HB_OT_LAYOUT_TABLE(Namespace, Type) Type.fini ();
HB_OT_LAYOUT_TABLES
#undef HB_OT_LAYOUT_TABLE
}
this->blob = hb_sanitize_context_t().reference_table<GDEF> (face);
hb_ot_layout_t *
_hb_ot_layout_create (hb_face_t *face)
{
hb_ot_layout_t *layout = (hb_ot_layout_t *) calloc (1, sizeof (hb_ot_layout_t));
if (unlikely (!layout))
return nullptr;
layout->table.init0 (face);
const OT::GSUB &gsub = *layout->table.GSUB;
const OT::GPOS &gpos = *layout->table.GPOS;
if (unlikely (_hb_ot_blacklist_gdef (layout->table.GDEF.get_blob ()->length,
layout->table.GSUB.get_blob ()->length,
layout->table.GPOS.get_blob ()->length)))
layout->table.GDEF.set_stored (hb_blob_get_empty ());
unsigned int gsub_lookup_count = layout->gsub_lookup_count = gsub.get_lookup_count ();
unsigned int gpos_lookup_count = layout->gpos_lookup_count = gpos.get_lookup_count ();
layout->gsub_accels = (hb_ot_layout_lookup_accelerator_t *) calloc (gsub_lookup_count, sizeof (hb_ot_layout_lookup_accelerator_t));
layout->gpos_accels = (hb_ot_layout_lookup_accelerator_t *) calloc (gpos_lookup_count, sizeof (hb_ot_layout_lookup_accelerator_t));
if (unlikely ((gsub_lookup_count && !layout->gsub_accels) ||
(gpos_lookup_count && !layout->gpos_accels)))
if (unlikely (_hb_ot_blacklist_gdef (this->blob->length,
_get_gsub_blob (face)->length,
_get_gpos_blob (face)->length)))
{
_hb_ot_layout_destroy (layout);
return nullptr;
hb_blob_destroy (this->blob);
this->blob = hb_blob_get_empty ();
}
for (unsigned int i = 0; i < gsub_lookup_count; i++)
layout->gsub_accels[i].init (gsub.get_lookup (i));
for (unsigned int i = 0; i < gpos_lookup_count; i++)
layout->gpos_accels[i].init (gpos.get_lookup (i));
return layout;
table = this->blob->as<GDEF> ();
}
void
_hb_ot_layout_destroy (hb_ot_layout_t *layout)
static void
_hb_ot_layout_set_glyph_props (hb_font_t *font,
hb_buffer_t *buffer)
{
if (layout->gsub_accels)
for (unsigned int i = 0; i < layout->gsub_lookup_count; i++)
layout->gsub_accels[i].fini ();
if (layout->gpos_accels)
for (unsigned int i = 0; i < layout->gpos_lookup_count; i++)
layout->gpos_accels[i].fini ();
_hb_buffer_assert_gsubgpos_vars (buffer);
free (layout->gsub_accels);
free (layout->gpos_accels);
layout->table.fini ();
free (layout);
const OT::GDEF &gdef = _get_gdef (font->face);
unsigned int count = buffer->len;
for (unsigned int i = 0; i < count; i++)
{
_hb_glyph_info_set_glyph_props (&buffer->info[i], gdef.get_glyph_props (buffer->info[i].codepoint));
_hb_glyph_info_clear_lig_props (&buffer->info[i]);
buffer->info[i].syllable() = 0;
}
}
// static inline const OT::BASE&
// _get_base (hb_face_t *face)
// {
// if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::BASE);
// hb_ot_layout_t * layout = hb_ot_layout_from_face (face);
// return *(layout->base.get ());
// }
static inline const OT::GDEF&
_get_gdef (hb_face_t *face)
{
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GDEF);
return *hb_ot_layout_from_face (face)->table.GDEF;
}
static inline const OT::GSUB&
_get_gsub (hb_face_t *face)
{
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GSUB);
return *hb_ot_layout_from_face (face)->table.GSUB;
}
static inline const OT::GPOS&
_get_gpos (hb_face_t *face)
{
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GPOS);
return *hb_ot_layout_from_face (face)->table.GPOS;
}
/*
* GDEF
*/
/* Public API */
hb_bool_t
hb_ot_layout_has_glyph_classes (hb_face_t *face)
@ -633,11 +614,11 @@ hb_ot_layout_table_get_lookup_count (hb_face_t *face,
{
case HB_OT_TAG_GSUB:
{
return hb_ot_layout_from_face (face)->gsub_lookup_count;
return hb_ot_face_data (face)->GSUB->lookup_count;
}
case HB_OT_TAG_GPOS:
{
return hb_ot_layout_from_face (face)->gpos_lookup_count;
return hb_ot_face_data (face)->GPOS->lookup_count;
}
}
return 0;
@ -851,13 +832,13 @@ hb_ot_layout_lookup_collect_glyphs (hb_face_t *face,
{
case HB_OT_TAG_GSUB:
{
const OT::SubstLookup& l = hb_ot_layout_from_face (face)->table.GSUB->get_lookup (lookup_index);
const OT::SubstLookup& l = hb_ot_face_data (face)->GSUB->table->get_lookup (lookup_index);
l.collect_glyphs (&c);
return;
}
case HB_OT_TAG_GPOS:
{
const OT::PosLookup& l = hb_ot_layout_from_face (face)->table.GPOS->get_lookup (lookup_index);
const OT::PosLookup& l = hb_ot_face_data (face)->GPOS->table->get_lookup (lookup_index);
l.collect_glyphs (&c);
return;
}
@ -930,18 +911,19 @@ hb_ot_layout_lookup_would_substitute_fast (hb_face_t *face,
unsigned int glyphs_length,
hb_bool_t zero_context)
{
if (unlikely (lookup_index >= hb_ot_layout_from_face (face)->gsub_lookup_count)) return false;
if (unlikely (lookup_index >= hb_ot_face_data (face)->GSUB->lookup_count)) return false;
OT::hb_would_apply_context_t c (face, glyphs, glyphs_length, (bool) zero_context);
const OT::SubstLookup& l = hb_ot_layout_from_face (face)->table.GSUB->get_lookup (lookup_index);
const OT::SubstLookup& l = hb_ot_face_data (face)->GSUB->table->get_lookup (lookup_index);
return l.would_apply (&c, &hb_ot_layout_from_face (face)->gsub_accels[lookup_index]);
return l.would_apply (&c, &hb_ot_face_data (face)->GSUB->accels[lookup_index]);
}
void
hb_ot_layout_substitute_start (hb_font_t *font, hb_buffer_t *buffer)
hb_ot_layout_substitute_start (hb_font_t *font,
hb_buffer_t *buffer)
{
OT::GSUB::substitute_start (font, buffer);
_hb_ot_layout_set_glyph_props (font, buffer);
}
/**
@ -1091,8 +1073,8 @@ struct GSUBProxy
typedef OT::SubstLookup Lookup;
GSUBProxy (hb_face_t *face) :
table (*hb_ot_layout_from_face (face)->table.GSUB),
accels (hb_ot_layout_from_face (face)->gsub_accels) {}
table (*hb_ot_face_data (face)->GSUB->table),
accels (hb_ot_face_data (face)->GSUB->accels) {}
const OT::GSUB &table;
const hb_ot_layout_lookup_accelerator_t *accels;
@ -1105,8 +1087,8 @@ struct GPOSProxy
typedef OT::PosLookup Lookup;
GPOSProxy (hb_face_t *face) :
table (*hb_ot_layout_from_face (face)->table.GPOS),
accels (hb_ot_layout_from_face (face)->gpos_accels) {}
table (*hb_ot_face_data (face)->GPOS->table),
accels (hb_ot_face_data (face)->GPOS->accels) {}
const OT::GPOS &table;
const hb_ot_layout_lookup_accelerator_t *accels;

View File

@ -26,15 +26,27 @@
* Google Author(s): Behdad Esfahbod
*/
#ifndef HB_OT_LAYOUT_PRIVATE_HH
#define HB_OT_LAYOUT_PRIVATE_HH
#ifndef HB_OT_LAYOUT_HH
#define HB_OT_LAYOUT_HH
#include "hb-private.hh"
#include "hb.hh"
#include "hb-font-private.hh"
#include "hb-buffer-private.hh"
#include "hb-set-digest-private.hh"
#include "hb-open-type-private.hh"
#include "hb-font.hh"
#include "hb-buffer.hh"
#include "hb-open-type.hh"
#include "hb-set-digest.hh"
namespace OT
{
struct GDEF;
struct GSUB;
struct GPOS;
}
HB_INTERNAL const OT::GDEF& _get_gdef (hb_face_t *face);
HB_INTERNAL const OT::GSUB& _get_gsub_relaxed (hb_face_t *face);
HB_INTERNAL const OT::GPOS& _get_gpos_relaxed (hb_face_t *face);
/* Private API corresponding to hb-ot-layout.h: */
@ -87,7 +99,22 @@ hb_ot_layout_substitute_start (hb_font_t *font,
hb_buffer_t *buffer);
struct hb_ot_layout_lookup_accelerator_t;
struct hb_ot_layout_lookup_accelerator_t
{
template <typename TLookup>
inline void init (const TLookup &lookup)
{
digest.init ();
lookup.add_coverage (&digest);
}
inline void fini (void) {}
inline bool may_have (hb_codepoint_t g) const
{ return digest.may_have (g); }
private:
hb_set_digest_t digest;
};
namespace OT {
struct hb_ot_apply_context_t;
@ -116,112 +143,6 @@ hb_ot_layout_position_finish_offsets (hb_font_t *font,
hb_buffer_t *buffer);
/*
* hb_ot_layout_t
*/
struct hb_ot_layout_lookup_accelerator_t
{
template <typename TLookup>
inline void init (const TLookup &lookup)
{
digest.init ();
lookup.add_coverage (&digest);
}
inline void fini (void)
{
}
inline bool may_have (hb_codepoint_t g) const {
return digest.may_have (g);
}
private:
hb_set_digest_t digest;
};
/* Most of these tables are NOT needed for shaping. But we need to hook them *somewhere*.
* This is as good as any place. */
#define HB_OT_LAYOUT_TABLES \
/* OpenType shaping. */ \
HB_OT_LAYOUT_TABLE(OT, GDEF) \
HB_OT_LAYOUT_TABLE(OT, GSUB) \
HB_OT_LAYOUT_TABLE(OT, GPOS) \
HB_OT_LAYOUT_TABLE(OT, JSTF) \
HB_OT_LAYOUT_TABLE(OT, BASE) \
/* AAT shaping. */ \
HB_OT_LAYOUT_TABLE(AAT, morx) \
HB_OT_LAYOUT_TABLE(AAT, kerx) \
HB_OT_LAYOUT_TABLE(AAT, ankr) \
HB_OT_LAYOUT_TABLE(AAT, trak) \
/* OpenType variations. */ \
HB_OT_LAYOUT_TABLE(OT, fvar) \
HB_OT_LAYOUT_TABLE(OT, avar) \
HB_OT_LAYOUT_TABLE(OT, MVAR) \
/* OpenType color. */ \
HB_OT_LAYOUT_TABLE(OT, COLR) \
HB_OT_LAYOUT_TABLE(OT, CPAL) \
HB_OT_LAYOUT_TABLE(OT, CBDT) \
HB_OT_LAYOUT_TABLE(OT, CBLC) \
HB_OT_LAYOUT_TABLE(OT, sbix) \
HB_OT_LAYOUT_TABLE(OT, svg) \
/* OpenType math. */ \
HB_OT_LAYOUT_TABLE(OT, MATH) \
/* OpenType fundamentals. */ \
HB_OT_LAYOUT_TABLE(OT, post) \
/* */
/* Declare tables. */
#define HB_OT_LAYOUT_TABLE(Namespace, Type) namespace Namespace { struct Type; }
HB_OT_LAYOUT_TABLES
#undef HB_OT_LAYOUT_TABLE
struct hb_ot_layout_t
{
unsigned int gsub_lookup_count;
unsigned int gpos_lookup_count;
hb_ot_layout_lookup_accelerator_t *gsub_accels;
hb_ot_layout_lookup_accelerator_t *gpos_accels;
/* Various non-shaping tables. */
struct tables_t
{
HB_INTERNAL void init0 (hb_face_t *face);
HB_INTERNAL void fini (void);
#define HB_OT_LAYOUT_TABLE_ORDER(Namespace, Type) \
HB_PASTE (ORDER_, HB_PASTE (Namespace, HB_PASTE (_, Type)))
enum order_t
{
ORDER_ZERO,
#define HB_OT_LAYOUT_TABLE(Namespace, Type) \
HB_OT_LAYOUT_TABLE_ORDER (Namespace, Type),
HB_OT_LAYOUT_TABLES
#undef HB_OT_LAYOUT_TABLE
};
hb_face_t *face; /* MUST be JUST before the lazy loaders. */
#define HB_OT_LAYOUT_TABLE(Namespace, Type) \
hb_table_lazy_loader_t<struct Namespace::Type, HB_OT_LAYOUT_TABLE_ORDER (Namespace, Type)> Type;
HB_OT_LAYOUT_TABLES
#undef HB_OT_LAYOUT_TABLE
} table;
};
HB_INTERNAL hb_ot_layout_t *
_hb_ot_layout_create (hb_face_t *face);
HB_INTERNAL void
_hb_ot_layout_destroy (hb_ot_layout_t *layout);
#define hb_ot_layout_from_face(face) ((hb_ot_layout_t *) face->shaper_data.ot.get_relaxed ())
/*
* Buffer var routines.
*/
@ -701,4 +622,4 @@ _hb_buffer_assert_gsubgpos_vars (hb_buffer_t *buffer)
#undef lig_props
#undef glyph_props
#endif /* HB_OT_LAYOUT_PRIVATE_HH */
#endif /* HB_OT_LAYOUT_HH */

View File

@ -26,9 +26,9 @@
* Google Author(s): Behdad Esfahbod
*/
#include "hb-ot-map-private.hh"
#include "hb-ot-map.hh"
#include "hb-ot-layout-private.hh"
#include "hb-ot-layout.hh"
void hb_ot_map_t::collect_lookups (unsigned int table_index, hb_set_t *lookups_out) const

View File

@ -26,10 +26,10 @@
* Google Author(s): Behdad Esfahbod
*/
#ifndef HB_OT_MAP_PRIVATE_HH
#define HB_OT_MAP_PRIVATE_HH
#ifndef HB_OT_MAP_HH
#define HB_OT_MAP_HH
#include "hb-buffer-private.hh"
#include "hb-buffer.hh"
struct hb_ot_shape_plan_t;
@ -250,4 +250,4 @@ struct hb_ot_map_builder_t
#endif /* HB_OT_MAP_PRIVATE_HH */
#endif /* HB_OT_MAP_HH */

View File

@ -27,8 +27,8 @@
#ifndef HB_OT_MATH_TABLE_HH
#define HB_OT_MATH_TABLE_HH
#include "hb-open-type-private.hh"
#include "hb-ot-layout-common-private.hh"
#include "hb-open-type.hh"
#include "hb-ot-layout-common.hh"
#include "hb-ot-math.h"
namespace OT {

View File

@ -24,17 +24,17 @@
* Igalia Author(s): Frédéric Wang
*/
#include "hb-open-type-private.hh"
#include "hb-open-type.hh"
#include "hb-ot-layout-private.hh"
#include "hb-ot-face.hh"
#include "hb-ot-math-table.hh"
static inline const OT::MATH&
_get_math (hb_face_t *face)
{
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::MATH);
hb_ot_layout_t * layout = hb_ot_layout_from_face (face);
return *(layout->table.MATH.get ());
hb_ot_face_data_t * data = hb_ot_face_data (face);
return *(data->MATH.get ());
}
/*

View File

@ -27,7 +27,7 @@
#ifndef HB_OT_MAXP_TABLE_HH
#define HB_OT_MAXP_TABLE_HH
#include "hb-open-type-private.hh"
#include "hb-open-type.hh"
#include "hb-subset-plan.hh"
namespace OT {

View File

@ -27,7 +27,7 @@
#ifndef HB_OT_NAME_TABLE_HH
#define HB_OT_NAME_TABLE_HH
#include "hb-open-type-private.hh"
#include "hb-open-type.hh"
namespace OT {

View File

@ -27,7 +27,7 @@
#ifndef HB_OT_OS2_TABLE_HH
#define HB_OT_OS2_TABLE_HH
#include "hb-open-type-private.hh"
#include "hb-open-type.hh"
#include "hb-ot-os2-unicode-ranges.hh"
#include "hb-subset-plan.hh"

View File

@ -27,7 +27,7 @@
#ifndef HB_OT_OS2_UNICODE_RANGES_HH
#define HB_OT_OS2_UNICODE_RANGES_HH
#include "hb-private.hh"
#include "hb.hh"
namespace OT {

View File

@ -27,7 +27,7 @@
#ifndef HB_OT_POST_MACROMAN_HH
#if 0 /* Make checks happy. */
#define HB_OT_POST_MACROMAN_HH
#include "hb-private.hh"
#include "hb.hh"
#endif

View File

@ -27,7 +27,7 @@
#ifndef HB_OT_POST_TABLE_HH
#define HB_OT_POST_TABLE_HH
#include "hb-open-type-private.hh"
#include "hb-open-type.hh"
#include "hb-subset-plan.hh"
#define HB_STRING_ARRAY_NAME format1_names
@ -295,6 +295,8 @@ struct post
DEFINE_SIZE_STATIC (32);
};
struct post_accelerator_t : post::accelerator_t {};
} /* namespace OT */

View File

@ -27,9 +27,9 @@
#ifndef HB_OT_SHAPE_COMPLEX_ARABIC_FALLBACK_HH
#define HB_OT_SHAPE_COMPLEX_ARABIC_FALLBACK_HH
#include "hb-private.hh"
#include "hb.hh"
#include "hb-ot-shape-private.hh"
#include "hb-ot-shape.hh"
#include "hb-ot-layout-gsub-table.hh"

View File

@ -313,7 +313,7 @@ OT_TABLE_END
* Include a second time to get the table data...
*/
#if 0
#include "hb-private.hh" /* Make check-includes.sh happy. */
#include "hb.hh" /* Make check-includes.sh happy. */
#endif
#ifdef OT_MEASURE
#include "hb-ot-shape-complex-arabic-win1256.hh"

Some files were not shown because too many files have changed in this diff Show More