[prev in list] [next in list] [prev in thread] [next in thread] 

List:       fop-user
Subject:    RE: when apache FOP will full support font-family lists and font-selection-strategy ?
From:       "Pascal Sancho" <pascal.sancho () takoma ! fr>
Date:       2005-12-27 9:57:25
Message-ID: 743B49C43C0964459527F8E8D4B04D8A399EA6 () mercure ! takoma ! fr
[Download RAW message or body]

Hi Guangxian Zou,

You can try to modify this following snippet (full xslt 1.0) to use it with chinese \
characters.

This works fine with Greek charaters that are in the symbol charset but not in the \
standard charsets (serif/sans serif/courrier).

You just need to replace $expression with chinese characters and choose appropriate \
                fo:inline/@font-family...
Note: the 1st $expression character is used to replace non latin characters in the \
translate() function.

Hope that helps you
Pascal

<xsl:template match="text()">
	<xsl:call-template name="testChar">
		<xsl:with-param name="text" select="."/>
	</xsl:call-template>
</xsl:template>

<xsl:template name="testChar">
	<xsl:param name="text"/>
	<xsl:variable name="expression">&#x0391;&#x0392;&#x0393;&#x0394;&#x0395;&#x0396;&#x03 \
97;&#x0398;&#x0399;&#x039A;&#x039B;&#x039C;&#x039D;&#x039E;&#x039F;&#x03A0;&#x03A1;&#x \
03A3;&#x03A4;&#x03A5;&#x03A6;&#x03A7;&#x03A8;&#x03A9;&#x03B1;&#x03B2;&#x03B3;&#x03B4;& \
#x03B5;&#x03B6;&#x03B7;&#x03B8;&#x03B9;&#x03BA;&#x03BB;&#x03BC;&#x03BD;&#x03BE;&#x03BF \
;&#x03C0;&#x03C1;&#x03C2;&#x03C3;&#x03C4;&#x03C5;&#x03C6;&#x03C7;&#x03C8;&#x03C9;&#x03D1;&#x03D2;&#x03D5;&#x03D6;</xsl:variable>
  <xsl:variable name="textTemplate" \
select="translate($text,$expression,'&#x0391;&#x0391;&#x0391;&#x0391;&#x0391;&#x0391;& \
#x0391;&#x0391;&#x0391;&#x0391;&#x0391;&#x0391;&#x0391;&#x0391;&#x0391;&#x0391;&#x0391 \
;&#x0391;&#x0391;&#x0391;&#x0391;&#x0391;&#x0391;&#x0391;&#x0391;&#x0391;&#x0391;&#x03 \
91;&#x0391;&#x0391;&#x0391;&#x0391;&#x0391;&#x0391;&#x0391;&#x0391;&#x0391;&#x0391;&#x \
0391;&#x0391;&#x0391;&#x0391;&#x0391;&#x0391;&#x0391;&#x0391;&#x0391;&#x0391;&#x0391;&#x0391;&#x0391;&#x0391;&#x0391;')"/>
  <xsl:choose>
		<xsl:when test="contains($textTemplate,'&#x0391;')">
			<xsl:variable name="textBefore" \
select="substring-before($textTemplate,'&#x0391;')"/>  <xsl:variable \
name="charPosition" select="string-length($textBefore)+1"/>  <xsl:value-of \
select="$textBefore"/><fo:inline font-weight="normal" \
                font-family="Symbol"><xsl:value-of
					select="substring($text,$charPosition,1)"/></fo:inline><xsl:call-template
					name="testChar">
					<xsl:with-param name="text" select="substring($text,$charPosition+1)"/>
				</xsl:call-template>
		</xsl:when>
		<xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
	</xsl:choose>
</xsl:template>
 

> -----Message d'origine-----
> De : Jeremias Maerki [mailto:dev@jeremias-maerki.ch] 
> Envoyé : jeudi 22 décembre 2005 08:01
> 
> Both properties are not fully implemented even in the latest 
> release FOP 0.90alpha1. Either you have to place either the 
> Chinese or the English text in fo:inlines and specify the 
> different fonts on the inlines or if you have a TrueType font 
> that supports both Chinese and English characters you can 
> have them mixed. The other option is to help us implement 
> font-selection-strategy and font-family lists.
> 
> On 21.12.2005 14:24:05 Guangxian Zou wrote:

> > thanks fop developers. :) i am using fop to translate xml to fo and 
> > then to pdf. :) I want to mixing chinese and english font, when 
> > print/render english use english font, and when print/render chinese 
> > character use chinese font. :) but I don't know how to do that in the 
> > current fop version (0.20.5).
> > can you give me some advice ? thanks.


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic