Skip to content

Gradient Part 5c: Fix gradient rotation on text & math#2606

Merged
laurmaedje merged 20 commits intotypst:mainfrom
Dherse:gradient-math-fix
Nov 8, 2023
Merged

Gradient Part 5c: Fix gradient rotation on text & math#2606
laurmaedje merged 20 commits intotypst:mainfrom
Dherse:gradient-math-fix

Conversation

@Dherse
Copy link
Contributor

@Dherse Dherse commented Nov 7, 2023

Math mode uses a different transform which was not compatible with the old way of handling gradients on text. Now there is an added parameter on TextItem which keeps track of whether the text item is part of a math equation. I would have preferred if math and text shared the transform "system" but I can't figure out why they differ especially since this is specific to PDF. In any case, that should fix the issue while remaining compatible.

@Dherse Dherse changed the title Gradient Part 5c: Fix gradient on math Gradient Part 5c: Fix gradient rotation on math Nov 7, 2023
@Dherse
Copy link
Contributor Author

Dherse commented Nov 7, 2023

This also changes the way rotation of gradient is handled in PDF to use the same technique used for SVGs. This technique, I have found, tends to bit more robust to weird transform matrices which should help too.

@laurmaedje
Copy link
Member

I would have preferred if math and text shared the transform "system" but I can't figure out why they differ especially since this is specific to PDF.

I totally agree. I'm really not a fan of the new math parameter that is chained through everywhere. I think, even if it's tricky, finding out why the transforms differ and fixing that is the way to go.

@Dherse
Copy link
Contributor Author

Dherse commented Nov 7, 2023

Ok now it's truly fixed in a way that should also avoid any future bug that are PDF transform related.

@Dherse Dherse changed the title Gradient Part 5c: Fix gradient rotation on math Gradient Part 5c: Fix gradient rotation on text & math Nov 7, 2023
@Dherse
Copy link
Contributor Author

Dherse commented Nov 7, 2023

This actually fixes a bunch of potential bugs with gradients on text that nobody seems to have noticed yet. At least they're already fixed, sorry for introducing bugs, but transforms are hard sigh

@laurmaedje laurmaedje merged commit d7fea70 into typst:main Nov 8, 2023
@laurmaedje
Copy link
Member

Thank you, it's great than you managed to make it simpler instead of more complicated than the previous state. :)

@Dherse
Copy link
Contributor Author

Dherse commented Nov 8, 2023

Thank you, it's great than you managed to make it simpler instead of more complicated than the previous state. :)

@laurmaedje I am mostly glad I managed to fix it "at the source" and prevent other similar bugs from eventually creeping up!

@Dherse Dherse mentioned this pull request Nov 18, 2023
13 tasks
@Dherse Dherse deleted the gradient-math-fix branch November 27, 2023 11:20
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