Michael Droettboom <md...@stsci.edu> writes:

> I've drafted a MEP with a plan to improve some of the text and font
> handling in matplotlib.
>
> I'd love any and all feedback.
>
> https://github.com/matplotlib/matplotlib/wiki/Mep14

I'm a bit late to the party, but here are a few thoughts:

What I see as the biggest problem in the current font-selection system
is its opaqueness. You can attempt to specify a style you'd like, but
it's up to the backend to find the relevant font. The naive user has no
way of knowing which font actually got selected, and no way of knowing
how to modify the parameters to get what they want (except if they
stumble upon the way to specify the full path to a font file). Each
backend can override the font-selection code, so e.g. the ps backend
has an option to use only "AFM fonts", meaning the core fonts built into
PostScripts viewers.

The subsetting system proposed in MEP14 (reading the font via FreeType,
then rendering or outputting the outlines into the result) would make
backends consistent with each other, as long as the same text engine is
used. Then at least the OO API could have font selection as an explicit
step, i.e. instead of 

  ax.text(x, y, s, family='serif', style='oblique')

you could write

  font = text_engine.find_font(family='serif', style='oblique')
  ax.text(x, y, s, font=font)

and also query the `font` object for what actual font is being used.
(Or would it look more like ax.text(x, y, text_engine.layout(s, font))?)

If we want to continue support for backend idiosyncracies like
ps.use_afm, I suppose those would need to be parameters to the text
engine.

  ----

The approach of subsetting fonts by writing a new Type-3 font in the
PostScript or PDF file would allow supporting any fonts that FreeType
can read, but this would lose hinting information in TTF and Type-1
fonts. I think we should at least leave open the possibility to embed
the original font (or a directly-derived subset).

  ----

The code that parses DVI files from TeX outputs not only glyphs but also
boxes, which are black rectangles used to implement things like the
underscore character and the varying-length part of the square-root
sign. To support this, I guess TextSpan.get_chars should be able to
return not only TextChar instances but also boxes.

-- 
Jouni K. Seppänen
http://www.iki.fi/jks


------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to