This fixes a nasty bug that manifests on windows when building without
precompiled headers. util/stringops.h used to silently replace strdup
with a macro that's compatible with mem_free(). This header would
typically be included everywhere due to PCH, but without it the strdup
from libc would sometimes be in scope. On most platforms mem_free() is
equivalent to free(), but not on windows, because we have to use
_aligned_free() there. Attempting to mem_free() the result of a libc
strdup() would segfault in such a configuration.
Avoid the footgun by banning strdup() entirely. Maybe redefining libc
names isn't such a great idea, who knew?
* Consistently use floats in the API and internally; don't round stuff
arbitrarily.
* Use freetype's "normal" hinting algorithm.
* Implement subpixel positioning to avoid bad glyph spacing at small
font sizes.
* Improved border control: inner and outer borders can be adjusted
separately and per-font. (The "inner border" affects the "highlight"
effect used in some shaders (blue channel)).
* Fix borders causing all glyphs to be misaligned (shifted down-right)
by a constant offset.
* Various other improvements.
This should fix a rare race condition in res_load_dependency where the
dep could make its way to ires_make_dependent_one without having the
name set yet, failing an assertion there.
It also gets rid of a name parameter to load_resource, since the name is
always known at that point.
Removed static_assert_nomsg, since static_assert's message argument is
optional now. In C2X mode this uses the native _Static_assert
functionality, otherwise it falls back to a macro-based overload.
Additionally, rewrote the assert macro so it correctly marks the failing
branch as a dead end.
Introduces wrappers around memory allocation functions in `memory.h`
that should be used instead of the standard C ones.
These never return NULL and, with the exception of `mem_realloc()`,
zero-initialize the allocated memory like `calloc()` does.
All allocations made with the memory.h API must be deallocated with
`mem_free()`. Although standard `free()` will work on some platforms,
it's not portable (currently it won't work on Windows). Likewise,
`mem_free()` must not be used to free foreign allocations.
The standard C allocation functions are now diagnosed as deprecated.
They are, however, available with the `libc_` prefix in case interfacing
with foreign APIs is required. So far they are only used to implement
`memory.h`.
Perhaps the most important change is the introduction of the `ALLOC()`,
`ALLOC_ARRAY()`, and `ALLOC_FLEX()` macros. They take a type as a
parameter, and allocate enough memory with the correct alignment for
that type. That includes overaligned types as well. In most
circumstances you should prefer to use these macros. See the `memory.h`
header for some usage examples.
Most client code no longer needs to care about paddings at all, aside
from some very special cases involving dynamic creation of padded
sprites. So far we only have one known example of this in portrait_render().
This should let us optimize most of our sprites with autotrimming in the
future.
Additionally, support for deprecated offset_{x,y} keys in sprite files
has been removed.