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
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ dwrote = { version = "0.9", default-features = false }
version = "0.3"
features = ["minwindef", "winbase"]

[target.'cfg(target_os = "macos")'.dependencies]
[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies]
core-foundation = "0.6"
core-graphics = "^0.17.1"
core-text = "13.2"

[target.'cfg(not(any(target_family = "windows", target_os = "macos")))'.dependencies]
[target.'cfg(not(any(target_family = "windows", target_os = "macos", target_os = "ios")))'.dependencies]
freetype = "^0.4.1"

[target.'cfg(not(any(target_family = "windows", target_os = "macos", target_arch = "wasm32")))'.dependencies]
[target.'cfg(not(any(target_family = "windows", target_os = "macos", target_os = "ios", target_arch = "wasm32")))'.dependencies]
servo-fontconfig = "0.4"

[target.'cfg(not(any(target_arch = "wasm32", target_family = "windows", target_os = "android")))'.dependencies]
Expand Down
11 changes: 7 additions & 4 deletions src/loaders/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,29 @@

//! The different system services that can load and rasterize fonts.

#[cfg(all(target_os = "macos", not(feature = "loader-freetype-default")))]
#[cfg(all(
any(target_os = "macos", target_os = "ios"),
not(feature = "loader-freetype-default")
))]
pub use crate::loaders::core_text as default;

#[cfg(all(target_family = "windows", not(feature = "loader-freetype-default")))]
pub use crate::loaders::directwrite as default;

#[cfg(any(
not(any(target_os = "macos", target_family = "windows")),
not(any(target_os = "macos", target_os = "ios", target_family = "windows")),
feature = "loader-freetype-default"
))]
pub use crate::loaders::freetype as default;

#[cfg(all(target_os = "macos"))]
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub mod core_text;

#[cfg(all(target_family = "windows"))]
pub mod directwrite;

#[cfg(any(
not(any(target_os = "macos", target_family = "windows")),
not(any(target_os = "macos", target_os = "ios", target_family = "windows")),
feature = "loader-freetype"
))]
pub mod freetype;
26 changes: 15 additions & 11 deletions src/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@ use crate::handle::Handle;
use crate::matching;
use crate::properties::Properties;

#[cfg(all(target_os = "macos", not(feature = "source-fontconfig-default")))]
#[cfg(all(
any(target_os = "macos", target_os = "ios"),
not(feature = "loader-freetype-default")
))]
pub use crate::sources::core_text::CoreTextSource as SystemSource;
#[cfg(all(target_family = "windows", not(feature = "source-fontconfig-default")))]
pub use crate::sources::directwrite::DirectWriteSource as SystemSource;
#[cfg(any(
not(any(
target_os = "android",
target_os = "macos",
target_os = "ios",
target_family = "windows",
target_arch = "wasm32"
)),
Expand All @@ -37,28 +41,28 @@ pub use crate::sources::fontconfig::FontconfigSource as SystemSource;
pub use crate::sources::fs::FsSource as SystemSource;

// FIXME(pcwalton): These could expand to multiple fonts, and they could be language-specific.
#[cfg(any(target_family = "windows", target_os = "macos"))]
#[cfg(any(target_family = "windows", target_os = "macos", target_os = "ios"))]
const DEFAULT_FONT_FAMILY_SERIF: &'static str = "Times New Roman";
#[cfg(any(target_family = "windows", target_os = "macos"))]
#[cfg(any(target_family = "windows", target_os = "macos", target_os = "ios"))]
const DEFAULT_FONT_FAMILY_SANS_SERIF: &'static str = "Arial";
#[cfg(any(target_family = "windows", target_os = "macos"))]
#[cfg(any(target_family = "windows", target_os = "macos", target_os = "ios"))]
const DEFAULT_FONT_FAMILY_MONOSPACE: &'static str = "Courier New";
#[cfg(any(target_family = "windows", target_os = "macos"))]
#[cfg(any(target_family = "windows", target_os = "macos", target_os = "ios"))]
const DEFAULT_FONT_FAMILY_CURSIVE: &'static str = "Comic Sans MS";
#[cfg(target_family = "windows")]
const DEFAULT_FONT_FAMILY_FANTASY: &'static str = "Impact";
#[cfg(target_os = "macos")]
#[cfg(any(target_os = "macos", target_os = "ios"))]
const DEFAULT_FONT_FAMILY_FANTASY: &'static str = "Papyrus";

#[cfg(not(any(target_family = "windows", target_os = "macos")))]
#[cfg(not(any(target_family = "windows", target_os = "macos", target_os = "ios")))]
const DEFAULT_FONT_FAMILY_SERIF: &'static str = "serif";
#[cfg(not(any(target_family = "windows", target_os = "macos")))]
#[cfg(not(any(target_family = "windows", target_os = "macos", target_os = "ios")))]
const DEFAULT_FONT_FAMILY_SANS_SERIF: &'static str = "sans-serif";
#[cfg(not(any(target_family = "windows", target_os = "macos")))]
#[cfg(not(any(target_family = "windows", target_os = "macos", target_os = "ios")))]
const DEFAULT_FONT_FAMILY_MONOSPACE: &'static str = "monospace";
#[cfg(not(any(target_family = "windows", target_os = "macos")))]
#[cfg(not(any(target_family = "windows", target_os = "macos", target_os = "ios")))]
const DEFAULT_FONT_FAMILY_CURSIVE: &'static str = "cursive";
#[cfg(not(any(target_family = "windows", target_os = "macos")))]
#[cfg(not(any(target_family = "windows", target_os = "macos", target_os = "ios")))]
const DEFAULT_FONT_FAMILY_FANTASY: &'static str = "fantasy";

