Repository: fschutt/printpdf (language: rust)

Issue:
target wasm32 is using stdweb
I am not sure which package tring to install stdweb but lopdf and printpdf using time package and somehow it install stdweb 0.4.2 which it is not compatible with syn v2. It only depends on wasm32 target.


Discussion / hints:
I've also had a look at this and resolved it on my local branch, 
I upgraded lopdf to 0.31.0
I upgraded time to 0.3.25

the upgrade to lopdf required me to change most if not all the f64 in the crate to f32 to be compatible with the 0.31.0 version, 
it now builds for me and the very basic functionality I was using is working again. 

if you add permissions for my user I can push up the branch where I have resolved it?
@learnplaycreate You can make your own branch and create a PR, I can merge from there, you don't need to wait for permission that's the point of forking.

Fix patch:
diff --git a/Cargo.lock b/Cargo.lock
index 836363d..fcdd9b2 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -80,12 +80,6 @@ version = "1.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
 
-[[package]]
-name = "base-x"
-version = "0.2.11"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270"
-
 [[package]]
 name = "base64"
 version = "0.13.1"
@@ -158,12 +152,6 @@ version = "1.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
 
-[[package]]
-name = "const_fn"
-version = "0.4.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fbdcdcb6d86f71c5e97409ad45898af11cbc995b4ee8112d59095a28d376c935"
-
 [[package]]
 name = "crc32fast"
 version = "1.3.2"
@@ -236,16 +224,10 @@ dependencies = [
 ]
 
 [[package]]
-name = "discard"
-version = "1.0.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0"
-
-[[package]]
-name = "dtoa"
-version = "0.4.8"
+name = "deranged"
+version = "0.3.7"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0"
+checksum = "7684a49fb1af197853ef7b2ee694bc1f5b4179556f1e5710e1760c5db6f5e929"
 
 [[package]]
 name = "either"
@@ -253,70 +235,6 @@ version = "1.9.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
 
-[[package]]
-name = "encoding"
-version = "0.2.33"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6b0d943856b990d12d3b55b359144ff341533e516d94098b1d3fc1ac666d36ec"
-dependencies = [
- "encoding-index-japanese",
- "encoding-index-korean",
- "encoding-index-simpchinese",
- "encoding-index-singlebyte",
- "encoding-index-tradchinese",
-]
-
-[[package]]
-name = "encoding-index-japanese"
-version = "1.20141219.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "04e8b2ff42e9a05335dbf8b5c6f7567e5591d0d916ccef4e0b1710d32a0d0c91"
-dependencies = [
- "encoding_index_tests",
-]
-
-[[package]]
-name = "encoding-index-korean"
-version = "1.20141219.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4dc33fb8e6bcba213fe2f14275f0963fd16f0a02c878e3095ecfdf5bee529d81"
-dependencies = [
- "encoding_index_tests",
-]
-
-[[package]]
-name = "encoding-index-simpchinese"
-version = "1.20141219.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d87a7194909b9118fc707194baa434a4e3b0fb6a5a757c73c3adb07aa25031f7"
-dependencies = [
- "encoding_index_tests",
-]
-
-[[package]]
-name = "encoding-index-singlebyte"
-version = "1.20141219.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3351d5acffb224af9ca265f435b859c7c01537c0849754d3db3fdf2bfe2ae84a"
-dependencies = [
- "encoding_index_tests",
-]
-
-[[package]]
-name = "encoding-index-tradchinese"
-version = "1.20141219.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fd0e20d5688ce3cab59eb3ef3a2083a5c77bf496cb798dc6fcdb75f323890c18"
-dependencies = [
- "encoding_index_tests",
-]
-
-[[package]]
-name = "encoding_index_tests"
-version = "0.1.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569"
-
 [[package]]
 name = "encoding_rs"
 version = "0.8.32"
@@ -497,17 +415,16 @@ checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
 
 [[package]]
 name = "lopdf"
