From 4448aa8ff0c7cff6f4755155290912d5c4de61cc Mon Sep 17 00:00:00 2001 From: Aloke Desai Date: Thu, 26 Dec 2024 13:32:04 -0500 Subject: [PATCH 1/3] Default to natural symmetric rendering for the directwrite backend --- src/loaders/directwrite.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/loaders/directwrite.rs b/src/loaders/directwrite.rs index 7ecb98a..c3c95d1 100644 --- a/src/loaders/directwrite.rs +++ b/src/loaders/directwrite.rs @@ -25,7 +25,7 @@ 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; @@ -600,9 +600,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, From 05c2621a7756eb365eaaeb636de1b6bb9ced7914 Mon Sep 17 00:00:00 2001 From: Aloke Desai Date: Thu, 26 Dec 2024 20:58:24 -0500 Subject: [PATCH 2/3] Add is_colored function --- src/loaders/directwrite.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/loaders/directwrite.rs b/src/loaders/directwrite.rs index c3c95d1..817ba4b 100644 --- a/src/loaders/directwrite.rs +++ b/src/loaders/directwrite.rs @@ -30,6 +30,8 @@ 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 { From 8579b562515b65b07547bcc71be33b584723b009 Mon Sep 17 00:00:00 2001 From: Aloke Desai Date: Thu, 26 Dec 2024 21:23:59 -0500 Subject: [PATCH 3/3] Add is_colored on linux --- src/loaders/freetype.rs | 6 ++++++ 1 file changed, 6 insertions(+) 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. ///