font是嵌入字体和非嵌入字体有什么区别? [英] What 's difference between font is embedd fonts and nonembedd font?

查看:1709
本文介绍了font是嵌入字体和非嵌入字体有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在书中我看到示例:

BaseFont bf = BaseFont.createFont("KozMinPro-Regular", "Identity-V", BaseFont.NOT_EMBEDDED);
Font font = new Font(bf, 20);
VerticalText vt = new VerticalText(writer.getDirectContent()); vt.setVerticalLayout(390, 570, 540, 12, 30);
font = new Font(bf, 20);
vt.addText(new Phrase(convertCIDs("a"), font));
vt.go();

public String convertCIDs(String text) {
  char cid[] = text.toCharArray();
  for (int k = 0; k < cid.length; ++k) {
  char c = cid[k];
  if (c == '\n')
    cid[k] = '\uff00';
  else
    cid[k] = (char) (c - ' ' + 8720);
  }
  return new String(cid);
}

当我改为:

BaseFont bf = BaseFont.createFont("/../KozMinProRegular.otf",BaseFont.IDENTITY_V, BaseFont.EMBEDDED);

结果:'a'没有顺时针旋转90度。

The result : 'a' isn't rotated 90 degrees clockwise.

推荐答案

当未嵌入字体时,PDF查看器不知道字体是什么样的。它不是使用实际字体,而是在查看文档的人的操作系统上搜索具有类似名称的字体。

When a font is not embedded, the PDF viewer does not know what the font looks like. Instead of using the actual font, it searches for a font with a similar name on the operating system of the person viewing the document.

例如:有14个 - 称为标准类型1字体,不需要嵌入:

For instance: there are 14 so-called Standard Type 1 fonts that do not need to be embedded:


  • zapfdingbats

  • times-roman

  • times-italic

  • helvetica-boldoblique

  • courier-boldoblique

  • helvetica-bold

  • helvetica

  • courier-oblique

  • helvetica-oblique

  • courier-bold

  • times-bolditalic

  • courier

  • times-bold

  • symbol

  • zapfdingbats
  • times-roman
  • times-italic
  • helvetica-boldoblique
  • courier-boldoblique
  • helvetica-bold
  • helvetica
  • courier-oblique
  • helvetica-oblique
  • courier-bold
  • times-bolditalic
  • courier
  • times-bold
  • symbol

如果您在iText中使用这些字体, iText将忽略嵌入式参数,因为可以安全地假设Adobe Reader和其他查看者可以正确呈现这些字体。

If you use these fonts in iText, iText will ignore the embedded parameter, because it is safe to assume that Adobe Reader and other viewers can render these fonts correctly.

现在假设您使用特殊字体(例如可口可乐字体)来绘制您看到的文字o可口可乐的广告,或者像沃尔特迪斯尼字体,使用卷曲的沃尔特·迪斯尼字形来绘制文字。在这种情况下,最好嵌入字体。如果不这样做,当用户打开PDF文档时,很可能无法正确显示字体。

Now suppose that you use a special font, such as the Coca Cola font to draw the text you see on a Coca Cola advertisement, or such as a Walt Disney font to draw text using the curly Walt Disney glyphs. In that case, it is better to embed the font. If you don't, there's a huge chance that the font won't be displayed correctly when a user opens his PDF document.

嵌入字体意味着包含完整字体的字形描述或字体的子集到PDF中。这会导致文件大小增加,但在某些情况下,必须嵌入字体。例如:如果您要遵守PDF / A标准,则需要嵌入所有字体。

Embedding a font, means that you include the glyph descriptions of the full font or a subset of the font into the PDF. This results in an increased file size, but in some cases, it is mandatory to embed the font. For instance: if you want to comply with the PDF/A standard, all fonts need to be embedded.

使用CJK字体时(在itext中定义的字体) -asian.jar),iText将忽略 embedded 参数。它将从不嵌入CJK字体,因为CJK字体期望在您的查看器中存在亚洲字体包(如果它不存在,Adobe Reader将要求您下载这样的字体包)。

When using a CJK font (one that is defined in the itext-asian.jar), iText will ignore the embedded parameter. It will never embed a CJK font, because CJK fonts expect the presence of an Asian font pack in your viewer (if it's not present, Adobe Reader will ask you to download such a font pack).

当使用 IDENTITY_H IDENTITY_V 时,iText也会忽略 embedded 参数,因为PDF规范要求在使用 encoding 参数的这些值时嵌入字体的子集。

When using IDENTITY_H or IDENTITY_V, iText will also ignore the embedded parameter because the PDF specification demands that you embed a subset of the font when using these values for the encoding parameter.

目前还不清楚为什么在更改 embedded 参数时,你会想到字形顺时针旋转90度。在我看来,你正在混合一些概念。 IDENTITY_V 与旋转字形无关。它是关于垂直渲染文本而不是水平渲染文本。对于西方语言,我们将文本水平地写成从左到右,从上到下的行。阿拉伯语和希伯来语从右到左用水平线写成。一些亚洲语言,例如日语,是从右到左的垂直书写的。这是你打算使用 IDENTITY_V ,而不是将字形旋转90度,而是确保不同字形之间的垂直间距是正确的(而 IDENTITY_H 定义水平间距。)

It is unclear why you would expect glyphs to be rotated 90 degrees clockwise when changing the embedded parameter. It seems to me that you are mixing some concepts. IDENTITY_V isn't about rotating glyphs. It's about rendering text vertically instead of horizontally. For Western languages, we write text horizontally in lines that go from left to right and top to bottom. Arabic and Hebrew are written in horizontal lines from right to left. Some Asian languages, such as Japanese, are written vertically, in columns from right to left. This is when you are going to use IDENTITY_V, not as much to rotate the glyphs by 90 degrees, but to make sure that the vertical spacing between the different glyphs is correct (whereas IDENTITY_H defines the horizontal spacing).

参见 vertical_text_1.pdf ,其中 V 是有意义的。还有一个我们旋转文本的例子:

See vertical_text_1.pdf for an example where the V makes sense. There's also an example where we rotate the text:

/**
 * Converts the CIDs of the horizontal characters of a String
 * into a String with vertical characters.
 * @param text The String with the horizontal characters
 * @return A String with vertical characters
 */
public String convertCIDs(String text) {
    char cid[] = text.toCharArray();
    for (int k = 0; k < cid.length; ++k) {
        char c = cid[k];
        if (c == '\n')
            cid[k] = '\uff00';
        else
            cid[k] = (char) (c - ' ' + 8720);
    }
    return new String(cid);
}

结果如下所示: vertical_text_2.pdf (不是那么好,我承认)。可以在此处找到此示例的完整代码。

The result looks like this: vertical_text_2.pdf (not that good, I admit). The full code for this example, can be found here.

这篇关于font是嵌入字体和非嵌入字体有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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