-version = "0.27.0"
+version = "0.31.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8146695b97752d9c66da0092c6364f8f3ca683f5ea34341db21e5550c3b8c4f4"
+checksum = "07c8e1b6184b1b32ea5f72f572ebdc40e5da1d2921fa469947ff7c480ad1f85a"
 dependencies = [
- "dtoa",
- "encoding",
+ "encoding_rs",
  "flate2",
- "itoa 0.4.8",
- "lazy_static",
+ "itoa 1.0.9",
  "linked-hash-map",
  "log",
+ "md5",
  "pom",
  "time",
  "weezl",
@@ -519,6 +436,12 @@ version = "0.1.10"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5"
 
+[[package]]
+name = "md5"
+version = "0.7.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "490cc448043f947bae3cbee9c203358d62dbee0db12107a74be5c30ccfd09771"
+
 [[package]]
 name = "memchr"
 version = "2.5.0"
@@ -763,12 +686,6 @@ dependencies = [
  "version_check",
 ]
 
-[[package]]
-name = "proc-macro-hack"
-version = "0.5.20+deprecated"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068"
-
 [[package]]
 name = "proc-macro2"
 version = "1.0.66"
@@ -836,15 +753,6 @@ version = "1.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
 
-[[package]]
-name = "rustc_version"
-version = "0.2.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
-dependencies = [
- "semver",
-]
-
 [[package]]
 name = "rustybuzz"
 version = "0.4.0"
@@ -873,64 +781,12 @@ version = "1.2.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
 
-[[package]]
-name = "semver"
-version = "0.9.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
-dependencies = [
- "semver-parser",
-]
-
-[[package]]
-name = "semver-parser"
-version = "0.7.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
-
 [[package]]
 name = "serde"
 version = "1.0.183"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "32ac8da02677876d532745a130fc9d8e6edfa81a269b107c5b00829b91d8eb3c"
 
-[[package]]
-name = "serde_derive"
-version = "1.0.183"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aafe972d60b0b9bee71a91b92fee2d4fb3c9d7e8f6b179aa99f27203d99a4816"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn 2.0.28",
-]
-
-[[package]]
-name = "serde_json"
-version = "1.0.104"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "076066c5f1078eac5b722a31827a8832fe108bed65dfa75e233c89f8206e976c"
-dependencies = [
- "itoa 1.0.9",
- "ryu",
- "serde",
-]
-
-[[package]]
-name = "sha1"
-version = "0.6.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c1da05c97445caa12d05e848c4a4fcbbea29e748ac28f7e80e9b010392063770"
-dependencies = [
- "sha1_smol",
-]
-
-[[package]]
-name = "sha1_smol"
-version = "1.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012"
-
 [[package]]
 name = "simd-adler32"
 version = "0.3.7"
@@ -958,64 +814,6 @@ version = "1.11.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9"
 
-[[package]]
-name = "standback"
-version = "0.2.17"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e113fb6f3de07a243d434a56ec6f186dfd51cb08448239fe7bcae73f87ff28ff"
-dependencies = [
- "version_check",
-]
-
-[[package]]
-name = "stdweb"
-version = "0.4.20"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5"
-dependencies = [
- "discard",
- "rustc_version",
- "stdweb-derive",
- "stdweb-internal-macros",
- "stdweb-internal-runtime",
- "wasm-bindgen",
-]
-
-[[package]]
-name = "stdweb-derive"
-version = "0.5.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef"
-dependencies = [
- "proc-macro2",
- "quote",
- "serde",
- "serde_derive",
- "syn 1.0.109",
-]
-
-[[package]]
-name = "stdweb-internal-macros"
-version = "0.2.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11"
-dependencies = [
- "base-x",
- "proc-macro2",
- "quote",
- "serde",
- "serde_derive",
- "serde_json",
- "sha1",
- "syn 1.0.109",
-]
-
-[[package]]
-name = "stdweb-internal-runtime"
-version = "0.1.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0"
-
 [[package]]
 name = "svg2pdf"
 version = "0.1.0"
@@ -1072,40 +870,30 @@ dependencies = [
 
 [[package]]
 name = "time"
-version = "0.2.27"
+version = "0.3.25"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4752a97f8eebd6854ff91f1c1824cd6160626ac4bd44287f7f4ea2035a02a242"
+checksum = "b0fdd63d58b18d663fbdf70e049f00a22c8e42be082203be7f26589213cd75ea"
 dependencies = [
- "const_fn",
- "libc",
- "standback",
- "stdweb",
+ "deranged",
+ "itoa 1.0.9",
+ "serde",
+ "time-core",
  "time-macros",
- "version_check",
- "winapi",
 ]
 
 [[package]]
-name = "time-macros"
+name = "time-core"
 version = "0.1.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "957e9c6e26f12cb6d0dd7fc776bb67a706312e7299aed74c8dd5b17ebb27e2f1"
-dependencies = [
- "proc-macro-hack",
- "time-macros-impl",
-]
+checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb"
 
 [[package]]
-name = "time-macros-impl"
-version = "0.1.2"
+name = "time-macros"
+version = "0.2.11"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fd3c141a1b43194f3f56a1411225df8646c55781d5f26db825b3d98507eb482f"
+checksum = "eb71511c991639bb078fd5bf97757e03914361c48100d52878b8e52b46fb92cd"
 dependencies = [
- "proc-macro-hack",
- "proc-macro2",
- "quote",
- "standback",
- "syn 1.0.109",
+ "time-core",
 ]
 
 [[package]]
@@ -1288,28 +1076,6 @@ version = "0.1.7"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb"
 
-[[package]]
-name = "winapi"
-version = "0.3.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
-dependencies = [
- "winapi-i686-pc-windows-gnu",
- "winapi-x86_64-pc-windows-gnu",
-]
-
-[[package]]
-name = "winapi-i686-pc-windows-gnu"
-version = "0.4.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
-
-[[package]]
-name = "winapi-x86_64-pc-windows-gnu"
-version = "0.4.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
-
 [[package]]
 name = "xmlparser"
 version = "0.13.5"
diff --git a/Cargo.toml b/Cargo.toml
index c71a127..16c8e19 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -15,11 +15,11 @@ edition = "2021"
 
 [dependencies]
 # minimum dependencies
-lopdf = { version = "0.27.0", default-features = false, features = [
+lopdf = { version = "0.31.0", default-features = false, features = [
     "pom_parser",
 ] }
 owned_ttf_parser = { version = "0.12", default-features = false }
-time = { version = "0.2.11", default-features = false, features = ["std"] }
+time = { version = "0.3.25", default-features = false, features = ["std"] }
 # optional: logging
 log = { version = "0.4.8", optional = true }
 # image reading (png / jpeg)
diff --git a/examples/image.rs b/examples/image.rs
index 67baf46..0689849 100644
--- a/examples/image.rs
+++ b/examples/image.rs
@@ -20,8 +20,8 @@ fn main() {
     let decoder = BmpDecoder::new(&mut reader).unwrap();
     let image = Image::try_from(decoder).unwrap();
 
-    let rotation_center_x = Px((image.image.width.0 as f64 / 2.0) as usize);
-    let rotation_center_y = Px((image.image.height.0 as f64 / 2.0) as usize);
+    let rotation_center_x = Px((image.image.width.0 as f32 / 2.0) as usize);
+    let rotation_center_y = Px((image.image.height.0 as f32 / 2.0) as usize);
 
     // layer,
     image.add_to_layer(
diff --git a/examples/svg.rs b/examples/svg.rs
index 4015847..e269695 100644
--- a/examples/svg.rs
+++ b/examples/svg.rs
@@ -11,8 +11,8 @@ fn main() {
     let current_layer = doc.get_page(page1).get_layer(layer1);
     let svg = Svg::parse(SVG).unwrap();
 
-    let rotation_center_x = Px((svg.width.0 as f64 / 2.0) as usize);
-    let rotation_center_y = Px((svg.height.0 as f64 / 2.0) as usize);
+    let rotation_center_x = Px((svg.width.0 as f32 / 2.0) as usize);
+    let rotation_center_y = Px((svg.height.0 as f32 / 2.0) as usize);
 
     let reference = svg.into_xobject(&current_layer);
 
@@ -21,12 +21,12 @@ fn main() {
             &current_layer,
             SvgTransform {
                 rotate: Some(SvgRotation {
-                    angle_ccw_degrees: i as f64 * 36.0,
+                    angle_ccw_degrees: i as f32 * 36.0,
                     rotation_center_x: rotation_center_x.into_pt(300.0),
                     rotation_center_y: rotation_center_y.into_pt(300.0),
                 }),
-                translate_x: Some(Mm(i as f64 * 20.0 % 50.0).into()),
-                translate_y: Some(Mm(i as f64 * 30.0).into()),
+                translate_x: Some(Mm(i as f32 * 20.0 % 50.0).into()),
+                translate_y: Some(Mm(i as f32 * 30.0).into()),
                 ..Default::default()
             },
         );
diff --git a/src/color.rs b/src/color.rs
index e21ae56..1262608 100644
--- a/src/color.rs
+++ b/src/color.rs
@@ -133,7 +133,7 @@ pub enum Color {
 
 impl Color {
     /// Consumes the color and converts into into a vector of numbers
-    pub fn into_vec(self) -> Vec<f64> {
+    pub fn into_vec(self) -> Vec<f32> {
         match self {
             Color::Rgb(rgb) => {
                 vec![rgb.r, rgb.g, rgb.b]
@@ -164,14 +164,14 @@ impl Color {
 /// RGB color
 #[derive(Debug, Clone, PartialEq)]
 pub struct Rgb {
-    pub r: f64,
-    pub g: f64,
-    pub b: f64,
+    pub r: f32,
+    pub g: f32,
+    pub b: f32,
     pub icc_profile: Option<IccProfileRef>,
 }
 
 impl Rgb {
-    pub fn new(r: f64, g: f64, b: f64, icc_profile: Option<IccProfileRef>) -> Self {
+    pub fn new(r: f32, g: f32, b: f32, icc_profile: Option<IccProfileRef>) -> Self {
         Self {
             r,
             g,
@@ -184,16 +184,16 @@ impl Rgb {
 /// CMYK color
 #[derive(Debug, Clone, PartialEq)]
 pub struct Cmyk {
-    pub c: f64,
-    pub m: f64,
-    pub y: f64,
-    pub k: f64,
+    pub c: f32,
+    pub m: f32,
+    pub y: f32,
+    pub k: f32,
     pub icc_profile: Option<IccProfileRef>,
 }
 
 impl Cmyk {
     /// Creates a new CMYK color
-    pub fn new(c: f64, m: f64, y: f64, k: f64, icc_profile: Option<IccProfileRef>) -> Self {
+    pub fn new(c: f32, m: f32, y: f32, k: f32, icc_profile: Option<IccProfileRef>) -> Self {
         Self {
             c,
             m,
@@ -207,12 +207,12 @@ impl Cmyk {
 /// Greyscale color
 #[derive(Debug, Clone, PartialEq)]
 pub struct Greyscale {
-    pub percent: f64,
+    pub percent: f32,
     pub icc_profile: Option<IccProfileRef>,
 }
 
 impl Greyscale {
-    pub fn new(percent: f64, icc_profile: Option<IccProfileRef>) -> Self {
+    pub fn new(percent: f32, icc_profile: Option<IccProfileRef>) -> Self {
         Self {
             percent,
             icc_profile,
@@ -226,14 +226,14 @@ impl Greyscale {
 /// currently they are the same as a CMYK color.
 #[derive(Debug, Copy, Clone, PartialEq)]
 pub struct SpotColor {
-    pub c: f64,
-    pub m: f64,
-    pub y: f64,
-    pub k: f64,
+    pub c: f32,
+    pub m: f32,
+    pub y: f32,
+    pub k: f32,
 }
 
 impl SpotColor {
-    pub fn new(c: f64, m: f64, y: f64, k: f64) -> Self {
+    pub fn new(c: f32, m: f32, y: f32, k: f32) -> Self {
         Self { c, m, y, k }
     }
 }
diff --git a/src/ctm.rs b/src/ctm.rs
index 5bfcb13..14fb805 100644
--- a/src/ctm.rs
+++ b/src/ctm.rs
@@ -13,20 +13,20 @@ pub enum CurTransMat {
     /// X and Y can have different values
     Translate(Pt, Pt),
     /// Rotation matrix (clockwise, in degrees)
-    Rotate(f64),
+    Rotate(f32),
     /// Combined rotate + translate matrix
-    TranslateRotate(Pt, Pt, f64),
+    TranslateRotate(Pt, Pt, f32),
     /// Scale matrix (1.0 = 100% scale, no change)
     /// X and Y can have different values
-    Scale(f64, f64),
+    Scale(f32, f32),
     /// Raw (PDF-internal) PDF matrix
-    Raw([f64; 6]),
+    Raw([f32; 6]),
     /// Identity matrix
     Identity,
 }
 
 impl CurTransMat {
-    pub fn combine_matrix(a: [f64; 6], b: [f64; 6]) -> [f64; 6] {
+    pub fn combine_matrix(a: [f32; 6], b: [f32; 6]) -> [f32; 6] {
         let a = [
             [a[0], a[1], 0.0, 0.0],
             [a[2], a[3], 0.0, 0.0],
@@ -136,17 +136,17 @@ impl CurTransMat {
 #[derive(Debug, Copy, Clone)]
 pub enum TextMatrix {
     /// Text rotation matrix, used for rotating text
-    Rotate(f64),
+    Rotate(f32),
     /// Text translate matrix, used for indenting (transforming) text
     /// (different to regular text placement)
     Translate(Pt, Pt),
     /// Combined translate + rotate matrix
-    TranslateRotate(Pt, Pt, f64),
+    TranslateRotate(Pt, Pt, f32),
     /// Raw matrix (/tm operator)
-    Raw([f64; 6]),
+    Raw([f32; 6]),
 }
 
-impl From<TextMatrix> for [f64; 6] {
+impl From<TextMatrix> for [f32; 6] {
     fn from(val: TextMatrix) -> Self {
         use crate::TextMatrix::*;
         match val {
@@ -167,7 +167,7 @@ impl From<TextMatrix> for [f64; 6] {
     }
 }
 
-impl From<CurTransMat> for [f64; 6] {
+impl From<CurTransMat> for [f32; 6] {
     fn from(val: CurTransMat) -> Self {
         use crate::CurTransMat::*;
         match val {
@@ -197,7 +197,7 @@ impl From<CurTransMat> for [f64; 6] {
 impl From<CurTransMat> for Operation {
     fn from(val: CurTransMat) -> Self {
         use lopdf::Object::*;
-        let matrix_nums: [f64; 6] = val.into();
+        let matrix_nums: [f32; 6] = val.into();
         let matrix: Vec<lopdf::Object> = matrix_nums.iter().copied().map(Real).collect();
         Operation::new("cm", matrix)
     }
@@ -206,7 +206,7 @@ impl From<CurTransMat> for Operation {
 impl From<TextMatrix> for Operation {
     fn from(val: TextMatrix) -> Self {
         use lopdf::Object::*;
-        let matrix_nums: [f64; 6] = val.into();
+        let matrix_nums: [f32; 6] = val.into();
         let matrix: Vec<lopdf::Object> = matrix_nums.iter().copied().map(Real).collect();
         Operation::new("Tm", matrix)
     }
@@ -215,7 +215,7 @@ impl From<TextMatrix> for Operation {
 impl From<CurTransMat> for lopdf::Object {
     fn from(val: CurTransMat) -> Self {
         use lopdf::Object::*;
-        let matrix_nums: [f64; 6] = val.into();
+        let matrix_nums: [f32; 6] = val.into();
         Array(matrix_nums.iter().copied().map(Real).collect())
     }
 }
@@ -226,21 +226,21 @@ fn test_ctm_translate() {
 
     // test that the translation matrix look like what PDF expects
     let ctm_trans = CurTransMat::Translate(Pt(150.0), Pt(50.0));
-    let ctm_trans_arr: [f64; 6] = ctm_trans.into();
-    assert_eq!([1.0_f64, 0.0, 0.0, 1.0, 150.0, 50.0], ctm_trans_arr);
+    let ctm_trans_arr: [f32; 6] = ctm_trans.into();
+    assert_eq!([1.0_f32, 0.0, 0.0, 1.0, 150.0, 50.0], ctm_trans_arr);
 
     let ctm_scale = CurTransMat::Scale(2.0, 4.0);
-    let ctm_scale_arr: [f64; 6] = ctm_scale.into();
-    assert_eq!([2.0_f64, 0.0, 0.0, 4.0, 0.0, 0.0], ctm_scale_arr);
+    let ctm_scale_arr: [f32; 6] = ctm_scale.into();
+    assert_eq!([2.0_f32, 0.0, 0.0, 4.0, 0.0, 0.0], ctm_scale_arr);
 
     let ctm_rot = CurTransMat::Rotate(30.0);
-    let ctm_rot_arr: [f64; 6] = ctm_rot.into();
+    let ctm_rot_arr: [f32; 6] = ctm_rot.into();
     assert_eq!(
         [
-            0.8660254037844384,
-            0.5000000000000004,
-            -0.5000000000000004,
-            0.8660254037844384,
+            0.86602527,
+            0.5000002,
+            -0.5000002,
+            0.86602527,
             0.0,
             0.0
         ],
diff --git a/src/extgstate.rs b/src/extgstate.rs
index bc19861..a5a3a20 100644
--- a/src/extgstate.rs
+++ b/src/extgstate.rs
@@ -133,7 +133,7 @@ pub struct ExtendedGraphicsState {
 
     /* LW float */
     /// __(Optional; PDF 1.3)__ The current line width
-    pub(crate) line_width: f64,
+    pub(crate) line_width: f32,
 
     /* LC integer */
     /// __(Optional; PDF 1.3)__ The current line cap style
@@ -145,7 +145,7 @@ pub struct ExtendedGraphicsState {
 
     /* ML float */
     /// __(Optional; PDF 1.3)__ The miter limit (see “Miter Limit” on page 217).
-    pub(crate) miter_limit: f64,
+    pub(crate) miter_limit: f32,
 
     /* D array */
     /// __(Optional; PDF 1.3)__ The line dash pattern, expressed as an array of the form
@@ -233,12 +233,12 @@ pub struct ExtendedGraphicsState {
     /* FL integer */
     /// __(Optional; PDF 1.3)__ The flatness tolerance (see Section 6.5.1, “Flatness Toler-
     /// ance”).
-    pub(crate) flatness_tolerance: f64,
+    pub(crate) flatness_tolerance: f32,
 
     /* SM integer */
     /// __(Optional; PDF 1.3)__ The smoothness tolerance (see Section 6.5.2, “Smooth-
     /// ness Tolerance”).
-    pub(crate) smoothness_tolerance: f64,
+    pub(crate) smoothness_tolerance: f32,
 
     /* SA integer */
     /// (Optional) A flag specifying whether to apply automatic stroke adjustment
@@ -268,11 +268,11 @@ pub struct ExtendedGraphicsState {
     /// stant shape or constant opacity value to be used for stroking operations in the
     /// transparent imaging model (see “Source Shape and Opacity” on page 526 and
     /// “Constant Shape and Opacity” on page 551).
-    pub(crate) current_stroke_alpha: f64,
+    pub(crate) current_stroke_alpha: f32,
 
     /* ca integer */
     /// __(Optional; PDF 1.4)__ Same as CA , but for nonstroking operations.
-    pub(crate) current_fill_alpha: f64,
+    pub(crate) current_fill_alpha: f32,
 
     /* AIS boolean */
     /// __(Optional; PDF 1.4)__ The alpha source flag (“alpha is shape”), specifying
@@ -302,7 +302,7 @@ impl ExtendedGraphicsStateBuilder {
 
     /// Sets the line width
     #[inline]
-    pub fn with_line_width(mut self, line_width: f64) -> Self {
+    pub fn with_line_width(mut self, line_width: f32) -> Self {
         self.gs.line_width = line_width;
         self.gs.changed_fields.insert(LINE_WIDTH);
         self
@@ -326,7 +326,7 @@ impl ExtendedGraphicsStateBuilder {
 
     /// Sets the miter limit
     #[inline]
-    pub fn with_miter_limit(mut self, miter_limit: f64) -> Self {
+    pub fn with_miter_limit(mut self, miter_limit: f32) -> Self {
         self.gs.miter_limit = miter_limit;
         self.gs.changed_fields.insert(MITER_LIMIT);
         self
@@ -446,7 +446,7 @@ impl ExtendedGraphicsStateBuilder {
 
     /// Sets the flatness tolerance
     #[inline]
-    pub fn with_flatness_tolerance(mut self, flatness_tolerance: f64) -> Self {
+    pub fn with_flatness_tolerance(mut self, flatness_tolerance: f32) -> Self {
         self.gs.flatness_tolerance = flatness_tolerance;
         self.gs.changed_fields.insert(FLATNESS_TOLERANCE);
         self
@@ -454,7 +454,7 @@ impl ExtendedGraphicsStateBuilder {
 
     /// Sets the smoothness tolerance
     #[inline]
-    pub fn with_smoothness_tolerance(mut self, smoothness_tolerance: f64) -> Self {
+    pub fn with_smoothness_tolerance(mut self, smoothness_tolerance: f32) -> Self {
         self.gs.smoothness_tolerance = smoothness_tolerance;
         self.gs.changed_fields.insert(SMOOTHNESS_TOLERANCE);
         self
@@ -486,7 +486,7 @@ impl ExtendedGraphicsStateBuilder {
 
     /// Sets the current alpha for strokes
     #[inline]
-    pub fn with_current_stroke_alpha(mut self, current_stroke_alpha: f64) -> Self {
+    pub fn with_current_stroke_alpha(mut self, current_stroke_alpha: f32) -> Self {
         self.gs.current_stroke_alpha = current_stroke_alpha;
         self.gs.changed_fields.insert(CURRENT_STROKE_ALPHA);
         self
@@ -494,7 +494,7 @@ impl ExtendedGraphicsStateBuilder {
 
     /// Sets the current alpha for fills
     #[inline]
-    pub fn with_current_fill_alpha(mut self, current_fill_alpha: f64) -> Self {
+    pub fn with_current_fill_alpha(mut self, current_fill_alpha: f32) -> Self {
         self.gs.current_fill_alpha = current_fill_alpha;
         self.gs.changed_fields.insert(CURRENT_FILL_ALPHA);
         self
@@ -810,7 +810,7 @@ pub enum TransferExtraFunction {}
 #[derive(Debug, PartialEq, Clone)]
 pub enum HalftoneType {
     /// 1: Defines a single halftone screen by a frequency, angle, and spot function
-    Type1(f64, f64, SpotFunction),
+    Type1(f32, f32, SpotFunction),
     /// 5: Defines an arbitrary number of halftone screens, one for each colorant or
     /// color component (including both primary and spot colorants).
     /// The keys in this dictionary are names of colorants; the values are halftone
@@ -1102,11 +1102,11 @@ pub enum SeperableBlendMode {
 /// # use printpdf::Rgb;
 /// # use printpdf::glob_macros::*;
 /// # fn main() { /* needed for testing*/ }
-/// fn luminosity(input: Rgb) -> f64 {
+/// fn luminosity(input: Rgb) -> f32 {
 ///     0.3 * input.r + 0.59 * input.g + 0.11 * input.b
 /// }
 ///
-/// fn set_luminosity(input: Rgb, target_luminosity: f64) -> Rgb {
+/// fn set_luminosity(input: Rgb, target_luminosity: f32) -> Rgb {
 ///     let d = target_luminosity - luminosity(input);
 ///     Rgb {
 ///         r: input.r + d,
@@ -1128,8 +1128,8 @@ pub enum SeperableBlendMode {
 ///     let mut min = min!(cur_r, cur_g, cur_b);
 ///     let mut max = max!(cur_r, cur_g, cur_b);
 ///
-///     let new_min = (min as f64) / 1000.0;
-///     let new_max = (max as f64) / 1000.0;
+///     let new_min = (min as f32) / 1000.0;
+///     let new_max = (max as f32) / 1000.0;
 ///
 ///     if new_min < 0.0 {
 ///         input.r = lum + (((input.r - lum) * lum) / (lum - new_min));
@@ -1144,7 +1144,7 @@ pub enum SeperableBlendMode {
 ///     return input;
 /// }
 ///
-/// fn saturation(input: Rgb) -> f64 {
+/// fn saturation(input: Rgb) -> f32 {
 ///     let mut cur_r = (input.r * 1000.0) as i64;
 ///     let mut cur_g = (input.g * 1000.0) as i64;
 ///     let mut cur_b = (input.b * 1000.0) as i64;
@@ -1153,8 +1153,8 @@ pub enum SeperableBlendMode {
 ///     let mut min = min!(cur_r, cur_g, cur_b);
 ///     let mut max = max!(cur_r, cur_g, cur_b);
 ///
-///     let new_min = (min as f64) / 1000.0;
-///     let new_max = (max as f64) / 1000.0;
+///     let new_min = (min as f32) / 1000.0;
+///     let new_max = (max as f32) / 1000.0;
 ///     new_max - new_min
 /// }
 /// ```
diff --git a/src/font.rs b/src/font.rs
index f8aaecb..7ba8043 100644
--- a/src/font.rs
+++ b/src/font.rs
@@ -464,20 +464,20 @@ impl ExternalFont {
         let mut current_width_vec = Vec::<Object>::new();
 
         // scale the font width so that it sort-of fits into an 1000 unit square
-        let percentage_font_scaling = 1000.0 / (face_metrics.units_per_em as f64);
+        let percentage_font_scaling = 1000.0 / (face_metrics.units_per_em as f32);
 
         for gid in 0..font_data.glyph_count() {
             if let Some(GlyphMetrics { width, .. }) = font_data.glyph_metrics(gid) {
                 if gid == current_high_gid {
                     current_width_vec
-                        .push(Integer((width as f64 * percentage_font_scaling) as i64));
+                        .push(Integer((width as f32 * percentage_font_scaling) as i64));
                     current_high_gid += 1;
                 } else {
                     widths_list.push(Integer(current_low_gid as i64));
                     widths_list.push(Array(current_width_vec.drain(..).collect()));
 
                     current_width_vec
-                        .push(Integer((width as f64 * percentage_font_scaling) as i64));
+                        .push(Integer((width as f32 * percentage_font_scaling) as i64));
                     current_low_gid = gid;
                     current_high_gid = gid + 1;
                 }
diff --git a/src/image.rs b/src/image.rs
index 6ef8f95..b40e988 100644
--- a/src/image.rs
+++ b/src/image.rs
@@ -42,15 +42,15 @@ pub struct ImageTransform {
     pub translate_y: Option<Mm>,
     /// Rotate (counter-clockwise) around a point, in degree angles
     pub rotate: Option<ImageRotation>,
-    pub scale_x: Option<f64>,
-    pub scale_y: Option<f64>,
+    pub scale_x: Option<f32>,
+    pub scale_y: Option<f32>,
     /// If set to None, will be set to 300.0 for images
-    pub dpi: Option<f64>,
+    pub dpi: Option<f32>,
 }
 
 #[derive(Debug, Copy, Clone, PartialEq, Default)]
 pub struct ImageRotation {
-    pub angle_ccw_degrees: f64,
+    pub angle_ccw_degrees: f32,
     pub rotation_center_x: Px,
     pub rotation_center_y: Px,
 }
diff --git a/src/pdf_layer.rs b/src/pdf_layer.rs
index 6469c44..71ec8f9 100644
--- a/src/pdf_layer.rs
+++ b/src/pdf_layer.rs
@@ -110,7 +110,7 @@ impl PdfLayerReference {
     /// Set the current font, only valid in a `begin_text_section` to
     /// `end_text_section` block
     #[inline]
-    pub fn set_font(&self, font: &IndirectFontRef, font_size: f64) {
+    pub fn set_font(&self, font: &IndirectFontRef, font_size: f32) {
         self.add_operation(Operation::new(
             "Tf",
             vec![font.name.clone().into(), (font_size).into()],
@@ -219,7 +219,7 @@ impl PdfLayerReference {
     /// __NOTE__: 0.0 is a special value, it does not make the line disappear, but rather
     /// makes it appear 1px wide across all devices
     #[inline]
-    pub fn set_outline_thickness(&self, outline_thickness: f64) {
+    pub fn set_outline_thickness(&self, outline_thickness: f32) {
         use lopdf::Object::*;
         self.add_operation(Operation::new(
             OP_PATH_STATE_SET_LINE_WIDTH,
@@ -283,7 +283,7 @@ impl PdfLayerReference {
     /// Sets the text line height inside a text block
     /// (must be called within `begin_text_block` and `end_text_block`)
     #[inline]
-    pub fn set_line_height(&self, height: f64) {
+    pub fn set_line_height(&self, height: f32) {
         self.add_operation(Operation::new("TL", vec![lopdf::Object::Real(height)]));
     }
 
@@ -291,7 +291,7 @@ impl PdfLayerReference {
     /// Values are given in points. A value of 3 (pt) will increase
     /// the spacing inside a word by 3pt.
     #[inline]
-    pub fn set_character_spacing(&self, spacing: f64) {
+    pub fn set_character_spacing(&self, spacing: f32) {
         self.add_operation(Operation::new("Tc", vec![lopdf::Object::Real(spacing)]));
     }
 
@@ -304,7 +304,7 @@ impl PdfLayerReference {
     /// However, the function itself is valid and _will work_
     /// with builtin fonts.
     #[inline]
-    pub fn set_word_spacing(&self, spacing: f64) {
+    pub fn set_word_spacing(&self, spacing: f32) {
         self.add_operation(Operation::new("Tw", vec![lopdf::Object::Real(spacing)]));
     }
 
@@ -313,7 +313,7 @@ impl PdfLayerReference {
     /// 50 will reduce the width of the written text by half,
     /// but stretch the text
     #[inline]
-    pub fn set_text_scaling(&self, scaling: f64) {
+    pub fn set_text_scaling(&self, scaling: f32) {
         self.add_operation(Operation::new("Tz", vec![lopdf::Object::Real(scaling)]));
     }
 
@@ -323,7 +323,7 @@ impl PdfLayerReference {
     /// number, for subscript, use a negative number. This does not
     /// change the size of the font
     #[inline]
-    pub fn set_line_offset(&self, offset: f64) {
+    pub fn set_line_offset(&self, offset: f32) {
         self.add_operation(Operation::new("Ts", vec![lopdf::Object::Real(offset)]));
     }
 
@@ -460,7 +460,7 @@ impl PdfLayerReference {
     ///
     /// [Windows-1252]: https://en.wikipedia.org/wiki/Windows-1252
     #[inline]
-    pub fn use_text<S>(&self, text: S, font_size: f64, x: Mm, y: Mm, font: &IndirectFontRef)
+    pub fn use_text<S>(&self, text: S, font_size: f32, x: Mm, y: Mm, font: &IndirectFontRef)
     where
         S: Into<String>,
     {
@@ -489,8 +489,8 @@ impl PdfLayerReference {
     /*
         /// Instantiate SVG data
         #[inline]
-        pub fn use_svg(&self, width_mm: f64, height_mm: f64,
-                       x_mm: f64, y_mm: f64, svg_data_index: SvgIndex)
+        pub fn use_svg(&self, width_mm: f32, height_mm: f32,
+                       x_mm: f32, y_mm: f32, svg_data_index: SvgIndex)
         {
             let svg_element_ref = {
                 let doc = self.document.upgrade().unwrap();
diff --git a/src/scale.rs b/src/scale.rs
index bb69d3f..51cd896 100644
--- a/src/scale.rs
+++ b/src/scale.rs
@@ -38,7 +38,7 @@ macro_rules! impl_ord {
 
 /// Scale in millimeter
 #[derive(Debug, Default, Copy, Clone, PartialOrd)]
-pub struct Mm(pub f64);
+pub struct Mm(pub f32);
 
 impl Mm {
     pub fn into_pt(&self) -> Pt {
@@ -49,7 +49,7 @@ impl Mm {
 
 impl From<Pt> for Mm {
     fn from(value: Pt) -> Mm {
-        Mm(value.0 * 0.352_778_f64)
+        Mm(value.0 * 0.352_778_f32)
     }
 }
 
@@ -60,11 +60,11 @@ impl_ord!(Mm);
 
 /// Scale in point
 #[derive(Debug, Default, Copy, Clone, PartialOrd)]
-pub struct Pt(pub f64);
+pub struct Pt(pub f32);
 
 impl From<Mm> for Pt {
     fn from(value: Mm) -> Pt {
-        Pt(value.0 * 2.834_646_f64)
+        Pt(value.0 * 2.834_646_f32)
     }
 }
 
@@ -84,8 +84,8 @@ impl_ord!(Pt);
 pub struct Px(pub usize);
 
 impl Px {
-    pub fn into_pt(self, dpi: f64) -> Pt {
-        Mm(self.0 as f64 * (25.4 / dpi)).into()
+    pub fn into_pt(self, dpi: f32) -> Pt {
+        Mm(self.0 as f32 * (25.4 / dpi)).into()
     }
 }
 
@@ -138,21 +138,21 @@ macro_rules! impl_sub_self {
     };
 }
 
-macro_rules! impl_mul_f64 {
+macro_rules! impl_mul_f32 {
     ($type:ident) => {
-        impl Mul<f64> for $type {
+        impl Mul<f32> for $type {
             type Output = Self;
-            fn mul(self, other: f64) -> Self {
+            fn mul(self, other: f32) -> Self {
                 Self { 0: self.0 * other }
             }
         }
     };
 }
 
-macro_rules! impl_mul_assign_f64 {
+macro_rules! impl_mul_assign_f32 {
     ($type:ident) => {
-        impl MulAssign<f64> for $type {
-            fn mul_assign(&mut self, other: f64) {
+        impl MulAssign<f32> for $type {
+            fn mul_assign(&mut self, other: f32) {
                 self.0 *= other;
             }
         }
@@ -162,24 +162,24 @@ macro_rules! impl_mul_assign_f64 {
 macro_rules! impl_div {
     ($type:ident) => {
         impl Div<$type> for $type {
-            type Output = f64;
+            type Output = f32;
             fn div(self, other: $type) -> Self::Output {
                 self.0 / other.0
             }
         }
-        impl Div<f64> for $type {
+        impl Div<f32> for $type {
             type Output = Self;
-            fn div(self, other: f64) -> Self::Output {
+            fn div(self, other: f32) -> Self::Output {
                 Self { 0: self.0 / other }
             }
         }
     };
 }
 
-macro_rules! impl_div_assign_f64 {
+macro_rules! impl_div_assign_f32 {
     ($type:ident) => {
-        impl DivAssign<f64> for $type {
-            fn div_assign(&mut self, other: f64) {
+        impl DivAssign<f32> for $type {
+            fn div_assign(&mut self, other: f32) {
                 self.0 /= other;
             }
         }
@@ -202,17 +202,17 @@ impl_sub_self!(Mm);
 impl_sub_self!(Pt);
 impl_sub_self!(Px);
 
-impl_mul_f64!(Mm);
-impl_mul_f64!(Pt);
+impl_mul_f32!(Mm);
+impl_mul_f32!(Pt);
 
-impl_mul_assign_f64!(Mm);
-impl_mul_assign_f64!(Pt);
+impl_mul_assign_f32!(Mm);
+impl_mul_assign_f32!(Pt);
 
 impl_div!(Mm);
 impl_div!(Pt);
 
-impl_div_assign_f64!(Mm);
-impl_div_assign_f64!(Pt);
+impl_div_assign_f32!(Mm);
+impl_div_assign_f32!(Pt);
 
 #[test]
 fn point_to_mm_conversion() {
diff --git a/src/svg.rs b/src/svg.rs
index 9838a32..56747f0 100644
--- a/src/svg.rs
+++ b/src/svg.rs
@@ -52,15 +52,15 @@ pub struct SvgTransform {
     pub translate_y: Option<Pt>,
     /// Rotate (clockwise), in degree angles
     pub rotate: Option<SvgRotation>,
-    pub scale_x: Option<f64>,
-    pub scale_y: Option<f64>,
+    pub scale_x: Option<f32>,
+    pub scale_y: Option<f32>,
     /// If set to None, will be set to 300.0 for images
-    pub dpi: Option<f64>,
+    pub dpi: Option<f32>,
 }
 
 #[derive(Debug, Copy, Clone, PartialEq, Default)]
 pub struct SvgRotation {
-    pub angle_ccw_degrees: f64,
+    pub angle_ccw_degrees: f32,
     pub rotation_center_x: Pt,
     pub rotation_center_y: Pt,
 }
diff --git a/src/utils.rs b/src/utils.rs
index 485e07e..6599611 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -5,7 +5,7 @@ use crate::Point;
 
 // PDF doesn't understand what a "circle" is, so we have to
 // approximate it.
-const C: f64 = 0.551915024494;
+const C: f32 = 0.551915024494;
 
 /// Calculates and returns the points for an approximated circle, given a radius and an
 /// offset into the centre of circle (starting from bottom left corner of page).


Test patch: