Flash 中的多种字体/语言支持
您好,
我正在编写一个支持多语言的 Flash 应用程序。 我最初选择的字体是 Tahoma,因为它支持 Unicode。 客户更喜欢非标准字体,例如 Lucida Handwriting。 Lucida 手写体没有与 Tahoma 相同的西里尔语支持,这提出了一个有几种方法可以解决的问题,我想征求您的建议,以了解哪种方法更可取:
据我所知,我可以:
- 为客户提供完全兼容 Unicode(西里尔文、希伯来文、阿拉伯文、繁体中文、东亚等)字体的列表以供选择。 (我不知道从哪里可以获得这样的列表;我在网络上的搜索只得到了部分符合 unicode 标准的字体列表。尝试 http://look.fo/list-of-unicode-filled-fonts 作为一个很好的起点来看看我在哪里看)。
- 根据客户的位置(我们已经拥有),为英语用户使用 Lucida Handwriting 进行渲染,为国际用户使用 Tahoma 进行渲染。 这可能有点让人头疼; 有人有过这种方法的经验吗?
- 构建一种新字体(IE、AlexeyMK Bold),它使用 Lucida Handwriting 表示英语,使用 Tahoma 表示其他字体。 这会向 Flash 文件的重量添加大约 500k 的内容,但应该(如果我理解正确的话)仅在第一次加载。
你有什么建议? 其中哪些是合理的解决方案,哪些是完全可行的? 有没有我没有想到的方法?
非常感谢! Alexey
编辑:关于该主题的一篇好文章: http://www.itworld.com/print/58558< /a>
Greetings,
I'm in the middle of writing a Flash application which has multilingual support. My initial choice of font for this was Tahoma, for its Unicode support. The client prefers a non-standard font such as Lucida Handwriting. Lucida Handwriting doesn't have the same, say, Cyrillic support as Tahoma, which poses a problem that there are a few ways to solve, and I'd like to ask for your advice on which is preferable:
From what I understand, I could:
- Give the client a list of fully Unicode-compatible (Cyrillic, Hebrew, Arabic, Traditional Chinese, East Asian, etc) fonts to choose from. (I have no idea where to get such a list; my search of the web has resulted only in lists of partially unicode-compliant fonts. Try http://look.fo/list-of-unicode-compliant-fonts as a good starting point to see where I looked).
- Depending on the client's location (which we already have), render in Lucida Handwriting for English-speaking users and in Tahoma for international users. This may be somewhat of a headache; has anyone had any experience with this approach?
- Build a new font (IE, AlexeyMK Bold) which uses Lucida Handwriting for English and Tahoma for everything else. This ads something like 500k to the weight of the Flash file, but should (if I understand correctly) only be loaded the first time.
What do you advise? Which of these are reasonable solutions, and which are completely out there? Is there a way that I'm not thinking of?
Much thanks!
Alexey
EDIT: A good article on the subject: http://www.itworld.com/print/58558
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,最终您只有两个真正的选择:要么在 SWF 中嵌入字体,保证字体的外观,要么不嵌入,并使用设备字体。 (或者两者的混合,根据区域使用嵌入或设备字体。)
如果您不嵌入任何字体,那么您为文本定义的任何字体最终都只是一个建议 - 用户将看到的是设备字体,由他们自己的机器渲染(使用该机器上的字体)。 因此,您可以“建议”Tahoma,但用户看到的内容将取决于他们是否拥有该字体(并且 Mac 版本的字体与 PC 版本的字体可能会有所不同)。 当然这也要看支持; 例如,如果他们没有亚洲字体,那么他们将看不到任何中文。 (注意:您还可以选择像“_sans”这样的字体,它只是告诉客户端使用其标准的无衬线字体。我的猜测是,在实践中,这最终将与您选择的字体相同。 d 定义了“Tahoma”,但 YMMV。)
如果您嵌入字体,那么用户将看到您所期望的内容,因为字体是由 Flash 而不是操作系统呈现的。 但如果你完全嵌入所有区域,包括中文所需的字形,那么我想你会发现它增加了超过 500K 的大小……根据我的经验,更像是 2-5MB。 但也许我遗漏了一些细节。 无论如何,对于通过网络传递的内容,我通常认为亚洲字体至少应该是设备字体。
要添加有关混合解决方案的一句话,我已经这样做了并且它是可行的。 也就是说,假设您可以将逻辑添加到 SWF,您可以(例如)为每个文本字段创建两个,一个使用嵌入式“Lucidawhat”,另一个使用非嵌入式“_sans”,然后在运行时创建一个其中一些不可见,并将文本放在另一个中,具体取决于您显示的区域。 (我通过创建一个 LocalizedTextfield 组件,并在初始化时让它从静态属性中读取区域设置来实现这一点。)然后,您只需为每个区域设置决定文件大小是否值得为该特定集合显示字形。
最后一句话是,您不一定可以假设您的字体所产生的文件大小只会加载一次。 如果您以简单的方式制作内容并将字体嵌入到文本字段中,那么字体信息将成为 SWF 的一部分,因此无论如何都会加载。 要外部化它,您可以将 Label 组件制作为一个单独的文件,然后决定是否加载它取决于浏览器的缓存设置。 您还可以外部化字体资源本身并将其用作共享资源,但在 AS2 中,这有点难以实现。 我听说 AS3 更容易,但我自己没有这样做过。
Well, ultimately you have only two real choices: either you embed a font in your SWF, guaranteeing what your fonts will look like, or you don't, and use device fonts. (Or a mixture of the two, using embedded or device fonts depending on region.)
If you don't embed any fonts, then whatever font you define for your text is ultimately just a suggestion - what the user will see is device fonts, being rendered by their own machine (using the fonts on that machine). So you can "suggest" Tahoma, but what the user sees will depend on whether they have that font (and it might vary for, say, Mac versions of the font vs. PC versions). Naturally this also depends on support; if they don't have Asian fonts then then they won't see any Chinese for example. (Note: you can also choose a font like "_sans", which just tells the client to use its standard sans-serif font. My guess is that in practice this will wind up being the same font that would have been chosen if you'd defined "Tahoma", but YMMV.)
If you embed your fonts, then the user will see exactly what you expect them to, because the font is rendered by Flash and not the OS. But if you embed fully for all regions, including the glyphs needed for Chinese, then I think you'll find it adds considerably more than 500K.. more like 2-5MB in my experience. But maybe there are some details I'm missing. Anyway, for content to be delivered over the web I would generally assume that, at minimum, asian fonts should be device fonts.
To add a word about a mixed solution, I've done this and it's doable. That is, assuming you can add the logic to your SWF, you could (for example) make two of each text field, one using embedded "Lucida whatever" and the other using non-embedded "_sans", and then at runtime make one of them invisible and put text in the other, depending on which region you're showing. (I did this by making a single LocalizedTextfield component, and having it read the locale out of a static property when it initialized.) Then you simply have to decide, for each locale, whether the file size is worth the display for that particular set of glyphs.
The final word is, you can't necessarily assume that the file size incurred by your fonts will only be loaded once. If you make your content the straightforward way and embed fonts in your text fields, then the font info will be part of your SWF, and thus loaded every time no matter what. To externalize it you could make the Label component a separate file, and then the decision to load it or not is up to the browser's caching settings. You can also externalize the font resource itself and use it as a shared resource, but in AS2 this is somewhat hairy to get working. I've heard it's easier in AS3 but not done it myself.