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

gpui: Add support for text in SVGs #26335

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

SethDusek
Copy link
Contributor

@SethDusek SethDusek commented Mar 9, 2025

Closes #21319
Before:
image
After:
image

Use fontdb to load system fonts and pass it to resvg renderer. This adds a small increase in startup time (around 30ms on my Linux system to traverse fonts on a cold start). In the future once cosmic-text bumps their version of fontdb we could clone the Database from CosmicTextSystem

Release Notes:

  • Added: support for rendering text in SVGs

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Mar 9, 2025
@zed-industries-bot
Copy link

zed-industries-bot commented Mar 9, 2025

Warnings
⚠️

This PR is missing release notes.

Please add a "Release Notes" section that describes the change:

Release Notes:

- Added/Fixed/Improved ...

If your change is not user-facing, you can use "N/A" for the entry:

Release Notes:

- N/A

Generated by 🚫 dangerJS against 2ab99da

@SethDusek SethDusek force-pushed the svgtext branch 2 times, most recently from 8e489e6 to f6c634e Compare March 9, 2025 03:07
@maxdeviant maxdeviant changed the title gpui: Add support for text in svgs gpui: Add support for text in SVGs Mar 9, 2025
@Angelk90
Copy link
Contributor

@SethDusek : It seems to work fine, I did a test with the following svg:

<svg xmlns="http://www.w3.org/2000/svg" width="83" height="20">
    <path
        d="M0,3 C0,1.34 1.35,0 3.0,0 L40,0 L40,20 L3.0,20 C1.35,20 0,18.65 0,17 L0,3 Z"
    />
    <text fill="#00FF00"><tspan x="0" y="14">GR</tspan></text>
    <text fill="#FF0000"><tspan x="20" y="14">RE</tspan></text>
</svg>

When trying the code online, there is no space between the texts, see the Vscode and Online image, what the space appears in the Zed.

Look comment: #21319 (comment)

Vscode:
Screenshot 2025-03-10 alle 13 15 53

Zed:
Screenshot 2025-03-10 alle 13 16 03

Online:
Screenshot 2025-03-10 alle 13 19 46

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Markdown preview: add svg text support
3 participants