Skip to content

Shape with the unscaled point size for trak - #942

Open
nicoburns wants to merge 2 commits into
linebender:mainfrom
DioxusLabs:devin/trak-point-size
Open

nicoburns wants to merge 2 commits into
linebender:mainfrom
DioxusLabs:devin/trak-point-size

Conversation

@nicoburns

@nicoburns nicoburns commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

The AAT trak table's tracking is looked up by the unscaled (logical pixel) font size, so we need to pass that size rather the scale (physical pixel) font size to HarfRust.

Screenshot

trak-urlbar

Changelog

Fixed

  • Fix trak table adjustments being off by the scale factor

Resolved font sizes include the layout's display scale, and that scaled size
was passed to HarfRust as the point size. The AAT `trak` table's tracking is
looked up by point size, so on a 2x display text got the tracking for twice
its size (for San Francisco: negative tracking at 11px instead of positive).

`ShapeOptions` now has a `point_size` that Parley sets to the font size before
display scaling.
@nicoburns
nicoburns requested a review from dfrg November 2, 2026 23:04
@nicoburns
nicoburns requested review from DJMcNab and tomcur November 4, 2026 18:18
@nicoburns nicoburns added the bug Something isn't working label Nov 4, 2026

@DJMcNab DJMcNab left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conceptually, I agree that this change is correct. The way this PR is structured made me need to research to work out what it's actually doing - I've made suggestions inline to more closely match my mental model.

It also isn't self-evident that storing the physical font size and then dividing it back out by the scale to get the logical font size is the right shape for this, although arguably that could just be kept as a todo?

Comment thread parley/src/shape/mod.rs
Comment on lines +62 to +63
// Resolved font sizes include the display scale, but size-dependent shaping (such as `trak`)
// must use the unscaled point size.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Resolved font sizes include the display scale, but size-dependent shaping (such as `trak`)
// must use the unscaled point size.

I don't find the term "unscaled point size" to be a self-explanatory phrase, and this isn't something subtle which requires a comment.

Comment on lines 25 to +31
/// The font size to shape the item with.
pub font_size: f32,
/// The font size in points (CSS pixels), before any display scaling.
///
/// Used by size-dependent shaping, such as the AAT `trak` table's tracking. This usually
/// equals `font_size` unless that has been multiplied by a display scale factor.
pub point_size: f32,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to see this changed to something like:

Suggested change
/// The font size to shape the item with.
pub font_size: f32,
/// The font size in points (CSS pixels), before any display scaling.
///
/// Used by size-dependent shaping, such as the AAT `trak` table's tracking. This usually
/// equals `font_size` unless that has been multiplied by a display scale factor.
pub point_size: f32,
/// The font size to shape the item with.
///
/// This is a number of device/physical points, i.e. the logical font size
/// multiplied by any active scale factor.
pub font_size: f32,
/// The logical font size in points (CSS pixels), i.e. ignoring .
///
/// Used by size-dependent shaping, such as the AAT `trak` table's tracking.
pub point_size: f32,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants