| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
I know this was an issue with PS and PDF backends, but will SVG have textual data stored as entered, or are the letters broken up and set individually? |
Sorry, something went wrong.
|
It depends on the value of rcParam "svg.embed_char_paths". Embedding the character paths makes the file portable to other machines without the necessary fonts. Not embedding the character paths makes the file editable, but if the fonts aren't installed, ugliness is very likely to ensue. SVG fonts, or CSS @font-face may be a way around this -- neither was very well supported by renderers last time I looked -- the situation may be better now. But this pull request doesn't really change the status quo of what the SVG backend was capable of previously in that regard. |
Sorry, something went wrong.
|
Based on WeatherGod's comment, this commit adds support for writing out SVG fonts. These are supported in Chrome, Opera and Safari (see here: http://caniuse.com/svg-fonts). This isn't quite the holy grail we want it to be, of course, since I'm not aware of any editors (eg. Inkscape) that support SVG fonts, so the difference between this and the chars-as-paths version (which is supported in all SVG-supporting browsers) is pretty academic. |
Sorry, something went wrong.
|
The backend fails when text.ustex=True (w/ svg.fonttype="path"). Here are some quick fixes. diff --git a/lib/matplotlib/backends/backend_svg.py b/lib/matplotlib/backends/ba
index ec17053..d606855 100644
--- a/lib/matplotlib/backends/backend_svg.py
+++ b/lib/matplotlib/backends/backend_svg.py
@@ -986,7 +986,12 @@ class RendererSVG(RendererBase):
writer.end('g')
def draw_tex(self, gc, x, y, s, prop, angle):
- self.draw_text_as_path(gc, x, y, s, prop, angle, ismath="TeX")
+ if rcParams['svg.fonttype'] == 'path':
+ self._draw_text_as_path(gc, x, y, s, prop, angle, ismath="TeX")
+ else:
+ self._draw_text_as_text(gc, x, y, s, prop, angle, ismath="TeX")
def draw_text(self, gc, x, y, s, prop, angle, ismath):
clipid = self._get_clip(gc)
diff --git a/lib/matplotlib/textpath.py b/lib/matplotlib/textpath.py
index a353a2b..6955b95 100644
--- a/lib/matplotlib/textpath.py
+++ b/lib/matplotlib/textpath.py
@@ -76,7 +76,7 @@ class TextToPath(object):
texmanager = self.get_texmanager()
fontsize = prop.get_size_in_points()
w, h, d = texmanager.get_text_width_height_descent(s, fontsize,
- renderer=self)
+ renderer=None)
return w, h, d
fontsize = prop.get_size_in_points()
@@ -130,7 +130,7 @@ class TextToPath(object):
for glyph_id, xposition, yposition, scale in glyph_info:
verts1, codes1 = glyph_map[glyph_id]
- if verts1:
+ if len(verts1):
verts1 = np.array(verts1)*scale + [xposition, yposition]
verts.extend(verts1)
codes.extend(codes1)
|
Sorry, something went wrong.
|
Since _draw_text_as_text does not seem to support ismath="TeX", we may simply do def draw_tex(self, gc, x, y, s, prop, angle):
self._draw_text_as_path(gc, x, y, s, prop, angle, ismath="TeX")
|
Sorry, something went wrong.
|
Thanks @leejjoon. This is now fixed. |
Sorry, something went wrong.
… logically if not officially.
… logically if not officially.
…ode characters (such as those used for STIX sans) work even on narrow-Unicode builds of Python.
…de code points are usually represented.
…uracy of text rendering in the new SVG backend.
adding dsnu prnu
| Back | FazBrowse Home | New Git URL |
Refactoring of the SVG backend to pave the way for an interactive SVG backend down the road. Uses an XMLWriter class to keep the code simpler and more likely to produce valid XML. Numerical precision of text placement is much better. Paths are now generated in C, resulting in a significant speed-up. All text (math and otherwise) is produced using the textpath.py module.