Commit Graph

2203 Commits

Author SHA1 Message Date
Sean Barrett 5bf78b8f23 stb_truetype: fix bad declaration 2021-07-09 05:37:56 -07:00
Sean Barrett 99e13217ce Merge branch 'dev' of https://github.com/nothings/stb into dev 2021-07-09 05:37:19 -07:00
Sean Barrett 4bb337ddf0 test including stb_c_lexer header independnet of implementation 2021-07-09 05:36:53 -07:00
Fabian Giesen 2b667e4d30 stb_rect_pack: Several minor fixes
1. Always use large rects mode to avoid definition of stbrp_coord
   in header file depending on implementation #defines
2. Expose STBRP__MAXVAL to users
3. Fix value of STBRP__MAXVAL for large rect mode (stbrp_coord
   is a 32-bit int, so needs to be <=0x7fffffff, 0xffffffff
   doesn't work)
4. Add comment at the top about which #define to set to get the
   implementation.

Fixes issue #1143, or rather, replaces that pull request.
2021-07-08 00:32:38 -07:00
Fabian Giesen 1e1efbdc75 stb_image_write: Make globals extern "C" in C++
Fixes issue #921
2021-07-08 00:24:00 -07:00
Fabian Giesen d2476c3845 stb_sprintf: GCC compilation fix
Fixes issue #1010.
2021-07-08 00:21:08 -07:00
Fabian Giesen 06b6009e3b stb_sprintf: Fix unused variable warning with STB_SPRINTF_NOFLOAT
Fixes issue #986.
2021-07-07 15:51:56 -07:00
Fabian Giesen 3be65f1c0c stb_sprintf: Small simplification
This was intentional but we might as well just set cs=0
directly here.

Fixes issue #997.
2021-07-07 15:43:47 -07:00
Fabian Giesen 013884b53b stb_sprintf: Fix string length calc
Factor out string length computation into helper func, comment
it a bit more, always use a limit to avoid 32b unsigned overflow,
and avoid reading past the bounds of non-0-terminated strings given
with specified precision.

Fixes issue #966.
2021-07-07 15:38:42 -07:00
Fabian Giesen 2af2e69219 stb_ds: Fix addn when n=0
In this case, the array pointer may still be 0 even after the
maybegrow.

Fixes issue #1015.
2021-07-07 14:59:13 -07:00
Fabian Giesen b14a80784c stb_image_write: Support writing BMPs with alpha
Fixes issue #1159.
2021-07-07 14:35:46 -07:00
Fabian Giesen 315e979f34 stb_truetype: Add protoype for stbtt_FindSVGDoc
Fixes issue #979.
2021-07-07 04:10:52 -07:00
Fabian Giesen 8af4d40950 stb_c_lexer: Move token enum defn to header portion
Required some tinkering, hope I didn't mess the logic up.

This now requires the config section to be set for the header
file, and different sites that include it should agree on what
the values are. This is kind of iffy but hard to avoid.

Fixes issue #647.
2021-07-07 04:02:32 -07:00
Fabian Giesen afc9c16bfd stb_truetype: Change spelling of fallthrough comment
To pacify GCC warnings at -Wimplicit-fallthrough=4. Why the
all-caps version works and the others don't, I'm not sure; the
GCC manual page lists regular expressions that GCC is checking for
but does not say which regular expression syntax variant it's using,
whether it's looking for a substring match or a full match for
the comment, and what exactly the text being matched against is
for a single-line comment. Sigh.

Fixes issue #507.
2021-07-07 03:43:15 -07:00
Fabian Giesen 46c259ff90 stb_sprintf: PUBLICDEC on declarations, as intended
The code was using PUBLICDEF on both declarations and
definitions.

Fixes issue #458.
2021-07-07 03:32:04 -07:00
Fabian Giesen 9fe3b4bb52 stb_truetype: GPOS handling formatting changes
Was using 4-character spaces and otherwise formatted unlike the
rest of the code, fix this. Also get rid of the outer switch in
GetGlyphGPOSInfoAdvance with just one case; just use an if.
No behavioral changes.
2021-07-07 03:12:33 -07:00
Fabian Giesen 1252a3e641 stb_truetype: GPOS parsing fixes
Glyphs not assigned a glyph class should default to class 0 as
per the OpenType spec. Also, change the code to treat malformed
data as an error to be handled, not an assert, and change the
way the version checking works.

Fixes the issue mentioned in PR #1035. Also, this part of the
code is indented incorrectly; will fix that in a subsequent
commit.
2021-07-07 02:58:28 -07:00
Fabian Giesen e590505492 stb_truetype: GCC warning fix
GCC warns about a potentially uninitialized variable here. It's
not (or at least I don't see how), but fix it anyway.
2021-07-07 02:45:41 -07:00
Andrew Kensler db6e91b7d8 Store uncompressed if compression was worse
If the data was uncompressible and this deflate implementation expanded
by more than the overhead of simply storing it uncompressed, fall back
to deflate's uncompressed storage mode.  This bounds the maximum deflated
size at the original size plus an overhead of 6 fixed bytes with another
5 bytes per 32767 byte block.

Fixes issue #948.
2021-07-07 02:32:46 -07:00
Fabian Giesen 14c224c84e stb_image_resize: Remove ill-advised asserts.
These mostly add very little and have caused problems for people,
nor does it make sense to require this when the underlying
computations are performed in floating-point arithmetic depending
on ratios of user-passed in image dimensions.

Arbitrary absolute epsilons here would just be garbage; we could
try and compute desired relative error bounds based on the
determined scale values, but this still leaves the questions of
what purpose this would even serve, which is unclear.

Leave the filter kernel asserts as comment for documentation
of what the behavior would be with exact math, but don't actually
bother asserting here.

Fixes issue #736.
2021-07-07 01:45:29 -07:00
Fabian Giesen e7f9f92c9d stb_divide: Update changelog 2021-07-07 01:33:35 -07:00
Fabian Giesen ab69a04d0a Merge branch 'dev' of github.com:nothings/stb into dev 2021-07-07 01:30:58 -07:00
Fabian Giesen c38ec91d22 stb_divide: Fix integer overflow issues
We've established the signs of values before so we can carefully
jiggle the expressions to be guaranteed overflow-free; the tests
for <0 here were meant to check if the value was "still negative",
i.e. if the sum did not underflow below INT_MIN, and we can
rewrite that using algebra to be overflow-free.

We need an extra case in the Euclidean dvision for
INT_MIN / INT_MIN which is a bit annoying but trivial; finally,
for two's complement platforms, note that abs(x) = (x > 0) ? x : -x
does not work (since for x=INT_MIN, -x still gives INT_MIN),
but the equivalent formulation for _negative_ absolute value
(x < 0) ? x : -x is always in range and overflow-free, so
rewrite the relevant expressions using that negative absolute
value instead.

Fixes issue #741.
2021-07-07 01:27:15 -07:00
Sean Barrett fc5b791228 stb_truetype: fix SDF handling of multiple move_to commands in a row 2021-07-07 01:21:37 -07:00
Sean Barrett ca0e6d06d8 stb_c_lexer: don't define default macro definitions on non-implementation includes 2021-07-07 00:57:43 -07:00
Sean Barrett 84e7a4ae24 stb_c_lexer: fix NUL eof test so it compiles 2021-07-07 00:43:40 -07:00
Sean Barrett 08e4b18650 Merge branch 'dev' of https://github.com/nothings/stb into dev 2021-07-07 00:39:10 -07:00
Sean Barrett a32aeefd6b Merge branch 'patch-1' of https://github.com/t-mw/stb into dev 2021-07-07 00:34:43 -07:00
Sean Barrett 95372dc4f8 stb.h: fix bug in stb_readdir caused by change to stb_strncpy 2021-07-07 00:29:19 -07:00
Randy dcb1116f13 ossfuzz: improve code coverage
fix .gif pattern matching
add netpbm test images derived from the public domain pngsuite
added more image types (downloaded in Dockerfile)
2021-07-06 21:50:18 -07:00
Randy b77192742d oss-fuzz: integrate with CIFuzz 2021-07-06 21:47:13 -07:00
Devendranath Thadi 9f98546022 Travis-ci: added support for ppc64le 2021-07-06 21:45:40 -07:00
Fabian Giesen 6ca560c9af stb_image: Update documentation for de-iPhone flag
It's default off, not default on.

Fixes issue #651.
2021-07-06 21:40:31 -07:00
Fabian Giesen 15d2dc5c51 stb_tilemap_editor: Update contributors 2021-07-06 21:25:41 -07:00
Werner Stoop 77eedd4fcf stb_tilemap_editor: Several fixes.
Re-added calls to `stbte__hittest()`, fixed some compiler errors.
Also fixed some GCC warnings about unused variables when
STBTE__COLORPICKER and STBTE_ALLOW_LINK is not defined.
2021-07-06 21:24:25 -07:00
Fabian Giesen 21bfcbbc3d stb_tilemap_editor: Update version, credits 2021-07-06 21:07:34 -07:00
Rob Loach b18c989dc2 stb_tilemap_editor: Fix variable usage 2021-07-06 21:06:39 -07:00
Fabian Giesen 7e10880f53 stb_image: Update credits 2021-07-06 20:47:30 -07:00
Vladimír Vondruš 2c8cd33e2e stb_image: make unpremultiply and de-iPhone flags thread_local.
Follows the change done for vertical flipping in
eb48fbdced for these two options as well.
2021-07-06 20:46:41 -07:00
Fabian Giesen b691fc4305 stb_truetype: Remove dead assignments
Confirmed from the OpenType spec that there's nothing missing
here. (These were just annotations listing the total sizes of
the tables, but this is not used for anything here.)

Fixes issue #704.
2021-07-06 20:39:35 -07:00
ocornut 44f046af0c stb_textedit: Fix paste failure handling breaking undo stack
Could lead to freezes.

Fixes issue #734.
2021-07-06 20:30:55 -07:00
Fabian Giesen eb677dda6e stb_textedit: Update credit, version history 2021-07-06 20:25:16 -07:00
Louis Schnellbach 85bc8060be Support for Page Up/Down
(changes from ocornut/imgui/commit/ec945f44)
2021-07-06 20:23:26 -07:00
Fabian Giesen 76a0a00874 stb.h: _MSC_VER in readdir_raw -> _WIN32
For MinGW.
2021-07-06 20:19:51 -07:00
Fabian Giesen e817b4a998 stb_ds: Fix typos in docs. 2021-07-06 20:17:12 -07:00
Fabian Giesen ba5cc43d33 stb_truetype: Fix stbtt__solve_cubic comment 2021-07-06 20:10:22 -07:00
Fabian Giesen a5d989c358 stb_truetype: Tabs->spaces
Whitespace only.
2021-07-06 20:07:12 -07:00
Fabian Giesen 1e82fd4a4e stb_image: BMP v4/v5 header parsing fixes
As per MS's own docs, should ignore the r/g/b bitmasks in the
header unless BI_BITFIELDS compression is selected. Factor out
setting the default masks since that now exists in two branches.

Add some more checking for unsupported compression formats and
illegal bpp/compression combinations while I'm at it.

Fixes issue #783.
2021-07-04 22:17:57 -07:00
Fabian Giesen 17bc84e15d stb_image: stbi__bmp_info only rewind stream on error
To be consistent with the other info functions.

Fixes issue #892.
2021-07-04 21:47:13 -07:00
Fabian Giesen ab18d9b250 stb_image: Fix two bugs found via VC++ /analyze
Also fixes issue #366.
2021-07-04 21:42:44 -07:00