#1 2013-05-11 15:32:50

vmkng
Member
Registered: 2013-05-11
Posts: 1

Some little mod

Hi,
  first of all thanks for your great product.

I have made some changes to your code related to the RenderMetaFile procedure:

1. for the problem decribed here: http://synopse.info/forum/viewtopic.php?id=1253

8024,8026c8024,8044
<   EMR_SETBKCOLOR:
<     font.BkColor := PEMRSetBkColor(R)^.crColor;
<   EMR_SETTEXTCOLOR:
<     font.Color := PEMRSetTextColor(R)^.crColor;
---
>   EMR_SETBKCOLOR:
>   begin
>     if PEMRSetBkColor(R)^.crColor = $1fffffff then
>     begin
>       font.BkColor := 0;
>     end
>     else
>     begin
>       font.BkColor := PEMRSetBkColor(R)^.crColor;
>     end;
>   end;
>   EMR_SETTEXTCOLOR:
>   begin
>     if PEMRSetTextColor(R)^.crColor = $1fffffff then
>     begin
>       font.Color := 0;
>     end
>     else
>     begin
>       font.Color := PEMRSetTextColor(R)^.crColor;
>     end;
>   end;

seems like the color $1fffffff (clNone) was interpreted like $00ffffff (clWhite)

2. for the character spacing:

9097c9115
<     wW, measW, W,H,hscale: Single;
---
>     wW, measW, W,H,hscale, CharOffX: Single;
9105a9123
>     tmpCh:array of WideChar;
9250,9251c9269,9296
<       Canvas.ShowGlyph(pointer(tmp),R.emrtext.nChars) else
<       Canvas.ShowText(pointer(tmp));
---
>     begin
>       Canvas.ShowGlyph(pointer(tmp),R.emrtext.nChars);
>     end
>     else
>     begin
>       if PtrUInt(@R)+R.emrtext.offDx = 0 then
>       begin
>         Canvas.ShowText(pointer(tmp));
>       end
>       else
>       begin
>         CharOffX:=R.emrtext.ptlReference.X - W;
>         SetLength(tmpCh,2);
>         for i:=0 to R.emrText.nChars - 1 do
>         begin
>           move(pointer(PtrUInt(@R)+R.emrtext.offString + i * 2)^,tmpCh[0],2);
> 
>           Canvas.ShowText(pointer(tmpCh));
> 
>           if i < R.emrText.nChars - 1 then
>           begin
>             Canvas.BeginText;
>             CharOffX:=CharOffX + DX^[i];
>             Canvas.MoveTextPoint(Canvas.I2X(CharOffX),Canvas.I2Y(R.emrtext.ptlReference.Y-H));
>           end;
>         end;
>       end;
>     end;  

In this way the character as spaced in the same way as the emf.

P.S.: sorry for may bad english.

bye vmkng.

Last edited by vmkng (2013-05-11 15:34:33)

Offline

#2 2013-05-12 12:54:45

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

Re: Some little mod

Thanks a lot for the input.

I've committed the first set of changes.
See  http://synopse.info/fossil/info/56f63184cb

For the 2nd modification, character spacing has been implemented until now with computing the average space between chars.
It reduces the generated pdf file a lot.

But for handling font kerning as expected, we need IMHO a new option, disabled by default to let the pdf file as small as possible.
This is the following feature request: http://synopse.info/fossil/tktview?name=7d6a3a3f0f

I've therefore introduced the new TPdfDocumentGDI.UseMetaFileTextPositioning property instead of former UseSetTextJustification property.
Now you can force exact font kerning positioning for each character, via tpExactTextCharacterPositining; this parameter has been also added to TPdfCanvas.RenderMetaFile().
See http://synopse.info/fossil/info/c6f7355eed

There is still some problems when font fallback is enabled, but it should work in your case!

And your English is pretty good.
At least at the same level than mine!

Offline

Board footer

Powered by FluxBB