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