Re: Issue 144 in plotinum: Allows fonts to be loaded from io.Reader

9 views
Skip to first unread message

plot...@googlecode.com

unread,
Aug 17, 2014, 10:29:10 AM8/17/14
to plotinum...@googlegroups.com
Updates:
Status: Accepted
Cc: plotinum...@googlegroups.com

Comment #1 on issue 144 by burns...@gmail.com: Allows fonts to be loaded
from io.Reader
http://code.google.com/p/plotinum/issues/detail?id=144

I am interested in this. The font situation in vg is awful. The problem is
that I don't know how to embed fonts into PDF and EPS files, so vg just
allows the fonts in FontMap, which are guaranteed to be supported by PDF
and PS. I don't know SVG, but it may have similar issues. The vgimg backend
is the only one that I am certain can support any arbitrary TrueType font.
Your proposal will allow the loading of arbitrary fonts. I have a few
questions about it.

Are you only loading the Plotinum-supplied fonts with font names that match
those in vg.FontMap? If so, then this is going to be perfectly safe for all
of the vg backends. (By the way, the fonts that are distributed with
Plotinum are from Ghostscript and are distributed under the GPL--whatever
that means for a font. If you add them into the binary of your program your
program probably needs to be under the GPL too.)

If no to the above question, are you using only the vgimg backend (are you
only generating raster images like PNG, etc.)? If so, then you probably
don't notice any problems. Have you tried saving a plot as a PDF, EPS, or
SVG file? I would be very surprised if it worked.

If we accept something like this change into Plotinum, I think that we have
to be careful. We either need to have very strongly worded comments
pointing out the danger of loading arbitrary fonts, or we need to make vg
panic when a backend doesn't support a font. I prefer the later, because
strongly worded comments are easy to miss and easy to ignore.

--
You received this message because you were CC'd on the issue.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

Reply to this email to add a comment.

plot...@googlecode.com

unread,
Aug 18, 2014, 2:17:07 PM8/18/14
to plotinum...@googlegroups.com

Comment #2 on issue 144 by rangels...@gmail.com: Allows fonts to be loaded
from io.Reader
http://code.google.com/p/plotinum/issues/detail?id=144

I added a check on load to see if the loaded font has a generic name in
font map, and loaded if togteher when loading the base font:

// if there is a map for the font, add it to loaded
for fn, fm := range FontMap {
if fm == name {
_, ok := loadedFonts[fn]
if !ok {
loadedFonts[fn] = font

plot...@googlecode.com

unread,
Aug 23, 2014, 1:50:45 PM8/23/14
to plotinum...@googlegroups.com

Comment #3 on issue 144 by burns...@gmail.com: Allows fonts to be loaded
from io.Reader
https://code.google.com/p/plotinum/issues/detail?id=144

Thanks. I'd like to think about this a bit more.

plot...@googlecode.com

unread,
Dec 1, 2014, 10:57:09 AM12/1/14
to plotinum...@googlegroups.com

Comment #4 on issue 144 by dgryski: Allows fonts to be loaded from io.Reader
https://code.google.com/p/plotinum/issues/detail?id=144

I also need something like this, to allow plotinum to be entire
self-contained as a single binary in my service.

plot...@googlecode.com

unread,
Jan 13, 2015, 10:39:10 AM1/13/15
to plotinum...@googlegroups.com
Updates:
Status: Fixed

Comment #5 on issue 144 by burns...@gmail.com: Allows fonts to be loaded
from io.Reader
https://code.google.com/p/plotinum/issues/detail?id=144

This should fix the
problem:https://code.google.com/p/plotinum/source/detail?r=6632c5f3e77e476cc756c9f259a9564b3a60cb03.
Reply all
Reply to author
Forward
0 new messages