diff --git a/Cargo.lock b/Cargo.lock index a2375c9155d..f2490dcaa79 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -634,7 +634,7 @@ dependencies = [ "euclid", "fnv", "font-kit", - "gfx", + "fonts", "half", "ipc-channel", "log", @@ -866,8 +866,8 @@ dependencies = [ "embedder_traits", "euclid", "fnv", - "gfx", - "gfx_traits", + "fonts", + "fonts_traits", "gleam", "image", "ipc-channel", @@ -899,7 +899,7 @@ dependencies = [ "crossbeam-channel", "embedder_traits", "euclid", - "gfx_traits", + "fonts_traits", "ipc-channel", "keyboard-types", "log", @@ -935,9 +935,9 @@ dependencies = [ "devtools_traits", "embedder_traits", "euclid", + "fonts", + "fonts_traits", "gaol", - "gfx", - "gfx_traits", "http", "ipc-channel", "keyboard-types", @@ -1782,6 +1782,68 @@ dependencies = [ "yeslogic-fontconfig-sys", ] +[[package]] +name = "fonts" +version = "0.0.1" +dependencies = [ + "app_units", + "atomic_refcell", + "base", + "bitflags 2.5.0", + "byteorder", + "core-foundation", + "core-graphics", + "core-text", + "crossbeam-channel", + "cssparser", + "dwrote", + "euclid", + "fnv", + "fonts_traits", + "fontsan", + "freetype-sys", + "harfbuzz-sys", + "ipc-channel", + "lazy_static", + "libc", + "log", + "malloc_size_of", + "malloc_size_of_derive", + "net_traits", + "parking_lot", + "range", + "serde", + "servo_allocator", + "servo_arc", + "servo_atoms", + "servo_url", + "smallvec", + "style", + "surfman", + "truetype", + "unicode-bidi", + "unicode-properties", + "unicode-script", + "url", + "webrender_api", + "webrender_traits", + "xi-unicode", + "xml-rs", + "yeslogic-fontconfig-sys", +] + +[[package]] +name = "fonts_traits" +version = "0.0.1" +dependencies = [ + "ipc-channel", + "malloc_size_of", + "malloc_size_of_derive", + "range", + "serde", + "webrender_api", +] + [[package]] name = "fontsan" version = "0.5.2" @@ -2030,68 +2092,6 @@ dependencies = [ "wasi 0.11.0+wasi-snapshot-preview1", ] -[[package]] -name = "gfx" -version = "0.0.1" -dependencies = [ - "app_units", - "atomic_refcell", - "base", - "bitflags 2.5.0", - "byteorder", - "core-foundation", - "core-graphics", - "core-text", - "crossbeam-channel", - "cssparser", - "dwrote", - "euclid", - "fnv", - "fontsan", - "freetype-sys", - "gfx_traits", - "harfbuzz-sys", - "ipc-channel", - "lazy_static", - "libc", - "log", - "malloc_size_of", - "malloc_size_of_derive", - "net_traits", - "parking_lot", - "range", - "serde", - "servo_allocator", - "servo_arc", - "servo_atoms", - "servo_url", - "smallvec", - "style", - "surfman", - "truetype", - "unicode-bidi", - "unicode-properties", - "unicode-script", - "url", - "webrender_api", - "webrender_traits", - "xi-unicode", - "xml-rs", - "yeslogic-fontconfig-sys", -] - -[[package]] -name = "gfx_traits" -version = "0.0.1" -dependencies = [ - "ipc-channel", - "malloc_size_of", - "malloc_size_of_derive", - "range", - "serde", - "webrender_api", -] - [[package]] name = "gif" version = "0.13.1" @@ -3307,8 +3307,8 @@ dependencies = [ "embedder_traits", "euclid", "fnv", - "gfx", - "gfx_traits", + "fonts", + "fonts_traits", "html5ever", "ipc-channel", "lazy_static", @@ -3355,9 +3355,9 @@ dependencies = [ "embedder_traits", "euclid", "fnv", + "fonts", + "fonts_traits", "fxhash", - "gfx", - "gfx_traits", "html5ever", "icu_segmenter", "ipc-channel", @@ -3397,9 +3397,9 @@ dependencies = [ "embedder_traits", "euclid", "fnv", + "fonts", + "fonts_traits", "fxhash", - "gfx", - "gfx_traits", "histogram", "ipc-channel", "layout_2013", @@ -3438,9 +3438,9 @@ dependencies = [ "embedder_traits", "euclid", "fnv", + "fonts", + "fonts_traits", "fxhash", - "gfx", - "gfx_traits", "ipc-channel", "layout_2020", "lazy_static", @@ -3593,9 +3593,9 @@ dependencies = [ "embedder_traits", "env_logger 0.10.2", "euclid", + "fonts", + "fonts_traits", "gaol", - "gfx", - "gfx_traits", "gleam", "gstreamer", "ipc-channel", @@ -3866,7 +3866,7 @@ name = "metrics" version = "0.0.1" dependencies = [ "base", - "gfx_traits", + "fonts_traits", "ipc-channel", "log", "malloc_size_of", @@ -3882,7 +3882,7 @@ name = "metrics_tests" version = "0.0.1" dependencies = [ "base", - "gfx_traits", + "fonts_traits", "ipc-channel", "metrics", "profile_traits", @@ -5138,9 +5138,9 @@ dependencies = [ "enum-iterator", "euclid", "fnv", + "fonts", + "fonts_traits", "fxhash", - "gfx", - "gfx_traits", "headers", "html5ever", "http", @@ -5220,8 +5220,8 @@ dependencies = [ "canvas_traits", "crossbeam-channel", "euclid", - "gfx", - "gfx_traits", + "fonts", + "fonts_traits", "html5ever", "ipc-channel", "libc", @@ -5268,7 +5268,7 @@ dependencies = [ "devtools_traits", "embedder_traits", "euclid", - "gfx_traits", + "fonts_traits", "http", "hyper_serde", "ipc-channel", diff --git a/Cargo.toml b/Cargo.toml index c7b4c3386b2..208afc47d00 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ fnv = "1.0" freetype-sys = "0.20" fxhash = "0.2" getopts = "0.2.11" -gfx_traits = { path = "components/shared/gfx" } +fonts_traits = { path = "components/shared/fonts" } gleam = "0.15" glib = "0.19" gstreamer = { version = "0.22", features = ["v1_18"] } diff --git a/components/canvas/Cargo.toml b/components/canvas/Cargo.toml index a0d2e41ffb5..c54b814323c 100644 --- a/components/canvas/Cargo.toml +++ b/components/canvas/Cargo.toml @@ -24,7 +24,7 @@ cssparser = { workspace = true } euclid = { workspace = true } font-kit = { version = "0.13" } fnv = { workspace = true } -gfx = { path = "../gfx" } +fonts = { path = "../fonts" } half = "2" ipc-channel = { workspace = true } log = { workspace = true } diff --git a/components/canvas/canvas_data.rs b/components/canvas/canvas_data.rs index 5396eaddea6..b7d878ef35f 100644 --- a/components/canvas/canvas_data.rs +++ b/components/canvas/canvas_data.rs @@ -13,9 +13,7 @@ use font_kit::font::Font; use font_kit::metrics::Metrics; use font_kit::properties::{Properties, Stretch, Style, Weight}; use font_kit::source::SystemSource; -use gfx::font_cache_thread::FontCacheThread; -use gfx::font_context::FontContext; -use gfx::font_template::FontTemplateRefMethods; +use fonts::{FontCacheThread, FontContext, FontTemplateRefMethods}; use ipc_channel::ipc::{IpcSender, IpcSharedMemory}; use log::{debug, error, warn}; use num_traits::ToPrimitive; diff --git a/components/canvas/canvas_paint_thread.rs b/components/canvas/canvas_paint_thread.rs index 2ace98e9f1f..d4d2bb877c7 100644 --- a/components/canvas/canvas_paint_thread.rs +++ b/components/canvas/canvas_paint_thread.rs @@ -11,8 +11,7 @@ use canvas_traits::canvas::*; use canvas_traits::ConstellationCanvasMsg; use crossbeam_channel::{select, unbounded, Sender}; use euclid::default::Size2D; -use gfx::font_cache_thread::FontCacheThread; -use gfx::font_context::FontContext; +use fonts::{FontCacheThread, FontContext}; use ipc_channel::ipc::{self, IpcSender}; use ipc_channel::router::ROUTER; use log::warn; diff --git a/components/compositing/Cargo.toml b/components/compositing/Cargo.toml index c5004e9b26d..52e2932104c 100644 --- a/components/compositing/Cargo.toml +++ b/components/compositing/Cargo.toml @@ -23,8 +23,8 @@ crossbeam-channel = { workspace = true } embedder_traits = { workspace = true } euclid = { workspace = true } fnv = { workspace = true } -gfx = { path = "../gfx" } -gfx_traits = { workspace = true } +fonts = { path = "../fonts" } +fonts_traits = { workspace = true } gleam = { workspace = true } image = { workspace = true } ipc-channel = { workspace = true } diff --git a/components/constellation/Cargo.toml b/components/constellation/Cargo.toml index edcf2293844..4d221d95f28 100644 --- a/components/constellation/Cargo.toml +++ b/components/constellation/Cargo.toml @@ -26,8 +26,8 @@ crossbeam-channel = { workspace = true } devtools_traits = { workspace = true } embedder_traits = { workspace = true } euclid = { workspace = true } -gfx = { path = "../gfx" } -gfx_traits = { workspace = true } +fonts = { path = "../fonts" } +fonts_traits = { workspace = true } http = { workspace = true } ipc-channel = { workspace = true } keyboard-types = { workspace = true } diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs index 36e6a190c5b..1889b9df250 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -121,7 +121,7 @@ use embedder_traits::{ }; use euclid::default::Size2D as UntypedSize2D; use euclid::Size2D; -use gfx::font_cache_thread::FontCacheThread; +use fonts::FontCacheThread; use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; use ipc_channel::router::ROUTER; use ipc_channel::Error as IpcError; diff --git a/components/constellation/pipeline.rs b/components/constellation/pipeline.rs index 9547aa8a354..b79609dc3a8 100644 --- a/components/constellation/pipeline.rs +++ b/components/constellation/pipeline.rs @@ -22,7 +22,7 @@ use compositing_traits::{CompositionPipeline, CompositorMsg, CompositorProxy}; use crossbeam_channel::{unbounded, Sender}; use devtools_traits::{DevtoolsControlMsg, ScriptToDevtoolsControlMsg}; use embedder_traits::EventLoopWaker; -use gfx::font_cache_thread::FontCacheThread; +use fonts::FontCacheThread; use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; use ipc_channel::router::ROUTER; use ipc_channel::Error; diff --git a/components/gfx/Cargo.toml b/components/fonts/Cargo.toml similarity index 97% rename from components/gfx/Cargo.toml rename to components/fonts/Cargo.toml index 879fcbb29be..e8a165c0524 100644 --- a/components/gfx/Cargo.toml +++ b/components/fonts/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "gfx" +name = "fonts" version.workspace = true authors.workspace = true license.workspace = true @@ -7,7 +7,7 @@ edition.workspace = true publish.workspace = true [lib] -name = "gfx" +name = "fonts" path = "lib.rs" test = false doctest = false @@ -22,7 +22,7 @@ crossbeam-channel = { workspace = true } euclid = { workspace = true } fnv = { workspace = true } fontsan = { git = "https://github.com/servo/fontsan" } -gfx_traits = { workspace = true } +fonts_traits = { workspace = true } harfbuzz-sys = "0.6.1" ipc-channel = { workspace = true } lazy_static = { workspace = true } diff --git a/components/gfx/font.rs b/components/fonts/font.rs similarity index 99% rename from components/gfx/font.rs rename to components/fonts/font.rs index ef93af1170e..14f5af4197e 100644 --- a/components/gfx/font.rs +++ b/components/fonts/font.rs @@ -30,9 +30,10 @@ use crate::font_context::FontContext; use crate::font_template::{FontTemplateDescriptor, FontTemplateRef, FontTemplateRefMethods}; use crate::platform::font::{FontTable, PlatformFont}; pub use crate::platform::font_list::fallback_font_families; -use crate::text::glyph::{ByteIndex, GlyphData, GlyphId, GlyphStore}; -use crate::text::shaping::ShaperMethods; -use crate::text::{EmojiPresentationPreference, FallbackFontSelectionOptions, Shaper}; +use crate::{ + ByteIndex, EmojiPresentationPreference, FallbackFontSelectionOptions, GlyphData, GlyphId, + GlyphStore, Shaper, +}; #[macro_export] macro_rules! ot_tag { diff --git a/components/gfx/font_cache_thread.rs b/components/fonts/font_cache_thread.rs similarity index 100% rename from components/gfx/font_cache_thread.rs rename to components/fonts/font_cache_thread.rs diff --git a/components/gfx/font_context.rs b/components/fonts/font_context.rs similarity index 99% rename from components/gfx/font_context.rs rename to components/fonts/font_context.rs index 124a21f6e37..a28621469d6 100644 --- a/components/gfx/font_context.rs +++ b/components/fonts/font_context.rs @@ -11,7 +11,7 @@ use std::sync::Arc; use app_units::Au; use crossbeam_channel::unbounded; use fnv::FnvHasher; -use gfx_traits::WebFontLoadFinishedCallback; +use fonts_traits::WebFontLoadFinishedCallback; use log::{debug, trace}; use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; use malloc_size_of_derive::MallocSizeOf; diff --git a/components/gfx/font_store.rs b/components/fonts/font_store.rs similarity index 100% rename from components/gfx/font_store.rs rename to components/fonts/font_store.rs diff --git a/components/gfx/font_template.rs b/components/fonts/font_template.rs similarity index 100% rename from components/gfx/font_template.rs rename to components/fonts/font_template.rs diff --git a/components/gfx/text/glyph.rs b/components/fonts/glyph.rs similarity index 99% rename from components/gfx/text/glyph.rs rename to components/fonts/glyph.rs index fd608e7ebaa..420d43b0774 100644 --- a/components/gfx/text/glyph.rs +++ b/components/fonts/glyph.rs @@ -9,7 +9,7 @@ use std::{fmt, mem, u16}; use app_units::Au; use euclid::default::Point2D; -pub use gfx_traits::ByteIndex; +pub use fonts_traits::ByteIndex; use log::debug; use malloc_size_of_derive::MallocSizeOf; use range::{self, EachIndex, Range, RangeIndex}; diff --git a/components/gfx/text/mod.rs b/components/fonts/lib.rs similarity index 81% rename from components/gfx/text/mod.rs rename to components/fonts/lib.rs index 9a44f743c7a..305db5e53ef 100644 --- a/components/gfx/text/mod.rs +++ b/components/fonts/lib.rs @@ -2,14 +2,27 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +#![deny(unsafe_code)] + +mod font; +mod font_cache_thread; +mod font_context; +mod font_store; +mod font_template; +mod glyph; +#[allow(unsafe_code)] +pub mod platform; +mod shaper; + +pub use font::*; +pub use font_cache_thread::*; +pub use font_context::*; +pub use font_store::*; +pub use font_template::*; +pub use glyph::*; +pub use shaper::*; use unicode_properties::{emoji, EmojiStatus, UnicodeEmoji}; -pub use crate::text::shaping::Shaper; - -pub mod glyph; -pub mod shaping; -pub mod util; - /// Whether or not font fallback selection prefers the emoji or text representation /// of a character. If `None` then either presentation is acceptable. #[derive(Clone, Copy, Debug, PartialEq)] @@ -66,3 +79,11 @@ impl FallbackFontSelectionOptions { } } } + +pub(crate) fn float_to_fixed(before: usize, f: f64) -> i32 { + ((1i32 << before) as f64 * f) as i32 +} + +pub(crate) fn fixed_to_float(before: usize, f: i32) -> f64 { + f as f64 * 1.0f64 / ((1i32 << before) as f64) +} diff --git a/components/gfx/platform/freetype/android/font_list.rs b/components/fonts/platform/freetype/android/font_list.rs similarity index 99% rename from components/gfx/platform/freetype/android/font_list.rs rename to components/fonts/platform/freetype/android/font_list.rs index dc466690a94..3343c7c3788 100644 --- a/components/gfx/platform/freetype/android/font_list.rs +++ b/components/fonts/platform/freetype/android/font_list.rs @@ -16,8 +16,7 @@ use style::values::computed::{ use style::Atom; use super::xml::{Attribute, Node}; -use crate::font_template::{FontTemplate, FontTemplateDescriptor}; -use crate::text::FallbackFontSelectionOptions; +use crate::{FallbackFontSelectionOptions, FontTemplate, FontTemplateDescriptor}; lazy_static::lazy_static! { static ref FONT_LIST: FontList = FontList::new(); diff --git a/components/gfx/platform/freetype/android/xml.rs b/components/fonts/platform/freetype/android/xml.rs similarity index 100% rename from components/gfx/platform/freetype/android/xml.rs rename to components/fonts/platform/freetype/android/xml.rs diff --git a/components/gfx/platform/freetype/font.rs b/components/fonts/platform/freetype/font.rs similarity index 99% rename from components/gfx/platform/freetype/font.rs rename to components/fonts/platform/freetype/font.rs index 1fa1a07fc3d..f3872298133 100644 --- a/components/gfx/platform/freetype/font.rs +++ b/components/fonts/platform/freetype/font.rs @@ -31,7 +31,7 @@ use crate::font::{ }; use crate::font_cache_thread::FontIdentifier; use crate::font_template::FontTemplateDescriptor; -use crate::text::glyph::GlyphId; +use crate::glyph::GlyphId; // This constant is not present in the freetype // bindings due to bindgen not handling the way diff --git a/components/gfx/platform/freetype/font_list.rs b/components/fonts/platform/freetype/font_list.rs similarity index 99% rename from components/gfx/platform/freetype/font_list.rs rename to components/fonts/platform/freetype/font_list.rs index 73d17ccd49e..95e4b4043d2 100644 --- a/components/gfx/platform/freetype/font_list.rs +++ b/components/fonts/platform/freetype/font_list.rs @@ -35,7 +35,7 @@ use super::c_str_to_string; use crate::font::map_platform_values_to_style_values; use crate::font_template::{FontTemplate, FontTemplateDescriptor}; use crate::platform::add_noto_fallback_families; -use crate::text::{EmojiPresentationPreference, FallbackFontSelectionOptions}; +use crate::{EmojiPresentationPreference, FallbackFontSelectionOptions}; /// An identifier for a local font on systems using Freetype. #[derive(Clone, Debug, Deserialize, Eq, Hash, MallocSizeOf, PartialEq, Serialize)] diff --git a/components/gfx/platform/freetype/library_handle.rs b/components/fonts/platform/freetype/library_handle.rs similarity index 100% rename from components/gfx/platform/freetype/library_handle.rs rename to components/fonts/platform/freetype/library_handle.rs diff --git a/components/gfx/platform/freetype/ohos/font_list.rs b/components/fonts/platform/freetype/ohos/font_list.rs similarity index 98% rename from components/gfx/platform/freetype/ohos/font_list.rs rename to components/fonts/platform/freetype/ohos/font_list.rs index a1717629ad5..75eef136189 100644 --- a/components/gfx/platform/freetype/ohos/font_list.rs +++ b/components/fonts/platform/freetype/ohos/font_list.rs @@ -15,8 +15,7 @@ use style::values::computed::{ }; use style::Atom; -use crate::font_template::{FontTemplate, FontTemplateDescriptor}; -use crate::text::FallbackFontSelectionOptions; +use crate::{FallbackFontSelectionOptions, FontTemplate, FontTemplateDescriptor}; lazy_static::lazy_static! { static ref FONT_LIST: FontList = FontList::new(); diff --git a/components/gfx/platform/macos/core_text_font_cache.rs b/components/fonts/platform/macos/core_text_font_cache.rs similarity index 100% rename from components/gfx/platform/macos/core_text_font_cache.rs rename to components/fonts/platform/macos/core_text_font_cache.rs diff --git a/components/gfx/platform/macos/font.rs b/components/fonts/platform/macos/font.rs similarity index 97% rename from components/gfx/platform/macos/font.rs rename to components/fonts/platform/macos/font.rs index 0e4617a8360..437950fbf4d 100644 --- a/components/gfx/platform/macos/font.rs +++ b/components/fonts/platform/macos/font.rs @@ -22,13 +22,11 @@ use style::values::computed::font::{FontStretch, FontStyle, FontWeight}; use webrender_api::FontInstanceFlags; use super::core_text_font_cache::CoreTextFontCache; -use crate::font::{ - map_platform_values_to_style_values, FontMetrics, FontTableMethods, FontTableTag, - FractionalPixel, PlatformFontMethods, CBDT, COLR, GPOS, GSUB, KERN, SBIX, +use crate::{ + map_platform_values_to_style_values, FontIdentifier, FontMetrics, FontTableMethods, + FontTableTag, FontTemplateDescriptor, FractionalPixel, GlyphId, PlatformFontMethods, CBDT, + COLR, GPOS, GSUB, KERN, SBIX, }; -use crate::font_cache_thread::FontIdentifier; -use crate::font_template::FontTemplateDescriptor; -use crate::text::glyph::GlyphId; const KERN_PAIR_LEN: usize = 6; diff --git a/components/gfx/platform/macos/font_list.rs b/components/fonts/platform/macos/font_list.rs similarity index 98% rename from components/gfx/platform/macos/font_list.rs rename to components/fonts/platform/macos/font_list.rs index c1d9621f61e..b2176b31f42 100644 --- a/components/gfx/platform/macos/font_list.rs +++ b/components/fonts/platform/macos/font_list.rs @@ -14,10 +14,11 @@ use style::Atom; use unicode_script::Script; use webrender_api::NativeFontHandle; -use crate::font_template::{FontTemplate, FontTemplateDescriptor}; use crate::platform::add_noto_fallback_families; use crate::platform::font::CoreTextFontTraitsMapping; -use crate::text::{EmojiPresentationPreference, FallbackFontSelectionOptions}; +use crate::{ + EmojiPresentationPreference, FallbackFontSelectionOptions, FontTemplate, FontTemplateDescriptor, +}; /// An identifier for a local font on a MacOS system. These values comes from the CoreText /// CTFontCollection. Note that `path` here is required. We do not load fonts that do not diff --git a/components/gfx/platform/mod.rs b/components/fonts/platform/mod.rs similarity index 99% rename from components/gfx/platform/mod.rs rename to components/fonts/platform/mod.rs index 542c6ab0aed..6aebc107f66 100644 --- a/components/gfx/platform/mod.rs +++ b/components/fonts/platform/mod.rs @@ -14,7 +14,7 @@ pub use crate::platform::macos::{core_text_font_cache, font, font_list}; #[cfg(target_os = "windows")] pub use crate::platform::windows::{font, font_list}; #[cfg(any(target_os = "linux", target_os = "macos"))] -use crate::text::FallbackFontSelectionOptions; +use crate::FallbackFontSelectionOptions; #[cfg(any(target_os = "linux", target_os = "android"))] mod freetype { diff --git a/components/gfx/platform/windows/font.rs b/components/fonts/platform/windows/font.rs similarity index 97% rename from components/gfx/platform/windows/font.rs rename to components/fonts/platform/windows/font.rs index 4aeb04fc29f..8dd2d78bb1f 100644 --- a/components/gfx/platform/windows/font.rs +++ b/components/fonts/platform/windows/font.rs @@ -22,13 +22,10 @@ use truetype::tables::WindowsMetrics; use truetype::value::Read; use webrender_api::FontInstanceFlags; -use crate::font::{ - FontMetrics, FontTableMethods, FontTableTag, FractionalPixel, PlatformFontMethods, +use crate::{ + ot_tag, FontIdentifier, FontMetrics, FontTableMethods, FontTableTag, FontTemplateDescriptor, + FractionalPixel, GlyphId, PlatformFontMethods, }; -use crate::font_cache_thread::FontIdentifier; -use crate::font_template::FontTemplateDescriptor; -use crate::ot_tag; -use crate::text::glyph::GlyphId; // 1em = 12pt = 16px, assuming 72 points per inch and 96 px per inch fn pt_to_px(pt: f64) -> f64 { diff --git a/components/gfx/platform/windows/font_list.rs b/components/fonts/platform/windows/font_list.rs similarity index 99% rename from components/gfx/platform/windows/font_list.rs rename to components/fonts/platform/windows/font_list.rs index 9ac7011e270..31c1d631160 100644 --- a/components/gfx/platform/windows/font_list.rs +++ b/components/fonts/platform/windows/font_list.rs @@ -12,8 +12,9 @@ use serde::{Deserialize, Serialize}; use style::values::computed::{FontStyle as StyleFontStyle, FontWeight as StyleFontWeight}; use style::values::specified::font::FontStretchKeyword; -use crate::font_template::{FontTemplate, FontTemplateDescriptor}; -use crate::text::{EmojiPresentationPreference, FallbackFontSelectionOptions}; +use crate::{ + EmojiPresentationPreference, FallbackFontSelectionOptions, FontTemplate, FontTemplateDescriptor, +}; pub static SANS_SERIF_FONT_FAMILY: &str = "Arial"; diff --git a/components/gfx/text/shaping/harfbuzz.rs b/components/fonts/shaper.rs similarity index 98% rename from components/gfx/text/shaping/harfbuzz.rs rename to components/fonts/shaper.rs index ddf085054ea..72d47de28fb 100644 --- a/components/gfx/text/shaping/harfbuzz.rs +++ b/components/fonts/shaper.rs @@ -25,12 +25,11 @@ use harfbuzz_sys::{ use lazy_static::lazy_static; use log::debug; -use crate::font::{Font, FontTableMethods, FontTableTag, ShapingFlags, ShapingOptions, KERN}; -use crate::ot_tag; use crate::platform::font::FontTable; -use crate::text::glyph::{ByteIndex, GlyphData, GlyphId, GlyphStore}; -use crate::text::shaping::ShaperMethods; -use crate::text::util::{fixed_to_float, float_to_fixed}; +use crate::{ + fixed_to_float, float_to_fixed, ot_tag, ByteIndex, Font, FontTableMethods, FontTableTag, + GlyphData, GlyphId, GlyphStore, ShapingFlags, ShapingOptions, KERN, +}; const NO_GLYPH: i32 = -1; const LIGA: u32 = ot_tag!('l', 'i', 'g', 'a'); @@ -361,10 +360,10 @@ pub fn unicode_to_hb_script(script: unicode_script::Script) -> harfbuzz_sys::hb_ } } -impl ShaperMethods for Shaper { +impl Shaper { /// Calculate the layout metrics associated with the given text when painted in a specific /// font. - fn shape_text(&self, text: &str, options: &ShapingOptions, glyphs: &mut GlyphStore) { + pub(crate) fn shape_text(&self, text: &str, options: &ShapingOptions, glyphs: &mut GlyphStore) { unsafe { let hb_buffer: *mut hb_buffer_t = hb_buffer_create(); hb_buffer_set_direction( @@ -420,9 +419,7 @@ impl ShaperMethods for Shaper { hb_buffer_destroy(hb_buffer); } } -} -impl Shaper { fn save_glyph_results( &self, text: &str, diff --git a/components/gfx/tests/font_context.rs b/components/fonts/tests/font_context.rs similarity index 95% rename from components/gfx/tests/font_context.rs rename to components/fonts/tests/font_context.rs index 85f3159bbd5..652760d7f33 100644 --- a/components/gfx/tests/font_context.rs +++ b/components/fonts/tests/font_context.rs @@ -10,14 +10,11 @@ use std::path::PathBuf; use std::rc::Rc; use app_units::Au; -use gfx::font::{ - fallback_font_families, FontDescriptor, FontFamilyDescriptor, FontFamilyName, FontSearchScope, +use fonts::{ + fallback_font_families, CSSFontFaceDescriptors, FallbackFontSelectionOptions, FontContext, + FontDescriptor, FontFamilyDescriptor, FontFamilyName, FontIdentifier, FontSearchScope, + FontSource, FontTemplate, FontTemplateRef, FontTemplates, }; -use gfx::font_cache_thread::{CSSFontFaceDescriptors, FontIdentifier, FontSource}; -use gfx::font_context::FontContext; -use gfx::font_store::FontTemplates; -use gfx::font_template::{FontTemplate, FontTemplateRef}; -use gfx::text::FallbackFontSelectionOptions; use ipc_channel::ipc; use net_traits::ResourceThreads; use servo_arc::Arc; @@ -25,7 +22,6 @@ use servo_atoms::Atom; use servo_url::ServoUrl; use style::properties::longhands::font_variant_caps::computed_value::T as FontVariantCaps; use style::properties::style_structs::Font as FontStyleStruct; -use style::stylesheets::Stylesheet; use style::values::computed::font::{ FamilyName, FontFamily, FontFamilyList, FontFamilyNameSyntax, FontSize, FontStretch, FontStyle, FontWeight, SingleFontFamily, diff --git a/components/gfx/tests/font_template.rs b/components/fonts/tests/font_template.rs similarity index 91% rename from components/gfx/tests/font_template.rs rename to components/fonts/tests/font_template.rs index 8ae6caf7a62..75290708cc9 100644 --- a/components/gfx/tests/font_template.rs +++ b/components/fonts/tests/font_template.rs @@ -11,10 +11,8 @@ fn test_font_template_descriptor() { use std::path::PathBuf; use std::sync::Arc; - use gfx::font::PlatformFontMethods; - use gfx::font_cache_thread::FontIdentifier; - use gfx::font_template::FontTemplateDescriptor; - use gfx::platform::font::PlatformFont; + use fonts::platform::font::PlatformFont; + use fonts::{FontIdentifier, FontTemplateDescriptor, PlatformFontMethods}; use servo_url::ServoUrl; use style::values::computed::font::{FontStretch, FontStyle, FontWeight}; diff --git a/components/gfx/tests/support/CSSTest/LICENSE b/components/fonts/tests/support/CSSTest/LICENSE similarity index 100% rename from components/gfx/tests/support/CSSTest/LICENSE rename to components/fonts/tests/support/CSSTest/LICENSE diff --git a/components/gfx/tests/support/CSSTest/README b/components/fonts/tests/support/CSSTest/README similarity index 100% rename from components/gfx/tests/support/CSSTest/README rename to components/fonts/tests/support/CSSTest/README diff --git a/components/gfx/tests/support/CSSTest/csstest-ascii.ttf b/components/fonts/tests/support/CSSTest/csstest-ascii.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-ascii.ttf rename to components/fonts/tests/support/CSSTest/csstest-ascii.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-basic-bold.ttf b/components/fonts/tests/support/CSSTest/csstest-basic-bold.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-basic-bold.ttf rename to components/fonts/tests/support/CSSTest/csstest-basic-bold.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-basic-bolditalic.ttf b/components/fonts/tests/support/CSSTest/csstest-basic-bolditalic.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-basic-bolditalic.ttf rename to components/fonts/tests/support/CSSTest/csstest-basic-bolditalic.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-basic-italic.ttf b/components/fonts/tests/support/CSSTest/csstest-basic-italic.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-basic-italic.ttf rename to components/fonts/tests/support/CSSTest/csstest-basic-italic.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-basic-regular.ttf b/components/fonts/tests/support/CSSTest/csstest-basic-regular.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-basic-regular.ttf rename to components/fonts/tests/support/CSSTest/csstest-basic-regular.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-fallback.ttf b/components/fonts/tests/support/CSSTest/csstest-fallback.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-fallback.ttf rename to components/fonts/tests/support/CSSTest/csstest-fallback.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-familyname-bold.ttf b/components/fonts/tests/support/CSSTest/csstest-familyname-bold.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-familyname-bold.ttf rename to components/fonts/tests/support/CSSTest/csstest-familyname-bold.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-familyname-funkyA.ttf b/components/fonts/tests/support/CSSTest/csstest-familyname-funkyA.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-familyname-funkyA.ttf rename to components/fonts/tests/support/CSSTest/csstest-familyname-funkyA.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-familyname-funkyB.ttf b/components/fonts/tests/support/CSSTest/csstest-familyname-funkyB.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-familyname-funkyB.ttf rename to components/fonts/tests/support/CSSTest/csstest-familyname-funkyB.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-familyname-funkyC.ttf b/components/fonts/tests/support/CSSTest/csstest-familyname-funkyC.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-familyname-funkyC.ttf rename to components/fonts/tests/support/CSSTest/csstest-familyname-funkyC.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-familyname.ttf b/components/fonts/tests/support/CSSTest/csstest-familyname.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-familyname.ttf rename to components/fonts/tests/support/CSSTest/csstest-familyname.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-verify.ttf b/components/fonts/tests/support/CSSTest/csstest-verify.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-verify.ttf rename to components/fonts/tests/support/CSSTest/csstest-verify.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-100.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-100.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-100.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-100.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-1479-w1.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-1479-w1.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-1479-w1.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-1479-w1.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-1479-w4.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-1479-w4.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-1479-w4.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-1479-w4.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-1479-w7.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-1479-w7.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-1479-w7.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-1479-w7.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-1479-w9.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-1479-w9.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-1479-w9.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-1479-w9.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-15-w1.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-15-w1.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-15-w1.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-15-w1.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-15-w5.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-15-w5.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-15-w5.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-15-w5.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-200.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-200.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-200.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-200.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-24-w2.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-24-w2.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-24-w2.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-24-w2.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-24-w4.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-24-w4.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-24-w4.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-24-w4.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-2569-w2.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-2569-w2.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-2569-w2.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-2569-w2.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-2569-w5.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-2569-w5.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-2569-w5.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-2569-w5.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-2569-w6.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-2569-w6.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-2569-w6.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-2569-w6.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-2569-w9.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-2569-w9.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-2569-w9.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-2569-w9.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-258-w2.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-258-w2.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-258-w2.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-258-w2.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-258-w5.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-258-w5.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-258-w5.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-258-w5.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-258-w8.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-258-w8.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-258-w8.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-258-w8.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-300.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-300.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-300.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-300.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-3589-w3.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-3589-w3.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-3589-w3.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-3589-w3.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-3589-w5.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-3589-w5.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-3589-w5.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-3589-w5.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-3589-w8.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-3589-w8.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-3589-w8.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-3589-w8.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-3589-w9.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-3589-w9.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-3589-w9.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-3589-w9.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-400.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-400.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-400.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-400.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-47-w4.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-47-w4.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-47-w4.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-47-w4.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-47-w7.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-47-w7.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-47-w7.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-47-w7.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-500.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-500.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-500.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-500.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-600.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-600.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-600.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-600.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-700.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-700.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-700.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-700.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-800.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-800.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-800.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-800.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-900.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-900.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-900.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-900.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-full-w1.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-full-w1.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-full-w1.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-full-w1.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-full-w2.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-full-w2.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-full-w2.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-full-w2.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-full-w3.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-full-w3.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-full-w3.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-full-w3.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-full-w4.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-full-w4.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-full-w4.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-full-w4.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-full-w5.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-full-w5.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-full-w5.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-full-w5.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-full-w6.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-full-w6.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-full-w6.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-full-w6.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-full-w7.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-full-w7.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-full-w7.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-full-w7.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-full-w8.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-full-w8.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-full-w8.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-full-w8.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-full-w9.ttf b/components/fonts/tests/support/CSSTest/csstest-weights-full-w9.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights-full-w9.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights-full-w9.ttf diff --git a/components/gfx/tests/support/CSSTest/csstest-weights.ttf b/components/fonts/tests/support/CSSTest/csstest-weights.ttf similarity index 100% rename from components/gfx/tests/support/CSSTest/csstest-weights.ttf rename to components/fonts/tests/support/CSSTest/csstest-weights.ttf diff --git a/components/gfx/tests/support/dejavu-fonts-ttf-2.37/AUTHORS b/components/fonts/tests/support/dejavu-fonts-ttf-2.37/AUTHORS similarity index 100% rename from components/gfx/tests/support/dejavu-fonts-ttf-2.37/AUTHORS rename to components/fonts/tests/support/dejavu-fonts-ttf-2.37/AUTHORS diff --git a/components/gfx/tests/support/dejavu-fonts-ttf-2.37/BUGS b/components/fonts/tests/support/dejavu-fonts-ttf-2.37/BUGS similarity index 100% rename from components/gfx/tests/support/dejavu-fonts-ttf-2.37/BUGS rename to components/fonts/tests/support/dejavu-fonts-ttf-2.37/BUGS diff --git a/components/gfx/tests/support/dejavu-fonts-ttf-2.37/LICENSE b/components/fonts/tests/support/dejavu-fonts-ttf-2.37/LICENSE similarity index 100% rename from components/gfx/tests/support/dejavu-fonts-ttf-2.37/LICENSE rename to components/fonts/tests/support/dejavu-fonts-ttf-2.37/LICENSE diff --git a/components/gfx/tests/support/dejavu-fonts-ttf-2.37/NEWS b/components/fonts/tests/support/dejavu-fonts-ttf-2.37/NEWS similarity index 100% rename from components/gfx/tests/support/dejavu-fonts-ttf-2.37/NEWS rename to components/fonts/tests/support/dejavu-fonts-ttf-2.37/NEWS diff --git a/components/gfx/tests/support/dejavu-fonts-ttf-2.37/README.md b/components/fonts/tests/support/dejavu-fonts-ttf-2.37/README.md similarity index 100% rename from components/gfx/tests/support/dejavu-fonts-ttf-2.37/README.md rename to components/fonts/tests/support/dejavu-fonts-ttf-2.37/README.md diff --git a/components/gfx/tests/support/dejavu-fonts-ttf-2.37/fontconfig/20-unhint-small-dejavu-sans-mono.conf b/components/fonts/tests/support/dejavu-fonts-ttf-2.37/fontconfig/20-unhint-small-dejavu-sans-mono.conf similarity index 100% rename from components/gfx/tests/support/dejavu-fonts-ttf-2.37/fontconfig/20-unhint-small-dejavu-sans-mono.conf rename to components/fonts/tests/support/dejavu-fonts-ttf-2.37/fontconfig/20-unhint-small-dejavu-sans-mono.conf diff --git a/components/gfx/tests/support/dejavu-fonts-ttf-2.37/fontconfig/20-unhint-small-dejavu-sans.conf b/components/fonts/tests/support/dejavu-fonts-ttf-2.37/fontconfig/20-unhint-small-dejavu-sans.conf similarity index 100% rename from components/gfx/tests/support/dejavu-fonts-ttf-2.37/fontconfig/20-unhint-small-dejavu-sans.conf rename to components/fonts/tests/support/dejavu-fonts-ttf-2.37/fontconfig/20-unhint-small-dejavu-sans.conf diff --git a/components/gfx/tests/support/dejavu-fonts-ttf-2.37/fontconfig/20-unhint-small-dejavu-serif.conf b/components/fonts/tests/support/dejavu-fonts-ttf-2.37/fontconfig/20-unhint-small-dejavu-serif.conf similarity index 100% rename from components/gfx/tests/support/dejavu-fonts-ttf-2.37/fontconfig/20-unhint-small-dejavu-serif.conf rename to components/fonts/tests/support/dejavu-fonts-ttf-2.37/fontconfig/20-unhint-small-dejavu-serif.conf diff --git a/components/gfx/tests/support/dejavu-fonts-ttf-2.37/fontconfig/57-dejavu-sans-mono.conf b/components/fonts/tests/support/dejavu-fonts-ttf-2.37/fontconfig/57-dejavu-sans-mono.conf similarity index 100% rename from components/gfx/tests/support/dejavu-fonts-ttf-2.37/fontconfig/57-dejavu-sans-mono.conf rename to components/fonts/tests/support/dejavu-fonts-ttf-2.37/fontconfig/57-dejavu-sans-mono.conf diff --git a/components/gfx/tests/support/dejavu-fonts-ttf-2.37/fontconfig/57-dejavu-sans.conf b/components/fonts/tests/support/dejavu-fonts-ttf-2.37/fontconfig/57-dejavu-sans.conf similarity index 100% rename from components/gfx/tests/support/dejavu-fonts-ttf-2.37/fontconfig/57-dejavu-sans.conf rename to components/fonts/tests/support/dejavu-fonts-ttf-2.37/fontconfig/57-dejavu-sans.conf diff --git a/components/gfx/tests/support/dejavu-fonts-ttf-2.37/fontconfig/57-dejavu-serif.conf b/components/fonts/tests/support/dejavu-fonts-ttf-2.37/fontconfig/57-dejavu-serif.conf similarity index 100% rename from components/gfx/tests/support/dejavu-fonts-ttf-2.37/fontconfig/57-dejavu-serif.conf rename to components/fonts/tests/support/dejavu-fonts-ttf-2.37/fontconfig/57-dejavu-serif.conf diff --git a/components/gfx/tests/support/dejavu-fonts-ttf-2.37/langcover.txt b/components/fonts/tests/support/dejavu-fonts-ttf-2.37/langcover.txt similarity index 100% rename from components/gfx/tests/support/dejavu-fonts-ttf-2.37/langcover.txt rename to components/fonts/tests/support/dejavu-fonts-ttf-2.37/langcover.txt diff --git a/components/gfx/tests/support/dejavu-fonts-ttf-2.37/status.txt b/components/fonts/tests/support/dejavu-fonts-ttf-2.37/status.txt similarity index 100% rename from components/gfx/tests/support/dejavu-fonts-ttf-2.37/status.txt rename to components/fonts/tests/support/dejavu-fonts-ttf-2.37/status.txt diff --git a/components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuMathTeXGyre.ttf b/components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuMathTeXGyre.ttf similarity index 100% rename from components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuMathTeXGyre.ttf rename to components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuMathTeXGyre.ttf diff --git a/components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSans-Bold.ttf b/components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSans-Bold.ttf similarity index 100% rename from components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSans-Bold.ttf rename to components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSans-Bold.ttf diff --git a/components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSans-BoldOblique.ttf b/components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSans-BoldOblique.ttf similarity index 100% rename from components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSans-BoldOblique.ttf rename to components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSans-BoldOblique.ttf diff --git a/components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSans-ExtraLight.ttf b/components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSans-ExtraLight.ttf similarity index 100% rename from components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSans-ExtraLight.ttf rename to components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSans-ExtraLight.ttf diff --git a/components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSans-Oblique.ttf b/components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSans-Oblique.ttf similarity index 100% rename from components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSans-Oblique.ttf rename to components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSans-Oblique.ttf diff --git a/components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSans.ttf b/components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSans.ttf similarity index 100% rename from components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSans.ttf rename to components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSans.ttf diff --git a/components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSansCondensed-Bold.ttf b/components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSansCondensed-Bold.ttf similarity index 100% rename from components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSansCondensed-Bold.ttf rename to components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSansCondensed-Bold.ttf diff --git a/components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSansCondensed-BoldOblique.ttf b/components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSansCondensed-BoldOblique.ttf similarity index 100% rename from components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSansCondensed-BoldOblique.ttf rename to components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSansCondensed-BoldOblique.ttf diff --git a/components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSansCondensed-Oblique.ttf b/components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSansCondensed-Oblique.ttf similarity index 100% rename from components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSansCondensed-Oblique.ttf rename to components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSansCondensed-Oblique.ttf diff --git a/components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSansCondensed.ttf b/components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSansCondensed.ttf similarity index 100% rename from components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSansCondensed.ttf rename to components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSansCondensed.ttf diff --git a/components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSansMono-Bold.ttf b/components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSansMono-Bold.ttf similarity index 100% rename from components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSansMono-Bold.ttf rename to components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSansMono-Bold.ttf diff --git a/components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSansMono-BoldOblique.ttf b/components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSansMono-BoldOblique.ttf similarity index 100% rename from components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSansMono-BoldOblique.ttf rename to components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSansMono-BoldOblique.ttf diff --git a/components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSansMono-Oblique.ttf b/components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSansMono-Oblique.ttf similarity index 100% rename from components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSansMono-Oblique.ttf rename to components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSansMono-Oblique.ttf diff --git a/components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSansMono.ttf b/components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSansMono.ttf similarity index 100% rename from components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSansMono.ttf rename to components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSansMono.ttf diff --git a/components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSerif-Bold.ttf b/components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSerif-Bold.ttf similarity index 100% rename from components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSerif-Bold.ttf rename to components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSerif-Bold.ttf diff --git a/components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSerif-BoldItalic.ttf b/components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSerif-BoldItalic.ttf similarity index 100% rename from components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSerif-BoldItalic.ttf rename to components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSerif-BoldItalic.ttf diff --git a/components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSerif-Italic.ttf b/components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSerif-Italic.ttf similarity index 100% rename from components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSerif-Italic.ttf rename to components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSerif-Italic.ttf diff --git a/components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSerif.ttf b/components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSerif.ttf similarity index 100% rename from components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSerif.ttf rename to components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSerif.ttf diff --git a/components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSerifCondensed-Bold.ttf b/components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSerifCondensed-Bold.ttf similarity index 100% rename from components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSerifCondensed-Bold.ttf rename to components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSerifCondensed-Bold.ttf diff --git a/components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSerifCondensed-BoldItalic.ttf b/components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSerifCondensed-BoldItalic.ttf similarity index 100% rename from components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSerifCondensed-BoldItalic.ttf rename to components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSerifCondensed-BoldItalic.ttf diff --git a/components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSerifCondensed-Italic.ttf b/components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSerifCondensed-Italic.ttf similarity index 100% rename from components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSerifCondensed-Italic.ttf rename to components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSerifCondensed-Italic.ttf diff --git a/components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSerifCondensed.ttf b/components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSerifCondensed.ttf similarity index 100% rename from components/gfx/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSerifCondensed.ttf rename to components/fonts/tests/support/dejavu-fonts-ttf-2.37/ttf/DejaVuSerifCondensed.ttf diff --git a/components/gfx/tests/support/dejavu-fonts-ttf-2.37/unicover.txt b/components/fonts/tests/support/dejavu-fonts-ttf-2.37/unicover.txt similarity index 100% rename from components/gfx/tests/support/dejavu-fonts-ttf-2.37/unicover.txt rename to components/fonts/tests/support/dejavu-fonts-ttf-2.37/unicover.txt diff --git a/components/gfx/lib.rs b/components/gfx/lib.rs deleted file mode 100644 index fc4533d4d4b..00000000000 --- a/components/gfx/lib.rs +++ /dev/null @@ -1,14 +0,0 @@ -/* 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 https://mozilla.org/MPL/2.0/. */ - -#![deny(unsafe_code)] - -pub mod font; -pub mod font_cache_thread; -pub mod font_context; -pub mod font_store; -pub mod font_template; -#[allow(unsafe_code)] -pub mod platform; -pub mod text; diff --git a/components/gfx/text/shaping/mod.rs b/components/gfx/text/shaping/mod.rs deleted file mode 100644 index 3862654fe6f..00000000000 --- a/components/gfx/text/shaping/mod.rs +++ /dev/null @@ -1,18 +0,0 @@ -/* 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 https://mozilla.org/MPL/2.0/. */ - -//! Shaper encapsulates a specific shaper, such as Harfbuzz, -//! Uniscribe, Pango, or Coretext. -//! -//! Currently, only harfbuzz bindings are implemented. - -pub use self::harfbuzz::Shaper; -use crate::font::ShapingOptions; -use crate::text::glyph::GlyphStore; - -pub mod harfbuzz; - -pub trait ShaperMethods { - fn shape_text(&self, text: &str, options: &ShapingOptions, glyphs: &mut GlyphStore); -} diff --git a/components/gfx/text/util.rs b/components/gfx/text/util.rs deleted file mode 100644 index feceb973eae..00000000000 --- a/components/gfx/text/util.rs +++ /dev/null @@ -1,11 +0,0 @@ -/* 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 https://mozilla.org/MPL/2.0/. */ - -pub fn float_to_fixed(before: usize, f: f64) -> i32 { - ((1i32 << before) as f64 * f) as i32 -} - -pub fn fixed_to_float(before: usize, f: i32) -> f64 { - f as f64 * 1.0f64 / ((1i32 << before) as f64) -} diff --git a/components/layout/Cargo.toml b/components/layout/Cargo.toml index edd0a1a88dc..1c716acf9db 100644 --- a/components/layout/Cargo.toml +++ b/components/layout/Cargo.toml @@ -21,8 +21,8 @@ canvas_traits = { workspace = true } embedder_traits = { workspace = true } euclid = { workspace = true } fnv = { workspace = true } -gfx = { path = "../gfx" } -gfx_traits = { workspace = true } +fonts = { path = "../fonts" } +fonts_traits = { workspace = true } html5ever = { workspace = true } ipc-channel = { workspace = true } lazy_static = { workspace = true } diff --git a/components/layout/context.rs b/components/layout/context.rs index 5767717e371..022d5c8d5b8 100644 --- a/components/layout/context.rs +++ b/components/layout/context.rs @@ -11,8 +11,7 @@ use std::thread; use base::id::PipelineId; use fnv::FnvHasher; -use gfx::font_cache_thread::FontCacheThread; -use gfx::font_context::FontContext; +use fonts::{FontCacheThread, FontContext}; use net_traits::image_cache::{ ImageCache, ImageCacheResult, ImageOrMetadataAvailable, UsePlaceholder, }; diff --git a/components/layout/display_list/builder.rs b/components/layout/display_list/builder.rs index c018448360e..d1e67c9724d 100644 --- a/components/layout/display_list/builder.rs +++ b/components/layout/display_list/builder.rs @@ -20,7 +20,7 @@ use embedder_traits::Cursor; use euclid::default::{Point2D, Rect, SideOffsets2D as UntypedSideOffsets2D, Size2D}; use euclid::{rect, SideOffsets2D}; use fnv::FnvHashMap; -use gfx::text::glyph::ByteIndex; +use fonts::ByteIndex; use ipc_channel::ipc; use log::{debug, warn}; use net_traits::image_cache::UsePlaceholder; diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index c3e75dad2f4..967bdfb1df3 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -16,7 +16,7 @@ use base::text::is_bidi_control; use bitflags::bitflags; use canvas_traits::canvas::{CanvasId, CanvasMsg}; use euclid::default::{Point2D, Rect, Size2D, Vector2D}; -use gfx::text::glyph::ByteIndex; +use fonts::ByteIndex; use html5ever::{local_name, namespace_url, ns}; use ipc_channel::ipc::IpcSender; use log::debug; diff --git a/components/layout/inline.rs b/components/layout/inline.rs index 733235ed09f..e6da98ccee8 100644 --- a/components/layout/inline.rs +++ b/components/layout/inline.rs @@ -11,7 +11,7 @@ use app_units::{Au, MIN_AU}; use base::print_tree::PrintTree; use bitflags::bitflags; use euclid::default::{Point2D, Rect, Size2D}; -use gfx::font::FontMetrics; +use fonts::FontMetrics; use log::debug; use range::{int_range_index, Range, RangeIndex}; use script_layout_interface::wrapper_traits::PseudoElementType; diff --git a/components/layout/text.rs b/components/layout/text.rs index e52484c3113..873622f0b38 100644 --- a/components/layout/text.rs +++ b/components/layout/text.rs @@ -10,9 +10,10 @@ use std::sync::Arc; use app_units::Au; use base::text::is_bidi_control; -use gfx::font::{self, FontMetrics, FontRef, RunMetrics, ShapingFlags, ShapingOptions}; -use gfx::font_cache_thread::FontIdentifier; -use gfx::text::glyph::ByteIndex; +use fonts::{ + self, ByteIndex, FontIdentifier, FontMetrics, FontRef, RunMetrics, ShapingFlags, + ShapingOptions, LAST_RESORT_GLYPH_ADVANCE, +}; use log::{debug, warn}; use range::Range; use style::computed_values::text_rendering::T as TextRendering; @@ -211,7 +212,7 @@ impl TextRunScanner { font.glyph_index(' ') .map(|glyph_id| font.glyph_h_advance(glyph_id)) }) - .unwrap_or(font::LAST_RESORT_GLYPH_ADVANCE); + .unwrap_or(LAST_RESORT_GLYPH_ADVANCE); inherited_text_style .word_spacing .to_used_value(Au::from_f64_px(space_width)) diff --git a/components/layout/text_run.rs b/components/layout/text_run.rs index fed03e48822..d860cb97890 100644 --- a/components/layout/text_run.rs +++ b/components/layout/text_run.rs @@ -8,8 +8,9 @@ use std::slice::Iter; use std::sync::Arc; use app_units::Au; -use gfx::font::{FontMetrics, FontRef, RunMetrics, ShapingFlags, ShapingOptions}; -use gfx::text::glyph::{ByteIndex, GlyphRun, GlyphStore}; +use fonts::{ + ByteIndex, FontMetrics, FontRef, GlyphRun, GlyphStore, RunMetrics, ShapingFlags, ShapingOptions, +}; use log::debug; use range::Range; use serde::{Deserialize, Serialize}; diff --git a/components/layout_2020/Cargo.toml b/components/layout_2020/Cargo.toml index 0ffa3aa3fb0..7993595c9d2 100644 --- a/components/layout_2020/Cargo.toml +++ b/components/layout_2020/Cargo.toml @@ -23,8 +23,8 @@ embedder_traits = { workspace = true } euclid = { workspace = true } fnv = { workspace = true } fxhash = { workspace = true } -gfx = { path = "../gfx" } -gfx_traits = { workspace = true } +fonts = { path = "../fonts" } +fonts_traits = { workspace = true } html5ever = { workspace = true } icu_segmenter = { workspace = true } ipc-channel = { workspace = true } diff --git a/components/layout_2020/context.rs b/components/layout_2020/context.rs index bfeac3035e3..82b953f18aa 100644 --- a/components/layout_2020/context.rs +++ b/components/layout_2020/context.rs @@ -6,8 +6,7 @@ use std::sync::Arc; use base::id::PipelineId; use fnv::FnvHashMap; -use gfx::font_cache_thread::FontCacheThread; -use gfx::font_context::FontContext; +use fonts::{FontCacheThread, FontContext}; use net_traits::image_cache::{ ImageCache, ImageCacheResult, ImageOrMetadataAvailable, UsePlaceholder, }; diff --git a/components/layout_2020/display_list/mod.rs b/components/layout_2020/display_list/mod.rs index 22f5aeec337..dd91f3b72c8 100644 --- a/components/layout_2020/display_list/mod.rs +++ b/components/layout_2020/display_list/mod.rs @@ -10,7 +10,7 @@ use base::WebRenderEpochToU16; use embedder_traits::Cursor; use euclid::{Point2D, SideOffsets2D, Size2D}; use fnv::FnvHashMap; -use gfx::text::glyph::GlyphStore; +use fonts::GlyphStore; use net_traits::image_cache::UsePlaceholder; use servo_geometry::MaxRect; use style::color::{AbsoluteColor, ColorSpace}; @@ -962,7 +962,7 @@ fn glyphs( mut baseline_origin: PhysicalPoint, justification_adjustment: Length, ) -> Vec { - use gfx_traits::ByteIndex; + use fonts_traits::ByteIndex; use range::Range; let mut glyphs = vec![]; diff --git a/components/layout_2020/flow/inline/line.rs b/components/layout_2020/flow/inline/line.rs index 77e428aa90e..f8752298de3 100644 --- a/components/layout_2020/flow/inline/line.rs +++ b/components/layout_2020/flow/inline/line.rs @@ -6,8 +6,7 @@ use std::vec::IntoIter; use app_units::Au; use atomic_refcell::AtomicRef; -use gfx::font::FontMetrics; -use gfx::text::glyph::GlyphStore; +use fonts::{FontMetrics, GlyphStore}; use servo_arc::Arc; use style::computed_values::white_space_collapse::T as WhiteSpaceCollapse; use style::properties::ComputedValues; diff --git a/components/layout_2020/flow/inline/mod.rs b/components/layout_2020/flow/inline/mod.rs index 18aeb24734b..29ef49ab3f7 100644 --- a/components/layout_2020/flow/inline/mod.rs +++ b/components/layout_2020/flow/inline/mod.rs @@ -79,8 +79,7 @@ use std::mem; use app_units::Au; use bitflags::bitflags; use construct::InlineFormattingContextBuilder; -use gfx::font::FontMetrics; -use gfx::text::glyph::GlyphStore; +use fonts::{FontMetrics, GlyphStore}; use line::{ layout_line_items, AbsolutelyPositionedLineItem, AtomicLineItem, FloatLineItem, InlineBoxLineItem, LineItem, LineItemLayoutState, LineMetrics, TextRunLineItem, diff --git a/components/layout_2020/flow/inline/text_run.rs b/components/layout_2020/flow/inline/text_run.rs index 0b563703f46..d22e7a7c693 100644 --- a/components/layout_2020/flow/inline/text_run.rs +++ b/components/layout_2020/flow/inline/text_run.rs @@ -6,11 +6,11 @@ use std::mem; use std::ops::Range; use app_units::Au; -use gfx::font::{FontRef, ShapingFlags, ShapingOptions}; -use gfx::font_cache_thread::FontCacheThread; -use gfx::font_context::FontContext; -use gfx::text::glyph::GlyphRun; -use gfx_traits::ByteIndex; +use fonts::{ + FontCacheThread, FontContext, FontRef, GlyphRun, ShapingFlags, ShapingOptions, + LAST_RESORT_GLYPH_ADVANCE, +}; +use fonts_traits::ByteIndex; use log::warn; use range::Range as ServoRange; use serde::Serialize; @@ -371,7 +371,7 @@ impl TextRun { let space_width = font .glyph_index(' ') .map(|glyph_id| font.glyph_h_advance(glyph_id)) - .unwrap_or(gfx::font::LAST_RESORT_GLYPH_ADVANCE); + .unwrap_or(LAST_RESORT_GLYPH_ADVANCE); specified_word_spacing.to_used_value(Au::from_f64_px(space_width)) }); diff --git a/components/layout_2020/fragment_tree/fragment.rs b/components/layout_2020/fragment_tree/fragment.rs index a5dc9b0433c..ace0bfc0b27 100644 --- a/components/layout_2020/fragment_tree/fragment.rs +++ b/components/layout_2020/fragment_tree/fragment.rs @@ -7,8 +7,7 @@ use std::sync::Arc; use app_units::Au; use base::id::{BrowsingContextId, PipelineId}; use base::print_tree::PrintTree; -use gfx::font::FontMetrics; -use gfx::text::glyph::GlyphStore; +use fonts::{FontMetrics, GlyphStore}; use serde::Serialize; use servo_arc::Arc as ServoArc; use style::properties::ComputedValues; diff --git a/components/layout_thread/Cargo.toml b/components/layout_thread/Cargo.toml index 61cd1c2fb14..53331fedd80 100644 --- a/components/layout_thread/Cargo.toml +++ b/components/layout_thread/Cargo.toml @@ -18,8 +18,8 @@ embedder_traits = { workspace = true } euclid = { workspace = true } fnv = { workspace = true } fxhash = { workspace = true } -gfx = { path = "../gfx" } -gfx_traits = { workspace = true } +fonts = { path = "../fonts" } +fonts_traits = { workspace = true } histogram = "0.6.8" ipc-channel = { workspace = true } layout = { path = "../layout", package = "layout_2013" } diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs index 803c3f7c829..1d8c3d89a72 100644 --- a/components/layout_thread/lib.rs +++ b/components/layout_thread/lib.rs @@ -21,11 +21,12 @@ use embedder_traits::resources::{self, Resource}; use euclid::default::{Point2D as UntypedPoint2D, Rect as UntypedRect, Size2D as UntypedSize2D}; use euclid::{Point2D, Rect, Scale, Size2D}; use fnv::FnvHashMap; +use fonts::{ + get_and_reset_text_shaping_performance_counter, FontCacheThread, FontContext, + FontContextWebFontMethods, +}; +use fonts_traits::WebFontLoadFinishedCallback; use fxhash::{FxHashMap, FxHashSet}; -use gfx::font; -use gfx::font_cache_thread::FontCacheThread; -use gfx::font_context::{FontContext, FontContextWebFontMethods}; -use gfx_traits::WebFontLoadFinishedCallback; use histogram::Histogram; use ipc_channel::ipc::IpcSender; use layout::construct::ConstructionResult; @@ -1119,8 +1120,7 @@ impl LayoutThread { }, ); // TODO(pcwalton): Measure energy usage of text shaping, perhaps? - let text_shaping_time = - font::get_and_reset_text_shaping_performance_counter() / num_threads; + let text_shaping_time = get_and_reset_text_shaping_performance_counter() / num_threads; profile_time::send_profile_data( profile_time::ProfilerCategory::LayoutTextShaping, self.profiler_metadata(), diff --git a/components/layout_thread_2020/Cargo.toml b/components/layout_thread_2020/Cargo.toml index e1bdd664895..b8d4dfaade0 100644 --- a/components/layout_thread_2020/Cargo.toml +++ b/components/layout_thread_2020/Cargo.toml @@ -18,8 +18,8 @@ embedder_traits = { workspace = true } euclid = { workspace = true } fnv = { workspace = true } fxhash = { workspace = true } -gfx = { path = "../gfx" } -gfx_traits = { workspace = true } +fonts = { path = "../fonts" } +fonts_traits = { workspace = true } ipc-channel = { workspace = true } layout = { path = "../layout_2020", package = "layout_2020" } lazy_static = { workspace = true } diff --git a/components/layout_thread_2020/lib.rs b/components/layout_thread_2020/lib.rs index e392a3b6f1b..32b3ea89e77 100644 --- a/components/layout_thread_2020/lib.rs +++ b/components/layout_thread_2020/lib.rs @@ -22,10 +22,9 @@ use embedder_traits::resources::{self, Resource}; use euclid::default::{Point2D as UntypedPoint2D, Rect as UntypedRect, Size2D as UntypedSize2D}; use euclid::{Point2D, Scale, Size2D, Vector2D}; use fnv::FnvHashMap; +use fonts::{FontCacheThread, FontContext, FontContextWebFontMethods}; +use fonts_traits::WebFontLoadFinishedCallback; use fxhash::FxHashMap; -use gfx::font_cache_thread::FontCacheThread; -use gfx::font_context::{FontContext, FontContextWebFontMethods}; -use gfx_traits::WebFontLoadFinishedCallback; use ipc_channel::ipc::IpcSender; use layout::context::LayoutContext; use layout::display_list::{DisplayList, WebRenderImageInfo}; diff --git a/components/metrics/Cargo.toml b/components/metrics/Cargo.toml index 44864913a7a..f2464ccf24b 100644 --- a/components/metrics/Cargo.toml +++ b/components/metrics/Cargo.toml @@ -12,7 +12,7 @@ path = "lib.rs" [dependencies] base = { workspace = true } -gfx_traits = { workspace = true } +fonts_traits = { workspace = true } ipc-channel = { workspace = true } log = { workspace = true } malloc_size_of = { workspace = true } diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml index f8a26d20790..d87ae88e0ab 100644 --- a/components/script/Cargo.toml +++ b/components/script/Cargo.toml @@ -53,8 +53,8 @@ enum-iterator = "0.3" euclid = { workspace = true } fnv = { workspace = true } fxhash = { workspace = true } -gfx_traits = { workspace = true } -gfx = { path = "../gfx" } +fonts_traits = { workspace = true } +fonts = { path = "../fonts" } headers = { workspace = true } html5ever = { workspace = true } http = { workspace = true } diff --git a/components/script/layout_dom/node.rs b/components/script/layout_dom/node.rs index f4e014a6a1b..efb05a2f121 100644 --- a/components/script/layout_dom/node.rs +++ b/components/script/layout_dom/node.rs @@ -9,7 +9,7 @@ use std::fmt; use std::sync::Arc as StdArc; use base::id::{BrowsingContextId, PipelineId}; -use gfx_traits::ByteIndex; +use fonts_traits::ByteIndex; use html5ever::{local_name, namespace_url, ns}; use pixels::{Image, ImageMetadata}; use range::Range; diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 8a8a80b9c2a..1d3fb58766a 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -47,7 +47,7 @@ use devtools_traits::{ }; use embedder_traits::EmbedderMsg; use euclid::default::{Point2D, Rect}; -use gfx::font_cache_thread::FontCacheThread; +use fonts::FontCacheThread; use headers::{HeaderMapExt, LastModified, ReferrerPolicy as ReferrerPolicyHeader}; use html5ever::{local_name, namespace_url, ns}; use hyper_serde::Serde; diff --git a/components/servo/Cargo.toml b/components/servo/Cargo.toml index 1ca1ee27562..8cee2c8b1d6 100644 --- a/components/servo/Cargo.toml +++ b/components/servo/Cargo.toml @@ -48,8 +48,8 @@ devtools_traits = { workspace = true } embedder_traits = { workspace = true } env_logger = { workspace = true } euclid = { workspace = true } -gfx = { path = "../gfx" } -gfx_traits = { workspace = true } +fonts = { path = "../fonts" } +fonts_traits = { workspace = true } gleam = { workspace = true } gstreamer = { workspace = true, optional = true } ipc-channel = { workspace = true } diff --git a/components/servo/lib.rs b/components/servo/lib.rs index 282fee3f67c..a135fef1f63 100644 --- a/components/servo/lib.rs +++ b/components/servo/lib.rs @@ -55,6 +55,7 @@ use crossbeam_channel::{unbounded, Sender}; use embedder_traits::{EmbedderMsg, EmbedderProxy, EmbedderReceiver, EventLoopWaker}; use env_logger::Builder as EnvLoggerBuilder; use euclid::Scale; +use fonts::FontCacheThread; #[cfg(all( not(target_os = "windows"), not(target_os = "ios"), @@ -64,7 +65,6 @@ use euclid::Scale; not(target_env = "ohos"), ))] use gaol::sandbox::{ChildSandbox, ChildSandboxMethods}; -use gfx::font_cache_thread::FontCacheThread; pub use gleam::gl; use ipc_channel::ipc::{self, IpcSender}; use log::{error, trace, warn, Log, Metadata, Record}; @@ -97,7 +97,7 @@ use webrender_traits::{ }; pub use { background_hang_monitor, base, bluetooth, bluetooth_traits, canvas, canvas_traits, compositing, - constellation, devtools, devtools_traits, embedder_traits, euclid, gfx, ipc_channel, + constellation, devtools, devtools_traits, embedder_traits, euclid, fonts, ipc_channel, keyboard_types, layout_thread_2013, layout_thread_2020, media, net, net_traits, profile, profile_traits, script, script_layout_interface, script_traits, servo_config as config, servo_config, servo_geometry, servo_url as url, servo_url, style, style_traits, webgpu, diff --git a/components/shared/compositing/Cargo.toml b/components/shared/compositing/Cargo.toml index ca31ce4201f..f46a35f6e03 100644 --- a/components/shared/compositing/Cargo.toml +++ b/components/shared/compositing/Cargo.toml @@ -15,7 +15,7 @@ base = { workspace = true } crossbeam-channel = { workspace = true } embedder_traits = { workspace = true } euclid = { workspace = true } -gfx_traits = { workspace = true } +fonts_traits = { workspace = true } ipc-channel = { workspace = true } keyboard-types = { workspace = true } log = { workspace = true } diff --git a/components/shared/gfx/Cargo.toml b/components/shared/fonts/Cargo.toml similarity index 89% rename from components/shared/gfx/Cargo.toml rename to components/shared/fonts/Cargo.toml index ffcbcc53c9f..32e10a7e389 100644 --- a/components/shared/gfx/Cargo.toml +++ b/components/shared/fonts/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "gfx_traits" +name = "fonts_traits" version.workspace = true authors.workspace = true license.workspace = true @@ -7,7 +7,7 @@ edition.workspace = true publish.workspace = true [lib] -name = "gfx_traits" +name = "fonts_traits" path = "lib.rs" [dependencies] diff --git a/components/shared/gfx/lib.rs b/components/shared/fonts/lib.rs similarity index 100% rename from components/shared/gfx/lib.rs rename to components/shared/fonts/lib.rs diff --git a/components/shared/script/Cargo.toml b/components/shared/script/Cargo.toml index 7624b542498..c8303658efa 100644 --- a/components/shared/script/Cargo.toml +++ b/components/shared/script/Cargo.toml @@ -21,7 +21,7 @@ crossbeam-channel = { workspace = true } devtools_traits = { workspace = true } embedder_traits = { workspace = true } euclid = { workspace = true } -gfx_traits = { workspace = true } +fonts_traits = { workspace = true } http = { workspace = true } hyper_serde = { workspace = true } ipc-channel = { workspace = true } diff --git a/components/shared/script_layout/Cargo.toml b/components/shared/script_layout/Cargo.toml index f4e310510ee..922df1ba324 100644 --- a/components/shared/script_layout/Cargo.toml +++ b/components/shared/script_layout/Cargo.toml @@ -17,8 +17,8 @@ atomic_refcell = { workspace = true } canvas_traits = { workspace = true } crossbeam-channel = { workspace = true } euclid = { workspace = true } -gfx = { path = "../../gfx" } -gfx_traits = { workspace = true } +fonts = { path = "../../fonts" } +fonts_traits = { workspace = true } html5ever = { workspace = true } ipc-channel = { workspace = true } libc = { workspace = true } diff --git a/components/shared/script_layout/lib.rs b/components/shared/script_layout/lib.rs index baf885e3524..bb9099e8b45 100644 --- a/components/shared/script_layout/lib.rs +++ b/components/shared/script_layout/lib.rs @@ -23,7 +23,7 @@ use canvas_traits::canvas::{CanvasId, CanvasMsg}; use crossbeam_channel::Sender; use euclid::default::{Point2D, Rect}; use euclid::Size2D; -use gfx::font_cache_thread::FontCacheThread; +use fonts::FontCacheThread; use ipc_channel::ipc::IpcSender; use libc::c_void; use malloc_size_of_derive::MallocSizeOf; diff --git a/components/shared/script_layout/wrapper_traits.rs b/components/shared/script_layout/wrapper_traits.rs index fe3fc69f47e..5c8da0315b4 100644 --- a/components/shared/script_layout/wrapper_traits.rs +++ b/components/shared/script_layout/wrapper_traits.rs @@ -10,7 +10,7 @@ use std::sync::Arc as StdArc; use atomic_refcell::AtomicRef; use base::id::{BrowsingContextId, PipelineId}; -use gfx_traits::ByteIndex; +use fonts_traits::ByteIndex; use html5ever::{local_name, namespace_url, ns, LocalName, Namespace}; use pixels::{Image, ImageMetadata}; use range::Range; diff --git a/docs/ORGANIZATION.md b/docs/ORGANIZATION.md index 4d543b583c8..b6ba6bcfb03 100644 --- a/docs/ORGANIZATION.md +++ b/docs/ORGANIZATION.md @@ -16,10 +16,10 @@ * In-process server to allow manipulating browser instances via a remote Firefox developer tools client. * devtools_traits * APIs to the devtools crate for crates that don't want to depend on the devtools crate for build speed reasons. - * gfx - * Draws the result of laying out a page, and sends the result to the compositor. - * gfx_traits - * APIs to the gfx crate for crates that don't want to depend on the gfx crate for build speed reasons. + * fonts + * Code for dealing with fonts and text shaping. + * fonts_traits + * APIs to the fonts crate for crates that don't want to depend on the fonts crate for build speed reasons. * layout * Converts page content into positioned, styled boxes and passes the result to the renderer. * layout_thread diff --git a/python/servo/testing_commands.py b/python/servo/testing_commands.py index eaa32854210..b05a89a7a30 100644 --- a/python/servo/testing_commands.py +++ b/python/servo/testing_commands.py @@ -152,7 +152,7 @@ class MachCommands(CommandBase): "compositing", "constellation", "crown", - "gfx", + "fonts", "hyper_serde", "layout_2013", "layout_2020", diff --git a/tests/unit/metrics/Cargo.toml b/tests/unit/metrics/Cargo.toml index 4310797207d..a9f969fd1b2 100644 --- a/tests/unit/metrics/Cargo.toml +++ b/tests/unit/metrics/Cargo.toml @@ -13,7 +13,7 @@ doctest = false [dependencies] base = { workspace = true } -gfx_traits = { workspace = true } +fonts_traits = { workspace = true } ipc-channel = { workspace = true } metrics = { path = "../../../components/metrics" } profile_traits = { workspace = true }