如何防止某些外语字体的文本位移?
我有一个多语言项目(目前有 13 种语言),它使用“Helvetica Neue”的许多不同字体变体,大部分是来自 LinoType Pro 字体集(包括西欧字符)的粗体、压缩和常规剪切,西里尔字母也是如此。我们将来可能会添加中文和日文版本。
我已经将项目设置为使用不同的 CSS 样式表,并根据用户选择的语言分别加载每个版本的字体,因此我可以有不同的行高、字距调整和/或字体大小,以使所有内容保持原始外观,即使字体看起来一点也不相似。
所有这些都运行良好,除了一个问题:由于某种原因,所有西里尔字母似乎都被替换了。它们出现在正确基线下方 2-3 个像素处,并且实际上突出于文本字段的底部边框,即使该字段设置为自动调整大小也是如此。当我使用 textfield.getCharBoundaries()
时,所有值似乎都是正确的,即使它们显然没有正确呈现。
为了使一切看起来整洁,我当然可以根据语言和字体大小手动向上或向下移动所有有问题的文本字段,但我想知道是否有某种方法可以防止或至少检测这种位移,以便自动处理调整 - Flash Player 应该有一些关于如何渲染事物的信息,不是吗?你们中有人遇到过类似的问题吗?或者更好的是:解决方案?
I have a multilingual project (currently 13 languages), which uses many different font variations of "Helvetica Neue", mostly bold, condensed and regular cuts from the LinoType Pro font set ( which includes western european characters) and the same for cyrillic. We will probably add chinese and japanese variations in the future.
I have set up the project to use different CSS stylesheets and separately load the fonts for each version, depending on which language the user selects, so I can have different line heights, kerning and/or font sizes to make everything keep the original look, even if the fonts look nothing alike.
All of this works well, except for one problem: For some reason, all cyrillic letters seem to be displaced. They appear 2-3 pixels below the correct base line, and actually protrude across the textfield's bottom border, even when the field is set to autosize. When I use textfield.getCharBoundaries()
, all values seem to be correct, even though they obviously aren't rendered correctly.
To make everything look neat, I could of course manually move all problematic textfields up or down according to language and font size, but I was wondering if there was some way to prevent or at least detect this kind of displacement in order to automatically handle the adjustments - the Flash Player should have some sort of information on how things are rendered, shouldn't it? Have any of you had similar problems? Or better yet: a solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
我在中文中遇到了这个问题,但仅限于 OS X 和 Windows。我也不知道如何自动获取角色实际位置的正确指标。我最终得到了一个粗略的函数,每次设置 TextField 时都会调用该函数:
我是在代码中而不是 IDE 中设置所有 TextField,所以这很容易。不过,我想这不是您正在寻找的解决方案!
I had this problem for Chinese, but only in OS X versus Windows. I couldn't figure out how to automatically get proper metrics for where the characters really were, either. I ended up with a rough function which I called whenever I set up a TextField:
I was setting up all my TextFields in code rather than the IDE, so this was easy. I guess it's the solution you're not looking for, though!
您的 Helvetica Neue 版本是否有西里尔字母字形?如果没有,那么您会得到字体后备,并且用于俄语的字体实际上不是 Helvetica Neue,而是具有其他指标的其他字体。
如果你使用中文,你会得到更多这样的东西,因为 Helvetica Neue 绝对不包含中文字形:-)
另一方面,真的真的考虑 TLF。国际化支持要好得多,Flash Player 10.0(引入了 TLF)已经有 2.5 年多了。尝试让您的客户相信,要求采用古老技术的高水平国际版式是不合理的。这是一个非此即彼的交易。
Does your version of Helvetica Neue have glyphs for Cyrillic? If not, then you get font fallback and the font used for Russian is in fact not Helvetica Neue, but something else, with other metrics.
And you will have more of this if you go to Chinese, because Helvetica Neue definitely does no contain Chinese glyphs :-)
On the other side, really-really consider TLF. It is way better for international support, and Flash Player 10.0 (which introduces TLF) is already more than 2.5 years old. Try to convince your customers that is unreasonable to ask for high level international typography with ancient technology. It is an either/or deal.
我在阿拉伯语方面也遇到过类似的问题。似乎 Adobe 应用程序在使用非英语语言时总是存在问题。在某些语言中,在 Flash Player 中,文本看起来已损坏,但在 Flash Player 中播放 Flash 时,问题并不存在。
我不确定什么可以解决您的问题,但您可以尝试一些解决方法。
尝试解决此问题,但它会变得更加复杂:
- 每次按键时,将按下的字符作为图像插入。它可以解决您的问题,但需要更多时间编写代码
I've experienced similar problem with Arabic language. Seems like Adobe applications always have issues with non-English languages. In some languages, in Flash player the text look corrupted, but while playing the Flash in Flash Player the problem doesn't exist.
I'm not sure what could be the solution for your problem, but you can try some work around.
Try this work around, but it becomes more complicated:
- on each keypress, insert the pressed character as an image. It could solve your problem, but it would take more time to write the code
我也遇到过类似的问题,并且我尝试过的所有解决方案都非常复杂,或者有一些缺点:
使用 TLF。我知道你不想
但它非常安全(但很复杂)
解决方案。
不要使用“可读性”抗锯齿,
使用“动画”。字体看起来
最差,但他们的指标应该是
更可靠一点。
尝试使用cacheAsBitmap,或者为null
过滤器(即 BlurFilter(0,0,0))。它
在某些情况下会起作用,但不是全部。
手动将所有文本字段缓存为
位图数据。这应该显示很多
更可靠的指标,但可以
棘手。您甚至可以在
使用 getColorBounds 飞行以获得
“真实”指标。但话又说回来,这就是全部
非常棘手,需要大量测试。
I've had similar issues, and all solutions I've tried are quite complex, or have some drawback:
Use TLF. I know you don't want to,
but it's a pretty safe (but complex)
solution.
Don't use "readability" antialiasing,
use "animation". Fonts will look
worst, but their metrics should be
a bit more reliable.
Try with cacheAsBitmap, or null
filters (i.e. BlurFilter(0,0,0)). It
will work in some cases, but not all.
Manually cache all textfields as
BitmapData. This should show much
more reliable metrics, but can be
tricky. You can even fix this on the
fly with getColorBounds to get the
"real" metrics. But again, it's all
very tricky, and needs a lot of testing.
听起来您使用的字体在西里尔文字形中存在实际错误。所以这里有一个非常简单但令人讨厌的解决方案。编辑字体。这听起来很疯狂,但西里尔字母字形并不多,而且您似乎只需要一种字体。编辑它,分发更正后的版本,就完成了。
Fontforge 相当不错,我敢打赌,一旦设置好,你可以在一小时内编辑字体。
It sounds like the font you are using has an actual error in the glyphs for cyrillic. So here's a brutally simple, but annoying solution. Edit the font. It sounds crazy, but there aren't that many Cyrillic glyphs, and you seem to want a single font. Edit it, distribute the corrected version, and you're done.
Fontforge is pretty decent, I'll bet you can edit the font in an hour once you're set up.
您是否尝试过使用固定宽度的字体?
Have you tried using a fixed width font?
您是否尝试过简单地修改字体以调整为 1px 左右。只需将字母向上(或向下)移动即可,我没有完全阅读每个人写的所有内容。虽然我目前没有安装它,但我相信我对编辑器的偏好是“Fontlab”。
Have you tried simply modifying the font to adjust for the 1px or so. Simply shift the letters upwards (or down) I didn't quite read everything that everyone wrote. Although I do not currently have it installed, I beleive my preference for editors is "Fontlab".