Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: behaviors of fit-to-height and fit-to-width #131

Merged
merged 2 commits into from
Dec 5, 2024

Conversation

enklht
Copy link
Contributor

@enklht enklht commented Dec 4, 2024

This PR addresses the behaviors of the fit-to-height and fit-to-width functions, resolving issues related to #109.

Changes

  1. Changed to use the width and height parameters of measure: Replaced previous hacks using hidden labels with measure's width and height parameters to accurately determine relative sizes within a container.
  2. Removed nested box for scale: Eliminated the need for a nested box to handle the size of the scale by utilizing the reflow parameter of scale.
  3. Updated examples in the comment: The actual size of 1fr is determined by other frs in the same container, so only one 0.5fr in the container is equivalent to 100%. To avoid this confusion, I slightly changed the documented examples to use % instead.

Notes

  • In simple theme, the headings are rendered in slide preamble instead of in the header. This causes relative sizes in simple-theme to appear larger than expected.

Please review the changes, particularly the updated example and the new implementation using measure. Any feedback is welcome!

@OrangeX4 OrangeX4 added the bug Something isn't working label Dec 4, 2024
@OrangeX4 OrangeX4 self-requested a review December 4, 2024 06:22
@OrangeX4
Copy link
Member

OrangeX4 commented Dec 4, 2024

It seems that the current method does not solve the problem #109. What I am thinking is whether we can make the following code work properly (both lorems are contained on the same page):

#import "@preview/touying:0.5.3": *
#import themes.simple: *

#show: simple-theme.with(aspect-ratio: "16-9")

= Title

== First Slide

#utils.fit-to-remaining-height[#lorem(50)]

#lorem(50)

It seems that this PR does not solve this problem at present, even using #utils.fit-to-height(100%)[#lorem(50)].

Maybe we can find inspiration here: https://forum.typst.app/t/how-to-auto-size-text-and-images/1290

@enklht
Copy link
Contributor Author

enklht commented Dec 4, 2024

I apologize for the misunderstanding regarding the function's purpose.
I initially thought it was meant to adjust the content size to fit within the outer container's dimensions, rather than using the remaining space. And at least, new implementation resolves the problem that the function makes only an empty space, as explained in #109

@OrangeX4
Copy link
Member

OrangeX4 commented Dec 4, 2024

Thanks. Yes it solves part of the problem, I just thought maybe there is a way to solve all of it. Maybe we still need to think about it.

@enklht
Copy link
Contributor Author

enklht commented Dec 5, 2024

By the way, have you tried the new fit-to-height function with a small percentage parameter, like 25%? I think this is the intended behavior in the example of issue #109. Since the parameter-free function is currently too complex, it makes sense to close the bug-fix issue and open a new one for fit-to-remaining-height. What do you think?

@OrangeX4 OrangeX4 merged commit 8cc0fa9 into touying-typ:main Dec 5, 2024
@enklht enklht deleted the fix-fit-to-height branch December 6, 2024 14:03
enklht added a commit to enklht/touying that referenced this pull request Dec 6, 2024
* refactor: use substitute hacks with std functions in `fit-to-height`, `fit-to-width`

* docs: update examples to use `%` instead of `fr`
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.

3 participants