开发者

How can I prevent text displacement for some foreign language fonts?

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开发者_StackOverflow中文版/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?


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:

  public static function adjustPositioning(field:TextField):void
  {
    if(OS != "MAC") return;
    var fontSize:int = field.defaultTextFormat.size as int;
    field.y += fontSize/5;
  }

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!


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.


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


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.


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?


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".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