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
Sam Atkins
a3b91378df
LibGfx: Store BitmapFont rows data as Bytes
2023-10-10 14:36:25 +02:00
Sam Atkins
415a024bc8
LibGfx: Store BitmapFont range mask as Bytes instead of pointer and size
2023-10-10 14:36:25 +02:00
Sam Atkins
533ec5a06f
LibGfx: Use Core::System helper for BitmapFont memory allocation
2023-10-10 14:36:25 +02:00
Sam Atkins
89ef3ed4ce
LibGfx: Mark BitmapFont::try_clone() as virtual
2023-10-10 14:36:25 +02:00
Sam Atkins
a1c24ef3ad
LibGfx: Remove infallible BitmapFont::create() factory function
...
This was only used in TestFontHandling. So, let's remove it, and use
the "create" name for the fallible one.
2023-10-10 14:36:25 +02:00
Tim Ledbetter
bc6638682d
LibGfx/BMPLoader: Ensure DIB size and offset are within expected range
2023-10-10 05:50:02 +02:00
Tim Ledbetter
4cc2fc4afa
LibGfx/PNGLoader: Remove redundant IHDR bit depth validation
2023-10-08 10:46:00 +02:00
Tim Ledbetter
bc6ae54b59
LibGfx/PNGLoader: Don't allow multiple consecutive IHDR chunks
2023-10-08 10:46:00 +02:00
Tim Ledbetter
c21efdfc8a
LibGfx/ICC: Avoid overflow when checking tag bounds
2023-10-07 09:48:01 +02:00
Tim Ledbetter
1abc52a689
LibGfx/DDSLoader: Avoid integer overflow in decode_color_block()
2023-10-06 22:18:27 +02:00
Tim Ledbetter
b25efa219b
LibGfx/DDSLoader: Allow image dimensions that are not divisible by 4
2023-10-06 22:18:27 +02:00
Tim Ledbetter
b64ed060d8
LibGfx/PNGLoader: Add validation for IHDR width, height and bit depth
2023-10-06 08:21:58 +02:00
Nicolas Ramz
7b4b5b735b
LibGfx/ILBMLoader: Add support for EHB mode
2023-10-03 16:09:55 -06:00
Tim Ledbetter
0b824ab7a6
LibGfx: Check bounds of color table access in TinyVGLoader
2023-10-03 22:59:38 +01:00
Tim Ledbetter
e6c1429311
LibGfx: Check bounds of color table accesses in BMPLoader
...
Previously, it was possible to crash the decoder by crafting a file
with invalid color table index values.
2023-10-03 08:33:53 +02:00
Tim Ledbetter
dd81bea9ef
LibGfx: Don't read past EOF in JPEGLoader
...
Previously, it was possible to pass JPEGLoader a crafted input which
would read past the end of the stream. We now return an error in such
cases.
2023-10-02 20:09:25 +02:00
Nico Weber
563bb9d20c
ICC: Implement Profile::to_pcs() for grayscale colors
...
There's probably a nicer way of doing this where we don't need to expand
the gray value into a full Vector3, but for now this is good enough.
Makes PDFs written by macOS 13.5.2's "Save as PDF..." feature show up.
2023-09-28 16:57:31 +01:00
Nico Weber
6b4da8680d
ICC: Move a lambda up a bit
...
No behavior change.
2023-09-28 16:57:31 +01:00
kleines Filmröllchen
062e0db46c
LibCore: Make MappedFile OwnPtr-based
...
Since it will become a stream in a little bit, it should behave like all
non-trivial stream classes, who are not primarily intended to have
shared ownership to make closing behavior more predictable. Across all
uses of MappedFile, there is only one use case of shared mapped files in
LibVideo, which now uses the thin SharedMappedFile wrapper.
2023-09-27 03:22:56 +02:00
Gabriel Nava Marino
3a071bc4dd
AK: Replace unsafe offset_pointer usage in OpenType code
...
In OpenType code, replace unsafe Span::offset_pointer with Span::offset,
which includes bounds checks.
2023-09-25 00:19:38 +02:00
MacDue
b69e8ee893
LibGfx: Add Gfx::Bitmap::apply_mask()
...
This allows applying an alpha or luminance mask to a bitmap (of the same
size) inplace.
2023-09-19 10:46:05 +02:00
Gabriel Nava
9a61041941
LibWeb: Add CanvasPath arcTo support
...
Adds initial CanvasPath arcTo support for 2D rendering contexts
https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-arcto
2023-09-17 17:22:52 +02:00
Nicolas Ramz
b8f8b22aa5
LibGfx/ILBM: Add support for uncompressed files
2023-09-14 21:00:54 +01:00
Bastiaan van der Plaat
494a8cb816
AK: Add to_radians and to_degrees math functions
2023-09-10 08:38:29 +01:00
Zaggy1024
883f44d397
LibWeb: Use CSSPixels
only when calculating radial gradient sizes
...
In order to do this, a function `sqrt(CSSPixels)` was added, which
currently just converts to floating point to run `AK::sqrt()`.
2023-09-09 13:03:11 +02:00
Andreas Kling
13db3c5ce0
LibGfx: Convert FontDatabase APIs to use FlyString
2023-09-06 11:29:03 -04:00
Andreas Kling
545d8336b8
LibGfx: Convert Font APIs to return String instead of DeprecatedString
2023-09-06 11:29:03 -04:00
Sergey Bugaev
8ebddc1ff6
LibGfx: Misc 32-bit build fixes
2023-09-06 07:21:07 -06:00
Andreas Kling
6a32634440
LibGfx: Don't crash on Typeface::get_font() with size 0
...
If someone wants a zero-sized font, we can just give it to them instead
of making a fuss.
2023-09-05 14:23:35 +02:00
MacDue
bbf66ea055
LibGfx: Remove maximum size limit for decoded images
...
It is unlikely this is needed anymore, and as pointed out things should
now safely return OOM if the bitmap is too large to allocate.
Also, no recently added decoders respected this limit anyway.
Fixes #20872
2023-09-03 14:36:54 +02:00
Andreas Kling
2cd89531f9
LibGfx: Add FontDatabase::for_each_typeface_with_family_name()
...
Some clients (e.g LibWeb) want to look up typefaces by name. Since we
already store typefaces in a HashMap keyed by family name, let's also
have a nice & fast API that takes advantage of this.
2023-08-24 14:58:22 +02:00