mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-08 02:30:09 +00:00
Fix #5316: StandardEncoding and ISOLatin1Encoding are Encoding resources
The standard encodings were names in systemdict only, and the Encoding category was empty, so `/StandardEncoding /Encoding findresource` failed with undefinedresource. The PLRM (3rd ed.) has both as instances of the Encoding category, the same arrays as the names. Ghostscript's eps2write prolog takes StandardEncoding that way for a font whose encoding is a Differences dictionary with no BaseEncoding, so files with its Type 3 text stopped there.
This commit is contained in:
@@ -105,13 +105,18 @@ impl<'a> Interp<'a> {
|
||||
pub fn new(src: &'a [u8], g: GState, out: Out) -> Self {
|
||||
let made = super::obj::track();
|
||||
let system = new_dict();
|
||||
// The standard encodings are also instances of the Encoding category, the same arrays
|
||||
// (PLRM 3rd ed., `findencoding` and §3.9.2).
|
||||
let encodings = new_dict();
|
||||
{
|
||||
let mut d = system.borrow_mut();
|
||||
for (op, name) in Op::ALL {
|
||||
d.insert(Key::name(name), Obj::Op(*op));
|
||||
}
|
||||
for name in ["StandardEncoding", "ISOLatin1Encoding"] {
|
||||
d.insert(Key::name(name), encoding());
|
||||
let e = encoding();
|
||||
d.insert(Key::name(name), e.clone());
|
||||
encodings.borrow_mut().insert(Key::name(name), e);
|
||||
}
|
||||
// An integer, as interpreters have it (`systemdict /languagelevel get 2 ge`): run, the
|
||||
// name pushes it all the same.
|
||||
@@ -122,6 +127,7 @@ impl<'a> Interp<'a> {
|
||||
CATEGORIES.split_whitespace().map(|c| (Key::name(c), Obj::dict(Dict::from([(Key::name("Category"), Obj::name(c))])))).collect();
|
||||
let resources = new_dict();
|
||||
resources.borrow_mut().insert(Key::name("Category"), Obj::dict(categories));
|
||||
resources.borrow_mut().insert(Key::name("Encoding"), Obj::Dict(encodings));
|
||||
let fonts = new_dict();
|
||||
system.borrow_mut().insert(Key::name("FontDirectory"), Obj::Dict(fonts.clone()));
|
||||
for name in ["GlobalFontDirectory", "SharedFontDirectory"] {
|
||||
|
||||
@@ -892,6 +892,17 @@ fn the_generic_category_defines_new_categories() {
|
||||
check("{ /X 5 /Category defineresource } stopped");
|
||||
}
|
||||
|
||||
/// The standard encodings are instances of the Encoding category, the same arrays as the names in
|
||||
/// `systemdict` (PLRM 3rd ed., `findencoding` and §3.9.2). Ghostscript's `eps2write` finds
|
||||
/// `StandardEncoding` that way for the fonts it embeds.
|
||||
#[test]
|
||||
fn the_standard_encodings_are_encoding_resources() {
|
||||
check("/StandardEncoding /Encoding findresource StandardEncoding eq");
|
||||
check("/ISOLatin1Encoding /Encoding findresource ISOLatin1Encoding eq");
|
||||
check("/StandardEncoding /Encoding resourcestatus { pop pop true } { false } ifelse");
|
||||
check("{ /Nope /Encoding findresource } stopped");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn clipsave_and_cliprestore_bring_the_clip_back() {
|
||||
// #234.
|
||||
|
||||
Reference in New Issue
Block a user