diff --git a/src/loaders/directwrite.rs b/src/loaders/directwrite.rs index 7ecb98a..817ba4b 100644 --- a/src/loaders/directwrite.rs +++ b/src/loaders/directwrite.rs @@ -25,11 +25,13 @@ use dwrote::InformationalStringId as DWriteInformationalStringId; use dwrote::OutlineBuilder as DWriteOutlineBuilder; use dwrote::{DWRITE_TEXTURE_ALIASED_1x1, DWRITE_TEXTURE_CLEARTYPE_3x1}; use dwrote::{DWRITE_GLYPH_RUN, DWRITE_MEASURING_MODE_NATURAL}; -use dwrote::{DWRITE_RENDERING_MODE_ALIASED, DWRITE_RENDERING_MODE_NATURAL}; +use dwrote::{DWRITE_RENDERING_MODE_ALIASED, DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC}; use pathfinder_geometry::line_segment::LineSegment2F; use pathfinder_geometry::rect::{RectF, RectI}; use pathfinder_geometry::transform2d::Transform2F; use pathfinder_geometry::vector::{Vector2F, Vector2I}; +use winapi::shared::minwindef::TRUE; +use winapi::um::dwrite_2::IDWriteFontFace2; use std::borrow::Cow; use std::ffi::OsString; use std::fmt::{self, Debug, Formatter}; @@ -203,6 +205,13 @@ impl Font { } } + pub fn is_colored(&self) -> bool { + unsafe { + let font_face = self.dwrite_font_face.as_ptr().cast::(); + (*font_face).IsColorFont() == TRUE + } + } + /// Determines whether a path points to a supported font, and, if so, what type of font it is. #[inline] pub fn analyze_path>(path: P) -> Result { @@ -600,9 +609,10 @@ impl Font { let rendering_mode = match rasterization_options.antialiasing_strategy { AntialiasingStrategy::Bilevel => DWRITE_RENDERING_MODE_ALIASED, AntialiasingStrategy::GrayscaleAa | AntialiasingStrategy::SubpixelAa => { - DWRITE_RENDERING_MODE_NATURAL + DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC } }; + Ok(DWriteGlyphRunAnalysis::create( &glyph_run, diff --git a/src/loaders/freetype.rs b/src/loaders/freetype.rs index a2af931..8d40758 100644 --- a/src/loaders/freetype.rs +++ b/src/loaders/freetype.rs @@ -418,6 +418,12 @@ impl Font { } None } + + pub fn is_colored(&self) -> bool { + // TODO: Determine the correct strategy for reading colored glyphs + // on Linux + false + } /// Returns the number of glyphs in the font. ///