mORMot and Open Source friends
Check-in [67f6191561]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:{936} includes Chaa patch for symbol fonts support in SynPdf
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 67f619156185dff9b263f6753086fef97dbccba6
User & Date: ab 2015-02-19 15:36:31
References
2015-02-20
06:53
{940} minor patch for [67f6191561] check-in: 162664c56e user: ab tags: trunk
Context
2015-02-19
18:11
{937} enhanced ARM compilation - Alf reported most of the tests to work on Raspberry Pi 2 (interface-based stubs should be generated in pascal code by mustache templates, in addition to current x86/x64 low-level stubs) check-in: 33b96ec7b3 user: ab tags: trunk
15:36
{936} includes Chaa patch for symbol fonts support in SynPdf check-in: 67f6191561 user: ab tags: trunk
15:08
{935} allow TSQLModel to be serialized as JSON (usefull e.g. for debugging purposes) check-in: 0aff4d1cd8 user: ab tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to SynPdf.pas.

2349
2350
2351
2352
2353
2354
2355

2356
2357
2358
2359
2360
2361
2362
....
4742
4743
4744
4745
4746
4747
4748

4749
4750
4751



4752
4753




4754
4755
4756

4757
4758
4759
4760
4761
4762
4763
....
7603
7604
7605
7606
7607
7608
7609

7610
7611
7612
7613
7614
7615
7616
....
7621
7622
7623
7624
7625
7626
7627






7628
7629
7630
7631
7632
7633
7634
....
8226
8227
8228
8229
8230
8231
8232
8233

8234

8235

8236
8237
8238
8239
8240
8241
8242
    fUsedWide: TUsedWide;
    fHGDI: HGDIOBJ;
    fFixedWidth: boolean;
    fFontDescriptor: TPdfDictionary;
    fFontFile2: TPdfStream;
    fUnicodeFont: TPdfFontTrueType;
    fWinAnsiFont: TPdfFontTrueType;

    // below are some bigger structures
    fLogFont: TLogFontW;
    fM: TTextMetric;
    fOTM: TOutlineTextmetric;
    procedure CreateAssociatedUnicodeFont;
    // update font description from used chars
    procedure PrepareForSaving;
................................................................................
  fAddGlyphFont := fNone;
  Add('>').Add(SHOWTEXTCMD[aNextLine]);
end;

procedure TPdfWrite.AddUnicodeHexTextNoUniScribe(PW: PWideChar;
  TTF: TPdfFontTrueType; NextLine: boolean; Canvas: TPdfCanvas);
var Ansi: integer;

