1 Sep 14:27
Re: Foreign Element tex4ht + svg
Till Tantau <tantau <at> tcs.uni-luebeck.de>
2008-09-01 12:27:01 GMT
2008-09-01 12:27:01 GMT
Dear Olivier,
I haven't had a look into this, but I'm sure translations can be fixed, somehow.
Concerning 2) this is much trickier. As TeX is compiling the text, TeX obviously has no real idea about the size of the text *in the final svg*. After all, from TeX's point of view, the
Am 13.08.2008 um 16:22 schrieb Olivier Binda:
Hello.-------------------------------------------------------------------------
As Firefox 3 now supports the ForeignObject element of the SVG 1.1 specification
I was wondering if pgf/tikz would support this feature for text nodes in the tex4ht driver.
That would remove the liit on complexity of text nodes for the tex4ht+svg engine and allow us to put online math courses beautifully decorated inside svg frames (for example)
I did a few experimenttions
(I basically let tex4ht do the translation to Xhtml and Mathml and only wrapp the code in <ForeignObject> and <xhtml> elements)
and with a quick and dirty hack of the pgfsys-tex4ht.def file, I somehow managed to produce valid xhtml code and svg with xhtml and mathml code inside that displayed ok in Firefox 3, even with very complicated text nodes.
There are a few caveats :
1) The translation is wrong (I got it wrong).
2) the size of the boxes are wrong too.
A partial solution would be to use the \tikz\text width and \tikz text height options.
But it would be really great if tikz could somehow automatically guess the sizes, say in most/lots of cases.
Now, is it possible to solve problem 1 ?
And what about problem 2 ?
If it isn't possible, maybee we can add some options to manually solve the problem for each picture/node ?
Here are my hacks :
\def\pgfsys <at> beginpicture{%
% \Configure{[]}{$}{$}
% \Configure{()}{$}{$}
% \Configure{$$}{}{}{}%$$
%\Configure{$}{}{}{}%$
%\Configure{SUB}{\HCode{<tspan baseline-shift="sub">}}{\HCode{</tspan>}}
%\Configure{SUP}{\HCode{<tspan baseline-shift="sub">}}{\HCode{</tspan>}}
%\Configure{SUBSUP}{}{}{}
%\Configure{htf}
% {0}{+}{<tspan font-family="}
% {\%s}{" font-size="\%s}{}{}
% {">}{</tspan>}
}
\def\pgfsys <at> endpicture{%
undo:
%\Configure{htf}{0}{+}{<span\Hnewline
% class="}{\%s}{-\%s}{x-x-\%d}{}{">}{</span>}
}
\def\pgfsys <at> hbox#1{%
\HCode{<g transform="scale(1,-1) translate(-5,-25)">
}%
\HCode{<foreignObject width="200" height="200"><body xmlns="http://www.w3.org/1999/xhtml">
}%
\box#1%
\HCode{</body>
</foreignObject></g>\Hnewline }%
}
With the xetex engine, the tex4ht driver, the hack and this code :
{\everypar={}%<----- this is important to produce valid xhtml code in tikzpicture with text nodes (in vboxes a.k.a. with the text width option)
% a similar fix could maybee be done with the tex4ht commands of paragraphs : \HtmlPar, \IgnorePar, \ShowPar, see there
\tikzpicture
\tikzstyle{everynode}=[text width=2cm]
\node[entity,text width=6cm] (sheep) {I love $\int_0^1{\sin(t)\over 1+{1\over 1+e^x}}d t=2$}
child {node[attribute] {name}}
child {node[attribute,text width=0.8cm] {$color$}};
\endtikzpicture}
it produces this svg picture (open it with firefox 3...and not internet explorer or opera) :
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="177.78247pt" height="69.16722pt" viewBox="-88.89124 -52.50311 177.78247 69.16722 ">
<g transform="translate(0, 16.66411 ) scale(1,-1) translate(0,52.50311 )">
<g>
<g stroke="rgb(0.0%,0.0%,0.0%)">
<g fill="rgb(0.0%,0.0%,0.0%)">
<g stroke-width="0.4pt">
<g>
</g>
<g>
<g>
<path d=" M -88.69124 -16.46411 h 177.38248 v 32.92822 h -177.38248 Z " style="fill:none"/>
<g>
<g transform="matrix(1.0,0.0,0.0,1.0,-85.35826,-5.8133)">
<g transform="scale(1,-1) translate(-5,-25)"> <foreignObject width="200" height="200"><body xmlns="http://www.w3.org/1999/xhtml"> I love
<!--l. 101--><math
xmlns="http://www.w3.org/1998/Math/MathML" display="inline" ><msubsup><mrow
><mo
class="MathClass-op">∫</mo>
<!--nolimits--></mrow><mrow
><mn>0</mn></mrow><mrow
><mn>1</mn></mrow></msubsup
><mfrac><mrow> <mo
class="MathClass-op">sin</mo><!--nolimits--><mrow ><mo
class="MathClass-open">(</mo><mrow><mi
>t</mi></mrow><mo
class="MathClass-close">)</mo></mrow></mrow>
<mrow><mn>1</mn><mo
class="MathClass-bin">+</mo><mfrac><mrow> <mn>1</mn></mrow>
<mrow><mn>1</mn><mo
class="MathClass-bin">+</mo><msup><mrow
><mi
>e</mi></mrow><mrow
><mi
>x</mi></mrow></msup
></mrow></mfrac></mrow></mfrac> <mi
>d</mi><mi
>t</mi> <mo
class="MathClass-rel">=</mo> <mn>2</mn></math></body> </foreignObject></g>
</g>
</g>
</g>
<g>
<g>
<path d=" M -0.1268 -42.67912 C -0.1268 -37.68419 -9.56664 -33.67912 -21.33954 -33.67912 C -33.11244 -33.67912 -42.55228 -37.68419 -42.55228 -42.67912 C -42.55228 -47.67406 -33.11244 -51.67912 -21.33954 -51.67912 C -9.56664 -51.67912 -0.1268 -47.67406 -0.1268 -42.67912 Z M -21.33954 -42.67912 " style="fill:none"/>
<g>
<g transform="matrix(1.0,0.0,0.0,1.0,-33.00623,-44.8319)">
<g transform="scale(1,-1) translate(-5,-25)"> <foreignObject width="200" height="200"><body xmlns="http://www.w3.org/1999/xhtml"> name</body> </foreignObject></g>
</g>
</g>
</g>
<path d=" M -8.33179 -16.66411 L -16.83815 -33.67552 " style="fill:none"/>
</g>
<g>
<g>
<path d=" M 42.1485 -42.67912 C 42.1485 -37.33789 32.88837 -33.05513 21.33958 -33.05513 C 9.7908 -33.05513 0.53067 -37.33789 0.53067 -42.67912 C 0.53067 -48.02036 9.7908 -52.30312 21.33958 -52.30312 C 32.88837 -52.30312 42.1485 -48.02036 42.1485 -42.67912 Z M 21.33958 -42.67912 " style="fill:none"/>
<g>
<g transform="matrix(1.0,0.0,0.0,1.0,9.95845,-46.15134)">
<g transform="scale(1,-1) translate(-5,-25)"> <foreignObject width="200" height="200"><body xmlns="http://www.w3.org/1999/xhtml"> <!--l. 103--><math
xmlns="http://www.w3.org/1998/Math/MathML" display="inline" ><mi
>c</mi><mi
>o</mi><mi
>l</mi><mi
>o</mi><mi
>r</mi></math> </body> </foreignObject></g>
</g>
</g>
</g>
<path d=" M 8.32925 -16.66411 L 16.5525 -33.10518 " style="fill:none"/>
</g>
</g>
</g>
</g>
</g>
</g>
</g>
</svg>
Best regards,
Olivier Binda
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/_______________________________________________
pgf-users mailing list
pgf-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pgf-users
--
Prof. Dr. Till Tantau <tantau <at> tcs.uni-luebeck.de>
------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________ pgf-users mailing list pgf-users <at> lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pgf-users
RSS Feed