Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/loaders/directwrite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -203,6 +205,13 @@ impl Font {
}
}

pub fn is_colored(&self) -> bool {
unsafe {
let font_face = self.dwrite_font_face.as_ptr().cast::<IDWriteFontFace2>();
(*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<P: AsRef<Path>>(path: P) -> Result<FileType, FontLoadingError> {
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions src/loaders/freetype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down
Loading