unicode字符的飞碟字体 [英] Flying Saucer font for unicode characters

查看:221
本文介绍了unicode字符的飞碟字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Grails导出插件(基本上,飞碟)生成PDF。我的GSP页面是一个UTF-8页面(或至少属性显示它是UTF-8,也在GSP页面的开头有一个<?xml version =1.0编码=UTF-8?> 指令)。首先生成的PDF正确包含变音字符äöüõ,但是从PDF中缺少西里尔字符(根本没有呈现)。然后我按照文档中所述改变了css文件,添加了以下内容:

  @ font-face {
src :url(ARIALUNI.TTF);
-fs-pdf-font-embed:embed;
-fs-pdf-font-encoding:UTF-8;
}
body {
font-family:Arial Unicode MS,Arial,sans-serif;
}

ArialUni.ttf也部署到服务器。但现在我得到两个变音字符和西里尔字符呈现为框。如果我将-fs-pdf-encoding属性值更改为Identity-H,那么乌拉尔字符将正确呈现,但是西里尔字符将呈现为问号。



什么字体可以用来正确呈现乌姆和西里尔字符?或者可能是我的CSS是什么错了?任何提示都将非常感激。



更新1:
我也试过下面的css =http://fontface.codeandmore.com/ =nofollow> http://fontface.codeandmore.com/ ):

  @ font-face {
font-family:'ArialUnicodeMS';
src:url('arialuni.ttf');
src:url('arialuni.eot?#iefix')format('embedded-opentype'),
url('arialuni.woff')format('woff'),
url ('arialuni.ttf')format('truetype'),
url('arialuni.svg#arialuni')format('svg');
font-weight:normal;
font-style:normal;
-fs-pdf-font-embed:embed;
-fs-pdf-font-encoding:UTF-8;
}

body {
font-family:'ArialUnicodeMS';
}

我已添加< meta http-equiv =Content-Typecontent =text / html; charset = UTF-8/>
我也试图运行grails with -Dfile.encoding = UTF-如下所述: http:// grails.1312388.n4.nabble.com/PDF-plugin-Having-problems-with-instalation-td2297840.html ,但没有任何帮助。西里尔字符根本不显示。任何其他想法可能是什么问题?



* BTW: *我将PDF封装为zip并发送回浏览器响应:

  response.setHeaderContent-disposition,attachment; filename = test.zip
response.setHeaderContent-Encoding,UTF-8
response.contentType ='application / zip'
response.outputStream< zip
response.outputStream.flush()
response.outputStream.close()

我需要以某种方式考虑编码,而压缩????,我这样做:

  public static byte [ ] zipBytes(Map< String,ByteArrayOutputStream> fileNameToByteContentMap)throws IOException {
ByteArrayOutputStream zipBaos = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(zipBaos);
fileNameToByteContentMap.eachWithIndex {String fileName,ByteArrayOutputStream baos,i - >
byte [] content = baos.buf
ZipEntry entry = new ZipEntry(fileName)
entry.setSize(content.length)
zos.putNextEntry zos.write(content)
zos.closeEntry()
}
zos.close()
return zipBaos.toByteArray();
}


解决方案

具有以下css和.ttf文件,它由face-kit-generator生成:

  @ font-face {
src:url('arialuni.ttf');
-fs-pdf-font-embed:embed;
-fs-pdf-font-encoding:Identity-H;
}

body {
font-family:Arial Unicode MS,Lucida Sans Unicode,Arial,verdana,arial,helvetica,sans-serif;
font-size:8.8pt;很奇怪的是,如果我把字体放到某个文件夹,让我们说fonts,然后输入fonts。 ,它会找到字体,但字符将不会呈现。


I am generating PDF using Grails export plugin (basically, Flying Saucer). My GSP page is an UTF-8 page (or at least properties are showing that it is UTF-8, also in the beginning of the GSP page there is a <?xml version="1.0" encoding="UTF-8"?> directive). At first generated PDF properly contained umlaut characters "äöüõ", but Cyrillic characters were missing from PDF (not rendered at all). Then I've changed my css file as described in documentation by adding following:

@font-face {
    src: url(ARIALUNI.TTF);
    -fs-pdf-font-embed: embed;
    -fs-pdf-font-encoding: UTF-8;
}
body {
      font-family: "Arial Unicode MS", Arial, sans-serif;
}

ArialUni.ttf is also deployed to the server. But now I am getting both umlaut characters and Cyrillic characters rendered as boxes. If I am changing -fs-pdf-encoding property value to Identity-H then umlaut characters are rendered properly, but Cyrillic characters are rendered as question marks.

Any ideas of what font can be used to properly render both umlaut and Cyrillic characters? Or may be my CSS is somehow wrong? Any hints would be much appreciated.

Upd 1: I have also tried following css (which was generated by http://fontface.codeandmore.com/):

@font-face {
    font-family: 'ArialUnicodeMS';
    src: url('arialuni.ttf');
    src: url('arialuni.eot?#iefix') format('embedded-opentype'),
        url('arialuni.woff') format('woff'),
        url('arialuni.ttf') format('truetype'),
        url('arialuni.svg#arialuni') format('svg');
    font-weight: normal;
    font-style: normal;
    -fs-pdf-font-embed: embed;
    -fs-pdf-font-encoding: UTF-8;
}

body {
    font-family:'ArialUnicodeMS';
}

I've added <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> I was also trying to run grails with -Dfile.encoding=UTF-8, as was mentioned here: http://grails.1312388.n4.nabble.com/PDF-plugin-Having-problems-with-instalation-td2297840.html, but nothing helps. Cyrillic characters are not shown at all. Any other ideas what might be the problem?

*BTW:*I am packaging my PDF as zip and sending it back to browser in the response like that:

response.setHeader "Content-disposition", "attachment; filename=test.zip"
response.setHeader "Content-Encoding", "UTF-8"
response.contentType = 'application/zip'
response.outputStream << zip
response.outputStream.flush()
response.outputStream.close()

Do I need to somehow consider encoding while zipping????, which I do like that:

public static byte[] zipBytes(Map<String, ByteArrayOutputStream> fileNameToByteContentMap) throws IOException {
        ByteArrayOutputStream zipBaos = new ByteArrayOutputStream();
        ZipOutputStream zos = new ZipOutputStream(zipBaos);
        fileNameToByteContentMap.eachWithIndex {String fileName, ByteArrayOutputStream baos, i  ->
            byte[] content = baos.buf
            ZipEntry entry = new ZipEntry(fileName)
            entry.setSize(content.length)
            zos.putNextEntry(entry)
            zos.write(content)
            zos.closeEntry()
        }
        zos.close()
        return zipBaos.toByteArray();
    }

解决方案

For some reason it started working with following css and .ttf file, which was generated by face-kit-generator:

@font-face {
    src: url('arialuni.ttf');
    -fs-pdf-font-embed: embed;
    -fs-pdf-font-encoding: Identity-H;
}

body {
    font-family: Arial Unicode MS, Lucida Sans Unicode, Arial, verdana, arial, helvetica, sans-serif;
    font-size: 8.8pt;
}

Weird thing is that if I put font into some folder, let say "fonts", it will find the font but characters won't be rendered.

这篇关于unicode字符的飞碟字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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