Commit graph

58463 commits

Author SHA1 Message Date
Tim Ledbetter 459fa8b840 LibPDF: Ensure that xref subsection numbers are u32
Previously, parsing an xref entry with a floating point subsection
number would cause a crash.
2024-01-18 15:11:42 +01:00
Nico Weber d2f3288666 LibPDF: Apply text matrix to each glyph's position
We still don't apply it to the glyph itself, so they don't show up
scaled or rotated, but they're at the right spot now.

One big thing this here hsa going for it is that the final glyph
position is now calculated with just
`ext_rendering_matrix.map(glyph_position)`.

Also, character_spacing and word_spacing are now used unmodified
in the SimpleFont::draw_string() loop. This also means we no longer
have to undo a scale when updating the position in
`Renderer::show_text()`.

Most of the rest stays pretty yucky though. The root cause of many
problems is that ScaledFont has its rendering sized baked into the
object. We want to render fonts at size font_size times scale from
text matrix times scale from current transformation matrix (but
not size from hotizontal_scaling). So we have to make that the
font_size, but then we have to undo that in a bunch of places to
get the actualy font size.

This will eventually get better when LibPDF moves off ScaledFont.
2024-01-18 14:01:30 +01:00
Nico Weber 09a91e54c0 Tests: Add a pdf with text rotation
As usual, lovingly hand-written, with offsets fixed up with

    mutool clean Tests/LibPDF/rotate.pdf  Tests/LibPDF/rotate.pdf
2024-01-18 14:01:30 +01:00
Nico Weber f54b0e7c22 LibPDF: Don't accidentally put horizontal_scaling in places
Fonts should have size font_size times total scaling. We tried to
get that by computing text_rendering_matrix.x_scale() * font_size,
but text_rendering_matrix.x_scale() also includes
horizontal_scaling, which shouldn't be part of font size.

Same for character_spacing and word_spacing.

This is all a big mess that's caused by LibPDF using ScaledFont,
which requires scaling to be aprt of the text type. I have an
in-progress local branch that moves LibPDF to directly use VectorFont,
which will hopefully make this (and other things) nicer. But first,
let's get this right, and then make sure we don't regress it when
things change :^)
2024-01-18 14:01:30 +01:00
Nico Weber abda5e66f6 LibPDF: Scale delta_x by horizontal_scaling in Renderer::show_text()
While PDFFont::draw_string() already returns a position scaled by
horizontal_scaling, the division by text_rendering_matrix.x_scale()
(which also contains the scaling factor) undid it. Reapply it.

Fixes the horizontal layout of the line
"should be the same on all lines: super" in Tests/LibPDF/text.pdf.
2024-01-18 14:01:30 +01:00
Nico Weber 470d1d8dcf LibPDF: Fix order of parameter, text, and current transform matrix
PDF spec 1.7 5.3.3 Text Space Details gives the correct multiplication
order: parameters * textmatrix * ctm.

We used to do text * ctm * parameters
(AffineTransform::multiply() does left-multiplication).

This only matters if `text_state().rise` is non-zero. In practice,
it's almost always zero, in which case the paramter matrix is a
diagonal matrix that commutes.

Fixes the horizontal offset of "super" in Tests/LibPDF/text.pdf.
2024-01-18 14:01:30 +01:00
Nico Weber 6c65c18c40 LibPDF: Add spec ref to Renderer::calculate_text_rendering_matrix() 2024-01-18 14:01:30 +01:00
Nico Weber 8507151850 Tests/LibPDF: Make text.pdf also use Tz, Tc, Tw, Ts operators
These set the horizontal scale factor, character spacing, word
spacing, and text rise respectively.

Also add a global scale transform, and set a text transform matrix
with a scale for some of the text.
2024-01-18 14:01:30 +01:00
Lucas CHOLLET 75d87ccf5f LibGfx/TIFF+CCITT: Start to decode CCITT Group 3 images
We currently only support 1D Group 3, but that's a start.

The test case was generated with GIMP (it happens to be 1D by chance).
2024-01-18 14:00:56 +01:00
Lucas CHOLLET 1cc10a6245 LibGfx/CCITT: Extract the code to decode a single CCITT3 1D line
This will be handy for the pure CCITT Group 3 decoder too :^)
2024-01-18 14:00:56 +01:00
Lucas CHOLLET 6a94b09029 LibGfx/TIFF: Make strip decoders take the strip height
While most decoders do not require it, it is necessary for the CCITT
Group 3 decoder.
2024-01-18 14:00:56 +01:00
Lucas CHOLLET 26494600c4 LibGfx/TIFF: Parse the T4Options CCITT field
This field is described in: Section 11: CCITT Bilevel Encodings.
2024-01-18 14:00:56 +01:00
Lucas CHOLLET edffdc35a9 LibGfx/TIFF+CCITT: Clarify naming of compression type 2
Type 2 <=> One-dimensional Group3, customized for TIFF
Type 3 <=> Two-dimensional Group3, uses the original 1D internally
Type 4 <=> Two-dimensional Group4

