diff options
Diffstat (limited to 'graphics/circuit_macros/svg.m4')
-rw-r--r-- | graphics/circuit_macros/svg.m4 | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/graphics/circuit_macros/svg.m4 b/graphics/circuit_macros/svg.m4 index 113174d0be..e686074a6b 100644 --- a/graphics/circuit_macros/svg.m4 +++ b/graphics/circuit_macros/svg.m4 @@ -1,7 +1,7 @@ divert(-1) svg.m4 Initialization for SVG output. -* Circuit_macros Version 9.5, copyright (c) 2021 J. D. Aplevich under * +* Circuit_macros Version 9.6, copyright (c) 2021 J. D. Aplevich under * * the LaTeX Project Public Licence in file Licence.txt. The files of * * this distribution may be redistributed or modified provided that this * * copyright notice is included and provided that modifications are clearly * @@ -26,6 +26,7 @@ dnl Put define(`Inkscape') in the source for Inkscape input ifelse(ifdef(`Inkscape',T)`'ifdef(`nosvgformat',T),T, `define(`svg_it',`$1') define(`svg_tt',`$1') +define(`svg_sf',`$1') define(`svg_norm',`$1') define(`svg_bf',`$1') define(`svg_small',`$1') @@ -99,15 +100,22 @@ dptextratio)') define(`svg_symbol',`changecom(,)`$1'changecom(`#',)') define(`svg_it',`<tspan font-style=\"italic\">`$1'</tspan>') define(`svg_tt',`<tspan font-family=\"Courier\">`$1'</tspan>') +define(`svg_sf',`<tspan font-family=\"Helvetica\">`$1'</tspan>') define(`svg_norm',`<tspan font-style=\"normal\">`$1'</tspan>') define(`svg_bf',`<tspan font-style=\"bold\">`$1'</tspan>') -dnl To get %% in a sprintf string, set the size explicitly, +dnl T0 GET %% in a sprintf string, set the size explicitly, dnl eg sprintf("x`'svg_sub(%g,50%)",i) define(`svg_small',`svg_fsize(`$1',ifelse(`$2',,66,`$2'))') define(`svg_fsize',`<tspan font-size=\"ifelse(`$2',,100,`$2')%\">`$1'</tspan>') +dnl svg_ul(text) Underline text +define(`svg_ul',`<tspan text-decoration=\"overline\">`$1'</tspan>') +dnl svg_ol(text) Overline text +define(`svg_ol',`<tspan text-decoration=\"overline\">`$1'</tspan>') + +dnl svg_sup dnl This is black magic but seems necessary to work with Firefox dnl Arg 2: size of subscript font in percent dnl Arg 3: vertical shift, e.g. svg_sub(1,,0.5ex) @@ -126,6 +134,29 @@ define(`svg_sub',`<tspan font-size=\"ifelse(`$2',,70,`$2')%\" font-size=\"ifelse(`$2',,70,`$2')%\" dy=\"-ifelse(`$3',,0.66ex,`$3')\" dx=\"-0.5ex\"> </tspan>')dnl note the space + + + `svg_frac(numerator[:wid],denominator[:wid]) + Basic fraction for simple arguments + wid is in drawing units' +define(`svg_frac',`define(`m4ex',`(textht*0.675)')dnl sans-serif: 0.8525 +define(`m4num',`patsubst(`$1',:.*)')dnl +define(`m4den',`patsubst(`$2',:.*)')dnl +define(`m4numx',`ifinstr(`$1',:,((patsubst(`$1',.*:))/m4ex),len(`$1'))')dnl +define(`m4denx',`ifinstr(`$2',:,((patsubst(`$2',.*:))/m4ex),len(`$2'))')dnl +define(`m4mx',`max(m4numx,m4denx)')dnl + "<tspan dx="+sprintf("\"%gex\"", m4mx/2)+"> </tspan><tspan dy=\"-1.2ex\" + dx="+sprintf("\"%gex\"", (m4mx-m4numx)/2)+">m4num</tspan><tspan + dy=\" 2.6ex\" + dx="+sprintf("\"%gex\"", -m4numx/2-m4denx/2)+">m4den</tspan><tspan + dy=\"-1.4ex\" dx="+sprintf("\"%gex\"", m4mx/2-m4denx/2)+"> </tspan>" + line right m4mx*m4ex from Here+((m4mx/2-0.8)*m4ex,-0.2*m4ex) + move to Here+(0,0.2*m4ex) + {box invis wid last line.len ht 2.8*textht with .w at last line.start} +') + +define(`svg_hat',`<tspan>svg_circ</tspan><tspan dx=\"-0.9ex\">`$1'</tspan>') + define(`svg_alpha',`svg_symbol(&`#'945;)') define(`svg_beta',`svg_symbol(&`#'946;)') define(`svg_chi',`svg_symbol(&`#'967;)') @@ -174,14 +205,15 @@ define(`svg_backsl',`svg_symbol(&`#'92;)') define(`svg_pound',`svg_symbol(&`#'35;)') define(`svg_circ',`svg_symbol(&`#'710;)') define(`svg_deg',`svg_symbol(&`#'176;)') +define(`svg_equiv',`svg_symbol(&`#'8801;)') ') define(`svgcolor',`sprintf("rgb(%g,%g,%g)",\ -round_(`$1'),round_(`$2'),round_(`$3'))') +int(`$1'+0.5),int(`$2'+0.5),int(`$3'+0.5))') # Obsolete but kept for compatibility. Use `rgbstring(r,g,b)' define(`svgcolor255', - `svgcolor(round_((`$1')*255),round_((`$2')*255),round_((`$3')*255))') + `svgcolor(int((`$1')*255+0.5),int((`$2')*255+0.5),int((`$3')*255+0.5))') define(`svgLink',`command "<a xlink:href=\"`$1'\"dnl ifelse(`$3',,`target=\"_blank\"',`$3',B,,`$3')> |