Skip to content

fontique: Fix synthesized slnt sign - #922

Merged
tomcur merged 2 commits into
linebender:mainfrom
tomcur:push-ysszszxwxmuu
Oct 22, 2026
Merged

tomcur merged 2 commits into
linebender:mainfrom
tomcur:push-ysszszxwxmuu

Conversation

@tomcur

@tomcur tomcur commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

LLM Contributions: Review, updated test.

On top of #921 due to conflicts.

slnt is counter-clockwise for a positive slant. That means we currently are trying to synthesize italics (if ital is missing) with a counter-clockwise slant. We should pass in a negative angle to get a clockwise slant. CSS's oblique is clockwise in the positive direction, so its sign also needs to be inverted. Roboto Flex clamps at 0, so it simply keeps glyphs upright when given the old values.

I think this wasn't caught because we normally match a font that is declared italic or oblique, so don't go through synthesis. The italic issue also only hits for fonts with slnt and without ital. (When the test updated here was written, I think the fact that Roboto Flex stayed upright was assumed to be an indicator that we don't synthesize; but we were attempting to synthesize in the wrong direction.)

Changelog

Fixed

Fontique

  • Italic and oblique styles using a variable font's slnt axis now slant clockwise. Previously, the synthesized slnt value had the wrong sign, which would usually leave glyphs upright.

Comment on lines -173 to +185
use parley::setting::Tag;
use parley::style::{FontFamily, FontVariation, FontVariations};

// Using Roboto Flex with slnt axis for italic/oblique effects
// TODO: FontStyle property doesn't automatically map to slnt axis for variable fonts,
// so, for this test, we use FontVariations directly
for (slnt_value, name) in [(0.0, "normal"), (-10.0, "italic"), (-10.0, "oblique")] {
let variations = FontVariations::List(Cow::Borrowed(&[FontVariation {
tag: Tag::new(b"slnt"),
value: slnt_value,
}]));
use parley::FontStyle;
use parley::style::FontFamily;

// Note Roboto Flex has a `slnt` axis but no `ital` axis, so italic and oblique get a `slnt`
// variation.
for (style, name) in [
(FontStyle::Normal, "normal"),
(FontStyle::Italic, "italic"),
(FontStyle::Oblique(None), "oblique"),
] {
let mut builder = env.ranged_builder(text);
builder.push_default(StyleProperty::FontFamily(FontFamily::named("Roboto Flex")));
builder.push_default(StyleProperty::FontVariations(variations));
builder.push_default(StyleProperty::FontStyle(style));

@tomcur tomcur Oct 20, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

With just this test change and without the fix, the snapshots render as follows (upright, as Roboto Flex's slnt has range [-10, 0]).

style_font_style_values-italic

Image

style_font_style_values-oblique

Image

@tomcur tomcur changed the title fontique: fontique: Fix synthesized slnt sign Oct 20, 2026
WilliamDGH pushed a commit to WilliamDGH/parley that referenced this pull request Oct 22, 2026
<!-- Please ensure that you have reviewed our LLM ("AI") policy at
https://linebender.org/wiki/llm-policy/.

If you did not use any LLM tools, please replace `Unspecified` with
`None`. -->
LLM Contributions: Flagged it, review.

Similar to linebender#922. The OpenType angle is counter-clockwise in the positive
direction, whereas our `FontStyle::Oblique` follows CSS and is
clockwise, i.e., we need to negate.

I think this went unnoticed because, as with linebender#922, this appears to be a
relatively cold path: no fonts on my system seem to hit this branch.

<!--
If our users need to know about this change, please describe that in the
quote block below.
What you write here will be edited by us later - it doesn't need to be
perfect.
If this change doesn't need a changelog entry, please replace the next
line with `**Changelog: None**`.
-->
**Changelog**

> ### Fixed
> #### Fontique
>
> - `FontInfo::style` now reports oblique angles with the correct sign.

@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.

Similarly, I don't think this is too impactful for me, but getting it out of open PRs is good.

@tomcur
tomcur force-pushed the push-ysszszxwxmuu branch from 3748fb8 to bf598fc Compare October 22, 2026 07:31
@tomcur
tomcur enabled auto-merge October 22, 2026 07:33
@tomcur
tomcur added this pull request to the merge queue Oct 22, 2026
Merged via the queue into linebender:main with commit 2133d78 Oct 22, 2026
24 checks passed
@tomcur
tomcur deleted the push-ysszszxwxmuu branch October 22, 2026 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants