summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlgs/Resource/Init/pdf_font.ps
diff options
context:
space:
mode:
Diffstat (limited to 'Master/tlpkg/tlgs/Resource/Init/pdf_font.ps')
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/pdf_font.ps148
1 files changed, 91 insertions, 57 deletions
diff --git a/Master/tlpkg/tlgs/Resource/Init/pdf_font.ps b/Master/tlpkg/tlgs/Resource/Init/pdf_font.ps
index 7060dbce6f0..02a3b0f6602 100644
--- a/Master/tlpkg/tlgs/Resource/Init/pdf_font.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/pdf_font.ps
@@ -268,7 +268,6 @@ currentdict /known_symbolic_fonts undef
/getfontmetrics { % <font-resource> <font> <Encoding|null> getfontmetrics
% <font-resource> <font> <Encoding|null>
% <Metrics|null> <GlyphMap|null>
-
2 index /Widths oknown {
dup //null eq { pop dup /Encoding get } if
7 dict begin
@@ -871,7 +870,9 @@ setglobal
{
0 1 2 index length 1 sub
{
- dup 2 index exch get dup 0 gt % We ignore entries of zero in the widths array
+ dup 2 index exch get
+ dup type /packedarraytype eq {exec} if % Handle entries which are indirect references (seriously ? !!)
+ dup 0 gt % We ignore entries of zero in the widths array
{
exch 5 index add % add FirstChar to the idx to get a char code
dup 64 gt 1 index 91 lt and % we only want to consider A~Z and....
@@ -986,48 +987,62 @@ setglobal
.dicttomark readonly def
% When Type 1 font reading procedure is executing, a copy of this dictionary is current.
-% We have to do something special about embedded fonts that execute definefont
-% more than once -- that is the function of topFontDict.
+% topFontDict allows us to *attempt* to handle the case where a Type 1 font definition
+% does not start by creating it's own dictionary (i.e. a number of the keys end up in
+% the currentdict rather than the font dictionary).
% The whole type1 stream can be executed directly. There's no need to process
% Length1, 2, 3 keys.
/readtype1dict 10 dict dup begin
- /definefont {
- exch pop
+ /prev_definefont /definefont load def
- /topFontDict where {
- { /FontType % in PLRM order
- /FontMatrix
- /FontName
- /FontInfo
- /WMode
- /Encoding
- /FontBBox
- /UniqueID
- /XUID
- /PaintType
- /StrokeWidth
- /Metrics
- /Metrics2
- /CDevProc
- /CharStrings
- /Private
- /WeightVector
- } {
- 2 copy .knownget {
- % Stack: font topFontDict /key val
- 3 index 3 1 roll put
+ /definefont {
+ % if a font defines any keys outside it's own dictionary,
+ % this attempts to cope by copying them into the font dictionary
+ [
+ /FontType % in PLRM order
+ /FontMatrix
+ /FontName
+ /FontInfo
+ /WMode
+ /Encoding
+ /FontBBox
+ /UniqueID
+ /XUID
+ /PaintType
+ /StrokeWidth
+ /Metrics
+ /Metrics2
+ /CDevProc
+ /CharStrings
+ /Private
+ /WeightVector
+ ]
+ {
+ 2 copy known
+ {pop}
+ {
+ dup where
+ {
+ 1 index get
+ 2 index
+ 3 1 roll put
dup /MisplacedKey 0 put
- } {
- pop
- } ifelse
- } forall
- /MisplacedKey known {
- ( **** Warning: Type 1 font defines some of the keys in the external scope.\n)
- pdfformatwarning
- } if
+ }
+ {pop} ifelse
+ } ifelse
+ } forall
+ dup /MisplacedKey known {
+ ( **** Warning: Type 1 font defines some required keys outside the font dictionary.\n)
+ pdfformatwarning
} if
+ dup /CharStrings get /.notdef known not {
+ dup /CharStrings get
+ /.notdef <9E35CED7FFD3622F09> put
+ ( **** Warning: Type 1 font has no /.notdef entry in /CharString dictionary.\n)
+ pdfformatwarning
+ } if
dup /UniqueID .knownget {
dup dup 0 lt exch 16#ffffff gt or {
( **** Warning: Ignoring invalid /UniqueID = ) exch =string cvs
@@ -1037,17 +1052,11 @@ setglobal
pop
} ifelse
} if
- dup /CharStrings get /.notdef known not {
- dup /CharStrings get
- /.notdef <9E35CED7FFD3622F09> put
- ( **** Warning: Type 1 font has no /.notdef entry in /CharString dictionary.\n)
- pdfformatwarning
- } if
- .completefont
+ prev_definefont
} bdef
/undef_proc_warning {
- /Repaired //true store % flag that we have warnings
+ /Repaired //true store % flag that we have warnings
UndefProcList exch 2 copy .knownget { 1 add } { 1 } ifelse put
} bdef
@@ -1182,18 +1191,48 @@ currentdict /eexec_pdf_param_dict .undef
% the character code to access the Widths.
/BuildChar {
% Stack: font charcode
- 1 index begin 3 dict begin
+ 1 index begin 4 dict begin
/Font 3 -1 roll def /CharCode 1 index def
Encoding exch get CharProcs exch knownoget {
- { //false resolvestream
+ dup /Length get 0 eq {
+ pop
+ %% Detect a 0 length stream. If this occurs
+ %% then we won't execute d0 or d1, and so won't adjust the
+ %% character width. So, pretend we got a
+ %% null d1, just so that we can adjust using the /Widths
+ %% (Bug 697805)
+ 0 0 0 0 0 0
+ pdfopdict /d1 get exec
+ }{
+ { //false resolvestream
% Stack: filepos stream
% Don't let setgcolor set the color inside the BuildGlyph
% procedure, because this causes an /undefined error.
- q //null /FillColor gput //null /StrokeColor gput
- Font /Resources get exch pdfopdict .pdfruncontext
- Q
- } PDFfile fileposition 2 .execn % Keep pdfcount valid.
- PDFfile exch setfileposition
+ q
+ %% This is (currently) needed to make sure that the current dictionary, which is
+ %% 'nodict' because we did a gsave, is writeable. If we don't execute gput
+ %% to make a writeable copy then it is a no access dicitonary and the 'def'
+ %% below will fail. It would be nice to fix the cases of this someday, but
+ %% we use 'nodict'[ to store other PDF state stuff that isn't gstate, and we
+ %% probably always will, so it may well be more trouble than its worth.
+ /Dummy false gput
+ Font /Resources get exch pdfopdict
+ /BuildCharDictDepth countdictstack def
+ .pdfruncontext
+ countdictstack BuildCharDictDepth sub
+ {
+ pdfdict /.Qqwarning_issued .knownget {not}{//true} ifelse
+ {
+ (\n **** Warning: Type 3 glyph has unbalanced q/Q operators \(too many q's\)\n Output may be incorrect.\n)
+ pdfformatwarning
+ pdfdict /.Qqwarning_issued //true .forceput
+ } if
+ Q
+ } repeat
+ Q
+ } PDFfile fileposition 2 .execn % Keep pdfcount valid.
+ PDFfile exch setfileposition
+ } ifelse
} {
% PDF Type 3 fonts don't use .notdef
% d1 implementation adjusts the width as needed
@@ -2282,12 +2321,7 @@ currentdict /bndef undef
% in multipage documents.
/patch_font_XUID % <font dict> <patch> patch_font_XUID <font dict'>
{
- %% Allow users to specify that we should not care about font object numbers
- %% that is, don't patch the XUID with the object number and filename.
- /PDFDontUseFontObjectNum where {/PDFDontUseFontObjectNum get}{//false}ifelse
- %% Do not modify the XUID if we don't have an object number (see above)
- 1 index //null eq
- or
+ dup //null eq
{pop}
{
pdfdict /InputPDFFileName .knownget {.CRCHashFilenameAndObject} if