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

Some SVGs don't display correctly #4204

Open
CTimmerman opened this issue Apr 14, 2024 · 2 comments
Open

Some SVGs don't display correctly #4204

CTimmerman opened this issue Apr 14, 2024 · 2 comments

Comments

@CTimmerman
Copy link

CTimmerman commented Apr 14, 2024

This one among many has some droop going on, most notably at the wrist:
requiredDiagnosticData

This flag of Serbia looks half plucked:
rs

This cog is also very droopy, unevenly so in its center:
settings
Apparently related to the number of points:
image

Spyder's splash screen should have white text and a transparent gradient revealing a laptop presentation in the top half:
splash

This folder SVG leaves its contents in the dark:
folder_image_pictures

Left Chrome, right PyGame:
Screenshot 2024-04-20 173141

This flag of Montenegro is missing the top yellow bar:
me_missing_top_bar

Chrome 123.0.6312.122 (Official Build) (64-bit) and their respective apps show those SVGs properly.

>pip show pygame
Name: pygame
Version: 2.5.2
>python   
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug  1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)] on win32

demo.py

from io import BytesIO
from PIL import Image  # pillow
import pygame

name ="shrubbery.svg"
surface = pygame.image.load(name)
pygame.image.save(surface, name + ".png")  # Works fine with SVG.
bf = BytesIO()
# pygame.image.save(surface, bf)  # PNG - ZIP according to IrfanView. Corrupts SVG!
pygame.image.save(surface, bf, "png")  # Now the droopy SVGs are fine.
im = Image.open(bf)
im.show()
@CTimmerman CTimmerman changed the title Some SVGs have malformed outputs Some SVGs have malformed outputs on save Apr 16, 2024
@CTimmerman CTimmerman changed the title Some SVGs have malformed outputs on save Some SVGs have malformed outputs on save to BytesIO without namehint Apr 16, 2024
@CTimmerman CTimmerman changed the title Some SVGs have malformed outputs on save to BytesIO without namehint Some SVGs don't display correctly Apr 20, 2024
@illume
Copy link
Member

illume commented Apr 28, 2024

Hello.

The SVG support is very limited. Unfortunately. It’s a mini svg renderer which works on only some things. The use case is when you’re constructing your SVG with the knowledge of what works.

pygame uses SDL image, which uses nanosvg.

It might be better to try something else for your use.

@CTimmerman
Copy link
Author

So the save function is in an upstream repo?

Adding libcairo libs is more work than disabling the import warnings for pygame.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants