mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-10 01:50:22 -06:00
Merge pull request #5317 from JonRC/fix/eps-encoding-resources
Fix #5316: StandardEncoding and ISOLatin1Encoding are Encoding resources
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., §3.9.2 and `findencoding`, <https://www.adobe.com/jp/print/postscript/pdfs/PLRM.pdf>).
|
||||
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., §3.9.2 and `findencoding`, <https://www.adobe.com/jp/print/postscript/pdfs/PLRM.pdf>).
|
||||
/// 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