Skip to content

Text in SVG with filter is rasterized at low resolution #4926

Closed

Description

@sebaseb98

Description

when I want to add a svg, which I created in Inkscape to my document, there occur some errors:

  • text gets blurry
  • arrows are missing

In the preview everything looks as expected, but when compiling these details somehow get lost

Reproduction URL

https://typst.app/project/r6AFmbX8lxASSH1fTptN19

Operating system

macOS

Typst version

  • I am using the latest version of Typst

Activity

  1. added
    bug
    on Sep 9, 2024
  2. LaurenzV commented on Sep 9, 2024

    @LaurenzV
    Collaborator

    arrows are missing

    This issue is already known and is already fixed in the newest development version, so it will work fine in the next update. See here: #3715

    text gets blurry

    The reason this is happening is because you have a guassian blur filter that is applied to the text. Since those cannot be represented natively in PDF, Typst instead resorts to rasterizing them, and in this case it unfortunately results in a very low resolution being chosen... Ideally, this should be configurable. With that said, you can avoid this in the first place by not applying a gaussian blur to the text, which you probably wouldn't want to do, anyway. 😄

  3. added
    svg
    pdf
    on Sep 9, 2024
  4. sebaseb98 commented on Sep 10, 2024

    @sebaseb98
    ContributorAuthor

    Thank you so much @LaurenzV!

    • Arrows are missing ✅
    • the blurry text:
      For future people finding this: I edited the text of the svg file and removed the filter line in the sections belonging to the text fields. This solved my problem

    Is this issue something that will be worked on - I mean technically you closed it by solving my problem but it still would be nice if svgs look the same in the compiled pdf as they look in other viewers. I leave it up to you to decide :)

  5. LaurenzV commented on Sep 10, 2024

    @LaurenzV
    Collaborator

    Yes, let’s keep it up until there is a way to adjust that from Typst.

  6. Enivex commented on Sep 10, 2024

    @Enivex
    Collaborator

    arrows are missing

    This issue is already known and is already fixed in the newest development version, so it will work fine in the next update. See here: #3715

    text gets blurry

    The reason this is happening is because you have a guassian blur filter that is applied to the text. Since those cannot be represented natively in PDF, Typst instead resorts to rasterizing them, and in this case it unfortunately results in a very low resolution being chosen... Ideally, this should be configurable. With that said, you can avoid this in the first place by not applying a gaussian blur to the text, which you probably wouldn't want to do, anyway. 😄

    I think technically it could be done with a type 1 shader? But it would be complicated and performance would probably be truly terrible....

  7. LaurenzV commented on Sep 10, 2024

    @LaurenzV
    Collaborator

    No idea, maybe it's possible somehow, but even if so there are other filters which most definitely are not possible, so it's much easier to just rasterize the SVG group as soon as we encounter at least one filter, instead of making case distinctions, especially when you have combined filters.

  8. changed the title [-]svg image not displayed correctly in compiled pdf[/-] [+]SVG image not displayed correctly in compiled PDF[/+] on Oct 8, 2024
  9. changed the title [-]SVG image not displayed correctly in compiled PDF[/-] [+]Text in SVG with filter is rasterized at low resolution[/+] on Oct 8, 2024
  10. laurmaedje commented on Oct 8, 2024

    @laurmaedje
    Member

    Yes, let’s keep it up until there is a way to adjust that from Typst.

    Do we really want to make that adjustable? That seems like a tad low-level for me. Can't we just increase the resolution to something that works well?

  11. LaurenzV commented on Oct 8, 2024

    @LaurenzV
    Collaborator

    Do we really want to make that adjustable? That seems like a tad low-level for me. Can't we just increase the resolution to something that works well?

    I guess that would work too, but we would have to adapt it depending on how big it ends up in the final PDF.

  12. EpicEricEE commented on Oct 8, 2024

    @EpicEricEE
    Contributor

    Maybe this can somehow be combined with #2554 to a single parameter for image resolutions, which for SVG then only accounts for the rasterized part?

  13. nineff commented on Oct 9, 2024

    @nineff
    Contributor

    The current rasterization resolution also leads to blurry edges at objects which should otherwise have a clearly defined corner. See the attached files.svg.pdf
    svg.svg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpdfsvg

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions