Blame SOURCES/ghostscript-9.27-Deal-with-different-VM-modes-during-CIDFont-loading.patch

ac8fca
From 0b74b65ecc0f36d40b8d04a7fa1fa8b5f9d2b3ff Mon Sep 17 00:00:00 2001
ac8fca
From: Chris Liddell <chris.liddell@artifex.com>
ac8fca
Date: Thu, 13 Oct 2022 14:55:28 +0100
ac8fca
Subject: [PATCH] Deal with different VM modes during CIDFont loading
ac8fca
ac8fca
To help differentiate between a substituted CIDFont and an embedded one, a
ac8fca
change was made to store the file path in the CIDFont dictionary. That change
ac8fca
failed to account for the possibility that the file object and the CIDFont
ac8fca
dictionary may not be in compatible VM modes.
ac8fca
ac8fca
This adds code to ensure that the string holding the path is in a suitable VM
ac8fca
mode to be stored into the dictionary.
ac8fca
ac8fca
Reported by Richard Lescak <rlescak@redhat.com>
ac8fca
---
ac8fca
 Resource/Init/gs_cidfn.ps | 23 +++++++++++++++++++----
ac8fca
 1 file changed, 19 insertions(+), 4 deletions(-)
ac8fca
ac8fca
diff --git a/Resource/Init/gs_cidfn.ps b/Resource/Init/gs_cidfn.ps
ac8fca
index 870a2e11c..fa050ed7a 100644
ac8fca
--- a/Resource/Init/gs_cidfn.ps
ac8fca
+++ b/Resource/Init/gs_cidfn.ps
ac8fca
@@ -1,4 +1,4 @@
ac8fca
-% Copyright (C) 2001-2019 Artifex Software, Inc.
ac8fca
+% Copyright (C) 2001-2022 Artifex Software, Inc.
ac8fca
 % All Rights Reserved.
ac8fca
 %
ac8fca
 % This software is provided AS-IS with no warranty, either express or
ac8fca
@@ -36,6 +36,17 @@
ac8fca
 
ac8fca
 30 dict begin
ac8fca
 
ac8fca
+/.gcompatstringcopy % <string> <global> .gcompatstringcopy <string>
ac8fca
+{
ac8fca
+   dup 2 index gcheck eq
ac8fca
+   { pop }
ac8fca
+   {
ac8fca
+       currentglobal 3 1 roll setglobal
ac8fca
+       dup length string copy
ac8fca
+       exch setglobal
ac8fca
+   } ifelse
ac8fca
+} bind def
ac8fca
+
ac8fca
 % The key in .cidfonttypes is the CIDFontType value;
ac8fca
 % the value is a procedure that takes a font name and the CIDFont dictionary
ac8fca
 % and replaces the latter with a real font.
ac8fca
@@ -58,7 +69,7 @@ dup 0 {
ac8fca
     end
ac8fca
   } if
ac8fca
   1 index exch .buildfont9
ac8fca
-  .currentresourcefile dup type /filetype eq { //.filename {1 index exch /ResourcePath exch put} if }{ pop} ifelse
ac8fca
+  .currentresourcefile dup type /filetype eq { //.filename {1 index gcheck //.gcompatstringcopy exec 1 index exch /ResourcePath exch put} if }{ pop} ifelse
ac8fca
   exch pop
ac8fca
 } put % Don't bind it here, because gs_fapi.ps redefines .buildfont9
ac8fca
 
ac8fca
@@ -138,10 +149,11 @@ dup 0 {
ac8fca
 
ac8fca
 % ------ CIDFontType 1 (FontType 10) ------ %
ac8fca
 
ac8fca
+
ac8fca
 dup 1 {
ac8fca
   10 //.checkfonttype exec pop
ac8fca
   1 index exch .buildfont10
ac8fca
-  .currentresourcefile dup type /filetype eq { //.filename {1 index exch /ResourcePath exch put} if }{ pop} ifelse
ac8fca
+  .currentresourcefile dup type /filetype eq { //.filename {1 index gcheck //.gcompatstringcopy exec 1 index exch /ResourcePath exch put} if }{ pop} ifelse
ac8fca
   exch pop
ac8fca
 } put % Don't bind it here because gs_fapi.ps redefines .buildfont10
ac8fca
 
ac8fca
@@ -150,12 +162,15 @@ dup 1 {
ac8fca
 dup 2 {
ac8fca
   11 //.checkfonttype exec pop
ac8fca
   1 index exch .buildfont11
ac8fca
-  .currentresourcefile dup type /filetype eq { //.filename {1 index exch /ResourcePath exch put} if }{ pop} ifelse
ac8fca
+  .currentresourcefile dup type /filetype eq { //.filename {1 index gcheck //.gcompatstringcopy exec 1 index exch /ResourcePath exch put} if }{ pop} ifelse
ac8fca
   exch pop
ac8fca
 } put % Don't bind it here because gs_fapi.ps redefines .buildfont11
ac8fca
 
ac8fca
+currentdict /.gcompatstringcopy .undef
ac8fca
+
ac8fca
 pop		% .cidfonttypes
ac8fca
 
ac8fca
+
ac8fca
 % ---------------- Reading CIDFontType 0 files ---------------- %
ac8fca
 
ac8fca
 /StartData {		% <(Binary)|(Hex)> <datalength> StartData -
ac8fca
-- 
ac8fca
2.37.3
ac8fca