在 Adob​​e Flex 中,为什么嵌入版本的字体与系统中安装的相同字体的行为不同

发布于 2024-08-30 02:43:55 字数 2067 浏览 5 评论 0原文

场景:

Flex 应用程序利用 @font-face 声明来嵌入字体。 (需要嵌入字体才能旋转文本。)

该应用程序最初是作为英语应用程序开发的,但在本地化过程中,需要找到能够显示亚洲字符的 unicode 字体。该应用程序的原始实现使用四种字体来满足字符强调的各种排列。粗体、粗体斜体、斜体和正常都是通过 Arial 系列中相应的 Arial 字体提供的。

问题:

当尝试通过类似的方式将字体编译为可用于粗体、斜体和粗体斜体的字体时(是的,这并不理想,这只是一个测试,看看是否可以完成):

@font-face { src:url("/fonts/ArialUnicode.ttf"); 
             fontFamily: myFamily;
             fontWeight: normal;
             fontStyle: normal;
             advancedAntiAliasing: true; }

@font-face { src:url("/fonts/ArialUnicode.ttf"); 
             fontFamily: myFamily;
             fontWeight: bold;
             fontStyle: normal;
             advancedAntiAliasing: true; }

etc.

问题是编译应用程序时 Flex 变得暴躁并给出以下错误消息:

[ERROR] /dirpath/Style.css:[49,-1] 转码期间出现异常:未找到具有斜体样式的别名“myFont”的字体at: file:/dirpath/fonts/ArialUnicode.ttf

因此,经过一些调查,确定由于 Unicode 既不支持斜体也不支持粗体,因此当 Flex 编译器尝试嵌入字体时,它会感到不高兴,因为它无法找到指定位置的字体将满足 css 要求。

现在,当字体声明恢复为最简单的形式时:

@font-face { src:url("/fonts/ArialUnicode.ttf"); 
             fontFamily: myFamily;
             fontWeight: normal;
             fontStyle: normal;
             advancedAntiAliasing: true; }

一切都编译良好,并且应用程序可以很好地显示所有正常粗细、正常样式的亚洲字符。但是,当在样式表中显示要以粗体或斜体显示的内容时,会出现一个框,表示没有嵌入字体或任何可以在这些样式中呈现该字符的系统字体。

现在事情变得奇怪了。

如果系统上安装了完全相同的 Unicode 字体,它将开始以粗体和斜体显示亚洲字符。这是没有意义的,因为粗体和斜体字符不在字体中,正如 Flex 尝试嵌入该字体以满足上面的 css 样式时所演示的那样。但很明显,这种字体被用来显示粗体和斜体字符,在它作为系统字体安装之前,它们只是方框。这是某种 Flex 巫术吗?如果是这样,我可以通过某种方式以编程方式调用所述巫术,因为我不能依赖用户必须出去并在其系统上安装 unicode 字体。

编辑: 以下是一些可能澄清该问题的进一步信息。

我的问题并不是我们如何为罗马字符设置多种字体和粗细,而是“Flex 如何将粗体和斜体应用于系统字体。更重要的是,当它说该字体在尝试嵌入时不支持这些字体时那个字体。”

重现该问题的步骤如下:

  1. 仅将 MS Arial Unicode 嵌入到应用程序中并进行部署。
  2. 在新的 Windows 2003 计算机上,打开 Firefox 并选择日语。
  3. 导航到应用程序 URL 并查看粗体和斜体所在的框。
  4. 现在退出火狐浏览器。将 MS Arial Unicode 字体安装到 Windows 2003 系统中。
  5. 打开 Firefox 并重复。以前是方框的区域现在是粗体/粗体斜体/斜体日语字符。

与其说是如何解决这个问题,不如说是如何解决这个问题。有很多可行的解决方案。然而,我真正想知道的是 Flex 如何将粗体和斜体应用到它说不支持粗体或斜体的字体。

谢谢, C

Scenario:

Flex application utilizing an @font-face declaration for embedding the font. (Embedded fonts are required to be able to rotate text.)

The application was originally developed as an English application, but during localization it became necessary to locate a unicode font capable of displaying Asian characters. The original implementation of the application uses four fonts to satisfy the various permutations of character emphasis. Bold, Bold Italic, Italic and Normal are all supplied through the corresponding Arial fonts in the Arial family.

Problem:

When trying to compile in the font as one that could be used for the bold, italic, and bold italic through something like (yes its not ideal, this was just a test to see if it could be done):

