Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Improved output of text in SVG and PDF #353

Copy link
Copy link
Closed
@ddale

Description

@ddale
Issue body actions

Original report at SourceForge, opened Mon Dec 15 05:08:09 2008

Text output to SVG is not preserved as pure text, but instead gets output as paths. This makes it very difficult to do adjustments afterwards in e.g. Inkscape. Text should be output as text.

In PDF-files, text is output as text, which is good. These files can be imported into Inkscape and edited, which makes it possible to go around the problem with SVG files. However, kerning is applied to all text, so there is extra spacing between each letter. This makes the text look bad and should, in my mind, be removed.

As far as possible, text objects should have sensible alignment. E.g. titles, x- and y-labels should be center-aligned, and when using fig.autofmt_xdate(), tick labels should be right-aligned. Currently, all text appears to be left-aligned.

SourceForge Comments

On Fri Jun 4 17:59:52 2010, leejjoon wrote:

I believe that this is a feature request rather than a bug in the current stage.
I'm moving this to a feature requests tracker.

-JJ

On Fri Dec 19 09:18:02 2008, mdboom wrote:

Text can be output as text only if the correct fonts are available on the machine on which the SVG is viewed/edited. Since a common use case of SVG is to share in a browser, embedded paths is often the best thing. The SVG font standard would be a much better way to solve this, but as of a year ago, last time I looked, none of Mozilla, Inkscape, or cairo-rsvg had SVG font support. Progress has been made in the intervening time, but until a release version of software supports it, it's not going to be very practical or useful. It's a bit of a chicken-and-egg problem. As John pointed out, though, the svg.embed_char_paths option allows the user to choose, as long as the viewer/editor has access to the same fonts as matplotlib.

As for your second point about text kerning in PDF files -- I suspect this is an issue in the PDF-to-SVG conversion, as the kerning looks fine in the original PDF, and is in fact required for the text to look correct, since we embed only a subset of the font. I'm trying to reproduce this, but my Inkscape (0.46) doesn't seem to have PDF import as an option (though it may just be a missing dependency). Can you file a separate bug for this and attach .pdf and .svg (converted from .pdf) that exhibits this problem?

Lastly, as for alignment, I think that's a reasonable goal, but is a reasonably large task. It will require refactoring all of the backends, which are currently completely ignorant of text alignment. Unfortunately, in the general case including math text, this is probably impossible -- we may only be able to support this for regular text.

As you can see, the emphasis has always been on output for display rather than editing (the latter is simply a lot harder to get right, as with any tool that generates code).

On Thu Dec 18 05:19:10 2008, malmjako wrote:

Thanks! Setting 'svg.embed_char_paths' False gave me plain text in the SVG. However, the text is not correctly aligned. Although the texts are qualitatively in the right place, center- and right-aligned texts are somewhat off, as it seems because the width is not correctly calculated for plain text output.

SVG text objects need to have the style attribute(s) 'text-anchor' and possibly 'text-align' correctly set (although changing the latter did not have any effect on how Inkscape rendered text objects), and the reference point set to the left, center or right point of the object, i.e. the position that the text should be aligned to. No width calculation would then be necessary, resulting in correctly aligned text when using plain text output. It would also make editing the text easier, because text would flow correctly without having to realign the text object.

I have matplotlib 0.98.3 from the Enthought Python Distribution for Windows. Please try with plain text output from 0.98.5 as well!
File Added: alignment_test_0.98.3_plaintext.svg

On Wed Dec 17 06:15:11 2008, jdh2358 wrote:

When I run the alignement_test, included below, all text appears to be aligned properly in svg. I am running 0.98.5 (what version are you running?)

You can control whether matplotlib embeds the character paths or the plain text using the rc paramter 'svg.embed_char_paths'. See http://matplotlib.sourceforge.net/users/customizing.html for info on how to set the rc paramters.

SourceForge History

  • On Fri Jun 4 17:59:52 2010, by leejjoon: data_type: 560723
  • On Fri Jun 4 17:59:52 2010, by leejjoon: resolution_id: 100
  • On Thu Dec 18 16:30:55 2008, by jdh2358: assigned_to: 395152
  • On Thu Dec 18 05:19:10 2008, by malmjako: File Added: 305825: alignment_test_0.98.3_plaintext.svg
  • On Wed Dec 17 06:16:01 2008, by jdh2358: File Added: 305696: alignment_test.svg
  • On Wed Dec 17 06:15:50 2008, by jdh2358: File Added: 305695: alignment_test.py
  • On Wed Dec 17 06:15:11 2008, by jdh2358: assigned_to: 100

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.