Skip to content

fix(csslib): retain line height and isolate font families when scaling - #17

Merged
palmoni5 merged 5 commits into
mainfrom
palmoni5/csslib-font-scale-fidelity-20261110
Nov 10, 2026
Merged

palmoni5 merged 5 commits into
mainfrom
palmoni5/csslib-font-scale-fidelity-20261110

Conversation

@palmoni5

@palmoni5 palmoni5 commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Findings

Font.scale dropped an explicitly specified line height, reused the caller's mutable font-family list, and threw a null-check error when the font did not specify a size (partial font styles).

Fix

  • Scale a fixed-pixel line height proportionally with the font size.
  • Keep a relative line-height ratio (inPixels: false) unchanged, so the computed height still follows the scaled size.
  • Copy the family list, so later mutation of the original list does not affect the scaled font (and vice versa).
  • Allow a null size; the other style values are preserved.

Regression tests

test/font_scale_test.dart: absolute and relative line height, default line height, weight, family-list isolation, and partial fonts without a size. Three of the four tests fail on main (null-check error); the default-line-height test documents unchanged behavior.

QA

Note: Font == compares family by identity, so font.scale(1) == font is now false when a family list is set (it was already false whenever a line height was set). No caller in csslib relies on it.

No Otzaria dependency repin.

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

PR Health

Publish ✔️
Package Version Status Publish tag (post-merge)
package:csslib ⭐ 1.0.3-wip WIP (no publish necessary)
  • 16 already published.
  • 26 WIP (no publish necessary).

Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.

This check can be disabled by tagging the PR with skip-publish-check.

Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

This check can be disabled by tagging the PR with skip-changelog-check (for example, for non-user-visible changes when the package version is already at -wip).

Breaking changes ✔️
Package Change Current Version New Version Needed Version Looking good?
csslib Non-Breaking 1.0.2 1.0.3-wip 1.0.3-wip ✔️

This check can be disabled by tagging the PR with skip-breaking-check.

API leaks ⚠️

The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.

Package Leaked API symbol Leaking sources
csslib Messages csslib/parser.dart::Analyzer::new::_messages
messages.dart::Messages::mergeMessages::newMessages
csslib/parser.dart::TopLevelIncludes::expand::messages
csslib/parser.dart::TopLevelIncludes::new::_messages
csslib/parser.dart::DeclarationIncludes::expand::messages
csslib/parser.dart::DeclarationIncludes::new::_messages
csslib/parser.dart::InheritExtends::new::_messages
csslib/parser.dart::PolyFill::new::_messages

This check can be disabled by tagging the PR with skip-leaking-check.

Unused Dependencies ✔️
Package Status
csslib ✔️ All dependencies utilized correctly.

For details on how to fix these, see dependency_validator.

This check can be disabled by tagging the PR with skip-unused-dependencies-check.

License Headers ✔️
// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

Files
no missing headers

All source files should start with a license header.

Unrelated files missing license headers
Files
pkgs/html/test/differential_test.dart
pkgs/html/test/dom_parsing_test.dart
pkgs/html/test/mxss_test.dart
pkgs/html/test/noah_ark_clause_limit_test.dart

This check can be disabled by tagging the PR with skip-license-check.

Coverage ✔️
File Coverage
pkgs/csslib/lib/src/property.dart 💚 49 % ⬆️ 6 %

This check for test coverage is informational (issues shown here will not fail the PR).

This check can be disabled by tagging the PR with skip-coverage-check.

@palmoni5
palmoni5 marked this pull request as ready for review November 10, 2026 19:37
@palmoni5
palmoni5 force-pushed the palmoni5/csslib-font-scale-fidelity-20261110 branch from e6cda67 to 91172fb Compare November 10, 2026 19:42
@palmoni5
palmoni5 merged commit 629070e into main Nov 10, 2026
17 checks passed
@palmoni5
palmoni5 deleted the palmoni5/csslib-font-scale-fidelity-20261110 branch November 10, 2026 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant