Преглед изворни кода

* Patch from Graeme Geldenhuys to disable embedding fonts.

git-svn-id: trunk@34543 -
michael пре 8 година
родитељ
комит
5d18c63b24
1 измењених фајлова са 42 додато и 14 уклоњено
  1. 42 14
      packages/fcl-pdf/src/fppdf.pp

+ 42 - 14
packages/fcl-pdf/src/fppdf.pp

@@ -33,10 +33,23 @@ uses
   fpparsettf;
   fpparsettf;
 
 
 Const
 Const
-  clBlack = $000000;
-  clBlue  = $0000FF;
-  clGreen = $00FF00;
-  clRed   = $FF0000;
+  { Some popular predefined colors. Channel format is: RRGGBB }
+  clBlack   = $000000;
+  clWhite   = $FFFFFF;
+  clBlue    = $0000FF;
+  clGreen   = $008000;
+  clRed     = $FF0000;
+  clAqua    = $00FFFF;
+  clMagenta = $FF00FF;
+  clYellow  = $FFFF00;
+  clLtGray  = $C0C0C0;
+  clMaroon  = $800000;
+  clOlive   = $808000;
+  clDkGray  = $808080;
+  clTeal    = $008080;
+  clNavy    = $000080;
+  clPurple  = $800080;
+  clLime    = $00FF00;
 
 
 type
 type
   TPDFPaperType = (ptCustom, ptA4, ptA5, ptLetter, ptLegal, ptExecutive, ptComm10, ptMonarch, ptDL, ptC5, ptB5);
   TPDFPaperType = (ptCustom, ptA4, ptA5, ptLetter, ptLegal, ptExecutive, ptComm10, ptMonarch, ptDL, ptC5, ptB5);
@@ -45,7 +58,7 @@ type
   TPDFPageLayout = (lSingle, lTwo, lContinuous);
   TPDFPageLayout = (lSingle, lTwo, lContinuous);
   TPDFUnitOfMeasure = (uomInches, uomMillimeters, uomCentimeters, uomPixels);
   TPDFUnitOfMeasure = (uomInches, uomMillimeters, uomCentimeters, uomPixels);
 
 
-  TPDFOption = (poOutLine, poCompressText, poCompressFonts, poCompressImages, poUseRawJPEG);
+  TPDFOption = (poOutLine, poCompressText, poCompressFonts, poCompressImages, poUseRawJPEG, poNoEmbeddedFonts);
   TPDFOptions = set of TPDFOption;
   TPDFOptions = set of TPDFOption;
 
 
   EPDF = Class(Exception);
   EPDF = Class(Exception);
@@ -3430,12 +3443,9 @@ end;
 
 
 function TPDFDocument.CreatePageEntry(Parent, PageNum: integer): integer;
 function TPDFDocument.CreatePageEntry(Parent, PageNum: integer): integer;
 var
 var
-
   PDict,ADict: TPDFDictionary;
   PDict,ADict: TPDFDictionary;
   Arr : TPDFArray;
   Arr : TPDFArray;
   PP : TPDFPage;
   PP : TPDFPage;
-  AnnotArr: TPDFArray;
-
 begin
 begin
   // add xref entry
   // add xref entry
   PP:=Pages[PageNum];
   PP:=Pages[PageNum];
@@ -3579,9 +3589,16 @@ begin
   CreateTTFDescendantFont(EmbeddedFontNum);
   CreateTTFDescendantFont(EmbeddedFontNum);
   Arr := CreateArray;
   Arr := CreateArray;
   FDict.AddElement('DescendantFonts', Arr);
   FDict.AddElement('DescendantFonts', Arr);
-  Arr.AddItem(TPDFReference.Create(self, GlobalXRefCount-4));
-  CreateToUnicode(EmbeddedFontNum);
-  FDict.AddReference('ToUnicode', GlobalXRefCount-1);
+  if (poNoEmbeddedFonts in Options) then
+  begin
+    Arr.AddItem(TPDFReference.Create(self, GlobalXRefCount-3));
+  end
+  else
+  begin
+    Arr.AddItem(TPDFReference.Create(self, GlobalXRefCount-4));
+    CreateToUnicode(EmbeddedFontNum);
+    FDict.AddReference('ToUnicode', GlobalXRefCount-1);
+  end;
   FontFiles.Add(Fonts[EmbeddedFontNum].FTrueTypeFile.Filename);
   FontFiles.Add(Fonts[EmbeddedFontNum].FTrueTypeFile.Filename);
 end;
 end;
 
 
@@ -3601,7 +3618,10 @@ begin
 
 
   // add fontdescriptor reference to font dictionary
   // add fontdescriptor reference to font dictionary
   CreateFontDescriptor(EmbeddedFontNum);
   CreateFontDescriptor(EmbeddedFontNum);
-  FDict.AddReference('FontDescriptor',GlobalXRefCount-2);
+  if (poNoEmbeddedFonts in Options) then
+    FDict.AddReference('FontDescriptor',GlobalXRefCount-1)
+  else
+    FDict.AddReference('FontDescriptor',GlobalXRefCount-2);
 
 
   Arr := CreateArray;
   Arr := CreateArray;
   FDict.AddElement('W',Arr);
   FDict.AddElement('W',Arr);
@@ -3642,8 +3662,16 @@ begin
   FDict.AddInteger('ItalicAngle', trunc(Fonts[EmbeddedFontNum].FTrueTypeFile.ItalicAngle));
   FDict.AddInteger('ItalicAngle', trunc(Fonts[EmbeddedFontNum].FTrueTypeFile.ItalicAngle));
   FDict.AddInteger('StemV', Fonts[EmbeddedFontNum].FTrueTypeFile.StemV);
   FDict.AddInteger('StemV', Fonts[EmbeddedFontNum].FTrueTypeFile.StemV);
   FDict.AddInteger('MissingWidth', Fonts[EmbeddedFontNum].FTrueTypeFile.MissingWidth);
   FDict.AddInteger('MissingWidth', Fonts[EmbeddedFontNum].FTrueTypeFile.MissingWidth);
-  CreateFontFileEntry(EmbeddedFontNum);
-  FDict.AddReference('FontFile2',GlobalXRefCount-1);
+  if (poNoEmbeddedFonts in Options) then
+  begin
+    //CreateFontFileEntry(EmbeddedFontNum);
+    //FDict.AddReference('FontFile2',GlobalXRefCount-1);
+  end
+  else
+  begin
+    CreateFontFileEntry(EmbeddedFontNum);
+    FDict.AddReference('FontFile2',GlobalXRefCount-1);
+  end;
 end;
 end;
 
 
 procedure TPDFDocument.CreateToUnicode(const EmbeddedFontNum: integer);
 procedure TPDFDocument.CreateToUnicode(const EmbeddedFontNum: integer);