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

Excalidraw diagrams, preview: text not rendered in virgil font #44

Open
deining opened this issue Nov 4, 2023 · 1 comment
Open

Excalidraw diagrams, preview: text not rendered in virgil font #44

deining opened this issue Nov 4, 2023 · 1 comment
Assignees
Labels
🐛 bug Something isn't working
Projects
Milestone

Comments

@deining
Copy link
Contributor

deining commented Nov 4, 2023

By default, Excalidraw diagrams are rendered in Virgil font, this font is defined inside the SVG returned by kroki service:

<svg version="1.1" xmlns="http:https://www.w3.org/2000/svg" viewBox="0 0 161.4166717529297 45" width="161.4166717529297" height="45">
  <!-- svg-source:excalidraw -->
  
  <defs>
    <style class="style-fonts">
      @font-face {
        font-family: "Virgil";
        src: url("https://unpkg.com/@excalidraw/[email protected]/dist/excalidraw-assets/Virgil.woff2");
      }
      @font-face {
        font-family: "Cascadia";
        src: url("https://unpkg.com/@excalidraw/[email protected]/dist/excalidraw-assets/Cascadia.woff2");
      }
    </style>
  </defs>

In the right preview pane, text inside Excalidraw diagrams is not rendered in Virgil Font.

Excalidraw source of a diagram that reveals the deficiency:

{
  "type": "excalidraw",
  "version": 2,
  "source": "https://excalidraw.com",
  "elements": [
    {
      "id": "Yg0DY0CKfYkWhRoWGWAdX",
      "type": "text",
      "x": 755,
      "y": 291,
      "width": 141.4166717529297,
      "height": 25,
      "angle": 0,
      "strokeColor": "#1e1e1e",
      "backgroundColor": "transparent",
      "fillStyle": "solid",
      "strokeWidth": 2,
      "strokeStyle": "solid",
      "roughness": 1,
      "opacity": 100,
      "groupIds": [],
      "frameId": null,
      "roundness": null,
      "seed": 930373583,
      "version": 43,
      "versionNonce": 593511215,
      "isDeleted": false,
      "boundElements": null,
      "updated": 1699117840578,
      "link": null,
      "locked": false,
      "text": "Niolesk is great!",
      "fontSize": 20,
      "fontFamily": 1,
      "textAlign": "left",
      "verticalAlign": "top",
      "baseline": 18,
      "containerId": null,
      "originalText": "Niolesk is great!",
      "lineHeight": 1.25
    }
  ],
  "appState": {
    "gridSize": null,
    "viewBackgroundColor": "#ffffff"
  },
  "files": {}
}
@gissehel
Copy link
Contributor

gissehel commented Nov 6, 2023

Hello,

Indeed, I confirm the issue. It seems to be due to the fact that the font is an external resource, and for security reasons, the external resources are not loaded when used as an img tag.

There seems to be a workaround which is to use an object tag to embed the svg. But it has some downsides I'm currently struggling with...

@gissehel gissehel added the 🐛 bug Something isn't working label Nov 6, 2023
@gissehel gissehel self-assigned this Nov 6, 2023
@gissehel gissehel added this to the Release 1.8 milestone Nov 6, 2023
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
Main board
Awaiting triage
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants