Commit Graph

11689 Commits

Author SHA1 Message Date
Behdad Esfahbod
4ae8aab83b [buffer] HB_NODISCARD has_separate_output() 2021-03-15 14:01:52 -06:00
Behdad Esfahbod
8d3701f507 [buffer] HB_NODISCARD in_error() 2021-03-15 14:01:32 -06:00
Behdad Esfahbod
41e05479b6 [buffer] HB_NODISCARD shift_forward() 2021-03-15 14:00:00 -06:00
Behdad Esfahbod
83b3784d1d [buffer] HB_NODISCARD make_room_for() 2021-03-15 13:59:14 -06:00
Behdad Esfahbod
c355508a89 [buffer] HB_NODISCARD ensure_glyphs() / ensure_unicode() 2021-03-15 13:58:30 -06:00
Behdad Esfahbod
bc22305b6a [buffer] HB_NODISCARD ensure_inplace() 2021-03-15 13:57:18 -06:00
Behdad Esfahbod
cac6c86d2f [buffer] HB_NODISCARD move_to() 2021-03-15 13:56:46 -06:00
Behdad Esfahbod
05d2d37f9a [buffer] HB_NODISCARD ensure() 2021-03-15 13:56:46 -06:00
Behdad Esfahbod
d8028a0762 [buffer] HB_NODISCARD enlarge() 2021-03-15 13:34:36 -06:00
Behdad Esfahbod
3f1998a065 [buffer] HB_NODISCARD replace_glyph() 2021-03-15 13:33:44 -06:00
Behdad Esfahbod
607979d12f [buffer] HB_NODISCARD replace_glyphs() 2021-03-15 13:23:48 -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
a5b8e7db4d [hangul] Improve error handling
I did a review; changed some "return"s to "break"s, which should be identical.
Removed one check just before "continue" because not necessary.
The added error check is the actual fix.

Should fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=31755
2021-03-15 12:46:58 -06:00
Behdad Esfahbod
99767f9386 [hangul] Whitespace 2021-03-15 12:36:59 -06:00
Behdad Esfahbod
3622120fab [subset] Make ClassDef format2 .intersects() return false if range value 0
We treat Class0 as "doesn't intersect".  That's the only meaningful
interpretation. If one allos Class0 to mean "intersects", then the
intersects() result should be true iff glyphset is non-empty.

