quarto-ext / fontawesome

Use Font Awesome icons in HTML and PDF documents.
https://quarto-ext.github.io/fontawesome/
MIT License
109 stars 10 forks source link

Incorrect path to fonts generated with Quarto v1.2+ #16

Closed andrewheiss closed 2 years ago

andrewheiss commented 2 years ago

I'm not sure if this is an issue with this extension specifically or an issue with Quarto v1.2's handling of external HTML resources.

When using Quarto v1.1.251, the path to the font files that is generated in all.css (site_libs/quarto-contrib/fontawesome6-0.1.0/all.css) correctly references the files that are placed in the webfonts directory one level back:

@font-face {
  font-family: 'Font Awesome 6 Free';
  ...
  src: url("../webfonts/fa-regular-400.woff2") format("woff2"), url("../webfonts/fa-regular-400.ttf") format("truetype"); }

When using Quarto v1.2.134 (and earlier iterations of v1.2), the path does not include ../webfonts/, which makes the fonts fail to load in the browser:

@font-face {
  font-family: 'Font Awesome 6 Free';
  ...
  src: url("fa-regular-400.woff2") format("woff2"), url("fa-regular-400.ttf") format("truetype"); }

image

dragonstyle commented 2 years ago

This is a legit issue in quarto itself (we are now doing additional resource discovery for CSS inside of extensions which has gone awry). I'm taking a look now!

dragonstyle commented 2 years ago

This should now be fixed as of build v1.2.140 - thank you for bringing it to our attention!

(https://quarto.org/docs/download/prerelease.html)

etiennebacher commented 2 years ago

Hello @dragonstyle, I have the same problem with quarto 1.2.150. In browser console:

downloadable font: download failed (font-family: "Font Awesome 6 Free" style:normal weight:900 stretch:100 src index:0): status=2152857618 source: file:///C:/Users/etienne/Desktop/Divers/quarto-fontawesome/foo_files/libs/quarto-contrib/fontawesome6-0.1.0/fa-solid-900.woff2 

Has this bug been reintroduced later? If it helps, here are the corresponding lines in all.css:

@font-face {
  font-family: "FontAwesome";
  font-display: block;
  src: url("fa-regular-400.woff2") format("woff2"), url("fa-regular-400.ttf") format("truetype");
...

And info about quarto:

> quarto check

[>] Checking Quarto installation......OK
      Version: 1.2.150
      Path: C:\Users\etienne\AppData\Local\Programs\Quarto\bin
      CodePage: 1252

[>] Checking basic markdown render....OK

[>] Checking Python 3 installation....OK
      Version: 3.9.12 (Conda)
      Path: C:/Users/etienne/Miniconda3/python.exe
      Jupyter: (None)

      Jupyter is not available in this Python installation.
      Install with conda install jupyter

[>] Checking R installation...........OK
      Version: 4.2.1
      Path: C:/Users/etienne/AppData/Local/Programs/R/R-4.2.1
      LibPaths:
        - C:/Users/etienne/AppData/Local/R/win-library/4.2
        - C:/Users/etienne/AppData/Local/Programs/R/R-4.2.1/library
      rmarkdown: 2.16

[>] Checking Knitr engine render......OK
dragonstyle commented 2 years ago

Hmm... It definitely shouldn't have been reintroduced :(.

Could you try removing the previously generated output (remove the foo_files directory) and trying again?

etiennebacher commented 2 years ago

I deleted foo_files directory but it didn't change anything. Here's foo.qmd:

---
title: My Awesome Document
format: html
---

## Section

This document uses Font Awesome {{< fa solid smile >}}.

And the folder organization:

.
├── foo.qmd
├── quarto-fontawesome.Rproj
└── _extensions
    └── quarto-ext
        └── fontawesome
            ├── assets
            │   ├── css
            │   │   ├── all.css
            │   │   └── latex-fontsize.css
            │   └── webfonts
            │       ├── fa-brands-400.ttf
            │       ├── fa-brands-400.woff2
            │       ├── fa-regular-400.ttf
            │       ├── fa-regular-400.woff2
            │       ├── fa-solid-900.ttf
            │       ├── fa-solid-900.woff2
            │       ├── fa-v4compatibility.ttf
            │       └── fa-v4compatibility.woff2
            ├── fontawesome.lua
            └── _extension.yml

The path in the error in browser console has a bit changed, but I don't know if it's due to the deletion of foo_files:

source: file:///C:/Users/etienne/Desktop/Divers/quarto-fontawesome/foo_files/libs/quarto-contrib/fontawesome6-0.1.0/1e21o67%C3%BA-solid-900.woff2

Extension version:

> quarto list extensions
Id                        Version    Contributes
quarto-ext/fontawesome    0.0.1      shortcodes
dragonstyle commented 2 years ago

Thank you for reporting this - the issue continued to exist on Windows specifically, which I have just fixed. This is available in the latest pre-release, here:

https://quarto.org/docs/download/prerelease.html

etiennebacher commented 2 years ago

Thank you, this works correctly now (quarto 1.2.157). For reference, need to remove previous files generated by quarto, e.g foo_files in my case (as said above).