#1 2025-02-06 15:58:40

Juergen_Bauer
Member
Registered: 2025-02-06
Posts: 4

Converting EMF content containing the Calibri font to PDF

Hello,

I would like to use your great component to convert EMF content to PDF.
But when the EMF file contains text with the font Calibri and is printed via:
   ExtTextout (Preview.Canvas.Handle, nXPos, nYPos, ETO_GLYPH_INDEX, nil, PChar(FontObjects.GR.lpGlyphs), FontObjects.GR.nGlyphs, PInteger(FontObjects.GR.lpDx))

the resulting PDF file "looses" some characters.
So if I print the German word "Auftrag", the PDF contains only "Au rag" ...

Any ideas?

Thanks a lot!

Offline

#2 2025-02-06 16:10:36

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,865
Website

Re: Converting EMF content containing the Calibri font to PDF

Did you try to enable the Uniscribe option?

Offline

#3 2025-02-06 16:31:10

Juergen_Bauer
Member
Registered: 2025-02-06
Posts: 4

Re: Converting EMF content containing the Calibri font to PDF

Hello,
I just set this option - without success :-(.
Unfortunately, I cannot attach the small sample EMF file ...

Offline

#4 2025-02-06 16:41:43

Juergen_Bauer
Member
Registered: 2025-02-06
Posts: 4

Re: Converting EMF content containing the Calibri font to PDF

Here is the correct link:
Sample EMF file in ZIP format

Offline

#5 2025-02-07 11:25:35

rvk
Member
Registered: 2022-04-14
Posts: 123

Re: Converting EMF content containing the Calibri font to PDF

The problem seems to be in this line:

R0035: [084] EMR_EXTTEXTOUTW	(s=112)	{ TXT=[?O?AO] [exScale(0.283008) eyScale(0.281890) iGraphicsMode(1), Bounds(88,84,136,102)] TxOPT[fOptions(16|ETO_GLYPH_INDEX), nChars(6), offDx(88), ptlRef(1320,1256), rcl(0,0,-1,-1)] Spacing[139,126,148,79,115,113 => Total(720) =>xPtRefRight(2039)]}

(used EMFexplorer)

I see there is nChar(6). That means the string should be 6 characters. But Auftrag is 7 characters.
Could it be that the tf in Auftraf is one character?

U+FB05 (ſt) – LATIN SMALL LIGATURE LONG S AND T

I'm not sure why the EMFexplorer renders this correctly. Maybe the unicode gets lost in SynPDF (although I do see tmp is WideChar in TPdfEnum.TextOut).

BTW. You say it is printed via ExtTextout. Where do you see that?
Are you using the old deprecated SynPDF or the newer mORMot PDF engine?

Offline

#6 2025-02-07 12:41:43

rvk
Member
Registered: 2022-04-14
Posts: 123

Re: Converting EMF content containing the Calibri font to PDF

Note for @ab
I did a bit of digging and found that in TPdfWrite.AddGlyphs the TPdfFontTrueType.GetAndMarkGlyphAsUsed is called.
For the unicode character U+FB05 ſt this function returns 0 because it can't find that character in fUsedWide.

Why doesn't it add the (unicode) character to the Glyph map when not found?

There is a FindOrAddUsedWideChar in there but that's only used when the Glyph is found in fUsedWide (in which case the add seems a little pointless).

Offline

#7 2025-02-07 12:46:07

Juergen_Bauer
Member
Registered: 2025-02-06
Posts: 4

Re: Converting EMF content containing the Calibri font to PDF

Hello,
as you already stated:
The two characters "ft" are transformed into one character. This is called ligature.

I create the EMF files myself - so that is the reason why I know that the content is created via ExtTextout.
The Delphi code looks like this:
              ExtTextout (Preview.Canvas.Handle, nXPos, nYPos, ETO_GLYPH_INDEX, nil, PChar(FontObjects.GR.lpGlyphs), FontObjects.GR.nGlyphs, PInteger(FontObjects.GR.lpDx))

I use the current SynPDF version (1.18).

Thanks a lot!

Offline

#8 2025-02-07 12:59:02

rvk
Member
Registered: 2022-04-14
Posts: 123

Re: Converting EMF content containing the Calibri font to PDF

Juergen_Bauer wrote:

I use the current SynPDF version (1.18).

The SynPDF version isn't developed actively anymore. For that you need the mormot.ui.pdf.pas in https://github.com/synopse/mORMot2/tree/master/src/ui.

But I do use mORMot2 and here the problem is the same (see previous post to @ab).
So there is indeed a problem with retrieving the Glyph for Unicodes (that ſt) used in the EMF.

Offline

Board footer

Powered by FluxBB