/// A database of installed fonts that can be queried.
Expand Down
9 changes: 7 additions & 2 deletions src/sources/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,19 @@
//! installed on the system. The remaining databases (`fs`, `mem`, and `multi`) allow `font-kit` to
//! query fonts not installed on the system.

#[cfg(target_os = "macos")]
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub mod core_text;

#[cfg(target_family = "windows")]
pub mod directwrite;

#[cfg(any(
not(any(target_os = "macos", target_family = "windows", target_arch = "wasm32")),
not(any(
target_os = "macos",
target_os = "ios",
target_family = "windows",
target_arch = "wasm32"
)),
feature = "source-fontconfig"
))]
pub mod fontconfig;
Expand Down
20 changes: 10 additions & 10 deletions src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ pub fn get_glyph_outline() {
assert_close!(events.next());
}

#[cfg(not(any(target_family = "windows", target_os = "macos")))]
#[cfg(not(any(target_family = "windows", target_os = "macos", target_os = "ios")))]
#[test]
pub fn get_glyph_outline() {
let mut path_builder = Path::builder();
Expand Down Expand Up @@ -196,7 +196,7 @@ pub fn get_glyph_outline() {

// Right now, only FreeType can do hinting.
#[cfg(all(
not(any(target_os = "macos", target_family = "windows")),
not(any(target_os = "macos", target_os = "ios", target_family = "windows")),
feature = "loader-freetype-default"
))]
#[test]
Expand Down Expand Up @@ -228,7 +228,7 @@ pub fn get_vertically_hinted_glyph_outline() {
assert_close!(events.next());
}

#[cfg(not(any(target_os = "macos", target_family = "windows")))]
#[cfg(not(any(target_os = "macos", target_os = "ios", target_family = "windows")))]
#[test]
pub fn get_vertically_hinted_glyph_outline() {
let mut path_builder = Path::builder();
Expand Down Expand Up @@ -263,7 +263,7 @@ pub fn get_vertically_hinted_glyph_outline() {

// Right now, only FreeType can do hinting.
#[cfg(all(
not(any(target_os = "macos", target_family = "windows")),
not(any(target_os = "macos", target_os = "ios", target_family = "windows")),
feature = "loader-freetype-default"
))]
#[test]
Expand Down Expand Up @@ -298,7 +298,7 @@ pub fn get_fully_hinted_glyph_outline() {
assert_close!(events.next());
}

#[cfg(not(any(target_os = "macos", target_family = "windows")))]
#[cfg(not(any(target_os = "macos", target_os = "ios", target_family = "windows")))]
#[test]
pub fn get_fully_hinted_glyph_outline() {
let mut path_builder = Path::builder();
Expand Down Expand Up @@ -345,7 +345,7 @@ pub fn get_empty_glyph_outline() {
assert_eq!(events.next(), None);
}

#[cfg(any(target_family = "windows", target_os = "macos"))]
#[cfg(any(target_family = "windows", target_os = "macos", target_os = "ios"))]
#[test]
pub fn get_glyph_typographic_bounds() {
let font = SystemSource::new()
Expand All @@ -363,7 +363,7 @@ pub fn get_glyph_typographic_bounds() {
);
}

#[cfg(not(any(target_family = "windows", target_os = "macos")))]
#[cfg(not(any(target_family = "windows", target_os = "macos", target_os = "ios")))]
#[test]
pub fn get_glyph_typographic_bounds() {
let font = SystemSource::new()
Expand Down Expand Up @@ -407,7 +407,7 @@ pub fn get_glyph_advance_and_origin() {
assert_eq!(font.origin(glyph), Ok(Point2D::zero()));
}

#[cfg(not(any(target_family = "windows", target_os = "macos")))]
#[cfg(not(any(target_family = "windows", target_os = "macos", target_os = "ios")))]
#[test]
pub fn get_glyph_advance_and_origin() {
let font = SystemSource::new()
Expand Down Expand Up @@ -439,7 +439,7 @@ pub fn get_font_metrics() {
assert_eq!(metrics.x_height, 1062.0);
}

#[cfg(not(any(target_family = "windows", target_os = "macos")))]
#[cfg(not(any(target_family = "windows", target_os = "macos", target_os = "ios")))]
#[test]
pub fn get_font_metrics() {
let font = SystemSource::new()
Expand Down Expand Up @@ -564,7 +564,7 @@ pub fn rasterize_glyph_bilevel() {
}

#[cfg(any(
not(any(target_os = "macos", target_family = "windows")),
not(any(target_os = "macos", target_os = "ios", target_family = "windows")),
feature = "loader-freetype-default"
))]
#[test]
Expand Down