summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlgs/Resource/Init/pdf_ops.ps
diff options
context:
space:
mode:
Diffstat (limited to 'Master/tlpkg/tlgs/Resource/Init/pdf_ops.ps')
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/pdf_ops.ps101
1 files changed, 42 insertions, 59 deletions
diff --git a/Master/tlpkg/tlgs/Resource/Init/pdf_ops.ps b/Master/tlpkg/tlgs/Resource/Init/pdf_ops.ps
index 47ff512d927..fe61b12dcdb 100644
--- a/Master/tlpkg/tlgs/Resource/Init/pdf_ops.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/pdf_ops.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2020 Artifex Software, Inc.
+% Copyright (C) 2001-2021 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -695,10 +695,11 @@ end
{ % Check OP and BM in case we need to push a group
//OPsaveDstack begin
//Dpush exec % push the current OPsaveDstack values into 'previous'
+ /SupportsDevn .special_op
okOPcs currentcolorspace 0 get dup /Indexed eq {
pop currentcolorspace 1 get % use the base space
} if
- known {
+ known or {
1 index /stroke ne { .currentfilloverprint } { .currentstrokeoverprint } ifelse
% Change BM to CompatibleOverprint if this has overprint true
dup /ChangeBM exch def
@@ -1478,19 +1479,8 @@ currentdict /clip_if_required .undef
% width under pdfwrite. Pdfwrite uses (in text mode) an identity
% CTM, so we need to calculate the stroke width which would result
% if the CTM had been unity.
- currentlinewidth dup
- currentdict /qTextSaveMatrix known {
- matrix defaultmatrix idtransform qTextSaveMatrix dtransform
- }{
- matrix defaultmatrix idtransform TextSaveMatrix dtransform
- } ifelse
- abs 2 copy exch abs eq {
- pop
- }{
- % non-square scaling reduces to Text matrix in pdfwrite , so
- % we can ignore it. (wrong answer, but consistent)
- pop pop currentlinewidth
- }ifelse setlinewidth
+ calc_text_linewidth
+ setlinewidth
show setlinewidth} bind executeonly
% Tr 2 - Fill then Stroke
{ currentlinewidth exch setsmaskstate
@@ -1498,19 +1488,8 @@ currentdict /clip_if_required .undef
% width under pdfwrite. Pdfwrite uses (in text mode) an identity
% CTM, so we need to calculate the stroke width which would result
% if the CTM had been unity.
- currentlinewidth dup
- currentdict /qTextSaveMatrix known {
- matrix defaultmatrix idtransform qTextSaveMatrix dtransform
- }{
- matrix defaultmatrix idtransform TextSaveMatrix dtransform
- } ifelse
- abs 2 copy exch abs eq {
- pop
- }{
- % non-square scaling reduces to Text matrix in pdfwrite , so
- % we can ignore it. (wrong answer, but consistent)
- pop pop currentlinewidth
- }ifelse setlinewidth
+ calc_text_linewidth
+ setlinewidth
setsmaskstate show setlinewidth} bind executeonly
% Tr 3 - Neither fill nor stroke
{ setsmaskstate show } bind executeonly
@@ -1525,38 +1504,50 @@ currentdict /clip_if_required .undef
setsmaskstate dup show grestore //true charpath } bind executeonly
% Tr 5 - Stroke, add to clip
{ gsave 1 .settextrenderingmode
- currentlinewidth dup
- matrix defaultmatrix idtransform TextSaveMatrix dtransform
- abs 2 copy exch abs eq {
- pop
- }{
- % non-square scaling reduces to Text matrix in pdfwrite , so
- % we can ignore it. (wrong answer, but consistent)
- pop pop currentlinewidth
- }ifelse setlinewidth
+ calc_text_linewidth
+ setlinewidth
setsmaskstate dup show grestore
//true charpath} bind executeonly
% Tr 6 - Fill, stroke, add to clip
{ gsave 2 .settextrenderingmode
- currentlinewidth dup
- currentdict /qTextSaveMatrix known {
- matrix defaultmatrix idtransform qTextSaveMatrix dtransform
- }{
- matrix defaultmatrix idtransform TextSaveMatrix dtransform
- } ifelse
- abs 2 copy exch abs eq {
- pop
- }{
- % non-square scaling reduces to Text matrix in pdfwrite , so
- % we can ignore it. (wrong answer, but consistent)
- pop pop currentlinewidth
- }ifelse setlinewidth
+ calc_text_linewidth
+ setlinewidth
setsmaskstate dup show grestore
//true charpath} bind executeonly
% Tr 7 - Add to clip
{ //true charpath} bind executeonly
] readonly def
+% - calc_text_linewidth calculated_width
+% This calculates the required linewidth for stroke for *pdfwrite*, it must not be
+% used for rendering. Because pdfwrite writes text scaled into a 72 dpi resolution
+% we cannot use the current linewidth for it, it will be too large. Instead we must
+% re-calculate the original linewidth (removing the default CTM) and then apply the
+% TextSaveMatrix to find the appropriate new linewidth.
+% We check to see if the x and y scaling are approximately the same, if they are not
+% then we calculate a linewidth based on a right triangle with the x and y values
+% of the current linewidth in each direction and then calculate the hypotenuse, which
+% we then use as an approximation to the required width.
+% The 'approximation' of 0.01 is just a guess.
+/calc_text_linewidth
+{
+ currentlinewidth dup
+ currentdict /qTextSaveMatrix known {
+ matrix defaultmatrix idtransform qTextSaveMatrix dtransform
+ }{
+ matrix defaultmatrix idtransform TextSaveMatrix dtransform
+ } ifelse
+ abs 2 copy exch abs sub abs 0.01 le {
+ pop
+ }{
+ % We used to leave the linewidth alone for non-square resolutions,
+ % claiming it reduced to the text matrix in pdfwrite. This is not
+ % true. So handle it the same way we usually do, the hypotenuse of
+ % the unit square transformed through the TextSaveMatrix.
+ dup mul exch dup mul add sqrt 2 div
+ }ifelse
+} bind executeonly def
+
/setstrokeforTrpreservation {
% Check to see if the current device supports Tr
/PreserveTrMode /GetDeviceParam .special_op {
@@ -1573,15 +1564,7 @@ currentdict /clip_if_required .undef
% CTM, so we need to calculate the stroke width which would result
% if the CTM had been unity. NOTE! Only interested in magnitudes,
% not signs.
- currentlinewidth dup
- matrix defaultmatrix idtransform TextSaveMatrix dtransform
- abs 2 copy exch abs eq {
- pop
- }{
- % non-square scaling reduces to Text matrix in pdfwrite , so
- % we can ignore it. (wrong answer, but consistent)
- pop pop currentlinewidth
- }ifelse
+ calc_text_linewidth
setlinewidth
} if
} if