You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Maxime Bégnis <ma...@neodoc.biz> on 2015/02/13 16:21:28 UTC

Chinese font?

Hi,

I'm trying to produce a PDF containing Chinese text using FOP 1.0. I
tried many TTF fonts but there is always some characters appearing as a "#".

Does anyone recommend a specific Chinese TTF font to be used with FOP?

Many thanks,

-- 
-- 
*NeoDoc*
*Maxime Bégnis*
maxime@neodoc.biz
Tél: +33 (0)4.42.52.24.20
5, rue de la Touloubre
13770 Venelles
France
http://www.neodoc.fr/

Re: Chinese font?

Posted by Robert Gurol <ro...@signavio.com>.
Hi Maxime,

a while ago I had the same issue, and ultimately decided to use the HanaMin
fonts (cf. here http://www.fonts.jp/hanazono/). The ttf is so large it is
split into two files, best configure them in a configuration file you feed
to FOP, like this:


        <!--  HanaMinA Regular -->
        <font kerning="yes" embed-url="HanaMin/HanaMinA.ttf">
            <font-triplet name="HanaMinA" style="normal" weight="normal"/>
        </font>
        <font kerning="yes" embed-url="HanaMin/HanaMinA.ttf">
            <font-triplet name="HanaMinA" style="normal" weight="bold"/>
        </font>
        <font kerning="yes" embed-url="HanaMin/HanaMinA.ttf">
            <font-triplet name="HanaMinA" style="italic" weight="normal"/>
        </font>
        <font kerning="yes" embed-url="HanaMin/HanaMinA.ttf">
            <font-triplet name="HanaMinA" style="italic" weight="bold"/>
        </font>
...

>From Java, you can source such configuration file using
DefaultConfiguration conf = (DefaultConfiguration) new
DefaultConfigurationBuilder().buildFromFile(f);

For more on configuration, check here:
https://xmlgraphics.apache.org/fop/1.1/configuration.html

If you are rendering SVG images, I found registering the font with the
graphics envoronment to be the best option:

GraphicsEnvironment lge = GraphicsEnvironment.getLocalGraphicsEnvironment();
for (File fontFile : myGetFontFilesTtf()) {
try {
Font font = Font.createFont(Font.TRUETYPE_FONT, fontFile);
if (!lge.registerFont(font)) {
LOGGER.warn("Font registration unsuccessful: " +
fontFile.getAbsolutePath());
} else {...}
...}
}

Best regards,

Robert

Re: Chinese font?

Posted by Glenn Adams <gl...@skynav.com>.
Try FOP 1.1 or current trunk build.

On Fri, Feb 13, 2015 at 8:21 AM, Maxime Bégnis <ma...@neodoc.biz> wrote:

>  Hi,
>
> I'm trying to produce a PDF containing Chinese text using FOP 1.0. I tried
> many TTF fonts but there is always some characters appearing as a "#".
>
> Does anyone recommend a specific Chinese TTF font to be used with FOP?
>
> Many thanks,
>
> --
> --
>  *NeoDoc*
> *Maxime Bégnis*
>  maxime@neodoc.biz
>  Tél: +33 (0)4.42.52.24.20
>  5, rue de la Touloubre
>  13770 Venelles
>  France
>  http://www.neodoc.fr/
>