LibPDF: Fix the zoom-related text scaling issue

Previously, text spacing on a page would only look correct on very
zoomed-in pages. When the page was zoomed out, the spacing between
characters was very large. The cause for this was incorrect initial
values for the Tc (character spacing) and Tw (word spacing) text
parameters. The initial values were too large, but they were only
about 3-5 pixels, which is why the error was only observable for
smaller pages.

The text placement still isn't perfect, but it is _much_ better!
This commit is contained in:
Matthew Olsson 2022-03-05 00:36:05 -07:00 committed by Andreas Kling
parent c1aa8c4a44
commit 7e1c823725
Notes: sideshowbarker 2024-07-17 17:51:04 +09:00

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Matthew Olsson <mattco@serenityos.org>
* Copyright (c) 2021-2022, Matthew Olsson <mattco@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -51,8 +51,8 @@ enum class TextRenderingMode : u8 {
};
struct TextState {
float character_spacing { 3.0f };
float word_spacing { 5.0f };
float character_spacing { 0.0f };
float word_spacing { 0.0f };
float horizontal_scaling { 1.0f };
float leading { 0.0f };
FlyString font_family { "Liberation Serif" };