我需要确定后记中字符串的高度(以给定的比例和字体)。
I need to determine the height of a string (in given scale and font) in postscript.
/Helvetic-Oblique findfont 10 scalefont setfont 10 10 1 0 360 arc fill 10 10 moveto (test) dup stringwidth pop 2 div neg 0 rmoveto show将打印测试水平居中(但尚未垂直)在(10,10)。 (为此,我还在10,10处显示了一个小圆圈)。我还需要确定字符串高度,以使文本垂直居中对齐,但是我找不到它的函数。
will print test centered horizontally (but not yet vertically) at (10,10). (to see this, I also show a small circle at 10,10). I also need to determine the string height to center the text vertically as well, but I cant find a function for it.
推荐答案您是否熟悉所使用的PostScript代码?还是只是从某个地方盲目复制并粘贴?如果您想了解它,则应该在Google上搜索 PostScript语言参考或红皮书或 PLRM。这些资源可从Adobe以PDF格式获得。
Are you familiar with the PostScript code you're using? Or is it just blindly copied and pasted from someplace? If you want to understand it, you should google for "PostScript Language Reference" or "Red Book" or "PLRM". These resources are available as PDFs from Adobe.
您的PostScript代码段使用以下步骤:
Your PostScript snippet uses the following steps:
那么考虑字符串的高度怎么办?尝试作为最后一行:
So what would work to take into account the string's height? Try as your last line:
200 700 moveto (test) dup true charpath pathbbox 3 -1 roll sub 2 div neg 3 1 roll sub 2 div exch 200 700 moveto rmoveto show"要了解我的更改,请查找 charpath , div , exch , 《红皮书》中的pathbbox , roll 和 sub 运算符。
To understand my changes look up the meaning of charpath, div, exch, pathbbox, roll and sub operators in The Red Book.
此命令使用Ghostscript在Windows上从代码创建PDF文件(更易于查看和检查结果):
This command uses Ghostscript to create a PDF file on Windows from the code (easier to view and check results):
gswin32c.exe ^ -o my.pdf ^ -sDEVICE=pdfwrite ^ -c "/Helvetic-Oblique findfont 10 scalefont setfont 200 700 1 0 360 arc fill 0 0 moveto (test test) dup true charpath pathbbox 3 -1 roll sub 2 div neg 3 1 roll sub 2 div exch 200 700 moveto rmoveto show"在Linux上使用:
gs \ -o my.pdf \ -sDEVICE=pdfwrite \ -c "/Helvetic-Oblique findfont 10 scalefont setfont 200 700 1 0 360 arc fill 0 0 moveto (test test) dup true charpath pathbbox 3 -1 roll sub 2 div neg 3 1 roll sub 2 div exch 200 700 moveto rmoveto show"可读性更好的形式是:
gswin32c ^ -o my.pdf ^ -sDEVICE=pdfwrite ^ -c "/Helvetic-Oblique findfont 10 scalefont setfont" ^ -c "200 700 1 0 360 arc fill 0 0 moveto (test test) dup" ^ -c "true charpath pathbbox 3 -1 roll sub 2 div neg 3 1 roll" ^ -c "sub 2 div exch 200 700 moveto rmoveto show"和
gs \ -o my.pdf \ -sDEVICE=pdfwrite \ -c "/Helvetic-Oblique findfont 10 scalefont setfont" \ -c "200 700 1 0 360 arc fill 0 0 moveto (test test) dup" \ -c "true charpath pathbbox 3 -1 roll sub 2 div neg 3 1 roll" \ -c "sub 2 div exch 200 700 moveto rmoveto show"更多推荐
如何确定PostScript中的字符串高度?
发布评论