Commit Graph

314 Commits

Author SHA1 Message Date
Behdad Esfahbod 3807061d63 [ot-layout] Don't remove_output() before reverse substitution
No need anymore, because of new swap_buffers() semantics.

Just assert instead.
2021-07-12 17:36:22 -06:00
Behdad Esfahbod 10a9960f0a [buffer] Restructure swap_buffers()
Is more of a "commit" operation now. Will rename when ready.
2021-07-12 17:36:22 -06:00
Behdad Esfahbod 05c17787c4 [buffer] Rewind cursor in clear_output() 2021-07-12 16:55:08 -06:00
Behdad Esfahbod 69310f14a6 [buffer] Change nil buffer have_output to false
Seems like a historical artefact that it was true.
2021-07-09 16:45:55 -07:00
Behdad Esfahbod 2337f0d047 Internally use hb_malloc/.../hb_free instead of malloc/.../free
Redefining those stock names as macros was conflicting with gcc 10
headers.

Fixes https://github.com/harfbuzz/harfbuzz/issues/3044
2021-07-08 10:54:09 -07:00
Behdad Esfahbod 93e6a9bc4e Revert "Remove unneeded buffer clear_output / remove_output calls"
This reverts commit 06175b7143.

One of the sanitizers is failing. Pushing again as PR to debug.
I have suspicions.
2021-06-15 15:38:49 -06:00
Behdad Esfahbod 06175b7143 Remove unneeded buffer clear_output / remove_output calls
Made sure clear_output is always paired with swap_buffers.
Trying to see if we can move towards RAII-like buffer iterators
instead of the buffer keeping an iterator internally.
2021-06-15 14:33:27 -06:00
Behdad Esfahbod c61ce962cf [buffer] In hb_buffer_get_positions(), return NULL if inside message callback
As discussed in https://github.com/harfbuzz/harfbuzz/issues/2468#issuecomment-645666066

Part of fixing https://github.com/harfbuzz/harfbuzz/issues/2468
2021-06-10 17:36:38 -06:00
Behdad Esfahbod 34a1204f10 [buffer] HB_NODISCARD output_glyph()
Also, generalize and use replace_glyphs() in morx where output_glyph() was used
in a loop.
2021-03-15 16:01:35 -06:00
Behdad Esfahbod b05e5d9a79 [buffer] HB_NODISCARD next_glyphs() 2021-03-15 14:08:08 -06:00
Behdad Esfahbod 05d2d37f9a [buffer] HB_NODISCARD ensure() 2021-03-15 13:56:46 -06:00
Behdad Esfahbod 906c9928bb [buffer] Return success status from buffer ops that can fail
Previous error-handling philosophy was that user doesn't need to
immediately know whether operation failed. But as can be seen after
we added malloc-failing fuzzing, there's just so many places in the
code that a failure of these operations needs to be mitigated before
further operations. So I'm moving towards returning success here,
and possibly making it nodiscard.
2021-03-15 13:13:45 -06:00
Behdad Esfahbod 2d39031f7b [buffer/set/map] Move immutable check only to C API boundary
The immutable objects are a concept only enforced by the C API.
So move checks only to that region.

This does assume that the rest of the code is careful not getting
into these internal methods on immutable objects, which something
we do, but have no way of enforcing (currently).

.
2021-02-19 18:40:48 -07:00
Behdad Esfahbod 21433fa563 m[buffer] In hb_buffer_append() don't change until allocation success 2021-02-19 18:40:48 -07:00
Behdad Esfahbod 3b91e0b592 m[buffer] Rename internal variable 2021-02-19 18:40:48 -07:00
Behdad Esfahbod 9fcba109bf [buffer] Make swap_buffers() copy rest 2021-02-19 18:40:48 -07:00
Khaled Hosny 9936490c04 [docs] Invalid use of "optional" annotation
It is valid only for out and inout parameters.

Fixes https://github.com/harfbuzz/harfbuzz/issues/1787
2020-12-30 19:21:49 -08:00
Khaled Hosny 2fdab788ad [docs] Complete hb-buffer docs a bit 2020-12-30 19:21:49 -08:00
Khaled Hosny cb319f0d80 [docs] Add some missing annotations to hb-buffer.cc 2020-12-24 21:47:05 +02:00
Khaled Hosny f88e845fc7 [docs] Minor fixes 2020-12-24 21:34:14 +02:00
Nathan Willis e8de26e1ef [docs] Add gtkdoc comments to hb-buffer 2020-12-24 21:34:14 +02:00
Khaled Hosny 71a3b54f3c 2.7.3 2020-12-23 15:33:15 +02:00
Behdad Esfahbod 77e704d1db [buffer] Add assert_unicode()/assert_glyphs() and use internally 2020-10-15 02:02:04 -06:00
Behdad Esfahbod 3232e6f2a9 [buffer] Add hb_buffer_has_positions()
Fixes https://github.com/harfbuzz/harfbuzz/issues/2716
2020-10-15 00:20:17 -06:00
Ebrahim Byagowi 48ad745996 [ENOMEM] Fix buffer's content check logic
So now rest of shape fuzzer also can be enabled.

Fixes #2571
2020-07-29 08:09:10 +04:30
Ebrahim Byagowi d0e2addd43 minor 2020-07-18 22:16:02 +04:30
Ebrahim Byagowi 2dda6dd744 minor, tweak spacing
turn 8 spaces to tab, add space before Null/Crap
2020-04-20 16:18:29 +04:30
Garret Rieger 14a7b6f1ab Set hb_buffer_t to use array_t.reverse(). 2020-03-04 16:52:29 -08:00
Evgeniy Reizner b79ceac3c6 Prefer UINT_MAX instead of uint overflow.
Also, prefer HB_FEATURE_GLOBAL_START and HB_FEATURE_GLOBAL_END.
2019-12-15 11:46:05 -08:00
Evgeniy Reizner b618e0ae13 Remove non-breaking spaces from comments.
`0xC2A0` was used, for some reasons. It's not really a problem, but Qt Creator
constatly trying to replace them with regular spaces, so I have to edit those
files separately.
2019-12-15 10:12:22 -08:00
Evgeniy Reizner 780d640c02 Remove unnecessary check in hb_buffer_t::set_masks.
Bounds are already checked by the caller.

Closes #2073
2019-12-15 10:08:38 -08:00
Behdad Esfahbod 5fddc5f169 Use foreach_cluster 2019-11-20 13:07:26 -05:00
Behdad Esfahbod 029775bcbd [buffer] Minor; improve HB_NO_BUFFER_MESSAGE 2019-10-17 10:00:40 -07:00
Ebrahim Byagowi 670fec231d Minor, add a zero length tolerant memset, hb_memset 2019-10-10 09:21:08 +03:30
Ebrahim Byagowi e6909ee58d minor 2019-09-18 23:16:52 +04:30
Ebrahim Byagowi bfb155a5f1 Don't call memset when length is zero
Fixes this -fno-sanitize-recover=undefined check,

/buffer/positions/empty: hb-buffer.cc:327:11: runtime error: null pointer passed as argument 1, which is declared to never be null

/usr/include/string.h:60:62: note: nonnull attribute specified here
    #0 0x4cf31c in hb_buffer_t::clear_positions() /home/user/code/harfbuzz/src/hb-buffer.cc:327:3
    #1 0x4d4dd4 in hb_buffer_get_glyph_positions /home/user/code/harfbuzz/src/hb-buffer.cc:1418:13
    #2 0x4cb553 in test_buffer_positions /home/user/code/harfbuzz/test/api/test-buffer.c:305:3
    #3 0x7f324187bf49  (/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x72f49)
    #4 0x7f324187be7a  (/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x72e7a)
    #5 0x7f324187be7a  (/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x72e7a)
    #6 0x7f324187c121 in g_test_run_suite (/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x73121)
    #7 0x7f324187c140 in g_test_run (/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x73140)
    #8 0x4c8bd3 in hb_test_run /home/user/code/harfbuzz/test/api/./hb-test.h:88:10
    #9 0x4c8bd3 in main /home/user/code/harfbuzz/test/api/test-buffer.c:884:10
    #10 0x7f324086db96 in __libc_start_main /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:310
    #11 0x41e919 in _start (/home/user/code/harfbuzz/test/api/test-buffer+0x41e919)
2019-09-18 23:16:52 +04:30
Ebrahim Byagowi a0b4ac4dce Turn 8 spaces to tab across the project
According to the current code style of the project
2019-08-27 02:40:41 +04:30
Behdad Esfahbod 7f3b409e85 Fix build with -O0
message_impl was not defined.  That causes trouble if compiler didn't
optimize the unreachable call out...
2019-06-20 14:24:43 -07:00
Behdad Esfahbod eb9798ef73 [config] Dont' compile buffer message API if HB_NO_BUFFER_MESSAGE
Part of https://github.com/harfbuzz/harfbuzz/issues/1652
2019-06-18 13:29:55 -07:00
Behdad Esfahbod c7439d4e3a Slightly massage buffer-messaging commit
Saves a few bytes.
2019-06-05 12:15:09 -07:00
Ebrahim Byagowi 815f002bb9 Don't use vsnprintf when HB_NO_BUFFER_MESSAGE is defined 2019-06-05 10:38:06 +04:30
Behdad Esfahbod 41248cce0e Remove MIN/MAX in favor of hb_min/hb_max 2019-05-07 20:54:31 -07:00
Ebrahim Byagowi e412008599 Remove redundant void from C++ sources (#1486) 2018-12-17 13:01:01 -05:00
Ebrahim Byagowi 7ee5c52345
minor style fix, use void in methods on no argument 2018-12-12 15:14:37 +03:30
Behdad Esfahbod 93ef20a83b Replace most uses of is_inert with is_immutable 2018-11-03 15:03:06 -04:00
Behdad Esfahbod cf5fa57f00 [docs] Change section titles again
I think I like the uniform "hb-*" more.
2018-10-27 04:51:42 -07:00
Behdad Esfahbod 5dd86aa33b [docs] Rename section titles to object names
More useful.
2018-10-27 04:47:41 -07:00
Behdad Esfahbod 00cf4e5eb6 [docs] Fill in some sections 2018-10-27 04:47:41 -07:00
Behdad Esfahbod 8d304ef7f9 [utf] Add UTF16-BE and UTF32-BE 2018-10-26 21:22:26 -07:00
Behdad Esfahbod 3d9a0306eb 2.0.0 2018-10-18 05:58:17 -07:00
Behdad Esfahbod 2e7c716511 [buffer] Add an assert
See if it helps debugging https://bugs.chromium.org/p/chromium/issues/detail?id=895117
2018-10-16 18:35:03 -07:00
David Corbett a03f5f4dfb Replace "ISO 639" with "BCP 47"
`hb_language_from_string` accepts not only ISO 639 but also BCP 47. Not
all ISO 639 codes are valid BCP 47 tags but the function does not accept
overlong language subtags anyway.
2018-10-11 13:54:28 -04:00
Behdad Esfahbod e42cd58c99 Rename invisible_codepoint to invisible_glyph in API
Deleted recently added API:
    hb_buffer_set_invisible_codepoint()
    hb_buffer_get_invisible_codepoint()

    hb-shape / hb-view --invisible-codepoint

New API:
    hb_buffer_set_invisible_glyph()
    hb_buffer_get_invisible_glyph()

    hb-shape / hb-view --invisible-glyph

Fixes https://github.com/harfbuzz/harfbuzz/issues/1216
2018-10-07 20:47:30 -04:00
Behdad Esfahbod 14ebf8af0c [buffer] Improve shift_forward()
"Improve" is a strong word in this case though, I understand.
2018-10-07 20:35:06 -04:00
Behdad Esfahbod 71b65eb27d Add API for setting invisible-codepoint
Fixes https://github.com/harfbuzz/harfbuzz/issues/1216

New API:
hb_buffer_set_invisible_codepoint()
hb_buffer_get_invisible_codepoint()

hb-shape / hb-view --invisible-codepoint
2018-10-07 18:43:26 +02:00
Behdad Esfahbod 2a6f15213e [buffer] Inline some more 2018-10-03 20:19:42 +02:00
Behdad Esfahbod ba0f0f156f Document setlocale() threadsafety issue
"Fixes" //github.com/harfbuzz/harfbuzz/issues/1191
2018-09-30 06:08:11 -04:00
Behdad Esfahbod 55bae6825e [docs] A few improvements
If we wrote just this much every day...
2018-09-24 10:43:06 -04:00
Behdad Esfahbod 606bf57430 Revert forcing use of single-parameter static_assert()
Some clang versions define static_assert as a macro apparently, so we cannot
redefine it...

This reverts commit 94bfea0ce6.
This reverts commit 4e62627831.
2018-09-16 19:34:39 +02:00
Behdad Esfahbod 4e62627831 Enforce single-param static_assert() only
So we don't accidentally break it again.
2018-09-16 18:09:36 +02:00
Behdad Esfahbod c77ae40852 Rename hb-*private.hh to hb-*.hh
Sorry for the noise, downstream custom builders.  Please adjust.
2018-08-25 22:36:36 -07:00
Behdad Esfahbod f0ef096b8c Don't add reference in get_unicode_funcs() functions
Users don't expect a new reference returned from a get() function.
Indeed, all users of that API I foud where NOT destroying the reference.
Just change the implementations to NOT return a reference.

This applies to the following APIs:
hb_unicode_funcs_get_default()
hb_glib_get_unicode_funcs()
hb_icu_get_unicode_funcs()

Fixes https://github.com/harfbuzz/harfbuzz/issues/1134
2018-08-13 10:30:41 -07:00
Behdad Esfahbod 3506672ce9 Port _nil objects to Null() machinery
Finally, unified!
2018-08-06 06:17:48 -07:00
Behdad Esfahbod bddeb2b10c Minor renamings of internal inline functions 2018-07-10 14:13:21 +02:00
Behdad Esfahbod 7185b273b3 Rename in_error to !successful
Towards possibly using Null pool for some nil objects.
2018-05-31 20:03:34 -07:00
Behdad Esfahbod f673cfbd64 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
2018-05-07 14:12:17 -07:00
Behdad Esfahbod cc1e0840ba [buffer] Tweak diff re glyph_flags again
We expect the buffer to have no flags that the reference doesn't...
Meh. Makes MORX tests pass now. Need to better define the behavior.
2018-02-06 10:20:48 -05:00
Ebrahim Byagowi d49ae5154e Fix hb-buffer logic error 2018-02-06 10:13:11 -05:00
Behdad Esfahbod 54e6efadd6 [aat] Fix unsafe-to-break
At any position, if state is not zero, mark unsafe-to-break before,
unless we can reason it safe.

At any position, if there's an action entry for end-of-text, mark
unsafe to break.

Also changes buffer diff impl to allow for flag differences as long
as the buffer glyph flags are superset of reference glyph flags.

With this, all MORX tests pass.
2018-02-04 17:18:54 -05:00
Behdad Esfahbod baf7779d2d Limit how much recursion GSUB/GPOS does
This only counts recursions right now.  Good start.

Hopefully...
Fixes https://github.com/behdad/harfbuzz/issues/429
2017-11-14 21:55:37 -08:00
ebraminio 102f5ead49
Enable PSVita (arm-none-eabi) compile again and add it to CI (#594) 2017-11-01 02:10:18 -07:00
Behdad Esfahbod dbdbfe3d7b Use nullptr instead of NULL 2017-10-15 12:11:08 +02:00
Behdad Esfahbod c3448e8d21 Use static_assert instead of custom ASSERT_STATIC 2017-10-15 12:02:00 +02:00
Behdad Esfahbod d03f11f246 Fix buffer_diff for empty buffers
If buffers are empty, content type should be ignored.

This fixes last of the failing tests: fuzzed.tests.  Green again!
2017-09-04 20:14:13 -07:00
Behdad Esfahbod 099472e08b hb_buffer_diff() tweak
I like to have a mode where CONTAINS_NOTDEF and CONTAINS_DOTTEDCIRCLE are not
returned.  Abused a value of -1 for that.  hb-shape now uses it.  Fixes two
of the six tests failing with --verify in test/shaping/run-tests.sh.
2017-08-30 16:45:06 -07:00
Behdad Esfahbod 224d20e4e1 [docs] Minor 2017-08-23 14:49:10 -07:00
Behdad Esfahbod b2dd0c1c32 Add hb_glyph_info_get_glyph_flags()
New API.
2017-08-23 13:12:54 -07:00
Behdad Esfahbod 3e8f4f1452 Rename HB_BUFFER_DIFF_FLAG_MASK_MISMATCH to HB_BUFFER_DIFF_FLAG_GLYPH_FLAGS_MISMATCH 2017-08-22 17:56:25 -07:00
Emil A Eklund (eae) 91770e1c56 Fix signed/unsigned warning (#522)
Change hb_buffer_diff to explicitly cast result of abs to unsigned when
comparing with position_fuzz to avoid unsafe signed/unsigned comparions
warnings on windows.
2017-08-15 16:25:18 -07:00
Jonathan Kew 331d66c7fe Add function to compare two buffers
Based on patch from Jonathan Kew.

Needs more cleaning up and documentation.

New API:
hb_buffer_diff_flags_t
hb_buffer_diff()
2017-08-14 11:44:12 -07:00
Behdad Esfahbod 05fabbd03e [unsafe-to-break] Towards verifying unsafe-to-break in --verify
We break and shape fragments and reconstruct shape result from them.
Remains to compare to original buffer.  Going to add some buffer
comparison API and use here, instead of open-coding.
2017-08-11 20:00:55 -07:00
Behdad Esfahbod 6ce25f57c6 Fix hb_buffer_append()
Ouch!
2017-08-11 19:31:05 -07:00
Behdad Esfahbod 1c17c2bde5 [unsafe-to-break] Copy flag to all glyphs in a cluster
Makes consumption easier.
2017-08-11 19:06:07 -07:00
Behdad Esfahbod ec104e5912 [unsafe-to-break] Mark unsafe is cluster merging is disabled
We were relying on cluster merges not requiring unsafe flagging because
they get merged.  If cluster level requests no merging, then we flag
unsafe when merge would have happened.
2017-08-11 18:24:27 -07:00
Behdad Esfahbod 39a9749430 New API: hb_buffer_append() 2017-08-11 15:52:06 -07:00
Behdad Esfahbod e2a2b5b229 [unsafe-to-break] Be careful with flag propagation when merging clusters 2017-08-10 20:11:35 -07:00
Behdad Esfahbod f2868c2008 Set mask to 0, instead of 1, by default
This shouldn't matter.
2017-08-10 20:10:53 -07:00
Behdad Esfahbod 91ce0c45d6 [safe-to-break] Fix logic when there is no out-buffer 2017-08-10 15:02:34 -07:00
Behdad Esfahbod a043c99f77 [unsafe-to-break] Simplify logic
Always use the algorithm for non-monotone case.  It's more robust.
2017-08-10 15:02:34 -07:00
Behdad Esfahbod 40bd7e9a1c [unsafe-to-break] Add UNSAFE_TO_BREAK flag
Not all shapers code is updated to set this properly.
GSUB and Arabic shaper are updated.
GPOS and other shapers are NOT.

Fixes https://github.com/behdad/harfbuzz/issues/224
2017-08-10 15:02:28 -07:00
Ebrahim Byagowi 3b0e47ca00 Fix arm-none-eabi build (fixes #451) (#496) 2017-06-19 14:47:09 +04:30
Behdad Esfahbod 6363d7df28 Clean up buffer area when rewinding
Fixes https://bugs.chromium.org/p/chromium/issues/detail?id=614647
If allocation fails, we might be leaving junk behind.  At least
clear it up.
2016-07-20 01:44:47 -07:00
Behdad Esfahbod 70e72e5f61 [gobject] Fix a few warnings
Part of https://github.com/behdad/harfbuzz/issues/277
2016-06-28 21:15:36 -07:00
Behdad Esfahbod 0c7fb7419c Speed up buffer variable allocation sanity check
This makes defining HB_NDEBUG much less relevant, to the
point of irrelevance.  Sorry about all the fuss in previous
release!
2016-02-25 14:40:09 +09:00
Behdad Esfahbod 91dd115652 Add HB_NDEBUG
API changes:
- If NDEBUG is defined, define HB_NDEBUG
- Disable costlier sanity checks if HB_NDEBUG is defined.

In 1.2.3 introduced some code to disable costly sanity checks if
NDEBUG is defined.  NDEBUG, however, disables all assert()s as
well.  With HB_NDEBUG, one can disable costlier checks but keep
assert()s.

I'll probably add a way to define HB_NDEBUG automatically in
release tarballs.  But for now, production systems that do NOT
define NDEBUG, are encouraged to define HB_NDEBUG for our build.
2016-02-25 13:56:47 +09:00
Behdad Esfahbod 988165021f Disable internal buffer variable bookkeeping in NDEBUG builds
Saves some sweet time and binary size!
2016-02-25 12:23:02 +09:00
Behdad Esfahbod b87e36f6f1 Avoid buffer->move_to() in case of buffer error
Fixes https://github.com/behdad/harfbuzz/issues/223

Right now we cannot test this because it has to be tested using hb-fuzzer.
We should move all fuzzing tests from test/shaping/tests/fuzzed.tests to
test/fuzzing/ and have its own test runner.  At that point, should add
test from this issue as well.
2016-02-19 14:52:31 +07:00
Khaled Hosny 9ab9f974d4 [docs] More buffers documentation 2016-01-01 20:38:21 +04:00
Khaled Hosny 9cffe329f1 [docs] Typo 2015-12-30 22:50:08 +04:00
Khaled Hosny fb192c263e [docs] A bit more buffers documentation 2015-12-30 17:59:01 +04:00