So let's clarify that this is not Group3 1D but the TIFF variant, which
is called `CCITTRLE` in libtiff. So let's stick with this name to avoid
confusion.
2024-01-18 14:00:56 +01:00
Lucas CHOLLET 9b50b5793b LibGfx/TIFF: Factorize code to verify that CCITT images are correct 2024-01-18 14:00:56 +01:00
Lucas CHOLLET a9a5ca6754 LibGfx/TIFF: Expose default value for numerical tags too
Due to the integer -> bool conversion rule, the condition was wrong. We
actually want to test for a not `None` state.
2024-01-18 14:00:56 +01:00
Bastiaan van der Plaat 5f5ac48908 LibWeb: Format all .idl files to use four space indentation 2024-01-18 14:00:06 +01:00
ronak69 d720fb8845 CMake: Set CMAKE_COLOR_DIAGNOSTICS to ON for colored diagnostics
This patch removes the explicit compile flag that only works for g++
(`-fdiagnostics-color=always`; clang++ needs `-fcolor-diagnostics`) and
uses CMake's built in variable that can control color output.

Now both compilers should output colored diagnostics.
2024-01-18 13:59:35 +01:00
Nicolas Ramz 534eeb6c4b LibGfx/ILBMLoader: Properly display images with a bitplane mask
Images with a display mask ("stencil" as it's called in DPaint) add
an extra bitplane which acts as a mask. For now, at least skip it
properly. Later we should render masked pixels as transparent, but
this requires some refactoring.
2024-01-18 13:59:17 +01:00
Tim Ledbetter 45181e8eaf Fuzzers: Continue if frame is malformed in GIF fuzzer 2024-01-18 13:59:04 +01:00
Tim Ledbetter 4173a9880f Fuzzers: Don't disable debug logging in GIF fuzzer if GIF_DEBUG is set 2024-01-18 13:59:04 +01:00
Tim Ledbetter d186582d30 LibAudio: Avoid UAF when loading WAV metadata 2024-01-17 16:09:59 -05:00
Bastiaan van der Plaat dc2233ef7a Ladybird+WebContent: Add chrome command line and exe path passing 2024-01-17 17:32:05 +01:00
Bastiaan van der Plaat c94fc7d3b0 Ladybird: Change default new tab URL to about:newtab 2024-01-17 17:32:05 +01:00
Aliaksandr Kalenik a22ef086f5 LibWeb/CSS: Support calc() in grid placement values
Fixes reduction in https://github.com/SerenityOS/serenity/issues/22802
but does not result in visual improvement on https://kotlinlang.org/
2024-01-17 17:26:55 +01:00
Aliaksandr Kalenik c254de3509 LibWeb: Remove duplicated code in grid auto track counting
This refactoring simplifies the resolution of minimum and maximum sizes
during the counting of auto tracks.

No changes in behavior are intended.
2024-01-17 17:25:58 +01:00
Andreas Kling 954c4496b1 LibWeb: Avoid more UsedValues hash lookups in BFC and IFC 2024-01-17 17:25:48 +01:00
Andreas Kling 7a34f1a4e2 LibWeb: Add pointer from BFC::FloatingBox to its UsedValues
This will allow us to skip a lot more hash lookups.
2024-01-17 17:25:48 +01:00
Andreas Kling 57fd494195 LibWeb: Use UsedValues containing block pointer in float layout 2024-01-17 17:25:48 +01:00
Andreas Kling 80ccfc51c2 LibWeb: Use UsedValues containing block pointer in many FC helpers 2024-01-17 17:25:48 +01:00
Andreas Kling 8e31bfb83c LibWeb: Give UsedValues a pointer to containing block UsedValues
This will allow us to skip hash lookups when traversing the containing
block chain and looking at everyone's UsedValues.
2024-01-17 17:25:48 +01:00
Aliaksandr Kalenik 0a09ff698f LibWeb: Fix accounting for gaps in auto-fit count calculation in GFC
Fixes a bug where gaps between repeated tracks were accounted for only
once instead of multiple times, corresponding to the repeat count.

Fixes https://github.com/SerenityOS/serenity/issues/22823
2024-01-17 15:15:06 +01:00
Nico Weber 13f007aadb LibPDF: Tweak vertical position of truetype fonts
The vertical coordinates for truetype fonts are different somehow.
We compensated a bit for that; now we compensate some more.

This is still not 100% perfect, but much better than before.
2024-01-17 08:44:07 +00:00
Nico Weber b5aef8e404 MacPDF: Add Debug menu items to hook up Clip Images/Paths settings 2024-01-17 08:42:56 +00:00
Nico Weber 1845a406ea LibPDF: Add debug settings for clipping paths and images 2024-01-17 08:42:56 +00:00
Nico Weber 2d8a22f4b4 LibPDF: Clip images too
Since we can't clip against a general path yet, this clips images
against the bounding box of the current clip path as well.

Clips for images are often rectangular, so this works out well.

(We wastefully still decode and color-convert the entire image.
In a follow-up, we could consider only converting the unclipped
part.)
2024-01-17 08:42:56 +00:00
Nico Weber 5615a2691a LibPDF: Extract activate_clip() / deactivate_clip() functions
No behavior change.
2024-01-17 08:42:56 +00:00
MacDue d55867e563 LibPDF: Fix paths with negatively sized re (rect) commands
Turns out the width/height in a `re` command can be negative. This
results in rectangles with different winding orders. For example, a
negative width results in a reversed winding order.

Previously, this was lost by passing the rect through an
`AffineTransform` before constructing the path. So instead, this
constructs the rect path, and then transforms the resulting path.
2024-01-16 21:31:20 +00:00
Aliaksandr Kalenik 6a4dd8fa47 LibWeb: Account for gaps in grid container's intrinsic size calculation
Fixes https://github.com/SerenityOS/serenity/issues/22804
2024-01-16 21:54:23 +01:00
Aliaksandr Kalenik f529188fb8 LibWeb: Resolve CSS transform lengths against padding rect
Fixes https://github.com/SerenityOS/serenity/issues/22797
2024-01-16 21:54:10 +01:00
Aliaksandr Kalenik ef0c390b79 LibWeb: Resolve CSS transform properties during layout commit
Now, instead of resolving "transform" and "transform-origin" during the
construction of the stacking context tree, we do so during the layout
commit.

This is part of a refactoring effort to make the paintable tree
independent from the layout tree.
2024-01-16 21:54:10 +01:00
Nico Weber aab3cd33f6 Meta/run.py: Fix grammar in method names
"Setup" is the noun, "to set up" is the verb.

No behavior change.
2024-01-16 09:55:42 -05:00
Nico Weber 0e91682283 LibPDF: Be more forgiving about trailing image data
The predictor code assumed that all stream data is image data
(...which would make sense: trailing data there is wasted space).

But some PDFs have trailing data there, e.g. 0000257.pdf, so be
forgiving about it.
2024-01-16 09:55:11 -05:00
hanaa12G 55b971e133 LibVT: Emit different sequences while in keypad application mode 2024-01-16 17:55:17 +03:30
hanaa12G dea61d95db LibVT: Mask out keypad keys while in keypad application mode 2024-01-16 17:55:17 +03:30
hanaa12G d6c8b4d279 LibVT: Adjust some method names to align with documentation
Align DECKPAM and DECKPNM method names with those from
https://vt100.net/docs/vt100-ug/chapter3.html#DECKPAM
2024-01-16 17:55:17 +03:30
Sam Atkins aeed1e04ca HackStudio: Make Files and Classes tabs have the same border width
This is something I messed up, back in
77ad0fdb07. Oops!
2024-01-16 15:23:07 +01:00
Andreas Kling 2d50dee920 LibWeb: Use correct max-size in intrinsic sizing of column flex layout
Regressed in 72dd37438d
2024-01-16 13:14:00 +01:00
Aliaksandr Kalenik 9e23503c9c LibWeb: Align with spec "stretch auto tracks" step in GFC
Now, we will evenly distribute the remaining free space across tracks
using the auto max-tracks sizing function, exactly as the specification
states. Many tests are affected, but they are not visually broken.

Fixes https://github.com/SerenityOS/serenity/issues/22798
2024-01-16 13:13:47 +01:00
Sam Atkins dd9f3c980f HackStudio: Absolutize project paths before opening them
Relative paths cause issues in a couple of ways:
- `open_project()` sets the working directory to that path, and then
  opens a project at that same path. This means opening `./foo` goes to
  `./foo`, and then tries to open `./foo/foo`.
- Even with that rearranged, we would then have issues with trying to
  open files, because again we would try to open `./foo/foo/file`
  instead of `./foo/file`.
- The relative path would get saved in "Recent Projects" which is wrong.

Absolutizing the path before using it means we avoid these issues, and
without having to rearchitect everything. :^)
2024-01-16 12:39:28 +01:00
Sam Atkins 6db4d3b898 HackStudio: Remove UTF-8 validation for project path 2024-01-16 12:39:28 +01:00