HTML to PDF / DOCX / RTF Java converter library › Forums › PD4ML v3 Archived Forums (Read Only) › Troubleshooting › Dynamic font substitution logic does not work for me?
- This topic has 5 replies, 2 voices, and was last updated Apr 19, 2011
16:32:05 by Anonymous.
-
AuthorPosts
-
April 13, 2011 at 19:05#26548
I saw in pdf-generation-library-licensing-f6/announcements-t162.html that since v360b2 version of the pd4ml the characters that cannot be drawn using their font will be drawn using some other font which can draw them.
I downloaded and used the version 370 PD4ML Pro (Trial), and this functionality did not work the way I expected it to works.
<br /> ...<br /> renderer.useTTF("/home/nenad/Desktop/fonts/", true);<br /> chineseTxt = "常常有不同的方法來寫同樣的漢字,這些被統。有些差異是由於性格的簡化,而有些則是純粹的字形差異,如中風造型。在造型的招用的明朝風格的字體來自康熙字典中使用。在大陸中";<br /> contentStr = "<p>AR PL New Sung: <font face='AR PL New Sung'>" + chineseTxt + "</font></p>"<br /> + "<p>KaiTi_GB2312: <font face='KaiTi_GB2312'>" + chineseTxt + "</font></p>"<br /> + "<p>arial: <font face='arial'>" + chineseTxt + "</font></p>"<br /> + "<p>one more time - without the font: " + chineseTxt + "</p>";<br /> renderer.render(new StringReader(contentStr), formStream);<br />
The result was that the “AR PL New Sung” and “KaiTi_GB2312” were displayed correctly (with Chinese characters), but the ‘arial’ and ‘one more time’ text are not printed at all. The text I used is:
We have been using 323fx1 PD4ML Pro and are considering an upgrade to the newer version because of this feature, but it seems to me that it does not work?
April 14, 2011 at 19:47#28509In order to find an appropriate font to display a text string, PD4ML walks the following lists:
[language=java:3vg6yswk]private static String[] serifFallback = new String[] {
“Times New Roman”,
“MS Mincho”,
“MingLiU”,
“SimSun”,
“Mangal”,
“David”,
“Batang”,
“Wingdings”,
“Symbol”,
“Lucida Sans Regular”,
};private static String[] sansFallback = new String[] {
“Arial”,
“MS Gothic”,
“MingLiU”,
“SimSun”,
“Mangal”,
“David”,
“Gulim”,
“Wingdings”,
“Symbol”,
“Lucida Sans Regular”,
};private static String[] monoFallback = new String[] {
“Courier New”,
“MS Gothic”,
“MingLiU”,
“SimSun”,
“Mangal”,
“David”,
“GulimChe”,
“Wingdings”,
“Symbol”,
“Lucida Sans Regular”,
};[/language:3vg6yswk]I guess, in your case an existence of SimSun among available fonts should help.
April 15, 2011 at 14:33#28510Tried with multiple versions of PD4ML with no result.
April 15, 2011 at 14:37#28511Try to switch PD4ML debug on and inspect STDOUT/server’s log. Does it tries to load TTF files at all?
April 16, 2011 at 07:15#28512I am trying with version 370fx2. the following html containing chinese text works .
常常有不同的方法來寫同樣的漢字,這些被統。有些差異是由於性格的簡化,而有些則是純粹的字形差異,如中風造型。在造型的招用的明朝風格的字體來自康熙字典中使用。在大陸中
However with Japanese html it does not works
煙草
I am getting the following in the logs
version: PD4ML 370fx2 DMS Pro
not yet in cache: file:D:/examples/pd4fonts.properties
‘serif’ is not in pd4fonts.properties file
reject TTF lookup for: ‘serif’
not yet in cache: file:C:/WINDOWS/Fonts/times.ttf
read ‘times new roman’ from file:C:/WINDOWS/Fonts/times.ttf
not yet in cache: file:C:/WINDOWS/Fonts/MSMINCHO.TTF
read ‘ms mincho’ from file:C:/WINDOWS/Fonts/MSMINCHO.TTF
not yet in cache: file:C:/WINDOWS/Fonts/mingliu.ttc
read ‘mingliu’ from file:C:/WINDOWS/Fonts/mingliu.ttc
not yet in cache: file:C:/WINDOWS/Fonts/simsun.ttc
read ‘simsun’ from file:C:/WINDOWS/Fonts/simsun.ttc
not yet in cache: file:C:/WINDOWS/Fonts/mangal.ttf
read ‘mangal’ from file:C:/WINDOWS/Fonts/mangal.ttf
not yet in cache: file:C:/WINDOWS/Fonts/david.ttf
read ‘david’ from file:C:/WINDOWS/Fonts/david.ttf
not yet in cache: file:C:/WINDOWS/Fonts/batang.ttc
read ‘batang’ from file:C:/WINDOWS/Fonts/batang.ttc
not yet in cache: file:C:/WINDOWS/Fonts/wingding.ttf
read ‘wingdings’ from file:C:/WINDOWS/Fonts/wingding.ttf
not yet in cache: file:C:/WINDOWS/Fonts/symbol.ttf
read ‘symbol’ from file:C:/WINDOWS/Fonts/symbol.ttf
not yet in cache: file:C:/WINDOWS/Fonts/lsans.ttf
read ‘lucida sans regular’ from file:C:/WINDOWS/Fonts/lsans.ttf
done in 2312ms.
done.Am I missing something here? And one more question, do we need to specify
each time?
@PD4ML wrote:
In order to find an appropriate font to display a text string, PD4ML walks the following lists:
[language=java:3q87729j]private static String[] serifFallback = new String[] {
“Times New Roman”,
“MS Mincho”,
“MingLiU”,
“SimSun”,
“Mangal”,
“David”,
“Batang”,
“Wingdings”,
“Symbol”,
“Lucida Sans Regular”,
};private static String[] sansFallback = new String[] {
“Arial”,
“MS Gothic”,
“MingLiU”,
“SimSun”,
“Mangal”,
“David”,
“Gulim”,
“Wingdings”,
“Symbol”,
“Lucida Sans Regular”,
};private static String[] monoFallback = new String[] {
“Courier New”,
“MS Gothic”,
“MingLiU”,
“SimSun”,
“Mangal”,
“David”,
“GulimChe”,
“Wingdings”,
“Symbol”,
“Lucida Sans Regular”,
};[/language:3q87729j]I guess, in your case an existence of SimSun among available fonts should help.
April 19, 2011 at 16:32#28513@PD4ML wrote:
In order to find an appropriate font to display a text string, PD4ML walks the following lists:
[language=java:o60jhw85]private static String[] serifFallback = new String[] {
“Times New Roman”,
“MS Mincho”,
“MingLiU”,
“SimSun”,
“Mangal”,
“David”,
“Batang”,
“Wingdings”,
“Symbol”,
“Lucida Sans Regular”,
};private static String[] sansFallback = new String[] {
“Arial”,
“MS Gothic”,
“MingLiU”,
“SimSun”,
“Mangal”,
“David”,
“Gulim”,
“Wingdings”,
“Symbol”,
“Lucida Sans Regular”,
};private static String[] monoFallback = new String[] {
“Courier New”,
“MS Gothic”,
“MingLiU”,
“SimSun”,
“Mangal”,
“David”,
“GulimChe”,
“Wingdings”,
“Symbol”,
“Lucida Sans Regular”,
};[/language:o60jhw85]I guess, in your case an existence of SimSun among available fonts should help.
Thanks, this was very very helpful – I’d sure go insane without this information!
However, the paths to fonts and pd4fonts.properties have to be monitored and corrected carefully. Even the http://pd4ml.com/examples.zip I downloaded did not work in Linux nor in Windows. I had to set the absolute paths to files in run.sh, and then it worked. I suppose the person(s) who made the example were working in root directory, or something like that, and that therefore it worked for them.Also, setting of the fallback fonts would be great option in the future, but at the moment it can be easily hacked – if you do not want to/cannot use some font from the list above, simply change in pd4fonts.properties the line of some existing font
<br /> #this is an autogenerated file. please remove manually any references to copyrighted fonts<br /> #Tue Apr 19 06:51:26 GMT-07:00 2011<br /> # font.dir.location=fonts<br /> KaiTi_GB2312=SIMKAI.TTF
change KaiTi_GB2312 to some font from the hardcoded list
#this is an autogenerated file. please remove manually any references to copyrighted fonts<br /> #Tue Apr 19 06:51:26 GMT-07:00 2011<br /> #font.dir.location=fonts<br /> SimSun=SIMKAI.TTF
and everything will work fine. -
AuthorPosts
The forum ‘Troubleshooting’ is closed to new topics and replies.