Tim Ledbetter
9ed8c0b183
LibGfx/JPEG: Propagate errors when creating JPEGLoadingContext
...
This allows the JPEG fuzzer to make progress.
2023-10-29 21:39:29 +01:00
Andrew Kaster
86ce502ae2
LibGfx+Utilities: Add helpers to load vector fonts from Core::Resources
2023-10-29 13:12:28 -06:00
Andrew Kaster
286dc6df7f
LibGfx: Remove ability to load fonts directly from a file path
...
Users must now either pass a Core::Resource, a resource:// URI, or
a Core::MappedFile
2023-10-29 13:12:28 -06:00
Andrew Kaster
1567332e34
Userland+Tests: Remove uses of direct file loading for BitmapFont
...
Route them through Core::Resource APIs instead.
2023-10-29 13:12:28 -06:00
Andrew Kaster
d587bd0a04
LibGfx: Add helpers to load BitmapFont from Core::Resource
2023-10-29 13:12:28 -06:00
Andrew Kaster
897f4d05eb
LibGfx: Add abstraction to load BitmapFont from a FixedMemoryStream
...
We'll use this to load from a Core::Resource in a later commit.
2023-10-29 13:12:28 -06:00
Lucas CHOLLET
e721c74598
LibGfx: Provide an implementation for ImageDecoderPlugin::icc_data()
2023-10-29 07:21:10 +00:00
Andrew Kaster
d8ab9ed87c
LibGfx+Userland: Remove dependency on GUI::TabWidget from StylePainter
...
Move TabPosition into its own file, and using it into the global
namespace the same way we do for Gfx::Orientation. This unbreaks the gn
build, and out of tree builds.
2023-10-27 16:51:03 -06:00
Tim Ledbetter
4b5b8fc564
LibGfx: Use safe version of count_leading_zeroes()
in WOFF parsers
...
This guards against undefined behavior when zero is given as an
argument.
2023-10-27 07:13:51 +02:00
Nico Weber
88bd7d83ad
LibGfx: Fix off-by-one in opentype cmap format 6 parsing
...
Fixes asserts when rendering 0000037.pdf, 0000116.pdf, 0000463.pdf,
0000483.pdf, 0000506.pdf, and 0000938.pdf in 0000.zip from the
pdfa dataset.
2023-10-27 07:13:19 +02:00
Nico Weber
2ef24e883c
LibGfx: Add spec links for cmap table formats
2023-10-27 07:13:19 +02:00
Nico Weber
864172084b
LibGfx: Call dbgln() on unimplemented cmap format
2023-10-27 07:13:19 +02:00
Nico Weber
c25538b2e3
LibGfx/ICC: Implement conversion to PCS for AToB*Tags using mAB
...
...as long as the mAB tag doesn't have A curves and a CLUT.
With this, we can convert images that use AToB* tags to the profile
connection space (and then from there to, say, sRGB), if the AToB* tag
uses the mAB format.
We can't yet do this if the mAB tag has A curves or a CLUT.
We can't convert back from PCS to this space yet.
We don't yet handle AToB* tags that use mft1 or mft2 instead of mAB.
2023-10-26 11:07:43 +02:00
Nico Weber
15bddf5de3
LibGfx/ICC: Gently rewrite CurveTagData::evaluate()
...
One less redundant expression. No behavior change.
2023-10-26 11:07:43 +02:00
Tim Ledbetter
1a4df4ffe7
LibGfx/ICC: Avoid overflow when constructing NamedColor2TagData
2023-10-26 10:59:22 +02:00
Tim Ledbetter
7096ea82f9
LibGfx: Use count_leading_zeroes
to calculate nearest power of 2
...
This removes the possibility of an infinite loop.
2023-10-26 08:39:26 +02:00
Tim Ledbetter
6e4c97a328
LibGfx/WOFF: Return error if numTables
is 0
...
This is consistent with WOFF2.
2023-10-26 08:39:26 +02:00
Tim Ledbetter
52f78d07b8
LibGfx/WOFF2: Ensure numTables
is within expected range
...
An error is now returned if `numTables` is zero or greater than 4096.
While this isn't explicitly mentioned in the specification, subsequent
calculations will be incorrect if the value falls outside this range.
2023-10-26 08:39:26 +02:00
Tim Ledbetter
2311e28d63
LibGfx/BMPLoader: Mitigate potential overflows when decoding bitmap DIB
2023-10-25 05:52:29 +02:00
Tim Ledbetter
8ec26f3b54
LibGfx/BMPLoader: Account for header size when checking DIB bounds
2023-10-25 05:52:29 +02:00
Tim Ledbetter
e9be1bcd09
LibGfx/WOFF2: Reject fonts with a compressed size larger than 10MiB
...
This prevents a potential OOM condition when the header is malformed.
2023-10-24 13:45:01 +02:00
Tim Ledbetter
af633523af
LibGfx/WOFF2: Tolerate incorrect totalSfntSize
in WOFF2 header
...
The specification says that this value is for reference only, so we
should be able to load a file where this value is incorrect.
2023-10-24 13:45:01 +02:00
Tim Ledbetter
c2112cde76
LibGfx/WOFF: Ensure header totalSfntSize
matches expected value
2023-10-24 07:29:09 +02:00
Tim Ledbetter
7ee09ca49d
LibGfx/WOFF: Avoid overflow in table directory search range
...
This commit limits `WOFF::Header::num_tables` to 4096. This limitation
is not explicitly mentioned in the specification, but allowing numbers
larger than this results in an overflow when calculating
`search_range` and `range_shift`.
2023-10-24 07:29:09 +02:00
Sam Atkins
e108f394bf
LibGfx: Replace manual offsets when producing WOFF2 loca table
2023-10-22 19:42:22 +02:00
Sam Atkins
885665b3a6
LibGfx: Simplify writing to WOFF2 reconstructed glyf table
2023-10-22 19:42:22 +02:00
Sam Atkins
ad717af63d
LibGfx: Read WOFF2 transformed GLYF table buffers in-place
...
This saves us from having to allocate a buffer and copying the data,
when it's already available to us. Also, less code. :^)
2023-10-22 19:42:22 +02:00
Sam Atkins
9642a0f43a
LibGfx: Use a struct for reading WOFF2 transformed GLYF table
2023-10-22 19:42:22 +02:00
Sam Atkins
8e96902c75
LibGfx: Use OpenType offset table structs when reading WOFF2 font data
2023-10-22 19:42:22 +02:00
Sam Atkins
b73b434f80
LibGfx: Use a Header struct when reading WOFF2 font data
2023-10-22 19:42:22 +02:00
Sam Atkins
9f93ae4bfc
LibGfx: Use offset table structs when reading WOFF font data
2023-10-22 19:42:22 +02:00
Sam Atkins
d80c528eb4
LibGfx: Add structs for OpenType offset table
2023-10-22 19:42:22 +02:00
Sam Atkins
e7fe377501
LibGfx: Use a Stream to read WOFF font data
...
This lets us read structs directly from the data, instead of having to
construct them from manual offsets.
2023-10-22 19:42:22 +02:00
Tim Ledbetter
023309fdc4
LibGfx/JPEGLoader: Check array access bounds when building lookup table
2023-10-20 07:17:27 +02:00
circl
a9208a18ca
LibGfx/BMPLoader: Make sure height passed to Gfx::Bitmap is positive
...
BMP files encode the direction of the rows with the sign of the height.
Our BMP decoder already makes all the proper checks, however when
constructing the Gfx::Bitmap, didn't actually make the height positive.
Boog neutralized :^)
2023-10-19 08:31:36 +02:00
Nico Weber
a4dec92ed0
LibGfx: Add Bitmap::scaled_to_size()
2023-10-18 20:03:35 +01:00
Aliaksandr Kalenik
c2eaa0eb1c
LibGfx: Fix crash during rasterizing glyphs containing only one point
...
Fixes https://github.com/SerenityOS/serenity/issues/20179
2023-10-18 01:16:21 +02:00
Andrew Kaster
639051d34e
LibGfx: Inspect font paths using LexicalPath::has_extension()
...
This prevents us from trying to load a file named "fonts/.font"
2023-10-17 11:02:01 -06:00
Andrew Kaster
21d027129d
LibGfx: Remove the ability to load fonts from a path directly
2023-10-17 11:02:01 -06:00
Andrew Kaster
e03357308c
LibGfx: Load fonts with new Resource API instead of filesystem paths
...
The old API is in place until we remove all the users.
2023-10-17 11:02:01 -06:00
Tim Ledbetter
f4a89c31c6
LibGfx/ILBM: Explicitly fail decoding if body chunk isn't present
...
Previously, the decoder would crash in this case.
2023-10-17 10:24:27 +02:00
MacDue
95bf6ddb8e
LibGfx: Fix serializing Gfx::Bitmaps
...
a396bb0
removed the palette field but did not update the allocation size
in `Bitmap::serialize_to_byte_buffer()`. This led to a few crashes (I
noticed this from a drag/drop crash in the file manager).
Fixes #21434
2023-10-15 20:34:29 +02:00
Tim Ledbetter
9e3ee0e2b5
LibGfx/ILBM: Avoid buffer overrun when reading header chunk
2023-10-15 08:37:27 +02:00
Andreas Kling
a396bb0c0b
LibGfx: Remove indexed palette formats from Bitmap and Painter
...
Nobody was actually using these formats anymore, and this simplifies
and shrinks the code. :^)
2023-10-12 07:39:05 +02:00
Andreas Kling
bcbaad0b1d
LibGfx: Make BMP decoder always produce BGRA8888 or BGRx8888 bitmaps
...
This was the only remaining codec that produced IndexedN bitmaps.
By removing them, we'll be able to get rid of those formats and simplify
the Bitmap and Painter classes.
2023-10-12 07:39:05 +02:00
Tim Ledbetter
a673062084
LibGfx/BMPLoader: Ensure data offset cannot point past EOF
2023-10-11 14:36:12 -04:00
Sam Atkins
18dfc61280
LibGfx: Expose BitmapFont glyph data as Spans instead of raw pointers
2023-10-10 14:36:25 +02:00
Sam Atkins
80e756daef
LibGfx: Load BitmapFont data more safely
...
Previously, `load_from_memory()` just took a raw pointer to the data,
and then manually calculated offsets from that pointer. Instead, let's
use the MappedFile we already have, to stream in the data, to make
things a bit safer. We also now check that the entire file's data was
read, since if there was data left over, then either the file is bad or
we've done something wrong.
I've moved the code directly into `try_load_from_mapped_file()` since
`load_from_memory()` was only called from there. The extra indirection
wasn't adding anything.
2023-10-10 14:36:25 +02:00
Sam Atkins
8e51c7112c
LibGfx: Store BitmapFont glyph widths as a Span<u8>
...
More raw pointer removal.
2023-10-10 14:36:25 +02:00
Sam Atkins
f6c40abdb1
LibGfx: Give GlyphBitmap its rows data as Bytes
...
Instead of giving it a raw pointer to the start of the font's rows data
and an offset, give it the Bytes for its rows only.
2023-10-10 14:36:25 +02:00