Greek letters in the SVG terminal

View: New views
7 Messages — Rating Filter:   Alert me  

Greek letters in the SVG terminal

by James R. Van Zandt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I'm trying to use the svg terminal in a recent version of gnuplot:

        G N U P L O T
        Version 4.3 patchlevel 0
        last modified March 2009

I can generate a sample file like this:

  set term svg enhanced
  set out "sine.svg"
  set label "e^{i{/Symbol p}}=-1" at graph .5,.5
  plot sin(x)
  set out

When I display the output using inkscape 0.46, I see three problems:

 - All the lines are missing
 - The superscripted characters are spaced out
 - The Greek letter pi appears as "p".

By googling I came up with workarounds for the first two problems:

  perl -p -i -e 's/color:([^;]*); *stroke:[^;]*;/color:$1; stroke:$1;/' sine.svg
  perl -p -i -e 's/xml:space=.preserve.//' sine.svg

Does anyone have suggestions about the Greek letters?

        - Jim Van Zandt

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
gnuplot-beta mailing list
gnuplot-beta@...
https://lists.sourceforge.net/lists/listinfo/gnuplot-beta

Re: Greek letters in the SVG terminal

by Ethan Merritt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Monday 14 September 2009 10:47:05 James R. Van Zandt wrote:

>
> I'm trying to use the svg terminal in a recent version of gnuplot:
>
>         G N U P L O T
>         Version 4.3 patchlevel 0
>         last modified March 2009
>
> I can generate a sample file like this:
>
>   set term svg enhanced
>   set out "sine.svg"
>   set label "e^{i{/Symbol p}}=-1" at graph .5,.5
>   plot sin(x)
>   set out
>
> When I display the output using inkscape 0.46, I see three problems:
>
>  - All the lines are missing
>  - The superscripted characters are spaced out
>  - The Greek letter pi appears as "p".
>
> By googling I came up with workarounds for the first two problems:
>
>   perl -p -i -e 's/color:([^;]*); *stroke:[^;]*;/color:$1; stroke:$1;/' sine.svg
>   perl -p -i -e 's/xml:space=.preserve.//' sine.svg
>
> Does anyone have suggestions about the Greek letters?

(1) Fonts
SVG is an XML variant, which means it natively uses UTF-8 encoding.
The "Symbol" font is an Adobe-specific encoding that nobody else uses.
So it works for PostScript and PDF, but probably nothing else.
Use UTF-8

(2) Spacing
Inkscape is broken.  
But hey, so are all the other SVG viewers I know of.

(3) General problems
We worked with the Sodipodi developers to fix a bunch of problems,
but when Sodipodi was forked to Inkscape they seem
to have forked it from an unfixed version.

On a similar note, in KDE3 the ksvg viewer was probably the best of
a bad lot.  But KDE4 switched to something else that doesn't work at all well.

I've given up on SVG.

I suggest to use the canvas terminal instead.

--
Ethan A Merritt
Biomolecular Structure Center
University of Washington, Seattle 98195-7742

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
gnuplot-beta mailing list
gnuplot-beta@...
https://lists.sourceforge.net/lists/listinfo/gnuplot-beta

Re: Greek letters in the SVG terminal

by Plotter-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ethan Merritt wrote:

> On Monday 14 September 2009 10:47:05 James R. Van Zandt wrote:
>> I'm trying to use the svg terminal in a recent version of gnuplot:
>>
>>         G N U P L O T
>>         Version 4.3 patchlevel 0
>>         last modified March 2009
>>
>> I can generate a sample file like this:
>>
>>   set term svg enhanced
>>   set out "sine.svg"
>>   set label "e^{i{/Symbol p}}=-1" at graph .5,.5
>>   plot sin(x)
>>   set out
>>
>> When I display the output using inkscape 0.46, I see three problems:
>>
>>  - All the lines are missing
>>  - The superscripted characters are spaced out
>>  - The Greek letter pi appears as "p".
>>
>> By googling I came up with workarounds for the first two problems:
>>
>>   perl -p -i -e 's/color:([^;]*); *stroke:[^;]*;/color:$1; stroke:$1;/' sine.svg
>>   perl -p -i -e 's/xml:space=.preserve.//' sine.svg
>>
>> Does anyone have suggestions about the Greek letters?
>
> (1) Fonts
> SVG is an XML variant, which means it natively uses UTF-8 encoding.
> The "Symbol" font is an Adobe-specific encoding that nobody else uses.
> So it works for PostScript and PDF, but probably nothing else.
> Use UTF-8
>
help svg refers the user to read help enhanced, this topic contains
several refernces to the use of /Symbol :

       set xlabel 'Time (10^6 {/Symbol m}s)'

this produces the following svg code:
<tspan style="font-family:Symbol" >m</tspan>

as James noted this does not give the expected results. My guess is the
system in question does not have a font called Symbol and is falling
back to a substitute that has little to do with the Adobe font.

