mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Rename gfx
to fonts
(#32556)
This crate only takes care of fonts now as graphics related things are split into other crates. In addition, this exposes data structures at the top of the crate, hiding the implementation details and making it simpler to import them. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
This commit is contained in:
parent
9f8118abc7
commit
cd2ab36759
159 changed files with 224 additions and 266 deletions
170
Cargo.lock
generated
170
Cargo.lock
generated
|
@ -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",
|
||||
|
|
|
@ -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"] }
|
||||
|
|
|
@ -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 }
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 }
|
||||
|
|
|
@ -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 }
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 }
|
|
@ -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 {
|
|
@ -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;
|
|
@ -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};
|
|
@ -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)
|
||||
}
|
|
@ -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();
|
|
@ -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
|
|
@ -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)]
|
|
@ -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();
|
|
@ -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;
|
||||
|
|
@ -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
|
|
@ -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 {
|
|
@ -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 {
|
|
@ -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";
|
||||
|
|
@ -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,
|
|
@ -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,
|
|
@ -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};
|
||||
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue