Files
sousa-gecko/testing/web-platform/tests/css/css-text/text-fit/spacing-ref.html
T
Kent Tamura f90a1ce80d Bug 2042394 [wpt PR 60172] - text-fit: Respect scale factor limit for additional paint-time scaling, a=testonly
Automatic update from web-platform-tests
text-fit: Respect scale factor limit for additional paint-time scaling

When 'text-fit' is applied to text with fixed spacing (e.g.,
letter-spacing in absolute units), the width does not scale linearly
with the font size. Blink handles this by applying a font-size scale and
then an additional paint-time scale to achieve a precise fit.

The paint-time scaling step previously ignored the scaling factor limit
specified in the 'text-fit' property (e.g., the '75%' in 'text-fit:
shrink per-line-all 75%'), which could cause text to shrink or grow
beyond the intended bounds.

This CL:
- Introduces a RestrictScale() helper to unify scaling limit enforcement.

- Applies this restriction to additional paint-time scaling for both
  'consistent' and 'per-line' fit targets.

- Fixes a tracking bug in the 'consistent' target case where the total
  scale factor was incorrectly calculated when paint-time scaling was
  applied.

Bug: 417306102
Change-Id: I9e919935047f22b0b617824c74b783e4073cf342
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7875484
Auto-Submit: Kent Tamura <tkent@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Reviewed-by: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1636062}

--

wpt-commits: 38e669267fcb074cbfd1c4927ebdf91723f32a43
wpt-pr: 60172
2026-05-29 15:58:04 +00:00

28 lines
1.2 KiB
HTML

<!DOCTYPE html>
<link rel="stylesheet" href="/fonts/ahem.css">
<style>
.target {
font: 20px/1 Ahem;
white-space: pre;
background: green;
margin-bottom: 10px;
}
</style>
<body>
<!-- 40 + 20 + 40 = 100 -->
<div class="target" style="width: 100px; font-size: 40px; letter-spacing: 20px;">A<span class="nospacing">A</span></div>
<!-- 50 + 10 + 50 = 110 -->
<div class="target" style="width: 110px; font-size: 50px; letter-spacing: 10px;">A<span class="nospacing">A</span></div>
<!-- 40 * 3 + 20 = 140 -->
<div class="target" style="width: 140px; font-size: 40px; word-spacing: 20px;">A A</div>
<!-- 40 * 3 + 10 = 130 -->
<div class="target" style="width: 130px; font-size: 40px; word-spacing: 10px;">A A</div>
<div class="target" style="width: 100px; font-size: 40px; letter-spacing: 20px;">A<span class="nospacing">A</span></div>
<div class="target" style="width: 110px; font-size: 50px; letter-spacing: 10px;">A<span class="nospacing">A</span></div>
<div class="target" style="width: 140px; font-size: 40px; word-spacing: 20px;">A A</div>
<div class="target" style="width: 130px; font-size: 40px; word-spacing: 10px;">A A</div>
<div class="target" style="width: 40px; letter-spacing: 10px; font-size:15px">ApA<span class="nospacing">p</span></div>
</body>