@font-face { src:url("/fonts/ArialUnicode.ttf"); 
             fontFamily: myFamily;
             fontWeight: normal;
             fontStyle: normal;
             advancedAntiAliasing: true; }

@font-face { src:url("/fonts/ArialUnicode.ttf"); 
             fontFamily: myFamily;
             fontWeight: bold;
             fontStyle: normal;
             advancedAntiAliasing: true; }

etc.

The problem is that when compiling the application Flex gets cranky and gives the following error message:

[ERROR] /dirpath/Style.css:[49,-1] exception during transcoding: Font for alias 'myFont' with italic style was not found at: file:/dirpath/fonts/ArialUnicode.ttf

So with some investigation it was determined that since Unicode supports neither Italics nor Bold, that when the Flex compiler attempts to embed the font, it gets unhappy as it cannot locate a font at the specified location that will satisfy the css requirement.

Now when the font-face declaration is taken back to its simplest form of:

@font-face { src:url("/fonts/ArialUnicode.ttf"); 
             fontFamily: myFamily;
             fontWeight: normal;
             fontStyle: normal;
             advancedAntiAliasing: true; }

everything compiles fine and the application displays all normal weight, normal style Asian characters fine. However when displaying things that are to be displayed in Bold or Italic in the style sheet, a box appears denoting that there is no embedded font nor any system font that can render that character in those styles.

Now here is where it gets weird.

If the exact same Unicode font is installed onto the system, it begins displaying the Asian characters in bold and italic. This makes no sense as the Bold and Italic characters are not in the font as demonstrated when Flex tried to embed that font to satisfy those css styles above. Yet it is evident that this font is being utilized to display the bold and italic characters as before they were just boxes before it was installed as a system font. Is this some kind of Flex voodoo? And if so is there some way I can programmatically invoke said voodoo as I cannot rely on the user having to go out and get the unicode font installed on their system.

Edit:
Here is some further information that may clarify the issue.

My question is not really how do we do multiple font faces and weights for roman characters, it is "How does Flex apply bolding and italics to a system font. Even more so when it says that that font does not support those when trying to embed that font."

The steps to make the issue reproducable are such:

  1. Embed only MS Arial Unicode into the application and deploy it.
  2. On a fresh Windows 2003 machine, open up Firefox and select Japanese language.
  3. Navigate to the application URL and view the boxes where the bold and italics should be.
  4. Now exit Firefox. Install the MS Arial Unicode font into the Windows 2003 system.
  5. Open Firefox and repeat. The areas that used to be boxes, are now bold/bold italics/italics Japanese characters.

It isn't so much the how to solve this issue. There are plenty of viable solutions. However what I would really like to know is how does Flex apply bold and italics to a font that it says does not support bold or italics.

Thanks,
C

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不如归去 2024-09-06 02:43:55

问题是您为所有四种字体变体指定了相同的文件名。单个 ArialUnicode.ttf 文件仅包含一种变体。

使用 c:\Windows\fonts 目录中的名称,您想要嵌入 arial.ttf、arialbd.ttf、arialbi.ttf 和 ariali.ttf。这些分别是正常、粗体、粗斜体和斜体变体。

请注意,从技术角度和法律角度来看,并非所有字体都可以自由嵌入。

从法律角度来说,字体是软件,因此需要像程序中包含的任何其他第三方代码一样获得许可。您可能想查看 Bitstream Vera 字体系列,因为它们是自由许可的。该系列功能强大,旨在用作 Linux 等中的核心字体。

从技术角度来说,这些规则已融入 TTF 和 OTF 文件格式中,并且 Flex 编译器等工具遵守文件中声明的许可证限制。如果字体标记为“不可嵌入”,则不会让您嵌入它。

The problem is that you're specifying the same file name for all four font variants. The single ArialUnicode.ttf file contains only one variant.

Using the names from your c:\Windows\fonts directory, you want to embed arial.ttf, arialbd.ttf, arialbi.ttf, and ariali.ttf. These are the normal, bold, bold-italic and italic variants, respectively.

Beware that not all fonts can be embedded freely, both from a technical standpoint and from a legal standpoint.

The legal side is that fonts are software, and so need to be licensed just like any other third-party code you include in your program. You might want to look at the Bitstream Vera font family, as they are liberally-licensed. The family is highly capable, designed to be used as core fonts in Linux and such.

The technical side is that these rules are baked into the TTF and OTF file formats, and tools like the Flex compiler obey the license restrictions declared in the file. If the font is marked "no embed", it won't let you embed it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文