summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlgs/lib/opdfread.ps
diff options
context:
space:
mode:
Diffstat (limited to 'Master/tlpkg/tlgs/lib/opdfread.ps')
-rw-r--r--Master/tlpkg/tlgs/lib/opdfread.ps81
1 files changed, 77 insertions, 4 deletions
diff --git a/Master/tlpkg/tlgs/lib/opdfread.ps b/Master/tlpkg/tlgs/lib/opdfread.ps
index 571cd2a7cb9..5e42816f093 100644
--- a/Master/tlpkg/tlgs/lib/opdfread.ps
+++ b/Master/tlpkg/tlgs/lib/opdfread.ps
@@ -15,7 +15,7 @@
% contact Artifex Software, Inc., 101 Lucas Valley Road #110,
% San Rafael, CA 94903, U.S.A., +1(415)492-9861.
-% $Id: opdfread.ps 8101 2007-07-04 19:52:15Z ray $
+% $Id: opdfread.ps 8296 2007-10-16 07:54:08Z ken $
% pdfread.ps - A procset for interpreting an ordered PDF 1.3 file.
% This module defines routines for interpreting a PDF file with
@@ -925,6 +925,35 @@ currentdict end readonly def
/Subtype get 1 index exch /FontFileType exch put
} bind def
+/UnPDFEscape { % <namepdf> UnPDFEscape <nameps>
+ dup dup length string cvs % /namepdf (name)
+ dup (#) search {
+ % name contains PDF-style escapes ("#hh") that need to be removed
+ { % ... (po..st) (#) (pre)
+ pop % ... (po..st) (#)
+ (16#--) 2 index 0 2 getinterval % ... (po..st) (#) (16#--) (po)
+ 1 index 3 2 getinterval copy pop % ... (po..st) (#) (16#po)
+ cvi % ... (po..st) (#) 16#po
+ 0 exch put % ... (po..st); 16#po patched into (#)
+ 0 % ... (po..st) 0
+ 1 index 2 1 index length 2 sub getinterval % ... (po..st) 0 (..st)
+ 3 copy putinterval % ... (..stst) 0 (XXst)
+ length % ... (..stst) 0 LEN_OF_(po..st)-2
+ 3 copy exch put % ... (..st\0t) 0 LEN_OF_(po..st)-2
+ getinterval % ... (..st), stored at begining of old (po..st)
+ (#) search not {
+ pop exit % /namepdf (nameps\0..)
+ } if
+ } loop
+ % we have a '\0' marker (not allowed in PDF names) after all usefull characters
+ (\0) search pop exch pop exch pop
+ cvn
+ exch pop
+ } {
+ pop pop
+ } ifelse
+} bind def
+
/TypeDaemons << % <id> <obj> proc <id> <obj>
/Page
{ //PDFR_DEBUG {
@@ -944,6 +973,9 @@ currentdict end readonly def
{ //PDFR_DEBUG {
(Recognized a font descriptor.) =
} if
+ dup /FontName //knownget exec {
+ 1 index /FontName 3 -1 roll //UnPDFEscape exec put
+ } if
{
dup dup /FontFile known {/FontFile} {/FontFile2} ifelse
//knownget exec { % id obj ff
@@ -963,6 +995,7 @@ currentdict end readonly def
(Recognized a font resource.) =
} if
dup /BaseFont //knownget exec {
+ //UnPDFEscape exec 2 copy /BaseFont exch put
% cache the installed font (if any) before replacing it.
//PDFReader /RemoveFontNamePrefix get exec
currentglobal exch % A hack against HP LaserJet 1320 bug :
@@ -1342,8 +1375,15 @@ end
/Encoding exch put % s fr f
1 index /Metrics //knownget exec { % s fr f M
2 index /Subtype get /TrueType ne {
- % Adjust Metrics for fonts converted from TrueTypes by 3d party.
- 1 index /FontMatrix get 0 get 0.001 div
+ 1 index /FontMatrix get 0 get
+ dup 0 eq {
+ % FontMatrix[0] == 0, so cannot downscale by it
+ % HACK: downscale by FontMatrix[1], and will get the target value of wx as wy
+ pop
+ 1 index /FontMatrix get 1 get
+ dup 0 eq { pop 1 } if % sorry, FontMatrix is singular so cannot enforce the PDF metrics
+ } if
+ 0.001 div
//ScaleMetrics exec
} if
1 index exch /Metrics exch put % s fr f
@@ -3130,6 +3170,7 @@ currentdict end readonly def
/SetFont % <resource_name> <size> SetFont -
{ dup //GraphicState exch /FontSize exch put
//ResolveAndSetFont exec
+ //GraphicState /FontMatrixNonHV currentfont /FontMatrix get 1 get 0 ne put
} bind def
/ShowText % <string> ShowText -
@@ -3137,15 +3178,42 @@ currentdict end readonly def
//GraphicState /WordSpacing get 0
32
//GraphicState /CharacterSpacing get 0
- 6 5 roll awidthshow
+ 6 5 roll
+ //GraphicState /FontMatrixNonHV get {
+ % Use xshow to force wy in text space to be 0 (PDF1.7 5.3.3 "Text Space Details")
+ %stack: wordspacing_wx wordspacing_wy space_char charspacing_wx charspacing_wy string
+ [ % wwx wwy sp cwx cwy str [
+ 7 -2 roll pop % sp cwx cwy str [ ww
+ 5 -2 roll pop % sp str [ ww cw
+ 5 -1 roll % str [ ww cw sp
+ { % str [ ... ww cw sp c wx wy
+ exch % will be removed, unless FontMatrix.xx == 0 (FontMatrixNonHV already true)
+ pop % str [ ... ww cw sp c w
+ 3 index add % str [ ... ww cw sp c w+cw
+ exch 2 index eq { 3 index add } if % str [ ... ww cw sp w+cw[+ww]
+ 4 1 roll % str [ ... w+cw[+ww] ww cw sp
+ }
+ currentfont /FontMatrix get 0 get 0 ne {
+ 1 1 index length 1 sub getinterval cvx % drop the "exch"
+ } if
+ 5 index % str [ ww cw sp {cshowproc} str
+ cshow % str [ widths... ww cw sp
+ pop pop pop ] % str [widths...]
+ xshow
+ } {
+ awidthshow
+ } ifelse
} {
//GraphicState /CharacterSpacing get 0 eq
+ //GraphicState /FontMatrixNonHV get not and
//GraphicState /WordSpacing get 0 eq and {
true charpath
} {
% Emulate with "{ charpath } cshow".
% Not sure how it works with CID fonts.
{ % c wx wy
+ exch % will be removed, unless FontMatrixNonHV && FontMatrix.xx == 0
+ pop 0 % (PDF1.7 5.3.3 "Text Space Details")
currentpoint 5 4 roll % wx wy x y c
( ) dup 0 3 index put true charpath % wx wy x y c
5 1 roll % c wx wy x y
@@ -3155,6 +3223,11 @@ currentdict end readonly def
//GraphicState /WordSpacing get 0 rmoveto
} if
}
+ //GraphicState /FontMatrixNonHV get dup not exch {
+ pop currentfont /FontMatrix get 0 get 0 ne
+ } if {
+ 1 1 index length 1 sub getinterval cvx
+ } if
exch cshow
} ifelse
} ifelse