Commit Graph

182 Commits

Author SHA1 Message Date
Behdad Esfahbod cba9893ac5 m[algs] Move roundf() here 2021-02-20 15:44:47 -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
Behdad Esfahbod ff7bf88192 m[algs] Fix BEInt -Wnarrowing errors 2021-02-20 15:39:29 -07:00
Behdad Esfahbod e208f80449 Make constexpr BEInt<Type, 2>::operator Type() C++11-compatible
Multiple return values not permitted until C++14
2021-02-20 15:31:43 -07:00
Behdad Esfahbod 47f01c0726 m[algs] Move BEInt here 2021-02-20 15:14:50 -07:00
Behdad Esfahbod e1706ffecd m [algs] Move flags here 2021-02-20 15:11:26 -07:00
Behdad Esfahbod ed04174a64 Whitespace 2021-02-09 18:48:05 -07:00
Behdad Esfahbod 921b4e46b0 [algs] Add hb_equal()
Use in hb_array_t::lfind()
2021-02-01 11:30:39 -08:00
Behdad Esfahbod 881ad720fe [algs] Remove passthru declaration
Let compiler figure it out.
2021-01-21 14:27:45 -07:00
Behdad Esfahbod 7c241651ac [algs] Don't forward rvalue twice
Part of https://github.com/harfbuzz/harfbuzz/issues/2293
2020-11-30 16:38:53 -07:00
David Corbett b207eab842 Round-trip OpenType tags through BCP 47 2020-05-15 15:00:15 -07:00
Ebrahim Byagowi 818f109bde Use float in avar calculation instead ints and checking their overflows 2020-04-17 00:53:39 +04:30
Ebrahim Byagowi 9ffa50fe5d Add an appropriate fallback to hb_int_mul_overflows 2020-04-17 00:38:38 +04:30
Ebrahim Byagowi 96d792ae80 [avar] Prevent mul overflow
Fixes https://crbug.com/oss-fuzz/21350
2020-03-26 15:01:14 +00:00
Ebrahim Byagowi b398748d8b
[algs] Add hb_clamp
Similar to stl and glsl's clamp
2020-03-04 11:18:19 +03:30
Behdad Esfahbod fa7edf87c9 [bsearch] Massage API some more 2019-12-09 17:51:41 -06:00
Behdad Esfahbod 70aa5071d8 [algs] Adjust return value of hb_ctz(0) to be 32 instead of 0 2019-12-09 17:48:10 -06:00
Behdad Esfahbod 48eef2724c [algs/array] Consolidate the last two bsearch implementations!
Yay!  Seems to work.
2019-12-06 05:04:11 +00:00
Behdad Esfahbod ed35dea8c0 Fourth try... sighs 2019-12-06 04:37:11 +00:00
Behdad Esfahbod 34f5cc2cc8 Second try at fixing build 2019-12-06 04:09:33 +00:00
Behdad Esfahbod 14ce5ab0b7 First try at fixing build errors 2019-12-06 03:54:46 +00:00
Behdad Esfahbod 2274270c6a [algs] Streamline bsearch some more 2019-12-06 03:42:21 +00:00
Behdad Esfahbod bd55d4b49f [algs] Streamline bsearch() API more towards hb_array_t::bsearch_impl()
Preparing to merge the two finally!
2019-12-06 03:35:24 +00:00
Ebrahim Byagowi 670fec231d Minor, add a zero length tolerant memset, hb_memset 2019-10-10 09:21:08 +03:30
Ebrahim Byagowi 65690b5a4b [number] Add whole buffer check and test it 2019-09-04 02:04:09 +04:30
Ebrahim Byagowi 3661eb6105 Don't check null terminaion of source in hb_codepoint_parse
This isn't what intended originally, just checking if consumed
all the buffer is enough.
2019-09-04 02:04:09 +04:30
Ebrahim Byagowi b5e6805ee7 [number] Minor tweak on parser related codes 2019-09-04 02:04:09 +04:30
Ebrahim Byagowi a77bb7eb41 Move hb_codepoint_parse to hb_parse_uint 2019-09-04 02:04:09 +04:30
Behdad Esfahbod 3bc86fb237 [algs] Fix hb_inc/dec signature 2019-08-31 12:24:56 -05:00
Behdad Esfahbod 2d5643aed4 [algs] Add hb_inc() and hb_dec()) 2019-08-31 12:24:56 -05:00
Behdad Esfahbod 4cb180d227 Revert "Use constexpr to replace passthru_ bools"
This reverts commit c4aa10ebc8.

