summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlgs/lib/pdf_font.ps
diff options
context:
space:
mode:
Diffstat (limited to 'Master/tlpkg/tlgs/lib/pdf_font.ps')
-rw-r--r--Master/tlpkg/tlgs/lib/pdf_font.ps110
1 files changed, 80 insertions, 30 deletions
diff --git a/Master/tlpkg/tlgs/lib/pdf_font.ps b/Master/tlpkg/tlgs/lib/pdf_font.ps
index d9cf7adb199..132c318f1e9 100644
--- a/Master/tlpkg/tlgs/lib/pdf_font.ps
+++ b/Master/tlpkg/tlgs/lib/pdf_font.ps
@@ -13,7 +13,7 @@
% contact Artifex Software, Inc., 101 Lucas Valley Road #110,
% San Rafael, CA 94903, U.S.A., +1(415)492-9861.
-% $Id: pdf_font.ps 8093 2007-06-30 23:46:18Z alexcher $
+% $Id: pdf_font.ps 8509 2008-01-28 10:31:45Z mpsuzuki $
% PDF font operations.
% Finding a font by name can't give a proper result when PDF font names aren't unique.
@@ -212,7 +212,24 @@ pdfdict begin
% character space, but the FontMatrix may specify
% some other scale factor. Compensate for this here,
% by scaling the Widths if necessary.
- 0.001 2 index /FontMatrix get 0 get div
+ 0.001 2 index /FontMatrix get 0 get
+ dup 0 eq {
+ % FontMatrix.xx == 0, so we cannot scale down by xx.
+ % - FontMatrix[0] == 0 implies either FontMatrix[1] <> 0 or
+ % FontMatrix cannot be inverted. In the 1st case we have
+ % FontMatrixNonHV == true and will render text with cshow + xshow.
+ % In the 2nd case, metrics in the PDF Font object cannot be enforced
+ % [by altering metrics in PS glyph space].
+ % HACK:
+ % - we scale down by FontMatrix[1];
+ % - given the format of Metrics entries we use, wy = 0 in glyph space;
+ % - as a result, the cshow procedure receives as wy the value we
+ % need for wx (all of this in PS user space).
+ pop
+ 2 index /FontMatrix get 1 get
+ dup 0 eq { pop 1 } if % sorry, no way to enforce PDF metrics by altering the font
+ } if
+ div
% Stack: font font-res mscale
/FirstChar 2 index /FirstChar oget def
/LastChar 2 index /LastChar oget def
@@ -569,8 +586,17 @@ setglobal
% If the font isn't available, synthesize one based on
% its descriptor.
dup /Font resourcestatus {
- pop pop pdffindcachedfont
+ pop pop dup pdffindcachedfont
+ dup .isregisteredfont
+ % <font-resource> <fontname> <font> true % font preloaded from disk
+ % <font-resource> <fontname> <font> false % font preloaded from document
+ { exch pop false } { pop true } ifelse
} {
+ true
+ } ifelse
+ % <font-resource> <font> false % font preloaded from disk
+ % <font-resource> <fontname> true % font not loaded yet or embedded
+ {
1 index /FontDescriptor knownoget {
% Stack: font-res fontname fontdesc
dup /Flags oget
@@ -642,7 +668,7 @@ setglobal
% No descriptor available, use the default algorithm.
pdffindcachedfont
} ifelse
- } ifelse
+ } if
exch pop
} bdef
@@ -657,6 +683,12 @@ setglobal
0 () /SubFileDecode filter
} bdef
+% Adobe Acrobat doesn't skip space characters after eexec
+/eexec_pdf_param_dict mark
+ .eexec_param_dict {} forall
+ /keep_spaces true
+.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.
@@ -689,7 +721,7 @@ setglobal
/eexec {
% Assume the font dictionary is directly below the file on the stack
count 0 gt { /topFontDict 2 index cvlit store } if
- //.eexec_param_dict /eexecDecode filter
+ //eexec_pdf_param_dict /eexecDecode filter
//missing-type1-procs begin
/userdict .systemvar begin
@@ -700,12 +732,30 @@ setglobal
{ stop } if
} bdef
- currentdict dup
+ /readonly-op-dict <<
+ /stringtype 0
+ /arraytype 0
+ /packedarraytype 0
+ /dicttype 0
+ >> readonly def
+
+ /readonly { % bug 689617
+ dup type //readonly-op-dict exch known {
+ readonly
+ } {
+ ( **** Warning: Type 1 font applies operator readonly to a wrong type.\n)
+ pdfformaterror
+ } ifelse } .bind def
+
+ currentdict dup dup
/undef_proc_warning undef
/missing-type1-procs undef
+ /readonly-op-dict undef
end readonly def
+currentdict /eexec_pdf_param_dict .undef
+
/readtype1 { % <font-resource> <stream-dict> readtype1 <font>
1 index exch % res res stream
PDFfile fileposition 3 1 roll % res pos res stream
@@ -779,26 +829,37 @@ end readonly def
% Stack: font charcode
1 index begin 3 dict begin
/Font 3 -1 roll def /CharCode 1 index def
- % Make unknown characters map to /.notdef
- Encoding exch get dup CharProcs exch known
- { CharProcs exch oget }
- { pop CharProcs /.notdef oget }
- ifelse
- PDFfile fileposition exch
- false resolvestream
+ Encoding exch get CharProcs exch knownoget {
+ PDFfile fileposition exch
+ //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 exch setfileposition
+ q //null /FillColor gput //null /StrokeColor gput
+ Font /Resources get exch pdfopdict .pdfruncontext
+ Q
+ PDFfile exch setfileposition
+ } {
+ % PDF Type 3 fonts don't use .notdef
+ % d1 implementation adjusts the width as needed
+ 0 0 0 0 0 0
+ pdfopdict /d1 get exec
+ } ifelse
end end
} bdef
dup currentdict Encoding .processToUnicode
FontName currentdict end definefont exch pop
} bdef
/.adjustcharwidth { % <wx> <wy> .adjustcharwidth <wx'> <wy'>
+ % Enforce the metrics, in glyph space, to the values found in the PDF Font object
+ % - force wy == 0 (assumed, and not stored in the PDF font)
+ % Even though PDF1.3-1.7 specifications state that this must be 0,
+ % Distiller sometimes creates Type3 fonts with non-zero wy. We set
+ % it to 0 since this is apparently what Acrobat Reader 4 and 5 do.
+ % PDF1.2 does not mention this restriction, it only says
+ % "see setcharwidth/ setcachedevice in the PostScript Reference".
+ % - get wx from the Widths array (do nothing if not present)
+ pop 0
/Widths where {
begin
CharCode FirstChar ge CharCode LastChar le and {
@@ -824,8 +885,6 @@ end readonly def
/buildTrueType { % <TrueType-font-resource> buildTrueType <font>
dup /BaseFont oget
- /Repaired true store % flag that we had warnings
- TTFWarnList 1 index true put % Add fontname to the list
dup /Font resourcestatus dup { exch pop exch pop } if not
TTfonts 2 index known and {
dup TTfonts exch get
@@ -1418,10 +1477,11 @@ end readonly def
} 2 bndef
<01000401> <01000402> <01000403> <01000404> % Type 1C
+ <01000C02>
{ exch pop
dup /Subtype get
fontloadprocs exch get exec
- } 4 bndef
+ } 5 bndef
<00010000> (true) (typ1) (ttcf) % TrueType OpenType
{ exch pop readtruetype
@@ -1519,16 +1579,6 @@ drawopdict begin
.adjustcharwidth setcharwidth
} bdef
/d1 {
- 4 index 0 ne {
- % invalid wy parameter for d1 in Type3 font (must be 0)
- % Even though the PDF 1.4 specification states that this must be 0,
- % Distiller sometimes creates Type3 fonts with non-zero wy. We set
- % it to 0 since this is apparently what Acrobat Reader 4 and 5 do,
- % but if the specification is ever changed to allow non-zero wy, this
- % will not work.
- 5 -1 roll pop 0 5 1 roll % set wy to 0
- } if
-
2 copy % ... llx lly urx ury | urx ury
0 ne exch 0 ne % ... llx lly urx ury | ury!=0 urx!=0
3 index 6 index eq and % ... llx lly urx ury | ury!=0 (urx!=0 && llx==urx)