Bug 1518770 - Re-vendor rust dependencies. r=kats
authorWR Updater Bot <graphics-team@mozilla.staktrace.com>
Wed, 09 Jan 2019 13:31:28 +0000
changeset 453070 91d96a779590e292f493eae19365c63355cdfc77
parent 453069 0eb6efe01bfbb46a7ac7018d9dfc46aac81c2cee
child 453071 aab09dc65108a5d2c663b1d1acc7b09ec44e04ef
push id111042
push usercsabou@mozilla.com
push dateWed, 09 Jan 2019 16:41:24 +0000
treeherdermozilla-inbound@eec2f1188f37 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1518770
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1518770 - Re-vendor rust dependencies. r=kats Depends on D16040 Differential Revision: https://phabricator.services.mozilla.com/D16041
Cargo.lock
third_party/rust/dwrote/.cargo-checksum.json
third_party/rust/dwrote/Cargo.toml
third_party/rust/dwrote/appveyor.yml
third_party/rust/dwrote/src/glyph_run_analysis.rs
third_party/rust/dwrote/src/lib.rs
third_party/rust/dwrote/src/types.rs
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -804,17 +804,17 @@ dependencies = [
 name = "dump_syms_rust_demangle"
 version = "0.1.0"
 dependencies = [
  "rustc-demangle 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "dwrote"
-version = "0.6.3"
+version = "0.7.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde_derive 1.0.80 (git+https://github.com/servo/serde?branch=deserialize_from_enums9)",
  "winapi 0.3.6 (git+https://github.com/froydnj/winapi-rs?branch=aarch64)",
 ]
@@ -2982,17 +2982,17 @@ dependencies = [
  "app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "bincode 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
  "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-foundation 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-graphics 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-text 13.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "dwrote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "dwrote 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "freetype 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "gleam 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "plane-split 0.13.3 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3012,33 +3012,33 @@ name = "webrender_api"
 version = "0.58.0"
 dependencies = [
  "app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "bincode 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-foundation 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-graphics 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "dwrote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "dwrote 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "euclid 0.19.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde_bytes 0.10.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde_derive 1.0.80 (git+https://github.com/servo/serde?branch=deserialize_from_enums9)",
  "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "webrender_bindings"
 version = "0.1.0"
 dependencies = [
  "app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "bincode 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-foundation 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-graphics 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "dwrote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "dwrote 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "euclid 0.19.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "foreign-types 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "gleam 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "nsstring 0.1.0",
  "rayon 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "thread_profiler 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3247,17 +3247,17 @@ dependencies = [
 "checksum devd-rs 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e7c9ac481c38baf400d3b732e4a06850dfaa491d1b6379a249d9d40d14c2434c"
 "checksum diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "3c2b69f912779fbb121ceb775d74d51e915af17aaebc38d28a592843a2dd0a3a"
 "checksum digest 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "03b072242a8cbaf9c145665af9d250c59af3b958f83ed6824e13533cf76d5b90"
 "checksum digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05f47366984d3ad862010e22c7ce81a7dbcaebbdfb37241a620f8b6596ee135c"
 "checksum dirs 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "88972de891f6118092b643d85a0b28e0678e0f948d7f879aa32f2d5aafe97d2a"
 "checksum docopt 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d8acd393692c503b168471874953a2531df0e9ab77d0b6bbc582395743300a4a"
 "checksum dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "09c3753c3db574d215cba4ea76018483895d7bff25a31b49ba45db21c48e50ab"
 "checksum dtoa-short 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "068d4026697c1a18f0b0bb8cfcad1b0c151b90d8edb9bf4c235ad68128920d1d"
-"checksum dwrote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f0beca78470f26189a662e72afe7a54c625b4feb06b2d36c207ac15319bd57c5"
+"checksum dwrote 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d2ea0fd88d96838ce5ed30326338cc04a0eb4cff10e3e15d188d74112777103"
 "checksum either 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18785c1ba806c258137c937e44ada9ee7e69a37e3c72077542cd2f069d78562a"
 "checksum ena 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "88dc8393b3c7352f94092497f6b52019643e493b6b890eb417cdb7c46117e621"
 "checksum encoding_c 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "769ecb8b33323998e482b218c0d13cd64c267609023b4b7ec3ee740714c318ee"
 "checksum encoding_rs 0.8.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1a8fa54e6689eb2549c4efed8d00d7f3b2b994a064555b0e8df4ae3764bcc4be"
 "checksum env_logger 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0561146661ae44c579e993456bc76d11ce1e0c7d745e57b2fa7146b6e49fa2ad"
 "checksum error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff511d5dc435d703f4971bc399647c9bc38e20cb41452e3b9feb4765419ed3f3"
 "checksum euclid 0.19.4 (registry+https://github.com/rust-lang/crates.io-index)" = "dbbf962bb6f877239a34491f2e0a12c6b824f389bc789eb90f1d70d4780b0727"
 "checksum failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6dd377bcc1b1b7ce911967e3ec24fa19c3224394ec05b54aa7b083d498341ac7"
--- a/third_party/rust/dwrote/.cargo-checksum.json
+++ b/third_party/rust/dwrote/.cargo-checksum.json
@@ -1,1 +1,1 @@
-{"files":{"Cargo.toml":"5f9a26a7a0f3fffc7093b0ac9e2fd84db133ba5516a9bfb53ed4f842b350564f","README.md":"d69d75705e2582721cbfb2d3b4b2af052c71679057a0b2ac53a22c03f1755bba","appveyor.yml":"7c1e0718a363d3567cecd1ef772d4e17c2a17f18906dc464dce8a2411adff6be","src/bitmap_render_target.rs":"fc13525d7459515e4bf9769c8a8961b046b4d1ba4042591aaf0925dd5edebf64","src/com_helpers.rs":"02535b27bfb0cee6e4d8db3abd22f2d2e8137a4ce3ab3504beaf4fa3ca9370df","src/comptr.rs":"84794cf04b772398e75fdb5d55fd8fa015abf26c61b1f9c761a597133682b2e1","src/font.rs":"a79b944f2f5125bbef9e24921355dc6996f073e3742ddd410b8efaa0df3a3ee2","src/font_collection.rs":"67cd566714f4c0a20cba24dd064ba471e75016fa2672b2153a19878e6b71f24d","src/font_collection_impl.rs":"a585a6ce62083b3346d67619ea47fec46423a7fb04cc11372828389ab26c5a05","src/font_face.rs":"7f78c4132df39857d8118ac3eacbb57e11bca1d69f9d7f8e1c1c24b7a2b69749","src/font_family.rs":"4e948542dba0c158187d0cb2d72343c443380480cacd12894070d0ef1351dd0a","src/font_file.rs":"1c012d0b436c2831d31cd76f77a59dab1edc5d63881c495eb486cd4febe23031","src/font_file_loader_impl.rs":"71c4153971dbfc21d42ba2e33f159fcb145f7dcfbd17e856e9fd75f0571d41e0","src/gdi_interop.rs":"04dbef7c34bb0fe62c4f2c2ceca62ca94c75a964d744b29b3322a6c3bbb4eabd","src/geometry_sink_impl.rs":"d615de212e55b8b8d95c8d605fc5d78044b4ae4dfd846f706911a16cc3afc049","src/glyph_run_analysis.rs":"3b2a351422098a19e8f490421e5b19227fc14a41a0df97d488c536fd1d4b552c","src/helpers.rs":"2f3c57642b24b80c45bbd012e7d6ca1fc524b1b42a8be004cb9b52ea13f4166d","src/lib.rs":"d6a109158cb69cf4a113722169ba8b339d9d38eccb2c9d6b2fe68dd40da22814","src/outline_builder.rs":"0f5c842b2ffe75e21d68f93be6a3834c120bd43303d4e490fdfee9f4f964cdc4","src/rendering_params.rs":"850a51143790f5d29422dc49cbceddc232d814ecd0e6933434ad644e6eec539b","src/test.rs":"158aa4d03655f4efef00327fe72a03dfb504659176aa0eef976ca2485b2c1d74","src/types.rs":"587aea2e50720e85b28efe237c8ea10bc45b52049ca724447a0fc9b0e6672b11"},"package":"f0beca78470f26189a662e72afe7a54c625b4feb06b2d36c207ac15319bd57c5"}
\ No newline at end of file
+{"files":{"Cargo.toml":"2456adfd958e59ec20d4c380e7621684d07817fc015c2372d1cb50473499d359","README.md":"d69d75705e2582721cbfb2d3b4b2af052c71679057a0b2ac53a22c03f1755bba","appveyor.yml":"6a91cdfbcc8c363ead82321b3be509bb7bf9cf8b90c63518d6484371abcfed48","src/bitmap_render_target.rs":"fc13525d7459515e4bf9769c8a8961b046b4d1ba4042591aaf0925dd5edebf64","src/com_helpers.rs":"02535b27bfb0cee6e4d8db3abd22f2d2e8137a4ce3ab3504beaf4fa3ca9370df","src/comptr.rs":"84794cf04b772398e75fdb5d55fd8fa015abf26c61b1f9c761a597133682b2e1","src/font.rs":"a79b944f2f5125bbef9e24921355dc6996f073e3742ddd410b8efaa0df3a3ee2","src/font_collection.rs":"67cd566714f4c0a20cba24dd064ba471e75016fa2672b2153a19878e6b71f24d","src/font_collection_impl.rs":"a585a6ce62083b3346d67619ea47fec46423a7fb04cc11372828389ab26c5a05","src/font_face.rs":"7f78c4132df39857d8118ac3eacbb57e11bca1d69f9d7f8e1c1c24b7a2b69749","src/font_family.rs":"4e948542dba0c158187d0cb2d72343c443380480cacd12894070d0ef1351dd0a","src/font_file.rs":"1c012d0b436c2831d31cd76f77a59dab1edc5d63881c495eb486cd4febe23031","src/font_file_loader_impl.rs":"71c4153971dbfc21d42ba2e33f159fcb145f7dcfbd17e856e9fd75f0571d41e0","src/gdi_interop.rs":"04dbef7c34bb0fe62c4f2c2ceca62ca94c75a964d744b29b3322a6c3bbb4eabd","src/geometry_sink_impl.rs":"d615de212e55b8b8d95c8d605fc5d78044b4ae4dfd846f706911a16cc3afc049","src/glyph_run_analysis.rs":"23c674e892287884ad92faf02813397e4347d61d3b363f6acb8d578c14e65051","src/helpers.rs":"2f3c57642b24b80c45bbd012e7d6ca1fc524b1b42a8be004cb9b52ea13f4166d","src/lib.rs":"16cc8c236226047bc5ca65f921d2aebec4a3a6101a2c8f2853f39a5db4639e16","src/outline_builder.rs":"0f5c842b2ffe75e21d68f93be6a3834c120bd43303d4e490fdfee9f4f964cdc4","src/rendering_params.rs":"850a51143790f5d29422dc49cbceddc232d814ecd0e6933434ad644e6eec539b","src/test.rs":"158aa4d03655f4efef00327fe72a03dfb504659176aa0eef976ca2485b2c1d74","src/types.rs":"9374d8c5bac80e5e0b66188c5ff4f5f49264e15db837049932d4fd703c33746e"},"package":"2d2ea0fd88d96838ce5ed30326338cc04a0eb4cff10e3e15d188d74112777103"}
\ No newline at end of file
--- a/third_party/rust/dwrote/Cargo.toml
+++ b/third_party/rust/dwrote/Cargo.toml
@@ -7,31 +7,37 @@
 #
 # If you believe there's an error in this file please file an
 # issue against the rust-lang/cargo repository. If you're
 # editing this file be aware that the upstream Cargo.toml
 # will likely look very different (and much more reasonable)
 
 [package]
 name = "dwrote"
-version = "0.6.3"
+version = "0.7.0"
 authors = ["Vladimir Vukicevic <vladimir@pobox.com>"]
 description = "Lightweight binding to DirectWrite."
 license = "MPL-2.0"
 repository = "https://github.com/servo/dwrote-rs"
 
 [lib]
 name = "dwrote"
 [dependencies.lazy_static]
 version = "1"
 
 [dependencies.libc]
 version = "0.2"
 
 [dependencies.serde]
 version = "1.0"
+optional = true
 
 [dependencies.serde_derive]
 version = "1.0"
+optional = true
 
 [dependencies.winapi]
 version = "0.3.6"
 features = ["dwrite", "dwrite_1", "dwrite_3", "winnt", "unknwnbase", "libloaderapi", "winnls"]
+
+[features]
+default = ["serde_serialization"]
+serde_serialization = ["serde", "serde_derive"]
--- a/third_party/rust/dwrote/appveyor.yml
+++ b/third_party/rust/dwrote/appveyor.yml
@@ -113,9 +113,10 @@ install:
 # 'cargo test' takes care of building for us, so disable Appveyor's build stage. This prevents
 # the "directory does not contain a project or solution file" error.
 build: false
 
 # Uses 'cargo test' to run tests and build. Alternatively, the project may call compiled programs
 #directly or perform other testing commands. Rust will automatically be placed in the PATH
 # environment variable.
 test_script:
+  - cargo check --no-default-features
   - cargo test --verbose %cargoflags%
--- a/third_party/rust/dwrote/src/glyph_run_analysis.rs
+++ b/third_party/rust/dwrote/src/glyph_run_analysis.rs
@@ -7,70 +7,80 @@ use std::cell::UnsafeCell;
 
 use comptr::ComPtr;
 use winapi::um::dcommon::DWRITE_MEASURING_MODE;
 use winapi::um::dwrite::{DWRITE_RENDERING_MODE, DWRITE_MATRIX};
 use winapi::um::dwrite::{DWRITE_GLYPH_RUN, DWRITE_TEXTURE_ALIASED_1x1, DWRITE_TEXTURE_TYPE};
 use winapi::um::dwrite::DWRITE_TEXTURE_CLEARTYPE_3x1;
 use winapi::shared::windef::RECT;
 use winapi::um::dwrite::IDWriteGlyphRunAnalysis;
+use winapi::um::winnt::HRESULT;
 use std::mem;
 use super::DWriteFactory;
 
 pub struct GlyphRunAnalysis {
     native: UnsafeCell<ComPtr<IDWriteGlyphRunAnalysis>>,
 }
 
 impl GlyphRunAnalysis {
     pub fn create(glyph_run: &DWRITE_GLYPH_RUN,
                   pixels_per_dip: f32,
                   transform: Option<DWRITE_MATRIX>,
                   rendering_mode: DWRITE_RENDERING_MODE,
                   measuring_mode: DWRITE_MEASURING_MODE,
                   baseline_x: f32,
-                  baseline_y: f32) -> GlyphRunAnalysis
+                  baseline_y: f32) -> Result<GlyphRunAnalysis, HRESULT>
     {
         unsafe {
             let mut native: ComPtr<IDWriteGlyphRunAnalysis> = ComPtr::new();
             let hr = (*DWriteFactory()).CreateGlyphRunAnalysis(glyph_run as *const DWRITE_GLYPH_RUN,
                                                                pixels_per_dip,
                                                                transform.as_ref().map(|x| x as *const _).unwrap_or(ptr::null()),
                                                                rendering_mode, measuring_mode,
                                                                baseline_x, baseline_y,
                                                                native.getter_addrefs());
-            assert!(hr == 0);
-            GlyphRunAnalysis::take(native)
+            if hr != 0 {
+                Err(hr)
+            } else {
+                Ok(GlyphRunAnalysis::take(native))
+            }
         }
     }
 
     pub fn take(native: ComPtr<IDWriteGlyphRunAnalysis>) -> GlyphRunAnalysis {
         GlyphRunAnalysis {
             native: UnsafeCell::new(native),
         }
     }
 
-    pub fn get_alpha_texture_bounds(&self, texture_type: DWRITE_TEXTURE_TYPE) -> RECT {
+    pub fn get_alpha_texture_bounds(&self, texture_type: DWRITE_TEXTURE_TYPE) -> Result<RECT, HRESULT> {
         unsafe {
             let mut rect: RECT = mem::zeroed();
             rect.left = 1234;
             rect.top = 1234;
             let hr = (*self.native.get()).GetAlphaTextureBounds(texture_type, &mut rect);
-            assert!(hr == 0);
-            rect
+            if hr != 0 {
+                Err(hr)
+            } else {
+                Ok(rect)
+            }
         }
     }
 
-    pub fn create_alpha_texture(&self, texture_type: DWRITE_TEXTURE_TYPE, rect: RECT) -> Vec<u8> {
+    pub fn create_alpha_texture(&self, texture_type: DWRITE_TEXTURE_TYPE, rect: RECT) -> Result<Vec<u8>, HRESULT> {
         unsafe {
             let rect_pixels = (rect.right - rect.left) * (rect.bottom - rect.top);
             let rect_bytes = rect_pixels * match texture_type {
                 DWRITE_TEXTURE_ALIASED_1x1 => 1,
                 DWRITE_TEXTURE_CLEARTYPE_3x1 => 3,
                 _ => panic!("bad texture type specified"),
             };
 
             let mut out_bytes: Vec<u8> = vec![0; rect_bytes as usize];
             let hr = (*self.native.get()).CreateAlphaTexture(texture_type, &rect, out_bytes.as_mut_ptr(), out_bytes.len() as u32);
-            assert!(hr == 0);
-            out_bytes
+            if hr != 0 {
+                Err(hr)
+            } else {
+                Ok(out_bytes)
+            }
         }
     }
 }
--- a/third_party/rust/dwrote/src/lib.rs
+++ b/third_party/rust/dwrote/src/lib.rs
@@ -1,31 +1,34 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #![allow(non_upper_case_globals)]
 
-#[macro_use]
+#[cfg_attr(feature = "serde_serialization", macro_use)]
+#[cfg(feature = "serde_serialization")]
 extern crate serde_derive;
+#[cfg(feature = "serde_serialization")]
+extern crate serde;
 
 #[macro_use]
 extern crate lazy_static;
 #[macro_use(DEFINE_GUID)]
 extern crate winapi;
 extern crate libc;
-extern crate serde;
 
 include!("types.rs");
 
 use winapi::Interface;
 use winapi::um::dwrite::DWRITE_FACTORY_TYPE_SHARED;
 use winapi::um::dwrite::IDWriteFactory;
 use winapi::um::dwrite::IDWriteRenderingParams;
-use winapi::um::winnt::{HRESULT, LPCSTR};
+pub use winapi::um::winnt::HRESULT;
+use winapi::um::winnt::LPCSTR;
 use winapi::shared::guiddef::REFIID;
 use winapi::um::unknwnbase::IUnknown;
 use winapi::um::dwrite::DWRITE_FACTORY_TYPE;
 use std::ffi::CString;
 
 use comptr::ComPtr;
 use winapi::shared::winerror::S_OK;
 
--- a/third_party/rust/dwrote/src/types.rs
+++ b/third_party/rust/dwrote/src/types.rs
@@ -2,17 +2,18 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* this is include!()'d in lib.rs */
 use std::mem;
 use winapi::um::dwrite::{DWRITE_FONT_STYLE, DWRITE_FONT_WEIGHT, DWRITE_FONT_STRETCH};
 
 // mirrors DWRITE_FONT_WEIGHT
-#[derive(Deserialize, Serialize, PartialEq, Debug, Clone, Copy)]
+#[cfg_attr(feature = "serde_serialization", derive(Deserialize, Serialize))]
+#[derive(PartialEq, Debug, Clone, Copy)]
 pub enum FontWeight {
     Thin,
     ExtraLight,
     Light,
     SemiLight,
     Regular,
     Medium,
     SemiBold,
@@ -58,17 +59,18 @@ impl FontWeight {
                 950 => FontWeight::ExtraBlack,
                 _ => FontWeight::Unknown(v)
             }
     }
 }
 
 // mirrors DWRITE_FONT_STRETCH
 #[repr(u32)]
-#[derive(Deserialize, Serialize, PartialEq, Debug, Clone, Copy)]
+#[cfg_attr(feature = "serde_serialization", derive(Deserialize, Serialize))]
+#[derive(PartialEq, Debug, Clone, Copy)]
 pub enum FontStretch {
     Undefined = 0,
     UltraCondensed = 1,
     ExtraCondensed = 2,
     Condensed = 3,
     SemiCondensed = 4,
     Normal = 5,
     SemiExpanded = 6,
@@ -82,17 +84,18 @@ impl FontStretch {
         unsafe { mem::transmute::<FontStretch, DWRITE_FONT_STRETCH>(*self) }
     }
     pub fn to_u32(&self) -> u32 { unsafe { mem::transmute::<FontStretch, u32>(*self) } }
     pub fn from_u32(v: u32) -> FontStretch { unsafe { mem::transmute::<u32, FontStretch>(v) } }
 }
 
 // mirrors DWRITE_FONT_STYLE
 #[repr(u32)]
-#[derive(Deserialize, Serialize, PartialEq, Debug, Clone, Copy)]
+#[cfg_attr(feature = "serde_serialization", derive(Deserialize, Serialize))]
+#[derive(PartialEq, Debug, Clone, Copy)]
 pub enum FontStyle {
     Normal = 0,
     Oblique = 1,
     Italic = 2,
 }
 
 impl FontStyle {
     fn t(&self) -> DWRITE_FONT_STYLE {
@@ -108,15 +111,16 @@ impl FontStyle {
 pub enum FontSimulations {
     None = winapi::um::dwrite::DWRITE_FONT_SIMULATIONS_NONE,
     Bold = winapi::um::dwrite::DWRITE_FONT_SIMULATIONS_BOLD,
     Oblique = winapi::um::dwrite::DWRITE_FONT_SIMULATIONS_OBLIQUE,
     BoldOblique = winapi::um::dwrite::DWRITE_FONT_SIMULATIONS_BOLD |
         winapi::um::dwrite::DWRITE_FONT_SIMULATIONS_OBLIQUE,
 }
 
-#[derive(Deserialize, Serialize, PartialEq, Debug, Clone)]
+#[cfg_attr(feature = "serde_serialization", derive(Deserialize, Serialize))]
+#[derive(PartialEq, Debug, Clone)]
 pub struct FontDescriptor {
     pub family_name: String,
     pub weight: FontWeight,
     pub stretch: FontStretch,
     pub style: FontStyle,
 }