tmac.eps 1.5 KB

123456789101112131415161718192021222324252627282930313233343536
  1. .\" tmac.eps
  2. .\"
  3. .\" .EPS file.eps [L|R|C|indents] [width] [height]
  4. .de EPS
  5. . ds eps.tmp /tmp/.eps.\n($$
  6. . \" obtaing the bounding box
  7. . ec @
  8. . ie '@$0'.PDF' .sy cat "@$1" | sed -n '/^.*MediaBox *\[ *\([-.0123456789]\{1,10\}\) *\([-.0123456789]\{1,10\}\) *\([-.0123456789]\{1,10\}\) *\([-.0123456789]\{1,10\}\) *\].*$/{s//.nr llx 0+\1p,.nr lly 0+\2p,.nr urx 0+\3p,.nr ury 0+\4p/p; q; }' | tr ',' '\\n' >@*[eps.tmp]
  9. . el .sy cat "@$1" | sed -n '/%%BoundingBox: *\([-0123456789]\{1,10\}\) *\([-0123456789]\{1,10\}\) *\([-0123456789]\{1,10\}\) *\([-0123456789]\{1,10\}\)/{s//.nr llx 0+\1p,.nr lly 0+\2p,.nr urx 0+\3p,.nr ury 0+\4p/p; q; }' | tr ',' '\\n' >@*[eps.tmp]
  10. . ec
  11. . so \\*[eps.tmp]
  12. . sy rm \\*[eps.tmp]
  13. . \" image scaling
  14. . ie '\\$3'' .nr eps.scale 100
  15. . el .nr eps.scale ((\\$3)*100/(\\n[urx]-\\n[llx]))
  16. . if !'\\$4'' .if \\n[eps.scale]>(((\\$4)*100/(\\n[ury]-\\n[lly]))) \
  17. . nr eps.scale ((\\$4)*100/(\\n[ury]-\\n[lly]))
  18. . nr eps.w (\\n[urx]-\\n[llx])*\\n[eps.scale]/100
  19. . nr eps.h (\\n[ury]-\\n[lly])*\\n[eps.scale]/100
  20. . \" the placement
  21. . ie '\\$2'' .nr eps.in 0
  22. . el .nr eps.in (\\$2)
  23. . if '\\$2'L' .nr eps.in 0
  24. . if '\\$2'C' .nr eps.in (\\n(.l-\\n(.i-\\n[eps.w])/2
  25. . if '\\$2'R' .nr eps.in (\\n(.l-\\n(.i-\\n[eps.w])
  26. . \" printing the image
  27. . br
  28. . ne \\n[eps.h]u
  29. . sp \\n[eps.h]u
  30. . ie '\\$0'.PDF' \h'|\\n[eps.in]u'\\X'pdf "\\$1" \\n[eps.w]'\h'\\n[eps.w]u'
  31. . el \h'|\\n[eps.in]u'\\X'eps "\\$1" \\n[eps.w]'\h'\\n[eps.w]u'
  32. . br
  33. ..
  34. .\" .PDF file.pdf [L|R|C|indents] [width] [height]
  35. .co EPS PDF