#1 2016-10-05 16:31:26

jeanmilost
Member
Registered: 2016-01-21
Posts: 35

Some additional features

Hello

I recently had to make changes in the SynPDF library to add some features that my project required but that were not available. Here they are:
- Support for multiple font linking, thus a valid font may be found in case the text contains many languages and both main font and first linked font did not support the language (e.g. FontFallBackNames := 'Arial,Verdana')
- Added a KerningHHorzScale property in TPdfDocumentGDI to be able to change the global Kerning horizontal scale value (in my case was useful to catch up some conversion errors between the GDI canvas and the PDF meta file)
- Added a UNISCRIBE_DYNAMIC_LINK define in case Uniscribe should be linked dynamically to the target application

I think (and hope) that these changes can serve to others, so I published them here: https://drive.google.com/file/d/0B7C-Rw … sp=sharing

Regards

Offline

#2 2016-10-05 19:24:11

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

Re: Some additional features

Thanks a lot for sharing!
smile

Offline

#3 2019-11-20 14:58:38

MtwStark
Member
From: Italy
Registered: 2016-01-05
Posts: 27

Re: Some additional features

Hi jeanmilost,
I use your FontFallBackNames feature in SynPDF.pas and I think I have found a little problem.

In TPdfCanvas.SetFont() function You have changed original code to look for a default font in FontFallBackIndexes but I think You have inverted the boolean test.

                        for i := 0 to count - 1 do begin
                            FontIndex := FDoc.fFontFallBackIndexes[i];
{$IFDEF TMW_TEST_NEW_FONT_FALLBACK}
                            if FontIndex >= 0 then    // this way better
{$ELSE}
                            if FontIndex < 0 then    // ??
{$ENDIF}
                                break;
                        end;

Can you confirm this?
Thank you

Last edited by MtwStark (2019-11-20 16:46:08)

Offline

#4 2019-11-22 14:18:03

MtwStark
Member
From: Italy
Registered: 2016-01-05
Posts: 27

Re: Some additional features

Hi jeanmilost,
about your function TPdfDocument.GetFontFallBackNames
I have added a check for validity of the font index to avoid AV in case of mispelled or not installed font.

function TPdfDocument.GetFontFallBackNames: string;
var
    i, count: Integer;
begin
    Result := '';
    // get font fallback count
    count := Length(fFontFallBackIndexes);
    // no font fallback defined?
    if (count = 0) then
        Exit;
    for i := 0 to count - 1 do begin
        // first font?
        if (i > 0) then
            // add separator
            Result := Result + ',';

        // add next font
{$IFDEF TMW_TEST_NEW_FONT_FALLBACK}        
        if fFontFallBackIndexes[i] < 0 then  // ------------------------------->>> avoid AV if font name was not found ;)
            Continue;
{$ENDIF}
        Result := Result + UTF8ToString(FTrueTypeFonts[fFontFallBackIndexes[i]]);
    end;
end;

Thank you for sharing your work

Offline

Board footer

Powered by FluxBB