#!/bin/bash
#generates text as a svg-file to stdout
#
#usage:
# svg_text "Text" [COLOR] [SHADOW_COLOR]
#
#Sigmund Berglund, dec 2013
#GPL

#read config if exist
[ -s $HOME/.config/ptheme/gtkdialog_active ] && . $HOME/.config/ptheme/gtkdialog_active
[ ! "$SVG_TEXT_COLOR" ]			&& SVG_TEXT_COLOR='#002A4A'
[ ! "$SVG_TEXT_SHADOW_COLOR" ]	&& SVG_TEXT_SHADOW_COLOR='#CFEFFF'

[ "$2" ] && SVG_TEXT_COLOR="$2"
[ "$3" ] && SVG_TEXT_SHADOW_COLOR="$3"

XCHAR=$(wc -c <<< "$1")
WIDTH=$((${XCHAR}*12))

echo '
<svg version="1.1" width="'${WIDTH}'" height="24">  
  <g style="font-family:DejuVu;font-size:18;font-weight:bold;text-anchor:middle">
    <text style="fill:'${SVG_TEXT_SHADOW_COLOR}'" x="'$(((${WIDTH}/2)+4))'" y="19" >'$1'</text>
    <text style="fill:'${SVG_TEXT_COLOR}'" x="'$(((${WIDTH}/2)+3))'" y="18" >'$1'</text>
  </g>
</svg>'
