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

[BUG] Inconsistencies with #fit-to-height #141

Open
KronosTheLate opened this issue Jan 22, 2024 · 8 comments
Open

[BUG] Inconsistencies with #fit-to-height #141

KronosTheLate opened this issue Jan 22, 2024 · 8 comments

Comments

@KronosTheLate
Copy link
Contributor

I figured that 1fr and 100% should do the same thing on an empty slide. But the results are different, and both look horrible:
image

The top case, using 1fr, ends up clipping. The bottom case does not clip, but reveals how both cases in fact do not use the full height of the slide.

I would expect them to do the same (on an empty slide), and to fill the height without clipping.

@KronosTheLate
Copy link
Contributor Author

I am not sure about the program state at this instant, but I found the following bug in my (hidden) terminal:

error: cannot divide by zero
    ┌─ @preview/polylux:0.3.1/utils/utils.typ:112:22
    │
112 │         let h-ratio = available-height / size.height
    │                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

That might provide a clue.

@andreasKroepelin
Copy link
Owner

You're really on a mission to find every hacky bit of Polylux, aren't you 😅 measureing stuff in Typst is somewhat error prone, I've run into issues with fit-to-width before as well. I'll see what I can do.

@ntjess
Copy link
Contributor

ntjess commented Jan 23, 2024

What theme are you using? This seems to work for me:

#import "@preview/polylux:0.3.1": *
#set page(paper: "presentation-16-9")
#polylux-slide[
  #fit-to-height(1fr)[
    Test
  ]
]

image

It still breaks on 100% though

@ntjess
Copy link
Contributor

ntjess commented Jan 23, 2024

I suspect the issue is with this unconditional space: https://github.com/andreasKroepelin/polylux/blob/main/utils/utils.typ#L75

One way to verify is using 100% - 1em

#import "@preview/polylux:0.3.1": *
#set page(paper: "presentation-16-9")
#polylux-slide[
  #fit-to-height(100% - 1.0000001em)[
    Test
  ]
]

@KronosTheLate
Copy link
Contributor Author

You're really on a mission to find every hacky bit of Polylux, aren't you 😅 measureing stuff in Typst is somewhat error prone, I've run into issues with fit-to-width before as well. I'll see what I can do.

I am actually just using it for the first time. I am enjoying it so far, but there are definitively some rough edges. I think mostly people find workaround, but I try to make issues where I find it reasonable. I hope I am not giving you too much of an headache xD

What theme are you using?
Metropolis

@andreasKroepelin
Copy link
Owner

It's great that you open issues! I just can't promise I'll have time to work on them soon.

@KronosTheLate
Copy link
Contributor Author

KronosTheLate commented Jan 24, 2024

Oh absolutely! Mainly intend to document issues that I observe, that might be only discoverable by certain use and with certain expectations, and notify "those in charge". What you do with that notification is none of my business - I have no claim to your time. If one or two of these get fixed months down the line, it is worth it to open up issues ^_^

@KronosTheLate KronosTheLate changed the title [BUG] Inconsistencies with #fit-to-width [BUG] Inconsistencies with #fit-to-height Jan 31, 2024
@KronosTheLate
Copy link
Contributor Author

The following Touying code:

#import "@preview/touying:0.2.0": *
#import "@preview/pinit:0.1.3": *

#let s = themes.metropolis.register(s, aspect-ratio: "16-9", footer: self => self.info.institution)
#let (init, slide, slides) = utils.methods(s)
#show: init
#show: slides

== Title 1
#utils.fit-to-height(1fr)[
  Test 1
]

== Title 2
#utils.fit-to-height(100%-1.0000001em)[
  Test 2
]

Produces similar looking slides, where it is now clear to me that the width is the limiting factor, which is why the full height is not used. Notably however is how the Touying examples do not clip:
image

Note that I had to use 100%-1.00000001em to avoid the content overflowing to the next line:
image

So the main issue here is actually that using 1fr clips, which it does not when using Touying. Using 100% when 1em is taken by the heading, leading to overflow, is not really a bug and can be disreguarded from this bug-report.

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

No branches or pull requests

3 participants