typst / webapp-issues

Issue tracker for Typst's web app.
https://typst.app
13 stars 0 forks source link

Weird ligature + zoom font bug (Fira Code) #275

Open Andrew15-5 opened 9 months ago

Andrew15-5 commented 9 months ago

Description

Why the ligature from Fire Code only looks normal at the 150% zoom in the browser? Looks like it is being cut out or overlapped by nothingness.

100%: image 100% < zoom < 150%: image 150%: image

reported used font settings ![image](https://github.com/typst/webapp-issues/assets/37143421/e04c2282-085a-4ceb-9d33-4d5807b0835b)

Discord: 100%: image 150%: image

reported used font settings ![image](https://github.com/typst/webapp-issues/assets/37143421/ab4c9f3a-aea7-46e9-8e90-6ac6a9daf440)

OP

Reproduction URL

No response

Browsers

Firefox

OS

Linux

Andrew15-5 commented 9 months ago

It looks like it's not entirely Typst's fault (https://github.com/typst/typst/pull/3393/files): image

(so it's not only #{, but also #[ and probably something else too)

pub struct TableCell {
    /// The cell's body.
    #[required]
    body: Content,
    pub body: Content,
}
Screenshot ![image](https://github.com/typst/webapp-issues/assets/37143421/c2f96362-b470-44a7-b763-954591166e71)

Further findings

Here is a code:

#[required]
#[required]

Here is how it is made and how it looks for me (on the GitHub):

imageimage

This means that specifying a language, i.e., syntax highlighting, does make a difference, which I didn't expect.

But then looking at this (Discord):

imageimage

I now know that the hunch before only applies to that specific website and not on the concept (of syntax highlighting) in general (on all websites).

Now need to figure out what Typst and GitHub have in common and how are they different from Discord. The findings hopefully should help with that.

Andrew15-5 commented 9 months ago

Oh, ok. Now I know why I even encountered this bug (or why it appeared). I disabled the "website's fonts" in Firefox font settings:

image

Enabling it back again make this bug disappear...on GitHub, but it is still present in Typst.

I also disabled a custom CSS for discord.com that applies the Fira Code font. It didn't change anything. So it's out of the equation.

laurmaedje commented 9 months ago

Typst uses Cascadia Mono for what it's worth.

Andrew15-5 commented 9 months ago

Why does this matter if I set Fira Code in the project's settings? (under the Vim mode toggle)

laurmaedje commented 9 months ago

I doesn't, but I didn't know that you did. I missed it.

Andrew15-5 commented 9 months ago

Fair. I didn't mention it here, but I did talk about it in the contributors thread, IIRC.

Andrew15-5 commented 7 months ago

Wanted to add a bit. I see this weird ligature bug more and more on different websites. So now I just felt like checking if this is a Firefox problem or not. Well, it looks like it is, at least for a single example.

https://dioxuslabs.com/blog/release-050:

Firefox ![Firefox 1](https://github.com/typst/webapp-issues/assets/37143421/af7d9adb-bcb6-46fd-8959-d5f606d47094)
Ungoogled Chromium ![Chromium 1](https://github.com/typst/webapp-issues/assets/37143421/5a91c56e-019c-4b32-800b-09b375cd4f09)

https://github.com/typst/typst/pull/3393/files:

Firefox ![Firefox 2](https://github.com/typst/webapp-issues/assets/37143421/26d61085-4d76-479a-bd13-c65e1157bad3) Here the `||` looks normal, all of a sudden: ![image](https://github.com/typst/webapp-issues/assets/37143421/c47092cd-8467-48d3-8680-4f11468316e3)
Ungoogled Chromium ![Chromium 2](https://github.com/typst/webapp-issues/assets/37143421/2f091b10-6903-4b56-a8a0-5546c4ddc645) ![image](https://github.com/typst/webapp-issues/assets/37143421/1ac481ea-7098-4dad-9f7f-1c2390648a17)

Firefox is installed through apt and Ungoogled Chromium through flatpak. Both see my system fonts, so they both should use the same "Fira Code" font, which means that this should be a fair/clean comparison.

I also tried "FiraCode Nerd Font*" which gave the same result. So it's not a corrupted font file.

So my guess is either this is a "Fira Code only" problem (I don't know about other ligature-enabled fonts), and/or a Firefox-only problem. (And yet on Discord the code looks perfectly fine on Firefox.) Need to ask their maintainers.