This may be useful:
http://www1.tip.nl/~t876506/EntitiesXHTML1.html

> (2) Spacing
> Inkscape is broken.  
> But hey, so are all the other SVG viewers I know of.
>
> (3) General problems
> We worked with the Sodipodi developers to fix a bunch of problems,
> but when Sodipodi was forked to Inkscape they seem
> to have forked it from an unfixed version.
>
> On a similar note, in KDE3 the ksvg viewer was probably the best of
> a bad lot.  But KDE4 switched to something else that doesn't work at all well.
>
> I've given up on SVG.
>
> I suggest to use the canvas terminal instead.
>

I know that Ethan is very down heartened by SVG viewers and probably
with some justfication having worked on fixing things only see them
reverted. He has probably gone into some considerable detail in testing
a broad range of features  but I can say for my usage of embedding plots
inside  html and having javascript make it interact with machine control
software on the server there are several viewers that work well.

Firefox3 , very good major improvement on ff 2.x
opera9 (OK over http but displays source on local file open)
ksvg from kde3 . (Have not tested svg on kde4 since the whole of kde 4
is still work in progress at this time.)

Inkscape was not much use for anything last time I looked and trying to
help by reporting bugs got me a "fix it yourself if you're not happy"
attitude :(  So sodipodioffi as far as I'm concerned.


HTH



------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
gnuplot-beta mailing list
gnuplot-beta@...
https://lists.sourceforge.net/lists/listinfo/gnuplot-beta

Re: Greek letters in the SVG terminal

by Mojca Miklavec :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Sep 14, 2009 at 19:59, Ethan Merritt wrote:

> On Monday 14 September 2009 10:47:05 James R. Van Zandt wrote:
>>
>> I can generate a sample file like this:
>>
>>   set term svg enhanced
>>   set out "sine.svg"
>>   set label "e^{i{/Symbol p}}=-1" at graph .5,.5
>>   plot sin(x)
>>   set out
>>
>> When I display the output using inkscape 0.46, I see three problems:
>>
>>  - All the lines are missing

I see them in Safari and Firefox, but I'm not sure about Inkscape and
I have no idea about proper SVG syntax.

>>  - The superscripted characters are spaced out

I don't know the specification, but removing the space, that means changing
        <tspan>e</tspan>
        <tspan font-size="9.6pt" dy="-6.00pt">iπ</tspan>
into
        <tspan>e</tspan><tspan font-size="9.6pt" dy="-6.00pt">iπ</tspan>
helped. I don't know whether this classifies as gnuplot problem or
viewer problem, but I would expect
    <text>a
    b
    c</text>
to print out "a b c", not "abc", so without reading exact
specification, I would vote for browser's behaviour, not for
gnuplot's, and that particular problem should be rather trivial to fix
in gnuplot itself.

Just a question (I don't know SVG at all, I just saw an example): wouldn't
    <tspan baseline-shift = "super">
do the job as well?

>>  - The Greek letter pi appears as "p".
>>
>> By googling I came up with workarounds for the first two problems:
>>
>>   perl -p -i -e 's/color:([^;]*); *stroke:[^;]*;/color:$1; stroke:$1;/' sine.svg
>>   perl -p -i -e 's/xml:space=.preserve.//' sine.svg
>>
>> Does anyone have suggestions about the Greek letters?
>
> (1) Fonts
> SVG is an XML variant, which means it natively uses UTF-8 encoding.
> The "Symbol" font is an Adobe-specific encoding that nobody else uses.
> So it works for PostScript and PDF, but probably nothing else.
> Use UTF-8

I agree. The following line:
    set label "e^{iπ}=-1" at graph .5,.5
works as expected (I don't know if you are able to read it though;
it's an UTF-8 letter pi). The PostScript example in as "ugly hack"
only.

Mojca

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
gnuplot-beta mailing list
gnuplot-beta@...
https://lists.sourceforge.net/lists/listinfo/gnuplot-beta

Re: Greek letters in the SVG terminal

by Ethan Merritt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Monday 14 September 2009 plotter@... wrote:
>
> help svg refers the user to read help enhanced, this topic contains
> several refernces to the use of /Symbol :
>
>        set xlabel 'Time (10^6 {/Symbol m}s)'

Hmm. That's a historical artifact. The enhanced text mode was originally a
feature of the postscript terminal only, so of course the original
documentation assumed you were using postscript.  It should be re-written.


On Monday 14 September 2009 13:41:21 Mojca Miklavec wrote:

> >>  - The superscripted characters are spaced out
>
> I don't know the specification, but removing the space, that means changing
> <tspan>e</tspan>
> <tspan font-size="9.6pt" dy="-6.00pt">iπ</tspan>
> into
> <tspan>e</tspan><tspan font-size="9.6pt" dy="-6.00pt">iπ</tspan>
> helped. I don't know whether this classifies as gnuplot problem or
> viewer problem, but I would expect
>     <text>a
>     b
>     c</text>
> to print out "a b c", not "abc", so without reading exact
> specification, I would vote for browser's behaviour, not for
> gnuplot's, and that particular problem should be rather trivial to fix
> in gnuplot itself.

The SVG spec allows you to either collapse all whitespace into a single blank,
   xml:space="default"
or preserve the whitespace in the input.
   xml:space="preserve"
The broken browsers (at least some of them) interpret that to mean
"preserve all the whitespace in the input, whether or not it is in a tspan
 element".  This is a problem.  
I reported the bug via Bugzilla some while ago.

> Just a question (I don't know SVG at all, I just saw an example): wouldn't
>     <tspan baseline-shift = "super">
> do the job as well?

I don't think such an SVG element was available at the time the driver was
written. Perhaps it could be revisited now.  But I don't think this would
handle nested super- and sub- scripts, so it would not be a complete solution.

        Ethan

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
gnuplot-beta mailing list
gnuplot-beta@...
https://lists.sourceforge.net/lists/listinfo/gnuplot-beta

Re: Greek letters in the SVG terminal

by Plotter-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ethan Merritt wrote:

> On Monday 14 September 2009 plotter@... wrote:
>> help svg refers the user to read help enhanced, this topic contains
>> several refernces to the use of /Symbol :
>>
>>        set xlabel 'Time (10^6 {/Symbol m}s)'
>
> Hmm. That's a historical artifact. The enhanced text mode was originally a
> feature of the postscript terminal only, so of course the original
> documentation assumed you were using postscript.  It should be re-written.
>
>
> On Monday 14 September 2009 13:41:21 Mojca Miklavec wrote:
>
>>>>  - The superscripted characters are spaced out
>> I don't know the specification, but removing the space, that means changing
>> <tspan>e</tspan>
>> <tspan font-size="9.6pt" dy="-6.00pt">iπ</tspan>
>> into
>> <tspan>e</tspan><tspan font-size="9.6pt" dy="-6.00pt">iπ</tspan>
>> helped. I don't know whether this classifies as gnuplot problem or
>> viewer problem, but I would expect
>>     <text>a
>>     b
>>     c</text>
>> to print out "a b c", not "abc", so without reading exact
>> specification, I would vote for browser's behaviour, not for
>> gnuplot's, and that particular problem should be rather trivial to fix
>> in gnuplot itself.
>
> The SVG spec allows you to either collapse all whitespace into a single blank,
>    xml:space="default"
> or preserve the whitespace in the input.
>    xml:space="preserve"
> The broken browsers (at least some of them) interpret that to mean
> "preserve all the whitespace in the input, whether or not it is in a tspan
>  element".  This is a problem.  
> I reported the bug via Bugzilla some while ago.

I don't follow how you relate this to the space in super script of this
example.

The newline in the input represents whitespace and is hence present in
the rendition of the page as a space. Since it is just one character the
question of collapse/preserve does not seem to apply. The fact that the
newline it is not in a tspan does not mean it should be ignored.


The following html snippet displays in a similar way and would seem to
be correct. Only c and d a juxtaposed (view source if your email client
is parsing this and showing "a b cd e f")

<html>
<body>

<span>a</span>
<span>b</span>
<span>c</span><span>d</span>
<span>e
f</span>

</body>
</html>

If the desired output is "abc" rather than "a b c" , it needs to be
output on the same line to prevent inserting whitespace.

regards, Peter.

>
>> Just a question (I don't know SVG at all, I just saw an example): wouldn't
>>     <tspan baseline-shift = "super">
>> do the job as well?
>
> I don't think such an SVG element was available at the time the driver was
> written. Perhaps it could be revisited now.  But I don't think this would
> handle nested super- and sub- scripts, so it would not be a complete solution.
>
> Ethan
>

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
gnuplot-beta mailing list
gnuplot-beta@...
https://lists.sourceforge.net/lists/listinfo/gnuplot-beta

Re: Greek letters in the SVG terminal

by Christoph Bersch :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Mojca Miklavec schrieb:

> I don't know the specification, but removing the space, that means changing
> <tspan>e</tspan>
> <tspan font-size="9.6pt" dy="-6.00pt">iπ</tspan>
> into
> <tspan>e</tspan><tspan font-size="9.6pt" dy="-6.00pt">iπ</tspan>
> helped. I don't know whether this classifies as gnuplot problem or
> viewer problem, but I would expect
>     <text>a
>     b
>     c</text>
> to print out "a b c", not "abc",


But what we have here, is

<text>a</text>
<text>b</text>
<text>c</text>

and then the spaces outside the tag should not matter.

Christoph



------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
gnuplot-beta mailing list
gnuplot-beta@...
https://lists.sourceforge.net/lists/listinfo/gnuplot-beta