begin
  Ansi := WideCharToWinAnsi(cardinal(PW^));
  if TTF<>nil then



    TTF := TTF.WinAnsiFont else // we expect the WinAnsi font in the code below
    if Ansi<0 then




      Ansi := ord('?'); // WinAnsi only font shows ? glyph for unicode chars
  while Ansi<>0 do begin
    if Ansi>0 then begin

      // add WinAnsi-encoded chars as such
      if (TTF<>nil) and (Canvas.FPage.Font<>TTF) then
        Canvas.SetPDFFont(TTF,Canvas.FPage.FontSize);
      Add('(');
      repeat
        case Ansi of
          40,41,92: Add('\');   // see PDF 2nd ed. p. 290
................................................................................
  PDF_FONT_ALL_CAP     = 65536;
  PDF_FONT_SMALL_CAP   = 131072;
  PDF_FONT_FORCE_BOLD  = 262144;


function TPdfFontTrueType.FindOrAddUsedWideChar(aWideChar: WideChar): integer;
var n, i: integer;

begin
  self := WinAnsiFont;
  result := fUsedWideChar.Add(ord(aWideChar));
  if result<0 then begin
    result := -(result+1); // this WideChar was already existing -> return index
    exit;
  end;
................................................................................
  if result<n then
    Move(fUsedWide[result],fUsedWide[result+1],(n-result)*4);
  // create associated Unicode Font if necessary
  if UnicodeFont=nil then
    CreateAssociatedUnicodeFont;
  // update fUsedWide[result] for current glyph
  i := UnicodeFont.fUsedWideChar.IndexOf(ord(aWideChar));






  if i<0 then // if this glyph doesn't exist in this font -> set to zero
    i := 0 else
    i := UnicodeFont.fUsedWide[i].int;
  fUsedWide[result].int := i; // update Width and Glyph
end;

function TPdfFontTrueType.GetAndMarkGlyphAsUsed(aGlyph: word): word;
................................................................................
    exit;
  Header := P;
  inc(PtrInt(P),SizeOf(TCmapHeader));
  off := 0;
  for i := 0 to Header^.numberSubtables-1 do
    with SubTable^[i] do
      if platformID=TTFCFP_MS_PLATFORMID then
        if platformSpecificID=TTFCFP_SYMBOL_CHAR_SET then

          off := offset else

        if platformSpecificID=TTFCFP_UNICODE_CHAR_SET then begin

          off := offset;
          break; // prefered specific ID
        end;
  if (off=0) or (off and 1<>0) then
    exit; // we handle only Microsoft platform
  i := LongRec(off).Lo; // offset swap to bswap conversion :)
  LongRec(off).Lo := LongRec(off).Hi;






>







 







>

<
|
>
>
>
|
<
>
>
>
>
|

<
>







 







>







 







>
>
>
>
>
>







 







|
>
|
>

>







2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
....
4743
4744
4745
4746
4747
4748
4749
4750
4751

4752
4753
4754
4755
4756

4757
4758
4759
4760
4761
4762

4763
4764
4765
4766
4767
4768
4769
4770
....
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
....
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
....
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
    fUsedWide: TUsedWide;
    fHGDI: HGDIOBJ;
    fFixedWidth: boolean;
    fFontDescriptor: TPdfDictionary;
    fFontFile2: TPdfStream;
    fUnicodeFont: TPdfFontTrueType;
    fWinAnsiFont: TPdfFontTrueType;
    fIsSymbolFont: Boolean;
    // below are some bigger structures
    fLogFont: TLogFontW;
    fM: TTextMetric;
    fOTM: TOutlineTextmetric;
    procedure CreateAssociatedUnicodeFont;
    // update font description from used chars
    procedure PrepareForSaving;
................................................................................
  fAddGlyphFont := fNone;
  Add('>').Add(SHOWTEXTCMD[aNextLine]);
end;

procedure TPdfWrite.AddUnicodeHexTextNoUniScribe(PW: PWideChar;
  TTF: TPdfFontTrueType; NextLine: boolean; Canvas: TPdfCanvas);
var Ansi: integer;
    isSymbolFont: Boolean;
begin

  if TTF<>nil then begin
    if TTF.UnicodeFont<>nil then
      isSymbolFont := TTF.UnicodeFont.fIsSymbolFont else
      isSymbolFont := TTF.fIsSymbolFont;
    TTF := TTF.WinAnsiFont; // we expect the WinAnsi font in the code below

  end else
    isSymbolFont := false;
  Ansi := WideCharToWinAnsi(cardinal(PW^));
  if (TTF=nil) and (Ansi<0) then
    Ansi := ord('?'); // WinAnsi only font shows ? glyph for unicode chars
  while Ansi<>0 do begin

    if (Ansi>0) and (not isSymbolFont) then begin
      // add WinAnsi-encoded chars as such
      if (TTF<>nil) and (Canvas.FPage.Font<>TTF) then
        Canvas.SetPDFFont(TTF,Canvas.FPage.FontSize);
      Add('(');
      repeat
        case Ansi of
          40,41,92: Add('\');   // see PDF 2nd ed. p. 290
................................................................................
  PDF_FONT_ALL_CAP     = 65536;
  PDF_FONT_SMALL_CAP   = 131072;
  PDF_FONT_FORCE_BOLD  = 262144;


function TPdfFontTrueType.FindOrAddUsedWideChar(aWideChar: WideChar): integer;
var n, i: integer;
    aSymbolAnsiChar: AnsiChar;
begin
  self := WinAnsiFont;
  result := fUsedWideChar.Add(ord(aWideChar));
  if result<0 then begin
    result := -(result+1); // this WideChar was already existing -> return index
    exit;
  end;
................................................................................
  if result<n then
    Move(fUsedWide[result],fUsedWide[result+1],(n-result)*4);
  // create associated Unicode Font if necessary
  if UnicodeFont=nil then
    CreateAssociatedUnicodeFont;
  // update fUsedWide[result] for current glyph
  i := UnicodeFont.fUsedWideChar.IndexOf(ord(aWideChar));
  if (i<0) and fIsSymbolFont then begin
    TSynAnsiConvert.Engine(fDoc.CodePage).UnicodeBufferToAnsi(
      @aSymbolAnsiChar,@aWideChar,1);
    aWideChar := WideChar($f000+ord(aSymbolAnsiChar));
    i := UnicodeFont.fUsedWideChar.IndexOf(ord(aWideChar));
  end;
  if i<0 then // if this glyph doesn't exist in this font -> set to zero
    i := 0 else
    i := UnicodeFont.fUsedWide[i].int;
  fUsedWide[result].int := i; // update Width and Glyph
end;

function TPdfFontTrueType.GetAndMarkGlyphAsUsed(aGlyph: word): word;
................................................................................
    exit;
  Header := P;
  inc(PtrInt(P),SizeOf(TCmapHeader));
  off := 0;
  for i := 0 to Header^.numberSubtables-1 do
    with SubTable^[i] do
      if platformID=TTFCFP_MS_PLATFORMID then
        if platformSpecificID=TTFCFP_SYMBOL_CHAR_SET then begin
          aUnicodeTTF.fIsSymbolFont := true;
          off := offset;
        end else
        if platformSpecificID=TTFCFP_UNICODE_CHAR_SET then begin
          aUnicodeTTF.fIsSymbolFont := false;
          off := offset;
          break; // prefered specific ID
        end;
  if (off=0) or (off and 1<>0) then
    exit; // we handle only Microsoft platform
  i := LongRec(off).Lo; // offset swap to bswap conversion :)
  LongRec(off).Lo := LongRec(off).Hi;

Changes to SynopseCommit.inc.

1
'1.18.935'
|
1
'1.18.936'