Broke several compilers... Sigh.  The version without constexpr
didn't fully optimize out the unreachable code on clang.
So, revert it is...
2019-07-02 19:44:18 -07:00
Behdad Esfahbod c4aa10ebc8 Use constexpr to replace passthru_ bools 2019-07-02 19:15:03 -07:00
Behdad Esfahbod 2e48fd0779 Sprinkle constexpr around
Being conservative.  Also not sure it makes any real difference
in our codebase.
2019-07-02 17:55:58 -07:00
Behdad Esfahbod ec8e635e0c [ucd] Use custom encoding to shrink composition data
Saves another 2.5kb.

Part of https://github.com/harfbuzz/harfbuzz/issues/1652
2019-06-24 12:37:23 -07:00
Behdad Esfahbod 60653a7adb Remove HB_VECTOR_SIZE
It was cumbersome to get it to work reliably, for dubious performance
gain, mostly in the subsetter maybe...

Life is easier without.  It was disabled forever anyway.
2019-06-18 13:01:11 -07:00
Behdad Esfahbod 24060d3aa7 Add hb_bitwise_neg 2019-06-18 12:50:42 -07:00
Behdad Esfahbod 7cf9169078 Remove accidentally left cruft 2019-06-18 12:44:03 -07:00
Behdad Esfahbod ff9b9b1c89 Simplify HB_PARTIALIZE impl
+this works on gcc 4.8 as well as default code path.
2019-06-10 12:48:25 -07:00
Behdad Esfahbod 451edbd4d0 Revert "Test new solution for HB_PARTIALIZE"
This reverts commit a0c4900799.
2019-06-10 12:46:54 -07:00
Behdad Esfahbod a0c4900799 Test new solution for HB_PARTIALIZE
Just testing bots.  Will finish based on results.
2019-06-10 12:33:23 -07:00
Ebrahim Byagowi 9407ef8d4b
minor, add HB_USE_INTERNAL_QSORT
The only thing I need for a working wasm in a minimum libc,
otherwise I have to provide the very same qsort inside that libc
2019-06-10 15:17:43 +04:30
Ebrahim Byagowi c4669fda78
[algs] minor 2019-06-09 11:50:36 +04:30
Ebrahim Byagowi eff579f743 Update and use internal qsort everywhere 2019-06-08 12:53:27 -07:00
Behdad Esfahbod 973699c49b Disable clang gcc impersonator 2019-06-07 12:49:06 -07:00
Behdad Esfahbod e4e518f33d Fix build on gcc 4.8
Fixes https://github.com/harfbuzz/harfbuzz/issues/1724
2019-06-07 12:41:09 -07:00
Eli Zaretskii d5e5f37832 This makes minor changes to allow building HarfBuzz with
mingw.org's MinGW.

src/hb-algs.hh: Don't compile _BitScanForward and _BitScanReverse
for GCC >= 4.  mingw.org's MinGW doesn't have these functions.

src/hb-atomic.hh: MemoryBarrier does exist in mingw.org's MinGW,
but it is not a macro, it is an inline function.  __MINGW32_VERSION
is a macro that exists only in mingw.org's MinGW, so conditioning
on it should not affect MinGW64, where MemoryBarrier is a macro.

src/hb-uniscribe.cc: Define E_NOT_SUFFICIENT_BUFFER if it is not
defined (mingw.org's MinGW doesn't).

