You are not logged in.
Pages: 1
System: Windows 7
Delphi Version: 2010
SynPDF Version: 1.18
When creating PDF documents containing "SimSun" font (SimSun.ttc) or "MingLiu" font (MingLiu.ttc), a very large file is generated and the font appears to be incorrectly embedded and cannot be displayed by Adobe Reader. The sample code below generates a file containing one common Chinese character.
Having tested several fonts with the sample code, fonts contained in ".ttc" files all generated large files with display problems. Other fonts were fine. This issue could be related to http://synopse.info/forum/viewtopic.php?id=1528.
Resulting file sizes in my test were:
Fonts with problem:
MingLiu: 16.2MB
SimSun: 7.6MB
Fonts without problem:
KaiTi: 55KB
Microsoft YaHei: 17KB
procedure CreatePDFDoc();
var
PDFDoc: TPDFDocumentGDI;
begin
PDFDoc := TPdfDocumentGDI.Create;
try
PDFDoc.NewDoc;
PDFDoc.AddPage;
PDFDoc.EmbeddedTTF := True;
PDFDoc.VCLCanvas.Font.Name := 'SimSun';
PDFDoc.VCLCanvas.TextOut(100,100,#22909);
PDFDoc.SaveToFile('PDFDoc_' + PDFDoc.VCLCanvas.Font.Name + '.pdf');
finally
PDFDoc.Free;
end;
end;
Thanks for any help that can be given.
Offline
Could you use the debugger and find out what is the problem when embedding the font?
Also ensure you got the latest version of SynPDF from http://synopse.info/files/mORMotNightlyBuild.zip or https://github.com/synopse/SynPDF
Online
The problem appears to be the call "CreateFontPackage" on line 7608 of SynPDF.pas (nightly build 19-Sep-2014). It does not correctly deal with fonts within ".ttc" rather than ".ttf" files.
For fonts within ".ttc" files:
The 6th parameter, "usFlags", needs to include the flag TTFCFP_FLAGS_TTC.
The 7th parameter, "usTTCIndex", needs to include the index of the font within the ttc collection
It appears that some additional code will be required to identify (1) whether a font is contained in a TTC collection and (2) if so, what is its index position.
Offline
Thanks. I have raised a ticket.
Offline
I have the same problem with Cambria Windows font who is also TrueType Collection (TTC)
Offline
You can try http://synopse.info/fossil/info/d87f982164
Thanks a lot David Mead (MDW) for the patch !
Online
Pages: 1