diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1de5659 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +target \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..ad726d7 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,85 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "approx" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "arrayvec" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "autocfg" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "byteorder" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "nodrop" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "num-traits" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "ordered-float" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rusttype" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "approx 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", + "ordered-float 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "stb_truetype 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "stb_truetype" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "typewriter" +version = "0.1.0" +dependencies = [ + "rusttype 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[metadata] +"checksum approx 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f0e60b75072ecd4168020818c0107f2857bb6c4e64252d8d3983f6263b40a5c3" +"checksum arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba" +"checksum autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b671c8fb71b457dd4ae18c4ba1e59aa81793daacc361d82fcd410cef0d491875" +"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" +"checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" +"checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" +"checksum ordered-float 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "18869315e81473c951eb56ad5558bbc56978562d3ecfb87abb7a1e944cea4518" +"checksum rusttype 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07c67d4df90dcc0296c39e293fa9cfbbd29def131a5a3ffb9bc671f8dc906942" +"checksum stb_truetype 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "824210d6fb52cbc3ad2545270ead6860c7311aa5450642b078da4515937b6f7a" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..287ec67 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "typewriter" +version = "0.1.0" +authors = ["Robert Lord "] +edition = "2018" + +[dependencies] +rusttype = "0.8.0" diff --git a/inconsolata-license.txt b/inconsolata-license.txt new file mode 100755 index 0000000..0b83a9a --- /dev/null +++ b/inconsolata-license.txt @@ -0,0 +1,93 @@ +Copyright 2006 The Inconsolata Project Authors + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/inconsolata.ttf b/inconsolata.ttf new file mode 100644 index 0000000..592ccd2 Binary files /dev/null and b/inconsolata.ttf differ diff --git a/license.md b/license.md new file mode 100644 index 0000000..aecde28 --- /dev/null +++ b/license.md @@ -0,0 +1,19 @@ +Copyright (c) 2019 Robert Lord + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..819fb19 --- /dev/null +++ b/readme.md @@ -0,0 +1,3 @@ +# plotter-quine + +A quine for the HP7440A. diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..5520071 --- /dev/null +++ b/src/main.rs @@ -0,0 +1 @@ +use rusttype::*;fn main() {println!("VS 1; SP 1;");let q=["use rusttype::*;fn main() {println!(\"VS 1; SP 1;\");let q=[","];let msg=format!(\"{}{:?},{:?}{}\", q[0], q[0], q[1], q[1]);let mut fd=Vec::new();let mut file=std::fs::File::open(\"./inconsolata.ttf\").unwrap();std::io::Read::read_to_end(&mut file, &mut fd).unwrap();let line_count=msg.len() / 90 + 1;for no in 0..line_count {let line=&msg[(no*90)..(no*90 + 90).min(msg.len())];let glyphs: Vec>=FontCollection::from_bytes(&fd).unwrap().into_font().unwrap().layout(line,Scale::uniform(240.),Point {x:0.,y:(7650-no*240-200) as f32},).collect();for glyph in glyphs {if let Some(contours)=glyph.shape() {for contour in contours {let mut res=vec![];for segment in contour.segments {match segment {Segment::Line(line)=>{res.push(line.p[0]); res.push(line.p[1])},Segment::Curve(c)=>{let p=c.p;for i in 0..3 {let t=i as f32*0.5;let x=(1.0-t)*(1.0-t)*p[0].x+2.0*(1.0-t)*t*p[1].x+t*t*p[2].x;let y=(1.0-t)*(1.0-t)*p[0].y+2.0*(1.0-t)*t*p[1].y+t*t*p[2].y;res.push(Point{x,y});}}}}let mut points=vec![];for item in res {if Some(&item)!=points.last() {points.push(item);}}if points.len()!=0 {println!(\"PU;\");println!(\"PA {}, {};\", points[0].x as i64, points[0].y as i64);println!(\"PD;\");for p in points {println!(\"PA {}, {};\", p.x as i64, p.y as i64);}println!(\"PU;\");}}}}}}"];let msg=format!("{}{:?},{:?}{}", q[0], q[0], q[1], q[1]);let mut fd=Vec::new();let mut file=std::fs::File::open("./inconsolata.ttf").unwrap();std::io::Read::read_to_end(&mut file, &mut fd).unwrap();let line_count=msg.len() / 90 + 1;for no in 0..line_count {let line=&msg[(no*90)..(no*90 + 90).min(msg.len())];let glyphs: Vec>=FontCollection::from_bytes(&fd).unwrap().into_font().unwrap().layout(line,Scale::uniform(240.),Point {x:0.,y:(7650-no*240-200) as f32},).collect();for glyph in glyphs {if let Some(contours)=glyph.shape() {for contour in contours {let mut res=vec![];for segment in contour.segments {match segment {Segment::Line(line)=>{res.push(line.p[0]); res.push(line.p[1])},Segment::Curve(c)=>{let p=c.p;for i in 0..3 {let t=i as f32*0.5;let x=(1.0-t)*(1.0-t)*p[0].x+2.0*(1.0-t)*t*p[1].x+t*t*p[2].x;let y=(1.0-t)*(1.0-t)*p[0].y+2.0*(1.0-t)*t*p[1].y+t*t*p[2].y;res.push(Point{x,y});}}}}let mut points=vec![];for item in res {if Some(&item)!=points.last() {points.push(item);}}if points.len()!=0 {println!("PU;");println!("PA {}, {};", points[0].x as i64, points[0].y as i64);println!("PD;");for p in points {println!("PA {}, {};", p.x as i64, p.y as i64);}println!("PU;");}}}}}} \ No newline at end of file