summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGfx
AgeCommit message (Collapse)Author
2023-03-29LibGfx/OpenType: Ignore glyphs with bogus offsetsAndreas Kling
Some fonts (like the Bootstrap Icons webfont) have bogus glyph offsets in the `loca` table that point past the end of the `glyf` table. AFAICT other rasterizers simply ignore these glyphs and treat them as if they were missing. So let's do the same. This makes https://changelog.serenityos.org/ actually work! :^)
2023-03-28LibGfx: Don't render OpenType glyphs that have no outlineJulian Offenhäuser
The spec tells us that for glyph offsets in the "loca" table, if an offset appears twice in a row, the index of the first one refers to a glyph without an outline (such as the space character). We didn't check for this, which would cause us to render a glyph outline where there should have been nothing.
2023-03-25LibGfx/JPEG: More support for scans with a single componentLucas CHOLLET
Introduced in 2c98eff, support for non-interleaved scans was not working for frames with a number of MCU per line or column that is odd. Indeed, the decoder assumed that they have scans that include a fabricated MCU like scans with multiple components. This patch makes the decoder handle images with a number of MCU per line or column that is odd. To do so, as in the current decoder state we do not know if components are interleaved at allocation time, we skip over falsely-created macroblocks when filling them. As stated in 2c98eff, this is probably not a good solution and a whole refactor will be welcome. It also comes with a test that open a square image with a side of 600px, meaning 75 MCUs.
2023-03-25LibGfx/JPEG: Rename `mb_index` to `macroblock_index`Lucas CHOLLET
2023-03-25LibGfx/JPEG: Log components present in a scanLucas CHOLLET
2023-03-24LibGfx: Handle signed distance field edges betterMacDue
Small change to treat pixels outside the signed distance field bitmap as outside the shape.
2023-03-24LibGfx/PortableFormat: Use `static_cast` instead of C-style castsLucas CHOLLET
2023-03-24LibGfx/PortableFormat: Propagate errors from `decode()`Lucas CHOLLET
2023-03-24LibGfx/PortableFormat: Propagate errors from `read_image_data()`Lucas CHOLLET
2023-03-24LibGfx/PortableFormat: Propagate errors from `read_magic_number()`Lucas CHOLLET
2023-03-24LibGfx: Remove unused class `Streamer`Lucas CHOLLET
2023-03-24LibGfx/PortableFormat: Port to StreamLucas CHOLLET
Each one of `[PBM, PGM, PPM]Loader` used yet another stream-like relic. This patch ports all of them to `AK::Stream`.
2023-03-24LibGfx/PortableFormat: Use finite loops in `read_image_data`Lucas CHOLLET
The `read_image_data` function of each one of[PBM, PGM, PPM]Loader use the same structure to read an image. This patch harmonizes the three functions and use finite loops instead of reading until EOF. It allows to quit early on bloated file, but it's mainly done for refactoring purpose.
2023-03-24LibGfx: Return true from `PortableImageDecoderPlugin::initialize()`Lucas CHOLLET
Reading the two magic bytes are always done in `decode()` by calling `read_magic_number()`. So no need to read it twice.
2023-03-24LibGfx: Remove unused functions `load_from_memory` and `load_impl`Lucas CHOLLET
2023-03-24LibGfx/PortableFormat: Propagate errors from some `read_*` functionsLucas CHOLLET
These functions are: - read_width - read_height - read_max_val
2023-03-24LibGfx/PortableFormat: Make `read_whitespace` return an `ErrorOr`Lucas CHOLLET
2023-03-24LibGfx/PortableFormat: Make `read_comment` return an `ErrorOr`Lucas CHOLLET
2023-03-24LibGfx/PortableFormat: Don't accept comments that don't start with `#`Lucas CHOLLET
2023-03-24LibGfx/PortableFormat: Simplify `read_number` signatureLucas CHOLLET
The function signature goes from: `bool read_number(Streamer& streamer, TValue* value)` to `ErrorOr<u16> read_number(Streamer& streamer)` It allows us to, on one hand use `ErrorOr` for error propagation, removing an out parameter in the meantime, and on the other hand remove the useless template.
2023-03-24LibGfx: Make `PortableImageDecoderPlugin` constructor privateLucas CHOLLET
2023-03-23LibGfx: Implement simple signed distance field renderingMacDue
This is mostly a simple grayscale bilinear scale, with an extra step of computing the distance and alpha with a little smoothing. This can be used to paint more scalable UI elements/icons from rather small distance fields. A tiny 16x16 SDF seems to do a decent job for simple icons.
2023-03-23LibGfx: Add a simple GrayscaleBitmap classMacDue
This is very similar to the existing CharacterBitmap class but instead intended for small static grayscale bitmaps (such as signed distance fields).
2023-03-22LibGfx/JPEG: Replace a FIXME with some explanationsLucas CHOLLET
Calling the `ycbcr_to_rgb` function still looks unsuitable for this usage, but it does the job correctly.
2023-03-21LibGfx: Move all image loaders and writers to a subdirectoryLucas CHOLLET
2023-03-21Everywhere: Use `LibFileSystem` where trivialCameron Youell
2023-03-21LibGfx/OpenType: Do not preemptively return while searching for kerningLukasACH
The kerning value for a particular glyph may not be in the first table. Continue until we either run out of tables or we find an applicable value.
2023-03-21LibGfx/OpenType: Get size of ValueRecord from PairPos valueFormat fieldLukasACH
The stored ValueRecord in the font file only contains the fields specified in the valueFormat field of the PairPosFormat1 table. This means we need to construct the ValueRecord dynamically at runtime and cannot bit_cast it to a struct.
2023-03-21LibGfx/OpenType: Move function read_value_record, add argument streamLukasACH
read_value_record(u16 value_format, FixedMemoryStream& stream) takes a bitmask value_format that describes the available fields of the ValueRecord and a FixedMemoryStream at the location of the next ValueRecord. It then advances the stream and returns a complete ValueRecord.
2023-03-21LibWeb: Don't try to parse GPOS lookup types we don't understand yetAndreas Kling
At the moment, we only understand lookup type 2 (pair adjustment) so let's ignore lookup tables with other types. This fixes an issue where we'd choke on Noto Sans versions that come with a chained context positioning lookup table (type 8). Fixes #17924
2023-03-21LibGfx/OpenType: Fix typo in 'kern' table parsingAndreas Kling
Thanks to Timon for spotting this :^)
2023-03-21LibGfx/OpenType: Extend support for GPOS glyph positioningLukasACH
This patch extends the kerning support using the GPOS table to fonts which use PairPosFormat1. Previously, only PairPosFormat2 was supported.
2023-03-21LibGfx: Use premultiplied alpha when scaling imagesTim Ledbetter
This commit replaces usages of `Color::interpolate()` with `Color::mixed_with()` in image scaling functions. The latter uses premultiplied alpha, which results in more visually pleasing edges when images are scaled against a transparent background. These changes affect the SmoothPixels and BilinearBlend scaling modes of `Painter::draw_scaled_bitmap()` as well as the `Bitmap::scaled()` function. Fixes #17153.
2023-03-19LibGfx/JPEG: Make JPEGImageDecoderPlugin's constructor take a StreamLucas CHOLLET
This allows us to get rid of the raw pointer and size in the JPEG context struct.
2023-03-19LibGfx: Correct the type of Lookup.subtable_offsetsMatt Purnell
According to the spec (and the variable name), it should be an array of offsets, not u16s. Noticed while watching Andreas' most recent video.
2023-03-17LibGfx/OpenType: Fix bound-checkgohai
2023-03-17LibGfx/OpenType: Add some initial support for GPOS glyph positioningAndreas Kling
This patch parses enough of GPOS tables to be able to support the kerning information embedded in Inter. Since that specific font only applies positioning offsets to the first glyph in each pair, I was able to get away with not changing our API. Once we start adding support for more sophisticated positioning, we'll need to be able to communicate more than a simple "kerning offset" to the clients of this code.
2023-03-16LibGfx: Remove stray space character in a commentNico Weber
2023-03-15LibGfx: Make the Palette constructor take NNRP<PaletteImpl>Andreas Kling
2023-03-15LibGfx+Userland: Make TextAttributes::underline_style optionalSam Atkins
Rather than having a style AND a field saying whether to use the style, just make the style Optional.
2023-03-15LibGfx: Make a comment in BMPWriter more preciseNico Weber
2023-03-15LibGfx: Let decode_bmp_v5_dib() skip reserved fieldNico Weber
This has no effect in practice: decode_bmp_v5_dib() is the last thing called with the streamer object (...the streamer is passed to set_dib_bitmasks(), but that doesn't read anything off it except for DIBType::Info bitmaps, which v5 bitmaps aren't). But dib_size is 16 larger for v5 than for v4, so we should read 16 bytes. This is also useful for a hypothetical person who might look at the reading code to figure out how the writing code should look like.
2023-03-15LibGfx: Make BMPWriter code a tiny bit shorterNico Weber
2023-03-15LibGfx: Let BMPWriter optionally embed an ICC profileNico Weber
2023-03-15LibGfx: Allow BMPWriter to write v5 bmps and make that the defaultNico Weber
2023-03-15LibGfx: VERIFY correct type length in PNGChunk ctorNico Weber
2023-03-15LibGfx: Make PNGChunk::m_type a String instead of a DeprecatedStringNico Weber
It's always 4 bytes, so the data fits in a String's inline buffer. (Else I would've used a StringView.)
2023-03-15LibGfx: Use * a b s t r a c t i o n * in PNGChunk::store_type()Nico Weber
2023-03-15LibGfx: Remove reckless PNGChunk::add(T) methodNico Weber
This method added function using host byte order, which is never what we want. In practice, it was fine because it was only called from add_u8() (which is just 1 byte large) and add_as_big_endian() (since that did endian swapping before calling the method). But the method doesn't really help any and is dangerous, so remove it. No behavior change.
2023-03-15LibGfx: Remove unused PNGChunk::add_as_little_endian() methodNico Weber
PNG uses big-endian data internally.