CMakeLists.txt | 16 - src/Makefile.sources | 1 src/hb-aat-layout-common-private.hh | 2 src/hb-aat-layout.cc | 6 src/hb-blob.cc | 101 +++------- src/hb-buffer.cc | 4 src/hb-common.cc | 6 src/hb-ot-layout-private.hh | 6 src/hb-ot-layout.cc | 29 -- src/hb-ot-map.cc | 3 src/hb-ot-shape.cc | 7 test/api/test-common.c | 1 test/shaping/data/in-house/Makefile.sources | 1 test/shaping/data/in-house/fonts/73e84dac2fc6a2d1bc9250d1414353661088937d.ttf |binary test/shaping/data/in-house/tests/none-directional.tests | 3 15 files changed, 83 insertions(+), 103 deletions(-)
New commits: commit f673cfbd64d0c9d97123500a7b851b9cfc09deb3 Author: Behdad Esfahbod <[email protected]> Date: Mon May 7 13:58:32 2018 -0700 Support scripts that are written both LTR and RTL Right now only Old Italic is marked as such. Fixes https://github.com/harfbuzz/harfbuzz/issues/1000 diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc index dc0639f4..f7a0495b 100644 --- a/src/hb-buffer.cc +++ b/src/hb-buffer.cc @@ -687,6 +687,8 @@ hb_buffer_t::guess_segment_properties (void) /* If direction is set to INVALID, guess from script */ if (props.direction == HB_DIRECTION_INVALID) { props.direction = hb_script_get_horizontal_direction (props.script); + if (props.direction == HB_DIRECTION_INVALID) + props.direction = HB_DIRECTION_LTR; } /* If language is not set, use default language from locale */ @@ -1489,6 +1491,8 @@ hb_buffer_reverse_clusters (hb_buffer_t *buffer) * Next, if buffer direction is not set (ie. is %HB_DIRECTION_INVALID), * it will be set to the natural horizontal direction of the * buffer script as returned by hb_script_get_horizontal_direction(). + * If hb_script_get_horizontal_direction() returns %HB_DIRECTION_INVALID, + * then %HB_DIRECTION_LTR is used. * * Finally, if buffer language is not set (ie. is %HB_LANGUAGE_INVALID), * it will be set to the process's default language as returned by diff --git a/src/hb-common.cc b/src/hb-common.cc index f38ebb04..956855c4 100644 --- a/src/hb-common.cc +++ b/src/hb-common.cc @@ -536,6 +536,12 @@ hb_script_get_horizontal_direction (hb_script_t script) case HB_SCRIPT_ADLAM: return HB_DIRECTION_RTL; + + + /* https://github.com/harfbuzz/harfbuzz/issues/1000 */ + case HB_SCRIPT_OLD_ITALIC: + + return HB_DIRECTION_INVALID; } return HB_DIRECTION_LTR; diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index dd10e346..5dc57842 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -306,13 +306,16 @@ static void hb_ensure_native_direction (hb_buffer_t *buffer) { hb_direction_t direction = buffer->props.direction; + hb_direction_t horiz_dir = hb_script_get_horizontal_direction (buffer->props.script); /* TODO vertical: * The only BTT vertical script is Ogham, but it's not clear to me whether OpenType * Ogham fonts are supposed to be implemented BTT or not. Need to research that * first. */ - if ((HB_DIRECTION_IS_HORIZONTAL (direction) && direction != hb_script_get_horizontal_direction (buffer->props.script)) || - (HB_DIRECTION_IS_VERTICAL (direction) && direction != HB_DIRECTION_TTB)) + if ((HB_DIRECTION_IS_HORIZONTAL (direction) && + direction != horiz_dir && horiz_dir != HB_DIRECTION_INVALID) || + (HB_DIRECTION_IS_VERTICAL (direction) && + direction != HB_DIRECTION_TTB)) { /* Same loop as hb_form_clusters(). * Since form_clusters() merged clusters already, we don't merge. */ diff --git a/test/api/test-common.c b/test/api/test-common.c index 74b50be9..f6f0d485 100644 --- a/test/api/test-common.c +++ b/test/api/test-common.c @@ -173,6 +173,7 @@ test_types_script (void) g_assert_cmpint (hb_script_get_horizontal_direction (HB_SCRIPT_LATIN), ==, HB_DIRECTION_LTR); g_assert_cmpint (hb_script_get_horizontal_direction (HB_SCRIPT_ARABIC), ==, HB_DIRECTION_RTL); + g_assert_cmpint (hb_script_get_horizontal_direction (HB_SCRIPT_OLD_ITALIC), ==, HB_DIRECTION_INVALID); g_assert_cmpint (hb_script_get_horizontal_direction (hb_script_from_iso15924_tag (wWyZ)), ==, HB_DIRECTION_LTR); } diff --git a/test/shaping/data/in-house/Makefile.sources b/test/shaping/data/in-house/Makefile.sources index 9a1434ec..bf4df201 100644 --- a/test/shaping/data/in-house/Makefile.sources +++ b/test/shaping/data/in-house/Makefile.sources @@ -31,6 +31,7 @@ TESTS = \ tests/mark-filtering-sets.tests \ tests/mongolian-variation-selector.tests \ tests/myanmar-syllable.tests \ + tests/none-directional.tests \ tests/spaces.tests \ tests/simple.tests \ tests/tibetan-contractions-1.tests \ diff --git a/test/shaping/data/in-house/fonts/73e84dac2fc6a2d1bc9250d1414353661088937d.ttf b/test/shaping/data/in-house/fonts/73e84dac2fc6a2d1bc9250d1414353661088937d.ttf new file mode 100644 index 00000000..46e7c1da Binary files /dev/null and b/test/shaping/data/in-house/fonts/73e84dac2fc6a2d1bc9250d1414353661088937d.ttf differ diff --git a/test/shaping/data/in-house/tests/none-directional.tests b/test/shaping/data/in-house/tests/none-directional.tests new file mode 100644 index 00000000..e59946d1 --- /dev/null +++ b/test/shaping/data/in-house/tests/none-directional.tests @@ -0,0 +1,3 @@ +../fonts/73e84dac2fc6a2d1bc9250d1414353661088937d.ttf::U+10300,U+10301:[u10300=0+1470|u10301=1+1284] +../fonts/73e84dac2fc6a2d1bc9250d1414353661088937d.ttf:--direction=ltr:U+10300,U+10301:[u10300=0+1470|u10301=1+1284] +../fonts/73e84dac2fc6a2d1bc9250d1414353661088937d.ttf:--direction=rtl:U+10300,U+10301:[u10301_r=1+1284|u10300_r=0+1470] commit 90869e6962caf0e55a480b5d7e777cc521596e8b Author: Behdad Esfahbod <[email protected]> Date: Mon May 7 14:04:01 2018 -0700 [ot] Apply langsys's required feature even if no other feature exists diff --git a/src/hb-ot-map.cc b/src/hb-ot-map.cc index 54b0ce37..b7cbafaa 100644 --- a/src/hb-ot-map.cc +++ b/src/hb-ot-map.cc @@ -164,9 +164,6 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m, &required_feature_tag[table_index]); } - if (!feature_infos.len) - return; - /* Sort features and merge duplicates */ { feature_infos.qsort (); commit 90baf721978236f2e06dff89ad1cb0cace0753ea Author: Behdad Esfahbod <[email protected]> Date: Thu May 3 22:14:54 2018 -0400 Move some blob functions to methods diff --git a/src/hb-blob.cc b/src/hb-blob.cc index 1435d307..b1319701 100644 --- a/src/hb-blob.cc +++ b/src/hb-blob.cc @@ -49,18 +49,6 @@ -static bool _try_writable (hb_blob_t *blob); - -static void -_hb_blob_destroy_user_data (hb_blob_t *blob) -{ - if (blob->destroy) { - blob->destroy (blob->user_data); - blob->user_data = nullptr; - blob->destroy = nullptr; - } -} - /** * hb_blob_create: (skip) * @data: Pointer to blob data. @@ -103,7 +91,7 @@ hb_blob_create (const char *data, if (blob->mode == HB_MEMORY_MODE_DUPLICATE) { blob->mode = HB_MEMORY_MODE_READONLY; - if (!_try_writable (blob)) { + if (!blob->try_make_writable ()) { hb_blob_destroy (blob); return hb_blob_get_empty (); } @@ -249,7 +237,7 @@ hb_blob_destroy (hb_blob_t *blob) { if (!hb_object_destroy (blob)) return; - _hb_blob_destroy_user_data (blob); + blob->fini_shallow (); free (blob); } @@ -384,7 +372,7 @@ hb_blob_get_data (hb_blob_t *blob, unsigned int *length) char * hb_blob_get_data_writable (hb_blob_t *blob, unsigned int *length) { - if (!_try_writable (blob)) { + if (!blob->try_make_writable ()) { if (length) *length = 0; @@ -398,8 +386,8 @@ hb_blob_get_data_writable (hb_blob_t *blob, unsigned int *length) } -static hb_bool_t -_try_make_writable_inplace_unix (hb_blob_t *blob) +bool +hb_blob_t::try_make_writable_inplace_unix (void) { #if defined(HAVE_SYS_MMAN_H) && defined(HAVE_MPROTECT) uintptr_t pagesize = -1, mask, length; @@ -414,25 +402,25 @@ _try_make_writable_inplace_unix (hb_blob_t *blob) #endif if ((uintptr_t) -1L == pagesize) { - DEBUG_MSG_FUNC (BLOB, blob, "failed to get pagesize: %s", strerror (errno)); + DEBUG_MSG_FUNC (BLOB, this, "failed to get pagesize: %s", strerror (errno)); return false; } - DEBUG_MSG_FUNC (BLOB, blob, "pagesize is %lu", (unsigned long) pagesize); + DEBUG_MSG_FUNC (BLOB, this, "pagesize is %lu", (unsigned long) pagesize); mask = ~(pagesize-1); - addr = (const char *) (((uintptr_t) blob->data) & mask); - length = (const char *) (((uintptr_t) blob->data + blob->length + pagesize-1) & mask) - addr; - DEBUG_MSG_FUNC (BLOB, blob, + addr = (const char *) (((uintptr_t) this->data) & mask); + length = (const char *) (((uintptr_t) this->data + this->length + pagesize-1) & mask) - addr; + DEBUG_MSG_FUNC (BLOB, this, "calling mprotect on [%p..%p] (%lu bytes)", addr, addr+length, (unsigned long) length); if (-1 == mprotect ((void *) addr, length, PROT_READ | PROT_WRITE)) { - DEBUG_MSG_FUNC (BLOB, blob, "mprotect failed: %s", strerror (errno)); + DEBUG_MSG_FUNC (BLOB, this, "mprotect failed: %s", strerror (errno)); return false; } - blob->mode = HB_MEMORY_MODE_WRITABLE; + this->mode = HB_MEMORY_MODE_WRITABLE; - DEBUG_MSG_FUNC (BLOB, blob, + DEBUG_MSG_FUNC (BLOB, this, "successfully made [%p..%p] (%lu bytes) writable\n", addr, addr+length, (unsigned long) length); return true; @@ -441,53 +429,53 @@ _try_make_writable_inplace_unix (hb_blob_t *blob) #endif } -static bool -_try_writable_inplace (hb_blob_t *blob) +bool +hb_blob_t::try_make_writable_inplace (void) { - DEBUG_MSG_FUNC (BLOB, blob, "making writable inplace\n"); + DEBUG_MSG_FUNC (BLOB, this, "making writable inplace\n"); - if (_try_make_writable_inplace_unix (blob)) + if (this->try_make_writable_inplace_unix ()) return true; - DEBUG_MSG_FUNC (BLOB, blob, "making writable -> FAILED\n"); + DEBUG_MSG_FUNC (BLOB, this, "making writable -> FAILED\n"); /* Failed to make writable inplace, mark that */ - blob->mode = HB_MEMORY_MODE_READONLY; + this->mode = HB_MEMORY_MODE_READONLY; return false; } -static bool -_try_writable (hb_blob_t *blob) +bool +hb_blob_t::try_make_writable (void) { - if (blob->immutable) + if (this->immutable) return false; - if (blob->mode == HB_MEMORY_MODE_WRITABLE) + if (this->mode == HB_MEMORY_MODE_WRITABLE) return true; - if (blob->mode == HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE && _try_writable_inplace (blob)) + if (this->mode == HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE && this->try_make_writable_inplace ()) return true; - if (blob->mode == HB_MEMORY_MODE_WRITABLE) + if (this->mode == HB_MEMORY_MODE_WRITABLE) return true; - DEBUG_MSG_FUNC (BLOB, blob, "current data is -> %p\n", blob->data); + DEBUG_MSG_FUNC (BLOB, this, "current data is -> %p\n", this->data); char *new_data; - new_data = (char *) malloc (blob->length); + new_data = (char *) malloc (this->length); if (unlikely (!new_data)) return false; - DEBUG_MSG_FUNC (BLOB, blob, "dupped successfully -> %p\n", blob->data); + DEBUG_MSG_FUNC (BLOB, this, "dupped successfully -> %p\n", this->data); - memcpy (new_data, blob->data, blob->length); - _hb_blob_destroy_user_data (blob); - blob->mode = HB_MEMORY_MODE_WRITABLE; - blob->data = new_data; - blob->user_data = new_data; - blob->destroy = free; + memcpy (new_data, this->data, this->length); + this->destroy_user_data (); + this->mode = HB_MEMORY_MODE_WRITABLE; + this->data = new_data; + this->user_data = new_data; + this->destroy = free; return true; } commit 5c64d61475f15d7f8de8993a52639735b2bcf750 Author: Behdad Esfahbod <[email protected]> Date: Thu May 3 21:10:57 2018 -0400 Add hb-blob-private.hh Towards making blob more memory-allocation-friendly diff --git a/src/Makefile.sources b/src/Makefile.sources index 1ed64fec..9fbb71e9 100644 --- a/src/Makefile.sources +++ b/src/Makefile.sources @@ -2,6 +2,7 @@ HB_BASE_sources = \ hb-atomic-private.hh \ + hb-blob-private.hh \ hb-blob.cc \ hb-buffer-private.hh \ hb-buffer-serialize.cc \ diff --git a/src/hb-blob.cc b/src/hb-blob.cc index 710765d1..1435d307 100644 --- a/src/hb-blob.cc +++ b/src/hb-blob.cc @@ -31,8 +31,7 @@ #include "hb-private.hh" #include "hb-debug.hh" - -#include "hb-object-private.hh" +#include "hb-blob-private.hh" #ifdef HAVE_SYS_MMAN_H #ifdef HAVE_UNISTD_H @@ -49,20 +48,6 @@ #include <fcntl.h> -struct hb_blob_t { - hb_object_header_t header; - ASSERT_POD (); - - bool immutable; - - const char *data; - unsigned int length; - hb_memory_mode_t mode; - - void *user_data; - hb_destroy_func_t destroy; -}; - static bool _try_writable (hb_blob_t *blob); @@ -507,6 +492,10 @@ _try_writable (hb_blob_t *blob) return true; } +/* + * Mmap + */ + #if defined(_WIN32) || defined(__CYGWIN__) #include <windows.h> #include <io.h> commit 203dc44ebc141af0ba8c54edec2dc0405664997a Author: Behdad Esfahbod <[email protected]> Date: Thu May 3 21:03:27 2018 -0400 [ot-layout] Remove unused members We should hang those off somewhere else. For now, the unused ones can go. diff --git a/src/hb-aat-layout-common-private.hh b/src/hb-aat-layout-common-private.hh index f7a7b86f..cf308227 100644 --- a/src/hb-aat-layout-common-private.hh +++ b/src/hb-aat-layout-common-private.hh @@ -134,7 +134,7 @@ struct BinSearchArrayOf protected: BinSearchHeader header; - HBUINT8 bytes[VAR]; + HBUINT8 bytes[VAR]; public: DEFINE_SIZE_ARRAY (10, bytes); }; diff --git a/src/hb-aat-layout.cc b/src/hb-aat-layout.cc index ad858495..7bd60272 100644 --- a/src/hb-aat-layout.cc +++ b/src/hb-aat-layout.cc @@ -44,6 +44,7 @@ * morx/kerx/trak */ +#if 0 static inline const AAT::ankr& _get_ankr (hb_face_t *face, hb_blob_t **blob = nullptr) { @@ -109,6 +110,7 @@ _get_trak (hb_face_t *face, hb_blob_t **blob = nullptr) *blob = layout->trak.blob; return trak; } +#endif // static inline void // _hb_aat_layout_create (hb_face_t *face) @@ -127,16 +129,19 @@ _get_trak (hb_face_t *face, hb_blob_t **blob = nullptr) void hb_aat_layout_substitute (hb_font_t *font, hb_buffer_t *buffer) { +#if 0 hb_blob_t *blob; const AAT::morx& morx = _get_morx (font->face, &blob); AAT::hb_aat_apply_context_t c (font, buffer, blob); morx.apply (&c); +#endif } void hb_aat_layout_position (hb_font_t *font, hb_buffer_t *buffer) { +#if 0 hb_blob_t *blob; const AAT::ankr& ankr = _get_ankr (font->face, &blob); const AAT::kerx& kerx = _get_kerx (font->face, &blob); @@ -145,4 +150,5 @@ hb_aat_layout_position (hb_font_t *font, hb_buffer_t *buffer) AAT::hb_aat_apply_context_t c (font, buffer, blob); kerx.apply (&c, &ankr); trak.apply (&c); +#endif } diff --git a/src/hb-ot-layout-private.hh b/src/hb-ot-layout-private.hh index 2454920c..caef70b9 100644 --- a/src/hb-ot-layout-private.hh +++ b/src/hb-ot-layout-private.hh @@ -173,15 +173,9 @@ struct hb_ot_layout_t /* TODO Move the following out of this struct. */ OT::hb_lazy_table_loader_t<struct OT::BASE> base; - OT::hb_lazy_table_loader_t<struct OT::COLR> colr; - OT::hb_lazy_table_loader_t<struct OT::CPAL> cpal; OT::hb_lazy_table_loader_t<struct OT::MATH> math; OT::hb_lazy_table_loader_t<struct OT::fvar> fvar; OT::hb_lazy_table_loader_t<struct OT::avar> avar; - OT::hb_lazy_table_loader_t<struct AAT::ankr> ankr; - OT::hb_lazy_table_loader_t<struct AAT::kerx> kerx; - OT::hb_lazy_table_loader_t<struct AAT::morx> morx; - OT::hb_lazy_table_loader_t<struct AAT::trak> trak; unsigned int gsub_lookup_count; unsigned int gpos_lookup_count; diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index 42d29aa1..f7e49648 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -30,19 +30,20 @@ #include "hb-open-type-private.hh" #include "hb-ot-layout-private.hh" +#include "hb-ot-map-private.hh" -#include "hb-ot-layout-base-table.hh" #include "hb-ot-layout-gdef-table.hh" #include "hb-ot-layout-gsub-table.hh" #include "hb-ot-layout-gpos-table.hh" -#include "hb-ot-layout-jstf-table.hh" // Just so we compile it; unused otherwise. -#include "hb-ot-name-table.hh" // Just so we compile it; unused otherwise. + +// Just so we compile them; unused otherwise: +#include "hb-ot-layout-base-table.hh" +#include "hb-ot-layout-jstf-table.hh" #include "hb-ot-color-colr-table.hh" #include "hb-ot-color-cpal-table.hh" -#include "hb-ot-color-sbix-table.hh" // Just so we compile it; unused otherwise. -#include "hb-ot-color-svg-table.hh" // Just so we compile it; unused otherwise. - -#include "hb-ot-map-private.hh" +#include "hb-ot-color-sbix-table.hh" +#include "hb-ot-color-svg-table.hh" +#include "hb-ot-name-table.hh" #ifndef HB_NO_VISIBILITY @@ -66,16 +67,9 @@ _hb_ot_layout_create (hb_face_t *face) layout->gpos_blob = OT::Sanitizer<OT::GPOS>().sanitize (face->reference_table (HB_OT_TAG_GPOS)); layout->gpos = OT::Sanitizer<OT::GPOS>::lock_instance (layout->gpos_blob); - layout->base.init (face); - layout->colr.init (face); - layout->cpal.init (face); layout->math.init (face); layout->fvar.init (face); layout->avar.init (face); - layout->ankr.init (face); - layout->kerx.init (face); - layout->morx.init (face); - layout->trak.init (face); { /* @@ -222,16 +216,9 @@ _hb_ot_layout_destroy (hb_ot_layout_t *layout) hb_blob_destroy (layout->gsub_blob); hb_blob_destroy (layout->gpos_blob); - layout->base.fini (); - layout->colr.fini (); - layout->cpal.fini (); layout->math.fini (); layout->fvar.fini (); layout->avar.fini (); - layout->ankr.fini (); - layout->kerx.fini (); - layout->morx.fini (); - layout->trak.fini (); free (layout); } commit ac92ed7d6875374451246a2391859fb763329adb Author: Ebrahim Byagowi <[email protected]> Date: Tue May 8 01:05:15 2018 +0430 Set inline hidden flag only on shared library building To avoid need of CMP0063 which is not available on older CMake versions diff --git a/CMakeLists.txt b/CMakeLists.txt index 55366c06..9ed7e56e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,4 @@ cmake_minimum_required(VERSION 2.8.0) -cmake_policy(SET CMP0063 NEW) - project(harfbuzz) enable_testing() @@ -526,17 +524,17 @@ endif () ## Define harfbuzz library add_library(harfbuzz ${project_sources} ${project_extra_sources} ${project_headers}) -set_target_properties(harfbuzz PROPERTIES - VISIBILITY_INLINES_HIDDEN TRUE) target_link_libraries(harfbuzz ${THIRD_PARTY_LIBS}) ## Define harfbuzz-subset library add_library(harfbuzz-subset ${subset_project_sources} ${subset_project_headers}) add_dependencies(harfbuzz-subset harfbuzz) -set_target_properties(harfbuzz-subset PROPERTIES - VISIBILITY_INLINES_HIDDEN TRUE) target_link_libraries(harfbuzz-subset harfbuzz ${THIRD_PARTY_LIBS}) +if (BUILD_SHARED_LIBS) + set_target_properties(harfbuzz harfbuzz-subset PROPERTIES VISIBILITY_INLINES_HIDDEN TRUE) +endif () + if (UNIX OR MINGW) # Make symbols link locally include (CheckCXXCompilerFlag) @@ -566,11 +564,13 @@ if (HB_HAVE_GOBJECT) ${hb_gobject_headers} ${hb_gobject_gen_headers} ) - set_target_properties(harfbuzz-gobject PROPERTIES - VISIBILITY_INLINES_HIDDEN TRUE) include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}/src) add_dependencies(harfbuzz-gobject harfbuzz) target_link_libraries(harfbuzz-gobject harfbuzz ${GOBJECT_LIBRARIES} ${THIRD_PARTY_LIBS}) + + if (BUILD_SHARED_LIBS) + set_target_properties(harfbuzz-gobject PROPERTIES VISIBILITY_INLINES_HIDDEN TRUE) + endif () endif () if (BUILD_SHARED_LIBS AND WIN32 AND NOT MINGW) _______________________________________________ HarfBuzz mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/harfbuzz
