Why is text truncated in PDF with Linux?

北城以北 提交于 2019-11-29 14:30:45
Petter Friberg

To calculate the font-metrics correctly, the font needs to be available to the java virtual macchine.

See this historical question: Font is not available to the JVM with Jasper Reports, that show various solution to the old error launched

However the correct solution with jasper-reports is to use font-extensions

If you use the distributed jasperreports-font.jar it contains these fonts:

DejaVu Sans
DejaVu Serif
DejaVu Sans Mono

You need to use one of these in font name example fontName="DejaVu Sans", there is no automatic mapping to other fonts, the jar physically contains only these .ttf and no other (open jar and verify for different version of jasper-reports).

Hence only font installed on the pc or included in font-extension are available for the JVM.

If you need other fonts, the best solution is to generate your own font-extension including a valid .ttf font this can be done from within the IDE.

Never assume a particular font is available on a client system – gone are the days when there were only a couple of desktop operating systems on the market, available in a handful of western languages, with well-known lists of fonts that were stable for decades.

It's now much easier to create new fonts, users access content in their own language (with language-specific fonts), the industry launches new form factors every few years (with new vanity fonts), Unicode.org releases new specifications (that require overhauling existing fonts) and as a result the actual fonts present on different systems vary widely.

OSX and Windows still function somewhat in the old "fixed font list" mode, but newer entrants don't.

For PDFs, that means you have to embed fonts in the documents. For the web, that means flexible site design that does not depend on exact pixel letter dimensions.

Trying to use an old legacy font like Helvetica or Arial is a pathologic case: either the client won't have it installed at all, and will alias it to something with different glyph metrics, or it will have an ancient version, that is lacking all the codepoints added since ASCII went out of favour, and won't be able to render modern international text. Arial is a bit more likely to work due to long windows dominance, but that's eroding quickly.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!