svg_text 832 B

12345678910111213141516171819202122232425262728
  1. #!/bin/bash
  2. #generates text as a svg-file to stdout
  3. #
  4. #usage:
  5. # svg_text "Text" [COLOR] [SHADOW_COLOR]
  6. #
  7. #Sigmund Berglund, dec 2013
  8. #GPL
  9. #read config if exist
  10. [ -s $HOME/.config/ptheme/gtkdialog_active ] && . $HOME/.config/ptheme/gtkdialog_active
  11. [ ! "$SVG_TEXT_COLOR" ] && SVG_TEXT_COLOR='#002A4A'
  12. [ ! "$SVG_TEXT_SHADOW_COLOR" ] && SVG_TEXT_SHADOW_COLOR='#CFEFFF'
  13. [ "$2" ] && SVG_TEXT_COLOR="$2"
  14. [ "$3" ] && SVG_TEXT_SHADOW_COLOR="$3"
  15. XCHAR=$(wc -c <<< "$1")
  16. WIDTH=$((${XCHAR}*12))
  17. echo '
  18. <svg version="1.1" width="'${WIDTH}'" height="24">
  19. <g style="font-family:DejuVu;font-size:18;font-weight:bold;text-anchor:middle">
  20. <text style="fill:'${SVG_TEXT_SHADOW_COLOR}'" x="'$(((${WIDTH}/2)+4))'" y="19" >'$1'</text>
  21. <text style="fill:'${SVG_TEXT_COLOR}'" x="'$(((${WIDTH}/2)+3))'" y="18" >'$1'</text>
  22. </g>
  23. </svg>'