如何确定PostScript字体的高度和深度? [英] How to determine height and depth of a PostScript font?

查看:206
本文介绍了如何确定PostScript字体的高度和深度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找能够估计PostScript字体高度(上升空间)和深度(下降空间)的PostScript代码。可以使用字体的边界框( FontBBox )吗?```

这是我的问题的一些背景:字体的字形坐在基线上。很显然,带下降符号的字形将会到达基线以下,我想知道基线下行可以达到多少,这样我就可以在布局中提供足够的空间。

我有看过呈现给定字符串来检查其维度的PostScript代码。我对一个给定的字体的一个普遍的答案感兴趣。

解决方案

那么,你已经发现了两个捷径。 FontBBox将字体中所有字形的边界框叠加在一起。 false charpath flattenpath pathbbox 给出指定字符串的框。



对于类型3(用户定义)字体这是所有你可以期待的事情;但对于比较流行的Type 1字体,字体和度量文件(对于其他应用程序)都有大量的度量信息。



但这是我不太了解的部分。因此,我将阅读(在Adobe Type 1手册中),并稍后展开此答案。

编辑:其实,看起来这些可能是一般最好的方法。


$ b 是类型1字体中垂直对齐值的数组,位于/ Private字典中,名称为/ BlueValues;但不能保证字体的荣誉。阵列中的第一个数字是基线超调;这是字母的下边缘,如O,低于基线。而阵列中的最大值将是上升高度超调或<高度超高(以较高者为准)。但是,任何单独的字符都可能被绘制,而不考虑这些值(因此,不能保证)。另一方面,FontBBox本身可能反映了任何特殊的字符,无论它们是否可以通过编码向量(即,你不能显示它们,但必须 glyphshow them)。



所以最好的办法是把 pathbbox 一串你打算使用的所有字符。这会忽略任何其他可能存在但与您的目的无关的角色的贡献。不要忘了< flattenpath 从曲线上移除控制点(这可能远离实际边界框)。

I'm looking for PostScript code that estimates a PostScript font's height (room for ascender) and depth (room for descender). Could a font's bounding box (FontBBox) be used for this?`

Here is some background for my question: glyphs of a font are sitting on a baseline. Obviously glyphs with descenders will reach below the baseline and I want to know how far below the baseline descenders can reach such that I can provide sufficient space in a layout.

I have seen PostScript code that renders a given string to check its dimension. I'm rather interested in a general answer for a given font.

解决方案

Well, you've already discovered the two "shortcuts". The FontBBox gives the bounding box of all the glyphs in the font superposed together. false charpath flattenpath pathbbox gives the box for a specified string.

For a Type 3 (user-defined) font this is all you can reaonably expect to do; but for the more-popular Type 1 fonts, there is a wealth of metric information both in the font and in a "metrics" file (for other applications).

But this is the part I don't know very well. So I'm going to read-up (in the Adobe Type 1 manual) and expand this answer later.

Edit: Actually, it looks like these may be the best ways in general.

There is an array of vertical alignment values in a Type 1 font, in the /Private dictionary, under the name /BlueValues; but there is no guarantee that the font honors them. The first number in the array is the baseline overshoot; this is the bottom edge of letters like 'O' which dip below the baseline. And the largest value in the array will be either the ascender-height overshoot or the cap-height overshoot (whichever is higher). But any individual character may be plotted without regard to these values (hence, no guarantee).

On the other hand, the FontBBox itself may reflect the bounding box of any "special" characters present in the font, whether or not they're accessible through the encoding vector (ie. you can't show them, but must glyphshow them).

So the best bet would probably be to take the pathbbox of a string of all the characters you intend to use. This would ignore the contribution of any other characters that may be present but are irrelevant to your purpose. And don't forget to flattenpath to remove the control points from the curves (which may be far outside the "real" bounding box).

这篇关于如何确定PostScript字体的高度和深度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