src/hb.hh: Don't include intrin.h for mingw.org's MinGW, since that
header is not available; instead, include windows.h.  Conditioned
on __MINGW32_VERSION to avoid affecting MinGW64.
2019-06-05 14:37:51 -07:00
Ebrahim Byagowi 760eb1bf93
Reapply possible bsearch overflow fix
Originally introduced in 21ede86 (#1314) but as it wasn't applied to hb_bsearch
accidentally removed while merging hb_bsearch_r to it.
2019-06-03 05:48:04 -07:00
Ebrahim Byagowi 8278ff7dce
minor 2019-06-02 00:36:30 +04:30
Ebrahim Byagowi 33d38e793e
Use a unified bsearch (#1741)
A part of #593
2019-06-02 00:19:57 +04:30
Behdad Esfahbod 619f5f1eb9 Fourth try at building VS bots
Based on https://github.com/harfbuzz/harfbuzz/issues/1730#issuecomment-497151210
2019-05-31 22:49:34 -07:00
Behdad Esfahbod aba3888d93 Third try at fixing VS build
https://github.com/harfbuzz/harfbuzz/issues/1730
2019-05-31 22:49:34 -07:00
Behdad Esfahbod 8aaecbb583 Second VS fix try
https://github.com/harfbuzz/harfbuzz/issues/1730
2019-05-31 22:49:34 -07:00
Behdad Esfahbod 5a1b5c0a8b Try fixing VS builds
Hopefully fixes https://github.com/harfbuzz/harfbuzz/issues/1730
2019-05-31 22:49:34 -07:00
Behdad Esfahbod 92fde3dea2 Whitespace 2019-05-31 22:49:34 -07:00
Behdad Esfahbod 65392b734e [ucdn] Replace UCDN with a new UCD implementation
UCDN was ~120kb of data.  New implementatoin is 69kb in default builds,
and 49kb if built with HB_OPTIMIZE_SIZE or __OPTIMIZE_SIZE__.  The
latter automatically enabled if built with -Os or -Oz.

There's room to shave off another 10kb or 20kb.  That will follow later.

Fixes https://github.com/harfbuzz/harfbuzz/issues/1652
2019-05-23 20:34:19 -04:00
Behdad Esfahbod b7be59311f Fix msan issue
The fact that HB_AUTO_RETURN will return rvalue-references for rvalues
is very disturbing.

Even apart from that, I'm totally lost re any hb_move needs or
hb_forward'ing to functions/templates where the type is fixed by
explicitly specifying template parameters.

==1==ERROR: AddressSanitizer: stack-use-after-return on address 0x7f6ad65e51e0 at pc 0x0000005da240 bp 0x7ffc104ab670 sp 0x7ffc104ab668
READ of size 4 at 0x7f6ad65e51e0 thread T0
SCARINESS: 55 (4-byte-read-stack-use-after-return)
     #0 0x5da23f in bool OT::Coverage::serialize<hb_map_iter_t<hb_map_iter_t<hb_filter_iter_t<OT::Coverage::iter_t, hb_set_t const&, $_7&, (void*)0>, OT::SingleSubstFormat1::subset(hb_subset_context_t*) const::'lambda'(unsigned int), (hb_function_sortedness_t)1, (void*)0>, $_20&, (hb_function_sortedness_t)1, (void*)0>, (void*)0>(hb_serialize_context_t*, hb_map_iter_t<hb_map_iter_t<hb_filter_iter_t<OT::Coverage::iter_t, hb_set_t const&, $_7&, (void*)0>, OT::SingleSubstFormat1::subset(hb_subset_context_t*) const::'lambda'(unsigned int), (hb_function_sortedness_t)1, (void*)0>, $_20&, (hb_function_sortedness_t)1, (void*)0>) harfbuzz/src/hb-ot-layout-common.hh:1055:16
     #1 0x5d88f9 in bool OT::SingleSubstFormat1::serialize<hb_map_iter_t<hb_map_iter_t<hb_filter_iter_t<OT::Coverage::iter_t, hb_set_t const&, $_7&, (void*)0>, OT::SingleSubstFormat1::subset(hb_subset_context_t*) const::'lambda'(unsigned int), (hb_function_sortedness_t)1, (void*)0>, $_20&, (hb_function_sortedness_t)1, (void*)0>, (void*)0>(hb_serialize_context_t*, hb_map_iter_t<hb_map_iter_t<hb_filter_iter_t<OT::Coverage::iter_t, hb_set_t const&, $_7&, (void*)0>, OT::SingleSubstFormat1::subset(hb_subset_context_t*) const::'lambda'(unsigned int), (hb_function_sortedness_t)1, (void*)0>, $_20&, (hb_function_sortedness_t)1, (void*)0>, unsigned int) harfbuzz/src/hb-ot-layout-gsub-table.hh:98:9
2019-05-16 13:34:19 -07:00
Behdad Esfahbod 6f51e55524 [algs] Rename hb_bind to hb_partial
Since our API is the invers of what std::bind is, and closer to Python
functools.partial().
2019-05-15 21:41:12 -07:00
Behdad Esfahbod 0888e7bc86 [algs] Change hb_bind parameter number to be from one
To match std:;bind, even though our interfaces are very different.
2019-05-15 21:36:42 -07:00
Behdad Esfahbod a06a236891 [algs] Partialize all operators 2019-05-15 21:16:09 -07:00
Behdad Esfahbod edc69ec935 [algs] Rewrite bind API
And add a partialization API use example to hb_add()
2019-05-15 21:09:56 -07:00
Behdad Esfahbod 16a3540ea4 [algs] Add hb_bind0 and hb_bind1 2019-05-15 20:48:20 -07:00
Behdad Esfahbod 243a5a6af2 [algs] Remove pair copy constructor
Use default.
2019-05-15 19:04:24 -07:00
Behdad Esfahbod 5da8a3a90d Remove variadic form of hb_min/hb_max
Unused, and why here and not in other functions...
2019-05-15 17:11:18 -07:00
Behdad Esfahbod e5cfe9d582 Add arithmetic operators 2019-05-15 16:59:36 -07:00
Behdad Esfahbod f7a458510d Add hb_bitwise_* ops 2019-05-15 16:53:12 -07:00
Behdad Esfahbod d3e1d5044f Add all pair_t comparison operators 2019-05-15 14:34:36 -07:00
Behdad Esfahbod e0315b4aad [meta] is_integer -> is_integral 2019-05-10 19:48:02 -07:00
Behdad Esfahbod 790315e0db [algs] Implement implicit casting between compatible pair types 2019-05-09 15:31:24 -07:00
Garret Rieger 5e3cbed048 [subset] Switch building of glyph maps in subset plan to use iterators. 2019-05-09 14:52:01 -07:00
Garret Rieger 971020eca7 Add sink support for hb_hashmap_t and a reverse call to hb_pair_t. 2019-05-09 14:52:01 -07:00
Behdad Esfahbod 98eec3dd5f Add hb_pair_t(,) macro as alternative to hb_pair_t<,>
Just so it's easier to use it in other macros.
2019-05-09 13:15:36 -07:00
Behdad Esfahbod c9b287a867 Add hb_lidentity(), and rename hb_rvalue() to hb_ridentity() 2019-05-09 12:43:57 -07:00
Behdad Esfahbod 4c94bc63d9 Move hb_invoke() back to hb-algs.hh 2019-05-08 15:57:33 -07:00
Behdad Esfahbod 27b2093009 [map] Return rvalues from keys()/values() 2019-05-08 15:32:57 -07:00
Behdad Esfahbod 5ceaafa5de [algs] Fix identity return type 2019-05-08 15:08:33 -07:00
Behdad Esfahbod 4a101d8ffc Add hb_match 2019-05-08 09:16:33 -07:00
Behdad Esfahbod 26adefd9ea [algs] Try f[v] in hb_get() as last resort 2019-05-08 09:14:44 -07:00
Behdad Esfahbod 56d2d0294b [algs] Sprinkle hb_min/max with hb-forward salad
Let's see if fixes MSVC fail.  Though, the error doesn't make sense to me.

  hb-blob.cc
c:\projects\harfbuzz\src\hb-algs.hh(166): error C2440: 'return': cannot convert from 'unsigned int' to 'unsigned int &&' [C:\projects\harfbuzz\build\harfbuzz.vcxproj]
  c:\projects\harfbuzz\src\hb-algs.hh(166): note: You cannot bind an lvalue to an rvalue reference
  c:\projects\harfbuzz\src\hb-algs.hh(174): note: see reference to function template instantiation 'T &&<unnamed-type-hb_min>::impl<T,unsigned int&>(T &&,T2) const' being compiled
          with
          [
              T=unsigned int,
              T2=unsigned int &
          ]
2019-05-07 23:08:49 -07:00
Behdad Esfahbod e8bd5fc3fa [meta] Move hb_invoke from algs to meta 2019-05-07 22:29:40 -07:00
Behdad Esfahbod 6fa1f38070 [algs] Accept varargs in hb_min/max 2019-05-07 21:33:26 -07:00
Behdad Esfahbod 1ad07080c3 Rename 2019-05-07 21:00:23 -07:00
Behdad Esfahbod 83e3eabd84 Whitespace 2019-05-07 20:58:43 -07:00
Behdad Esfahbod 2b9402a86a Use universal references in hb_min/max 2019-05-07 20:55:33 -07:00
Behdad Esfahbod 41248cce0e Remove MIN/MAX in favor of hb_min/hb_max 2019-05-07 20:54:31 -07:00
Behdad Esfahbod 7654ebe3a5 Whitespace 2019-05-07 16:53:03 -07:00
Behdad Esfahbod 240f57e58d Rename hb_deref_pointer() to hb_deref() 2019-05-06 23:17:39 -07:00
Behdad Esfahbod bf22338f49 Remove dead code 2019-05-02 13:51:52 -07:00
Behdad Esfahbod 0268db1196 [map] Use hb_invoke() with pointer-to-method 2019-04-24 10:53:39 -04:00
Behdad Esfahbod 8f79a5750e [algs] Add more hb_forward<>()'s 2019-04-24 10:32:49 -04:00
Behdad Esfahbod 25dd88efc6 Err, fix hb_invoke() variadic 2019-04-22 17:47:07 -04:00
Behdad Esfahbod c862a532df Add variadic arguments to hb_invoke() 2019-04-22 17:32:19 -04:00
Behdad Esfahbod c67a0d581f Add HB_RETURN 2019-04-17 10:29:10 -04:00
Behdad Esfahbod 5b33427f2c Rename HB_AUTO_RETURN_EXPR to HB_AUTO_RETURN 2019-04-16 18:28:17 -04:00
Behdad Esfahbod da293b0e59 Use HB_AUTO_RETURN_EXPR in hb_min/max 2019-04-16 18:27:25 -04:00
Behdad Esfahbod 0241a40f2a Use auto return type for hb_first/hb_second 2019-04-16 18:26:30 -04:00
Behdad Esfahbod fe30fcd228 Use hb_deref_pointer() to reduce number of overloads 2019-04-16 17:34:06 -04:00
Behdad Esfahbod c918a6706f Properly prioritize hb_hash() 2019-04-16 17:28:18 -04:00
Behdad Esfahbod 75fd845a4a Move around 2019-04-16 17:22:29 -04:00
Behdad Esfahbod 973717175d Fix priorities 2019-04-16 16:50:07 -04:00
Behdad Esfahbod 54ece299bc Use type aliasing for meta-functions, ie. those returning a type 2019-04-16 16:45:53 -04:00