1

我用自定义字体创建了一个网页,我可以看到在浏览器中应用的字体,但在打印页面中没有应用。

我按照以下方式进行打印:

fonttest.css 文件包含以下内容:

@font-face {
font-family: "myriad";
src: url("../fonts/myriad.otf") format('truetype');
}
@font-face {
font-family: "serifa-bold";
src: url("../fonts/serifa_bold.ttf") format('truetype');
}
@font-face {
font-family: "serifa";
src: url("../fonts/serifa.ttf") format('truetype');
}
@font-face {
font-family: "AlexandriaFLF";
src: url("../fonts/AlexandriaFLF.ttf") format('truetype');
}
@font-face {
font-family: "AlexandriaFLF-Bold";
src: url("../fonts/AlexandriaFLF-Bold.ttf") format('truetype');
}
@font-face {
font-family: "AlexandriaFLF-BoldItalic";
src: url("../fonts/AlexandriaFLF-BoldItalic.ttf") format('truetype');
}
@font-face {
font-family: "AlexandriaFLF-Italic";
src: url("../fonts/AlexandriaFLF-Italic.ttf") format('truetype');
}

在 HTML 文件中,CSS 文件链接如下:

<link rel='stylesheet' type='text/css' media='all'  href='resource/css/fonttest.css' />

我正在打印以下行:

<p style="font-family:myriad;color:#000000">myriad-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789</p>
<p style="font-family:serifa-bold;color:#000000">serifa-bold-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789</p>
<p style="font-family:serifa;color:#000000">serifa-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789</p>
<p style="font-family:AlexandriaFLF;color:#000000">AlexandriaFLF-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789</p>
<p style="font-family:AlexandriaFLF-Italic;color:#000000">AlexandriaFLF-Italic-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789</p>
<p style="font-family:AlexandriaFLF-Bold;color:#000000">AlexandriaFLF-Bold-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789</p>
<p style="font-family:AlexandriaFLF-BoldItalic;color:#000000">AlexandriaFLF-BoldItalic-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789</p>

请帮我 ?

4

4 回答 4

1

尝试将您的样式表媒体属性设置为 print :

<link rel='stylesheet' type='text/css' media='print'  href='resource/css/fonttest.css' />
于 2012-11-20T06:11:36.103 回答
1

如果您找不到执行此操作的方法,则可以使用另一种方法。

您可以使用wkhtml2pdf并制作可打印的 PDF 文件。

于 2012-11-20T11:31:22.937 回答
1

也许您可能需要在您的 css 中包含更多字体格式。像这样的东西:

@font-face {
font-family: 'XXXXX';
src: url('XXXXX.eot');
src: url('XXXXX.eot?#iefix') format('embedded-opentype'),
     url('XXXXX.woff') format('woff'),
     url('XXXXX.ttf') format('truetype'),
     url('XXXXX.svg#XXXXX') format('svg');
font-weight: normal;
font-style: normal;

}
于 2012-11-21T10:43:58.013 回答
1

the url https://bugzilla.mozilla.org/show_bug.cgi?id=468568 which explains why print is not working for custom fonts, so I tested in firefox-20.0a1.en-US.win32.installer.exe. The fonts with ttf and otf are applied exactly as it should be.

于 2012-11-26T10:54:14.043 回答