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

When use grid with font awesome package, the output is weird #2578

Open
1 task done
tomowang opened this issue Nov 3, 2023 · 5 comments
Open
1 task done

When use grid with font awesome package, the output is weird #2578

tomowang opened this issue Nov 3, 2023 · 5 comments
Labels
bug Something isn't working layout Related to layout, positioning, etc. needs-investigation More investigation is necessary. text Text layout, shaping, internationalization, etc.

Comments

@tomowang
Copy link

tomowang commented Nov 3, 2023

Description

fa-icon("\u{f445}") and fa-chess-queen() works fine, but not fa-icon("chess-queen"),
while fa-icon("chess-queen") works fine out of grid layout.

Sample code

#import "@preview/fontawesome:0.1.0": *
#grid(
  columns: auto,
  rows: auto,
  column-gutter: 1em,
  row-gutter: 1em,
  fa-icon("\u{f445}"),  // works
  fa-chess-queen(),  // works
  fa-icon("chess-queen"),  // not work
  fa-icon("chess-queen", fa-set: "Free Solid"),  // not work
)

#fa-icon("chess-queen")  // works

The output of above code is like:

image

I now use fa-icon("\u{f445}") for a workaround.

This issue seems to be similar with duskmoon314/typst-fontawesome#2

Reproduction URL

https://typst.app/project/r4eYUzsDig3IrjArCX_02R

Operating system

Web app, macOS

Typst version

  • I am using the latest version of Typst
@tomowang tomowang added the bug Something isn't working label Nov 3, 2023
@laurmaedje laurmaedje added layout Related to layout, positioning, etc. text Text layout, shaping, internationalization, etc. needs-investigation More investigation is necessary. labels Nov 13, 2023
@duskmoon314
Copy link

In the current package, fa-chess-queen is actually fa-icon.with("\u{f445}"). So, I think the weird output has something to do with ligature. However I have no idea how to find out what is happening.

@pyxyne
Copy link

pyxyne commented Mar 14, 2024

I encountered this issue as well while using Font Awesome "manually" (without the package).

Here is a link to some simpler (?) experiments using boxes on the web app. It seems that a ligature can fail to be applied if the first line of the version before the ligature is applied overflows its container? The behavior seems quite arcane.

There is a simple workaround: place the icon in a box with an explicit, oversized width.

@SillyFreak
Copy link
Sponsor Contributor

It seems the ligature fails if this first line doesn't fit the container. However this begs the question of why the first ligature (#fa[chess]) succeeds...

That's pretty clearly because "chess" doesn't have any place where it could be broken across lines. the word "chess" overflows the box but stays on the same line, and then ligatures are applied, coincidentally making it fit the box after all.

@pyxyne
Copy link

pyxyne commented Mar 15, 2024

That's pretty clearly because "chess" doesn't have any place where it could be broken across lines. the word "chess" overflows the box but stays on the same line, and then ligatures are applied, coincidentally making it fit the box after all.

Right you are! Then I guess the specific trigger for the bug is: have text that would otherwise be a ligature be broken over multiple lines, where the first one still doesn't fit the container.

@SillyFreak
Copy link
Sponsor Contributor

I was about to edit my comment because I don't agree with myself any more... it seems to be that way, but that is arcane: my hypothesis would explain (to me) why the "chess" ligature always works, but not why that specific width leads to "chess-queen" or even "network-wired" to work...

I would assume that rendering the ligatures leads to multiple layout passes; it would be interesting to see what happens on these individual layout passes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working layout Related to layout, positioning, etc. needs-investigation More investigation is necessary. text Text layout, shaping, internationalization, etc.
Projects
None yet
Development

No branches or pull requests

5 participants