Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Michele Mostarda
    @michelemostarda
    When rendering an svg on my dev laptop (osx) I get a certain rendering, when using it on prod server based on linux ubuntu I get a really different one, despite I installed the same font set used in SVG
    Guillaume Ayoub
    @liZe
    Oh :/. Could you please share the SVG file and the renderings?
    Michele Mostarda
    @michelemostarda
    sure
    this is the svg
    Guillaume Ayoub
    @liZe
    Hm… It’s truncated. You can attach files with a simple drag and drop.
    Michele Mostarda
    @michelemostarda
    this is the rendering on osx
    d&d not working
    this is the SVG template
    tmpbx_5z59_.PNG
    This is the image rendered on osx
    Michele Mostarda
    @michelemostarda
    This is the same template, same code, generated on ubuntu
    tmpnnd4r2pc.png
    Guillaume Ayoub
    @liZe
    The fonts are different, that’s probably the only problem you have. Your Ubuntu box can’t find the Avenir-BlackOblique font.
    How did you install the font on Ubuntu?
    Michele Mostarda
    @michelemostarda
    fc-list | grep BlackOblique
    /usr/share/fonts/custom/Avenir-BlackOblique.ttf: Avenir,Avenir Black Oblique:style=Black Oblique,Regular
    /usr/share/fonts/truetype/custom/Avenir-BlackOblique.ttf: Avenir,Avenir Black Oblique:style=Black Oblique,Regular
    /home/affilio/.fonts/Avenir-BlackOblique.ttf: Avenir,Avenir Black Oblique:style=Black Oblique,Regular
    custom installation, in several locations, to be sure
    Guillaume Ayoub
    @liZe
    Can you launch fc-match "Avenir-BlackOblique"?
    Michele Mostarda
    @michelemostarda
    fc-match "Avenir-BlackOblique"
    Avenir-Book.ttf: "Avenir" "Book"
    Guillaume Ayoub
    @liZe
    That’s not the black oblique version of Avenir, that’s why it doesn’t work.
    I think that "Avenir Black Oblique" will work, instead of "Avenir-BlackOblique"
    Michele Mostarda
    @michelemostarda
    fc-match "Avenir Black Oblique"
    Avenir-BlackOblique.ttf: "Avenir" "Black Oblique"
    Guillaume Ayoub
    @liZe
    You can use this in the SVG file, it will work on Ubuntu. It will probably work on macOS too.
    Michele Mostarda
    @michelemostarda
    so I just need to replace the font family with "Avenir Black Oblique"?
    will try in a moment
    Guillaume Ayoub
    @liZe
    OK!
    Michele Mostarda
    @michelemostarda
    IT WORKS, thank you very much
    Guillaume Ayoub
    @liZe
    :)
    Michele Mostarda
    @michelemostarda
    How can I send you a beer?
    Guillaume Ayoub
    @liZe
    You can donate here, we’ll definitely think about you when drinking a beer!
    Thank you very much.
    :heart:
    Michele Mostarda
    @michelemostarda
    Done, see you for the next issue :D
    Guillaume Ayoub
    @liZe
    No problem! :beers:
    goyaldin
    @goyaldin
    Hey guys, I have a query. My application is in Java. And I want to convert our SVG files to pdf. Are there any APIs exposed through which the application can connect to CairoSVG and get the file converted in realtime?
    Guillaume Ayoub
    @liZe
    @goyaldin Hello!
    The easiest solution is probably to use the command line interface.
    You can even use standard input and output to avoid temporary files.
    goyaldin
    @goyaldin
    yeah @liZe, I saw that but that needs installation on the server machine which I can't do considering the way our application is deployed on Kubernetes. I was looking more of a sort of exposed API which can be used by applications written in a different language than python. Please let me know if there is a feasible option for such a case.
    Guillaume Ayoub
    @liZe
    @goyaldin Some people install CairoSVG in a Python web application (a simple version is ~20 lines) that gets the SVG in a request and returns the image. That’s a good solution if you don’t want to install CairoSVG in your app, but it requires you to install another app elsewhere.
    goyaldin
    @goyaldin
    thanks, @liZe for the suggestions. I will check out what can be done here
    dlwns87
    @dlwns87
    Hey! I have a question regarding SVG2PNG function in python. When it rasterizes the vector format SVG to a pixel formatPNG, it automatically adds anti-aliasing feature (adding grayscale). Do you know what algorithm(https://en.wikipedia.org/wiki/Spatial_anti-aliasing) it performs? is it based on the percentage of the region that covers the pixel? if not, could you explain how it's performed? Also, are there other anti-aliasing options? how do I change that? Thanks!
    Guillaume Ayoub
    @liZe
    Hello @dlwns87!
    CairoSVG handles the shape-rendering and text-rendering to set different antialiasing options
    It then tells Cairo to use these different antialiasing options
    Cairo provides various options (see documentation)
    You can find the supported SVG values and their corresponding Cairo options in surface.py
    dlwns87
    @dlwns87
    Thanks @liZe !