Related to https://github.com/harfbuzz/harfbuzz/issues/2703
2021-03-10 12:21:43 -07:00
David Corbett
e19de65eae
Update hb-ot-tag-table.hh (#2890) 2021-03-08 10:12:47 -08:00
Khaled Hosny
7686ff854b
[ot] Keep substituted Default_Ignorables (#2886)
Don’t replace Default_Ignorables with zero-width space if they are
substituted or multiplied, not just when ligated.

After this change, HarfBuzz output matches that of Uniscribe and
CoreText for the new tests.

Fixes https://github.com/harfbuzz/harfbuzz/issues/2883
2021-03-04 13:09:32 -08:00
Behdad Esfahbod
5efa04c890 [Makefile] Rebuild .def files if config changed
I was getting check-symbols failure because my previous build was
without CoreText, and after reconfiguring with CoreText, the old
harfbuzz.defs file was not being regenerated.
2021-03-02 16:30:13 -07:00
Behdad Esfahbod
d351bbf0fb [Makefile] Remove unused variable HBNODISTHEADERS
Not sure what it was used for before.
2021-03-02 16:30:13 -07:00
Behdad Esfahbod
fd489433a8 [indic] Fix cluster-merging logic with cluster-level=1
Was producing non-monotonic cluster numbers because our faulty logic
was not merging clusters if something from before base and after base
had switched positions.

Fixes https://github.com/harfbuzz/harfbuzz/issues/2272
2021-03-02 16:30:09 -07:00
Behdad Esfahbod
2902529b92 [subset] Fix HB_TINY build
Fixes https://github.com/harfbuzz/harfbuzzjs/issues/34#issuecomment-789247723
2021-03-02 15:05:39 -07:00
Behdad Esfahbod
7cb22ba7eb
Include C headers with their C++ names (#2882)
Remove unnecessary includes.

Fixes build with some known broken SDKs (Nintendo Switch?)

https://en.cppreference.com/w/cpp/header

Fixes https://github.com/harfbuzz/harfbuzz/pull/2881
2021-03-01 11:44:06 -08:00
Behdad Esfahbod
dbcf2f417f [cmake] Fix syntax 2021-03-01 12:43:32 -07:00
Behdad Esfahbod
93745f9f49
Merge pull request #2875 from harfbuzz/constexpr-inttype
[constexpr] Add constructors to IntType
2021-02-23 14:54:45 -07:00
Behdad Esfahbod
486da35cc0 m Add comments to IntType cast out operator
Okay, bots seem to be happy. Merging.
2021-02-23 13:58:35 -07:00
Behdad Esfahbod
83b66bfb66 Another try to fix narrowing error
../src/hb-ot-layout-gsubgpos.hh: In instantiation of ‘void OT::ChainRule::serialize_array(hb_serialize_context_t*, OT::HBUINT16, Iterator) const [with Iterator = hb_map_iter_t<hb_array_t<const OT::IntType<short unsigned int> >, const hb_map_t*&, (hb_function_sortedness_t)0, 0>; typename hb_enable_if<hb_is_iterator_of<Lhs, typename Lhs::item_t>::value>::type* <anonymous> = 0; OT::HBUINT16 = OT::IntType<short unsigned int>]’:
../src/hb-ot-layout-gsubgpos.hh:2341:30:   required from here
../src/hb-ot-layout-gsubgpos.hh:2326:15: error: narrowing conversion of ‘(unsigned int)g’ from ‘unsigned int’ to ‘short unsigned int’ inside { } [-Werror=narrowing]
       c->copy (HBUINT16 {g});
       ~~~~~~~~^~~~~~~~~~~~~~

https://github.com/harfbuzz/harfbuzz/pull/2875
2021-02-23 13:04:38 -07:00
Behdad Esfahbod
6c4bb60829 Fix narrowing errors with recent changes 2021-02-22 23:05:55 -07:00
Behdad Esfahbod
d6bd00a488 Revert back IntType out cast to signed/unsigned
Previous commit didn't fix the bots. Putting it back now that I
understand why I initially did the "Wide" casts.  But only doing
it for out-cast this time.  This causes "narrowing" warnings
whenever we are converting signed/unsigned to smaller HBUINT16
etc.  But those are valuable warnings.  We should address those
separately instead of ignoring.

Maybe we should start using uint16_t more liberally in the
internal subsetter function signatures then.
2021-02-22 22:42:50 -07:00
Behdad Esfahbod
0983601399 Add back wider cast to IntType
My local clang12 is fine, but many bots are not:

../src/hb-ot-cff1-table.hh: In instantiation of ‘bool CFF::Charset1_2<TYPE>::sanitize(hb_sanitize_context_t*, unsigned int) const [with TYPE = OT::IntType<unsigned char>]’:
../src/hb-ot-cff1-table.hh:554:13:   required from here
../src/hb-ot-cff1-table.hh:377:60: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
       if (unlikely (!ranges[i].sanitize (c) || (num_glyphs < ranges[i].nLeft + 1)))
                                                ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~

Enabling the extra cast operator mentioned in previous commit to see if
that fixes this case.

Again, I'd be happy to say "use 1u instead of 1" if this was universally
erred on.  But since some compilers happily compile this while others
err, it would be a huge headache. Let's see...

https://github.com/harfbuzz/harfbuzz/pull/2875
2021-02-22 22:33:17 -07:00
Behdad Esfahbod
567cedcc5f Narrow down cast operators on IntType
Say for USHORT, we were implementing casts from and to unsigned.
With this change, we cast from and to uint16_t only.  This allows
compiler more opportunities to catch possible narrowing issues in
the code.

It needed a couple of fixes in the codebase though, because
previously, if a USHORT was participating in arithmetic with signed
numbers, eg. "u + 1", the result would have been unsigned.  With
this change, it would be signed.  The correct fix is to update the
code to read "u + 1u".

That said, I think about conditionally adding back the cast
out to signed/unsigned, to facilitate better type deduction.
But I couldn't think of a real situation where that would help
with anything.  So I didn't add.  Here's what it was:

  template <typename Type2 = hb_conditional<hb_is_signed (Type), signed, unsigned>,
           hb_enable_if (sizeof (Type) < sizeof (Type2))>
  operator hb_type_identity_t<Type2> () const { return v; }

https://github.com/harfbuzz/harfbuzz/pull/2875
2021-02-22 22:32:42 -07:00
Behdad Esfahbod
f4f35a4d5f [constexpr] Use initializer instead of assignment 2021-02-22 22:32:42 -07:00
Behdad Esfahbod
cc16b26ef4 [constexpr] IntType
See https://github.com/harfbuzz/harfbuzz/pull/2875
2021-02-22 21:59:56 -07:00
Behdad Esfahbod
8b2f9adf29 m Simplify Tag operator char* 2021-02-22 17:42:24 -07:00
Behdad Esfahbod
021a1725ed
Merge pull request #2874 from harfbuzz/constexpr2
Some more cleanup towards using constexpr to simplify our internal datastrcutures.

https://github.com/harfbuzz/harfbuzz/pull/2874
2021-02-22 17:40:22 -07:00
Behdad Esfahbod
11c28cb5fa [cmake] Define HAVE_PTHREAD if not on win32
Yeah...
2021-02-22 17:38:53 -07:00
Behdad Esfahbod
b368a0736b [atomic] Remove IBM/AIX implementation
The C++11 implementation shall be enough for everyone.
2021-02-22 17:24:09 -07:00
Behdad Esfahbod
52f9126960 [atomic] Remove Windows implementation
Since we require C++11 now, there's no point to do a macro version check.
Which means we don't hit the MSVC issue defining __cplusplus wrongly.
2021-02-22 17:22:09 -07:00
Behdad Esfahbod
a666fe64a9 [atomic] Comment 2021-02-22 17:21:27 -07:00
Behdad Esfahbod
3528a21e8d [atomic] Remove Apple implementation
Continuation of https://github.com/harfbuzz/harfbuzz/pull/676
2021-02-22 17:19:43 -07:00
Behdad Esfahbod
140797d4a2 [constexpr] hb_atomic_int_t 2021-02-22 17:19:26 -07:00
Behdad Esfahbod
2ec802b42a [object] Simplify reference_count_t 2021-02-22 17:18:47 -07:00
Behdad Esfahbod
4d116ed0f0 [ci] Remove cmake
Apparently(?) our cmake build never bothered setting up pthreads.
So when I removed the busy-loop mutex impl it now doesn't build.

711c241f6c

https://github.com/harfbuzz/harfbuzz/pull/2874#issuecomment-782778263
2021-02-22 17:14:45 -07:00
Behdad Esfahbod
1c693e8c28 [test] Fix unused-var warning 2021-02-22 17:11:36 -07:00
Behdad Esfahbod
12a283d513 m[ft] No need to use atomic ops for cached_x_scale
We have added a mutex since, so no need for atomicity.
2021-02-22 12:51:09 -07:00
Behdad Esfahbod
b39c1f7829 a[build] Fix distcheck 2021-02-20 15:46:17 -07:00
Behdad Esfahbod
a3c35aee30 m Move HB_SCRIPT_MYANMAR_ZAWGYI 2021-02-20 15:45:34 -07:00
Behdad Esfahbod
c55bf55154 Remove HB_CONST_FUNC and HB_PURE_FUNC
They are not necessary for inline functions.
2021-02-20 15:45:12 -07:00
Behdad Esfahbod
cba9893ac5 m[algs] Move roundf() here 2021-02-20 15:44:47 -07:00
Behdad Esfahbod
f0947717ff m[machinery] Move HB_VAR_ARRAY here 2021-02-20 15:44:25 -07:00
Behdad Esfahbod
69464e9da0 [algs] Another try at fixing BEInt constexpr
../src/hb-algs.hh:120:3: error: body of constexpr function ‘constexpr BEInt<Type, 2>::operator Type() const [with Type = short unsigned int]’ not a return-statement
2021-02-20 15:42:44 -07:00