You are not logged in.
Pages: 1
Hello,
I need to create PDF from RichText documents, which uses fonts from the "Myriad Pro" family (Adobe). The fonts are installed as OpenType fonts on the Windows 7 machine.
When creating PDF documents using TPdfDocumentGDI with EmbeddedTTF := True, those fonts are NOT embedded into the PDF file; all text uses "Arial Unicode MS" as fallback; which looks not as desired when viewing the PDF on a different computer (without those fonts installed).
I've tracked down the problem to function EnumFontsProcW in TPdfDocument: Only fonts which are pure TrueType fonts are collected in FTrueTypeFonts array.
What would be necessary to also embed OpenType fonts into the PDF document?
TIA
Achim
Offline
Hello ab,
I've modified the function ENumFontsProcW as following:
"var TextMetric" changed from TTextMetric to TNewTextMetric as described in MSDN documentation:
http://msdn.microsoft.com/en-us/library … 85%29.aspx
Now I can test TextMetric.ntmFlags for OpenType fonts.
With that new modified code, the "Myriad Pro" font gets embedded into the PDF file.
However, the PDF file size increases from 5 KB (not embedded) to 180 KB (EmbeddedWholeTTF = False) and up to 510 KB (EmbeddedWholeTTF = True), but the OpenType font file is only 94 KB. I don't know why the PDF gets that large. And I don't have any tools to analyze the PDF files.
Here are my changes:
const
NTM_PS_OPENTYPE = (1 shl 17); // Bit 17: PostScript OpenType font
NTM_TT_OPENTYPE = (1 shl 18); // Bit 18: TrueType OpenType font
function EnumFontsProcW(var LogFont: TLogFontW; var TextMetric: TNewTextMetric;
FontType: Integer; var List: TRawUTF8DynArray): Integer; stdcall;
// we enumerate all available fonts, whatever the charset is, because
// we may won't enumerate Arial or Times New Roman if current FCharSet is
// chinese e.g.
var Temp: RawUTF8;
begin
with LogFont do
if ( (FontType=TRUETYPE_FONTTYPE)
or ((TextMetric.ntmFlags and NTM_PS_OPENTYPE) <> 0) // <<< added
or ((TextMetric.ntmFlags and NTM_TT_OPENTYPE) <> 0) // <<< added
)
and (lfFaceName[0]<>'@')
then begin
Temp := RawUnicodeToUtf8(lfFaceName,StrLenW(lfFaceName));
if (pointer(List)=nil) or (List[high(List)]<>Temp) then
AddRawUTF8(List,Temp,true,true);
end;
Result := 1;
end;
Nevertheless I will submit a feature request.
Regards,
Achim
Offline
Ticket created:
http://synopse.info/fossil/tktview/bb79 … e4b63048aa
Offline
Pages: 1