summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pgf/systemlayer/pgfsys-tex4ht.def
blob: f7864d34070c1ef07721d1067e31db16b892393d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
\ProvidesFileRCS $Header: /cvsroot/pgf/pgf/generic/pgf/systemlayer/pgfsys-tex4ht.def,v 1.8 2005/08/13 18:59:56 tantau Exp $

% Copyright 2005 by Till Tantau <tantau@cs.tu-berlin.de>.
%
% This program can be redistributed and/or modified under the terms
% of the GNU Public License, version 2.


\RequirePackage{xcolor}


% Driver commands for tex4ht

%
% Load common pdf commands:
%
\input pgfsys-common-svg.def

%
% tex4ht-specific stuff:
%
\def\pgfsys@invoke#1{\HCode{#1}}

\newcount\pgf@sys@svg@picnum


\def\pgfsys@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@endpicture{%
  % undo:
  \Configure{htf}{0}{+}{<span\Hnewline
     class="}{\%s}{-\%s}{x-x-\%d}{}{">}{</span>}
}
 
\def\pgfsys@typesetpicturebox#1{%
  \global\advance\pgf@sys@svg@picnum by 1\relax%
  % Ok, compute width/height
  \pgf@xa=\pgf@picminx%
  \pgf@ya=\pgf@picminy%
  \pgf@xb=\pgf@picmaxx%
  \pgf@yb=\pgf@picmaxy%
  \pgf@x=\pgf@xb%
  \advance\pgf@x by-\pgf@xa%
  \pgf@y=\pgf@yb%
  \advance\pgf@y by-\pgf@ya%
  \ifdim\pgf@y<1pt%
    \pgf@y=1pt%
  \fi%
  \HCode{<object data="\jobname-\the\pgf@sys@svg@picnum.svg"
    width="\the\pgf@x" height="\the\pgf@y"
    type="image/svg+xml"><p>SVG-Viewer needed.</p></object>}%
  \special{t4ht>\jobname-\the\pgf@sys@svg@picnum.svg}%
  \pgfsys@invoke{<svg width="\the\pgf@x" height="\the\pgf@y" viewBox="}%
  \pgf@sys@pt{\pgf@xa}\pgf@sys@pt{\pgf@ya}\pgf@sys@pt{\pgf@x}\pgf@sys@pt{\pgf@y}%
  \pgfsysprotocol@flushcurrentprotocol%
  \pgf@ya=-\pgf@ya%
  \pgfsys@invoke{">\Hnewline  <g transform="translate(0,\the\pgf@yb) scale(1,-1)
    translate(0,\the\pgf@ya)">\Hnewline }%
  \setlength\pgf@x{\pgf@shift@baseline}%
  \advance\pgf@x by-\pgf@picminy\relax%
  \advance\pgf@picmaxy by-\pgf@picminy\relax% maxy is now the height
  \advance\pgf@picmaxx by-\pgf@picminx\relax% maxx is now the width
  \setbox#1=\hbox{\hskip-\pgf@picminx\lower\pgf@picminy\box#1}%
  \ht#1=\pgf@picmaxy%
  \wd#1=\pgf@picmaxx%
  \dp#1=0pt%
  \leavevmode\raise-\pgf@x\box#1%
  \pgfsys@invoke{</g>\Hnewline </svg>\Hnewline }%
  \special{t4ht<\jobname-\the\pgf@sys@svg@picnum.svg}%
}

\def\pgfsys@hbox#1{%
  \pgf@x=.5\wd#1%
  \ifx\tikz@textcolor\relax%
  \else%
    \ifx\tikz@textcolor\@empty%
      \pgfsetfillcolor{.}%
    \else%
      \pgfsetfillcolor{\tikz@textcolor}%
    \fi%
  \fi% tweak for TikZ
  \HCode{<text
    style="stroke:none"
    transform="scale(1,-1) translate(\the\pgf@x,0pt)"
    text-anchor="middle"
  }%
  \ifx\f@size\@empty%
  \else%
    \HCode{ font-size="\f@size"}%
  \fi%  
  \HCode{>\Hnewline }%
    \wd#1=0pt%
    \ht#1=0pt%
    \dp#1=0pt%
    \box#1
  \HCode{</text>\Hnewline }%
}

\def\pgfsys@outerinvoke{\ifpgfpicture\expandafter\pgfsys@invoke\else\expandafter\@gobble\fi}


\def\pgfsys@shadingoutsidepgfpicture#1{%
  \begingroup%
    #1%
    \setbox\pgfpic=\hbox to0pt{%
      \pgfsys@beginpicture%
        \pgfsys@beginscope%
          \pgf@sys@svg@sh@defs%
          \pgf@sys@svg@sh%
        \pgfsys@endscope%
      \pgfsys@endpicture%
      \hss%  
    }%
    \pgf@process{\pgf@sys@svg@pos}%
    \pgf@picminx=0pt%
    \pgf@picminy=0pt%
    \pgf@picmaxx=\pgf@x%
    \pgf@picmaxy=\pgf@y%
    \pgf@baseline=0pt%
    \pgfsys@typesetpicturebox\pgfpic%
  \endgroup%
}

\def\pgfsys@shadinginsidepgfpicture#1{%
  #1%
  \pgf@sys@svg@sh@defs% hmmm....
  \pgf@process{\pgf@sys@svg@pos}
  \pgf@xa=-.5\pgf@x%
  \pgf@ya=-.5\pgf@y%
  \pgfsysprotocol@literal{<g transform="translate(\pgf@sys@tonumber{\pgf@xa},\pgf@sys@tonumber{\pgf@ya})">\Hnewline}%
  \pgf@sys@svg@sh%
  \pgfsysprotocol@literal{</g>\Hnewline}%
}



% Protect against color.4ht evil meddling with xcolor:
\let\pgf@xcolor@declaredcolor=\@declaredcolor
\let\pgf@xcolor@undeclaredcolor=\@undeclaredcolor

\AtBeginDocument{
  \let\pgf@texht@declaredcolor=\@declaredcolor
  \let\pgf@texht@undeclaredcolor=\@undeclaredcolor
  \def\@declaredcolor{\ifpgfpicture\expandafter\pgf@xcolor@declaredcolor\else\expandafter\pgf@texht@declaredcolor\fi}
  \def\@undeclaredcolor{\ifpgfpicture\expandafter\pgf@xcolor@undeclaredcolor\else\expandafter\pgf@texht@undeclaredcolor\fi}
  \ConfigureEnv{pgfpicture}{}{}{}{}
}

\endinput


%%% Local Variables: 
%%% mode: latex
%%% End: