src/Makefile.am | 6 src/hb-atomic-private.hh | 2 src/hb-glib.cc | 2 src/hb-icu.cc | 2 src/hb-ot-font.cc | 260 +++++++++++++++++++++++++++++++++++ src/hb-ot-font.h | 41 +++++ src/hb-ot-hhea-table.hh | 2 src/hb-ot-hmtx-table.hh | 2 src/hb-ot-layout-gsubgpos-private.hh | 1 src/hb-ot.h | 1 src/hb-tt-font.cc | 77 ---------- util/Makefile.am | 4 util/options.cc | 4 13 files changed, 318 insertions(+), 86 deletions(-)
New commits: commit 05870ed62edd8728d6d732f60d6b7e149d45e6f4 Author: Primiano Tucci <[email protected]> Date: Wed Apr 2 11:35:27 2014 +0100 Use __aarch64__ for 64-bit ARM detection, not __arm64__ Many GCC versions don't define __arm64__ diff --git a/src/hb-atomic-private.hh b/src/hb-atomic-private.hh index 1c4e120..60cbcf9 100644 --- a/src/hb-atomic-private.hh +++ b/src/hb-atomic-private.hh @@ -82,7 +82,7 @@ typedef int32_t hb_atomic_int_t; #if (MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4 || __IPHONE_VERSION_MIN_REQUIRED >= 20100) #define hb_atomic_ptr_cmpexch(P,O,N) OSAtomicCompareAndSwapPtrBarrier ((void *) (O), (void *) (N), (void **) (P)) #else -#if __ppc64__ || __x86_64__ || __arm64__ +#if __ppc64__ || __x86_64__ || __aarch64__ #define hb_atomic_ptr_cmpexch(P,O,N) OSAtomicCompareAndSwap64Barrier ((int64_t) (O), (int64_t) (N), (int64_t*) (P)) #else #define hb_atomic_ptr_cmpexch(P,O,N) OSAtomicCompareAndSwap32Barrier ((int32_t) (O), (int32_t) (N), (int32_t*) (P)) commit 04d894e89795041b2055dc172744a018644f2bca Author: Behdad Esfahbod <[email protected]> Date: Tue Mar 25 12:11:32 2014 -0700 Minor diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh index bdd773e..cd27c05 100644 --- a/src/hb-ot-layout-gsubgpos-private.hh +++ b/src/hb-ot-layout-gsubgpos-private.hh @@ -882,6 +882,7 @@ static inline void ligate_input (hb_apply_context_t *c, break; } } + TRACE_RETURN (true); } static inline bool match_backtrack (hb_apply_context_t *c, commit 903648437c180c7b039801cdb0672e0f8e14afd4 Author: Behdad Esfahbod <[email protected]> Date: Mon Mar 24 14:26:36 2014 -0700 Start fleshing out builtin font functions diff --git a/src/Makefile.am b/src/Makefile.am index fd60d04..e2dd944 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -51,7 +51,6 @@ HBSOURCES = \ hb-shaper-impl-private.hh \ hb-shaper-private.hh \ hb-shaper.cc \ - hb-tt-font.cc \ hb-unicode-private.hh \ hb-unicode.cc \ hb-utf-private.hh \ @@ -76,6 +75,7 @@ HBNODISTHEADERS = \ if HAVE_OT HBSOURCES += \ + hb-ot-font.cc \ hb-ot-layout.cc \ hb-ot-layout-common-private.hh \ hb-ot-layout-gdef-table.hh \ @@ -112,6 +112,7 @@ HBSOURCES += \ $(NULL) HBHEADERS += \ hb-ot.h \ + hb-ot-font.h \ hb-ot-layout.h \ hb-ot-shape.h \ hb-ot-tag.h \ diff --git a/src/hb-glib.cc b/src/hb-glib.cc index c35d996..af43cab 100644 --- a/src/hb-glib.cc +++ b/src/hb-glib.cc @@ -340,7 +340,7 @@ hb_glib_unicode_decompose_compatibility (hb_unicode_funcs_t *ufuncs HB_UNUSED, void *user_data HB_UNUSED) { #if GLIB_CHECK_VERSION(2,29,12) - return g_unichar_fully_decompose (u, TRUE, decomposed, HB_UNICODE_MAX_DECOMPOSITION_LEN); + return g_unichar_fully_decompose (u, true, decomposed, HB_UNICODE_MAX_DECOMPOSITION_LEN); #endif /* If the user doesn't have GLib >= 2.29.12 we have to perform diff --git a/src/hb-icu.cc b/src/hb-icu.cc index c177be2..86c8b5c 100644 --- a/src/hb-icu.cc +++ b/src/hb-icu.cc @@ -323,7 +323,7 @@ hb_icu_unicode_decompose_compatibility (hb_unicode_funcs_t *ufuncs HB_UNUSED, /* Copy @u into a UTF-16 array to be passed to ICU. */ len = 0; - err = FALSE; + err = false; U16_APPEND (utf16, len, ARRAY_LENGTH (utf16), u, err); if (err) return 0; diff --git a/src/hb-ot-font.cc b/src/hb-ot-font.cc new file mode 100644 index 0000000..1a35057 --- /dev/null +++ b/src/hb-ot-font.cc @@ -0,0 +1,260 @@ +/* + * Copyright © 2011,2014 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, Roozbeh Pournader + */ + +#include "hb-private.hh" + +#include "hb-ot.h" + +#include "hb-font-private.hh" + +#include "hb-ot-hhea-table.hh" +#include "hb-ot-hmtx-table.hh" + + + +struct hb_ot_font_t +{ + unsigned int num_glyphs; + unsigned int num_hmetrics; + const OT::hmtx *hmtx; + hb_blob_t *hmtx_blob; +}; + + +static hb_ot_font_t * +_hb_ot_font_create (hb_font_t *font) +{ + hb_ot_font_t *ot_font = (hb_ot_font_t *) calloc (1, sizeof (hb_ot_font_t)); + + if (unlikely (!ot_font)) + return NULL; + + ot_font->num_glyphs = font->face->get_num_glyphs (); + + { + hb_blob_t *hhea_blob = OT::Sanitizer<OT::hhea>::sanitize (font->face->reference_table (HB_OT_TAG_hhea)); + const OT::hhea *hhea = OT::Sanitizer<OT::hhea>::lock_instance (hhea_blob); + ot_font->num_hmetrics = hhea->numberOfHMetrics; + hb_blob_destroy (hhea_blob); + } + ot_font->hmtx_blob = OT::Sanitizer<OT::hmtx>::sanitize (font->face->reference_table (HB_OT_TAG_hmtx)); + if (unlikely (!ot_font->num_hmetrics || + 2 * (ot_font->num_hmetrics + ot_font->num_glyphs) < hb_blob_get_length (ot_font->hmtx_blob))) + { + hb_blob_destroy (ot_font->hmtx_blob); + free (ot_font); + return NULL; + } + + ot_font->hmtx = OT::Sanitizer<OT::hmtx>::lock_instance (ot_font->hmtx_blob); + + return ot_font; +} + +static void +_hb_ot_font_destroy (hb_ot_font_t *ot_font) +{ + hb_blob_destroy (ot_font->hmtx_blob); + + free (ot_font); +} + + +static hb_bool_t +hb_ot_get_glyph (hb_font_t *font HB_UNUSED, + void *font_data, + hb_codepoint_t unicode, + hb_codepoint_t variation_selector, + hb_codepoint_t *glyph, + void *user_data HB_UNUSED) + +{ +#if 0 + FT_Face ft_face = (FT_Face) font_data; + +#ifdef HAVE_FT_FACE_GETCHARVARIANTINDEX + if (unlikely (variation_selector)) { + *glyph = FT_Face_GetCharVariantIndex (ft_face, unicode, variation_selector); + return *glyph != 0; + } +#endif + + *glyph = FT_Get_Char_Index (ft_face, unicode); + return *glyph != 0; +#endif + return true; +} + +static hb_position_t +hb_ot_get_glyph_h_advance (hb_font_t *font, + void *font_data, + hb_codepoint_t glyph, + void *user_data HB_UNUSED) +{ + const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data; + + if (unlikely (glyph >= ot_font->num_glyphs)) + return 0; /* Maybe better to return notdef's advance instead? */ + + if (glyph >= ot_font->num_hmetrics) + glyph = ot_font->num_hmetrics - 1; + + return font->em_scale_x (ot_font->hmtx->longHorMetric[glyph].advanceWidth); +} + +static hb_position_t +hb_ot_get_glyph_v_advance (hb_font_t *font HB_UNUSED, + void *font_data, + hb_codepoint_t glyph, + void *user_data HB_UNUSED) +{ + /* TODO */ + return 0; +} + +static hb_bool_t +hb_ot_get_glyph_h_origin (hb_font_t *font HB_UNUSED, + void *font_data HB_UNUSED, + hb_codepoint_t glyph HB_UNUSED, + hb_position_t *x HB_UNUSED, + hb_position_t *y HB_UNUSED, + void *user_data HB_UNUSED) +{ + /* We always work in the horizontal coordinates. */ + return true; +} + +static hb_bool_t +hb_ot_get_glyph_v_origin (hb_font_t *font HB_UNUSED, + void *font_data, + hb_codepoint_t glyph, + hb_position_t *x, + hb_position_t *y, + void *user_data HB_UNUSED) +{ + /* TODO */ + return false; +} + +static hb_position_t +hb_ot_get_glyph_h_kerning (hb_font_t *font, + void *font_data, + hb_codepoint_t left_glyph, + hb_codepoint_t right_glyph, + void *user_data HB_UNUSED) +{ + /* TODO */ + return 0; +} + +static hb_position_t +hb_ot_get_glyph_v_kerning (hb_font_t *font HB_UNUSED, + void *font_data HB_UNUSED, + hb_codepoint_t top_glyph HB_UNUSED, + hb_codepoint_t bottom_glyph HB_UNUSED, + void *user_data HB_UNUSED) +{ + return 0; +} + +static hb_bool_t +hb_ot_get_glyph_extents (hb_font_t *font HB_UNUSED, + void *font_data, + hb_codepoint_t glyph, + hb_glyph_extents_t *extents, + void *user_data HB_UNUSED) +{ + /* TODO */ + return false; +} + +static hb_bool_t +hb_ot_get_glyph_contour_point (hb_font_t *font HB_UNUSED, + void *font_data, + hb_codepoint_t glyph, + unsigned int point_index, + hb_position_t *x, + hb_position_t *y, + void *user_data HB_UNUSED) +{ + /* TODO */ + return false; +} + +static hb_bool_t +hb_ot_get_glyph_name (hb_font_t *font HB_UNUSED, + void *font_data, + hb_codepoint_t glyph, + char *name, unsigned int size, + void *user_data HB_UNUSED) +{ + /* TODO */ + return false; +} + +static hb_bool_t +hb_ot_get_glyph_from_name (hb_font_t *font HB_UNUSED, + void *font_data, + const char *name, int len, /* -1 means nul-terminated */ + hb_codepoint_t *glyph, + void *user_data HB_UNUSED) +{ + /* TODO */ + return false; +} + + +static hb_font_funcs_t * +_hb_ot_get_font_funcs (void) +{ + static const hb_font_funcs_t ot_ffuncs = { + HB_OBJECT_HEADER_STATIC, + + true, /* immutable */ + + { +#define HB_FONT_FUNC_IMPLEMENT(name) hb_ot_get_##name, + HB_FONT_FUNCS_IMPLEMENT_CALLBACKS +#undef HB_FONT_FUNC_IMPLEMENT + } + }; + + return const_cast<hb_font_funcs_t *> (&ot_ffuncs); +} + + +void +hb_ot_font_set_funcs (hb_font_t *font) +{ + hb_ot_font_t *ot_font = _hb_ot_font_create (font); + if (unlikely (!ot_font)) + return; + + hb_font_set_funcs (font, + _hb_ot_get_font_funcs (), + ot_font, + (hb_destroy_func_t) _hb_ot_font_destroy); +} diff --git a/src/hb-ot-font.h b/src/hb-ot-font.h new file mode 100644 index 0000000..7a8c04a --- /dev/null +++ b/src/hb-ot-font.h @@ -0,0 +1,41 @@ +/* + * Copyright © 2014 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, Roozbeh Pournader + */ + +#ifndef HB_OT_FONT_H +#define HB_OT_FONT_H + +#include "hb.h" + +HB_BEGIN_DECLS + + +void +hb_ot_font_set_funcs (hb_font_t *font); + + +HB_END_DECLS + +#endif /* HB_OT_FONT_H */ diff --git a/src/hb-ot-hhea-table.hh b/src/hb-ot-hhea-table.hh index 611de8a..f34bd26 100644 --- a/src/hb-ot-hhea-table.hh +++ b/src/hb-ot-hhea-table.hh @@ -49,7 +49,7 @@ struct hhea return TRACE_RETURN (c->check_struct (this) && likely (version.major == 1)); } - protected: + public: FixedVersion version; /* 0x00010000 for version 1.0. */ FWORD ascender; /* Typographic ascent. <a * href="http://developer.apple.com/fonts/TTRefMan/RM06/Chap6hhea.html"> diff --git a/src/hb-ot-hmtx-table.hh b/src/hb-ot-hmtx-table.hh index d107cf9..e918e3b 100644 --- a/src/hb-ot-hmtx-table.hh +++ b/src/hb-ot-hmtx-table.hh @@ -59,7 +59,7 @@ struct hmtx return TRACE_RETURN (true); } - protected: + public: LongHorMetric longHorMetric[VAR]; /* Paired advance width and left side * bearing values for each glyph. The * value numOfHMetrics comes from diff --git a/src/hb-ot.h b/src/hb-ot.h index e9a280b..47c92a5 100644 --- a/src/hb-ot.h +++ b/src/hb-ot.h @@ -30,6 +30,7 @@ #include "hb.h" +#include "hb-ot-font.h" #include "hb-ot-layout.h" #include "hb-ot-tag.h" #include "hb-ot-shape.h" diff --git a/src/hb-tt-font.cc b/src/hb-tt-font.cc deleted file mode 100644 index 2233a4f..0000000 --- a/src/hb-tt-font.cc +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright © 2011 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Google Author(s): Behdad Esfahbod - */ - -#include "hb-font-private.hh" /* Shall be first since may include windows.h */ - -#include "hb-open-type-private.hh" - -#include "hb-ot-hhea-table.hh" -#include "hb-ot-hmtx-table.hh" - -#include <string.h> - - - -#if 0 -struct hb_tt_font_t -{ - const struct hhea *hhea; - hb_blob_t *hhea_blob; -}; - - -static hb_tt_font_t * -_hb_tt_font_create (hb_font_t *font) -{ - /* TODO Remove this object altogether */ - hb_tt_font_t *tt = (hb_tt_font_t *) calloc (1, sizeof (hb_tt_font_t)); - - tt->hhea_blob = Sanitizer<hhea>::sanitize (font->face->reference_table (HB_OT_TAG_hhea)); - tt->hhea = Sanitizer<hhea>::lock_instance (tt->hhea_blob); - - return tt; -} - -static void -_hb_tt_font_destroy (hb_tt_font_t *tt) -{ - hb_blob_destroy (tt->hhea_blob); - - free (tt); -} - -static inline const hhea& -_get_hhea (hb_face_t *face) -{ - return likely (face->tt && face->tt->hhea) ? *face->tt->hhea : Null(hhea); -} - - -/* - * hb_tt_font_funcs_t - */ - -#endif diff --git a/util/Makefile.am b/util/Makefile.am index 51a584b..266681c 100644 --- a/util/Makefile.am +++ b/util/Makefile.am @@ -24,8 +24,8 @@ LDADD = \ $(NULL) if HAVE_GLIB -if HAVE_FREETYPE +if HAVE_FREETYPE if HAVE_CAIRO_FT hb_view_SOURCES = \ hb-view.cc \ @@ -49,6 +49,7 @@ hb_view_LDADD = \ $(NULL) bin_PROGRAMS += hb-view endif # HAVE_CAIRO_FT +endif # HAVE_FREETYPE hb_shape_SOURCES = \ hb-shape.cc \ @@ -69,7 +70,6 @@ hb_ot_shape_closure_SOURCES = \ bin_PROGRAMS += hb-ot-shape-closure endif # HAVE_OT -endif # HAVE_FREETYPE endif # HAVE_GLIB -include $(top_srcdir)/git.mk diff --git a/util/options.cc b/util/options.cc index 835add7..f872bb4 100644 --- a/util/options.cc +++ b/util/options.cc @@ -28,6 +28,8 @@ #ifdef HAVE_FREETYPE #include <hb-ft.h> +#else +#include <hb-ot-font.h> #endif @@ -486,6 +488,8 @@ font_options_t::get_font (void) const #ifdef HAVE_FREETYPE hb_ft_font_set_funcs (font); +#else + hb_ot_font_set_funcs (font); #endif return font; commit 343a0e4e747d93eeeb724c5d585f5ba036a0df84 Author: Behdad Esfahbod <[email protected]> Date: Fri Mar 21 14:37:27 2014 -0700 Add "make built-sources" diff --git a/src/Makefile.am b/src/Makefile.am index 87d9890..fd60d04 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -284,8 +284,9 @@ arabic-table: gen-arabic-table.py ArabicShaping.txt UnicodeData.txt mv hb-ot-shape-complex-arabic-table.hh.tmp $(srcdir)/hb-ot-shape-complex-arabic-table.hh || \ ($(RM) hb-ot-shape-complex-arabic-table.hh.tmp; false) +built-sources: $(BUILT_SOURCES) -.PHONY: unicode-tables arabic-table indic-table +.PHONY: unicode-tables arabic-table indic-table built-sources BUILT_SOURCES += \ hb-buffer-deserialize-json.hh \
_______________________________________________ HarfBuzz mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/harfbuzz
