Strict import formatting (grouping and granularity) (#30325)

* strict imports formatting

* Reformat all imports
This commit is contained in:
Samson 2023-09-11 21:16:54 +02:00 committed by GitHub
parent 413da4ca69
commit aad2dccc9c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
802 changed files with 6861 additions and 6395 deletions

View file

@ -2,6 +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/. */
use std::borrow::ToOwned;
use std::cell::RefCell;
use std::collections::HashMap;
use std::rc::Rc;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;
use std::{iter, str};
use app_units::Au;
use bitflags::bitflags;
use euclid::default::{Point2D, Rect, Size2D};
use log::debug;
use serde::{Deserialize, Serialize};
use servo_atoms::{atom, Atom};
use smallvec::SmallVec;
use style::computed_values::{font_stretch, font_style, font_variant_caps, font_weight};
use style::properties::style_structs::Font as FontStyleStruct;
use style::values::computed::font::{GenericFontFamily, SingleFontFamily};
use unicode_script::Script;
use webrender_api::FontInstanceKey;
use crate::font_context::{FontContext, FontSource};
use crate::font_template::FontTemplateDescriptor;
use crate::platform::font::{FontHandle, FontTable};
@ -11,26 +32,6 @@ use crate::platform::font_template::FontTemplateData;
use crate::text::glyph::{ByteIndex, GlyphData, GlyphId, GlyphStore};
use crate::text::shaping::ShaperMethods;
use crate::text::Shaper;
use app_units::Au;
use bitflags::bitflags;
use euclid::default::{Point2D, Rect, Size2D};
use log::debug;
use serde::{Deserialize, Serialize};
use servo_atoms::{atom, Atom};
use smallvec::SmallVec;
use std::borrow::ToOwned;
use std::cell::RefCell;
use std::collections::HashMap;
use std::iter;
use std::rc::Rc;
use std::str;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;
use style::computed_values::{font_stretch, font_style, font_variant_caps, font_weight};
use style::properties::style_structs::Font as FontStyleStruct;
use style::values::computed::font::{GenericFontFamily, SingleFontFamily};
use unicode_script::Script;
use webrender_api::FontInstanceKey;
#[macro_export]
macro_rules! ot_tag {

View file

@ -2,15 +2,12 @@
* 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/. */
use crate::font::{FontFamilyDescriptor, FontFamilyName, FontSearchScope};
use crate::font_context::FontSource;
use crate::font_template::{FontTemplate, FontTemplateDescriptor};
use crate::platform::font_context::FontContextHandle;
use crate::platform::font_list::for_each_available_family;
use crate::platform::font_list::for_each_variation;
use crate::platform::font_list::system_default_family;
use crate::platform::font_list::SANS_SERIF_FONT_FAMILY;
use crate::platform::font_template::FontTemplateData;
use std::borrow::ToOwned;
use std::collections::HashMap;
use std::ops::Deref;
use std::sync::{Arc, Mutex};
use std::{f32, fmt, mem, thread};
use app_units::Au;
use gfx_traits::{FontData, WebrenderApi};
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
@ -20,15 +17,19 @@ use net_traits::{fetch_async, CoreResourceThread, FetchResponseMsg};
use serde::{Deserialize, Serialize};
use servo_atoms::Atom;
use servo_url::ServoUrl;
use std::borrow::ToOwned;
use std::collections::HashMap;
use std::ops::Deref;
use std::sync::{Arc, Mutex};
use std::{f32, fmt, mem, thread};
use style::font_face::{EffectiveSources, Source};
use style::values::computed::font::FamilyName;
use webrender_api::{FontInstanceKey, FontKey};
use crate::font::{FontFamilyDescriptor, FontFamilyName, FontSearchScope};
use crate::font_context::FontSource;
use crate::font_template::{FontTemplate, FontTemplateDescriptor};
use crate::platform::font_context::FontContextHandle;
use crate::platform::font_list::{
for_each_available_family, for_each_variation, system_default_family, SANS_SERIF_FONT_FAMILY,
};
use crate::platform::font_template::FontTemplateData;
/// A list of font templates that make up a given font family.
pub struct FontTemplates {
templates: Vec<FontTemplate>,

View file

@ -2,6 +2,22 @@
* 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/. */
use std::cell::RefCell;
use std::collections::HashMap;
use std::default::Default;
use std::hash::{BuildHasherDefault, Hash, Hasher};
use std::rc::Rc;
use std::sync::atomic::{AtomicUsize, Ordering};
use app_units::Au;
use fnv::FnvHasher;
use log::debug;
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
use servo_arc::Arc;
use style::computed_values::font_variant_caps::T as FontVariantCaps;
use style::properties::style_structs::Font as FontStyleStruct;
use webrender_api::{FontInstanceKey, FontKey};
use crate::font::{
Font, FontDescriptor, FontFamilyDescriptor, FontGroup, FontHandleMethods, FontRef,
};
@ -9,20 +25,6 @@ use crate::font_cache_thread::FontTemplateInfo;
use crate::font_template::FontTemplateDescriptor;
use crate::platform::font::FontHandle;
pub use crate::platform::font_context::FontContextHandle;
use app_units::Au;
use fnv::FnvHasher;
use log::debug;
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
use servo_arc::Arc;
use std::cell::RefCell;
use std::collections::HashMap;
use std::default::Default;
use std::hash::{BuildHasherDefault, Hash, Hasher};
use std::rc::Rc;
use std::sync::atomic::{AtomicUsize, Ordering};
use style::computed_values::font_variant_caps::T as FontVariantCaps;
use style::properties::style_structs::Font as FontStyleStruct;
use webrender_api::{FontInstanceKey, FontKey};
static SMALL_CAPS_SCALE_FACTOR: f32 = 0.8; // Matches FireFox (see gfxFont.h)

View file

@ -2,19 +2,21 @@
* 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/. */
use std::fmt::{Debug, Error, Formatter};
use std::io::Error as IoError;
use std::sync::{Arc, Weak};
use serde::{Deserialize, Serialize};
use servo_atoms::Atom;
use style::computed_values::font_stretch::T as FontStretch;
use style::computed_values::font_style::T as FontStyle;
use style::properties::style_structs::Font as FontStyleStruct;
use style::values::computed::font::FontWeight;
use crate::font::FontHandleMethods;
use crate::platform::font::FontHandle;
use crate::platform::font_context::FontContextHandle;
use crate::platform::font_template::FontTemplateData;
use serde::{Deserialize, Serialize};
use servo_atoms::Atom;
use std::fmt::{Debug, Error, Formatter};
use std::io::Error as IoError;
use std::sync::{Arc, Weak};
use style::computed_values::font_stretch::T as FontStretch;
use style::computed_values::font_style::T as FontStyle;
use style::properties::style_structs::Font as FontStyleStruct;
use style::values::computed::font::FontWeight;
/// Describes how to select a font from a given family. This is very basic at the moment and needs
/// to be expanded or refactored when we support more of the font styling parameters.

View file

@ -2,10 +2,12 @@
* 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/. */
use std::path::Path;
use ucd::{Codepoint, UnicodeBlock};
use super::xml::{Attribute, Node};
use crate::text::util::is_cjk;
use std::path::Path;
use ucd::{Codepoint, UnicodeBlock};
lazy_static! {
static ref FONT_LIST: FontList = FontList::new();

View file

@ -2,9 +2,8 @@
* 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/. */
use xml::reader::XmlEvent::*;
pub(super) use xml::attribute::OwnedAttribute as Attribute;
use xml::reader::XmlEvent::*;
pub(super) enum Node {
Element {

View file

@ -2,35 +2,36 @@
* 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/. */
use super::c_str_to_string;
use crate::font::{FontHandleMethods, FontMetrics, FontTableMethods};
use crate::font::{FontTableTag, FractionalPixel, GPOS, GSUB, KERN};
use crate::platform::font_context::FontContextHandle;
use crate::platform::font_template::FontTemplateData;
use crate::text::glyph::GlyphId;
use crate::text::util::fixed_to_float;
use app_units::Au;
use freetype::freetype::FT_Sfnt_Tag;
use freetype::freetype::{FT_Done_Face, FT_New_Face, FT_New_Memory_Face};
use freetype::freetype::{FT_F26Dot6, FT_Face, FT_FaceRec};
use freetype::freetype::{FT_Get_Char_Index, FT_Get_Postscript_Name};
use freetype::freetype::{FT_Get_Kerning, FT_Get_Sfnt_Table, FT_Load_Sfnt_Table};
use freetype::freetype::{FT_GlyphSlot, FT_Library, FT_Long, FT_ULong};
use freetype::freetype::{FT_Int32, FT_Kerning_Mode, FT_STYLE_FLAG_ITALIC};
use freetype::freetype::{FT_Load_Glyph, FT_Set_Char_Size};
use freetype::freetype::{FT_SizeRec, FT_Size_Metrics, FT_UInt, FT_Vector};
use freetype::succeeded;
use freetype::tt_os2::TT_OS2;
use log::debug;
use servo_atoms::Atom;
use std::ffi::CString;
use std::os::raw::{c_char, c_long};
use std::sync::Arc;
use std::{mem, ptr};
use app_units::Au;
use freetype::freetype::{
FT_Done_Face, FT_F26Dot6, FT_Face, FT_FaceRec, FT_Get_Char_Index, FT_Get_Kerning,
FT_Get_Postscript_Name, FT_Get_Sfnt_Table, FT_GlyphSlot, FT_Int32, FT_Kerning_Mode, FT_Library,
FT_Load_Glyph, FT_Load_Sfnt_Table, FT_Long, FT_New_Face, FT_New_Memory_Face, FT_Set_Char_Size,
FT_Sfnt_Tag, FT_SizeRec, FT_Size_Metrics, FT_UInt, FT_ULong, FT_Vector, FT_STYLE_FLAG_ITALIC,
};
use freetype::succeeded;
use freetype::tt_os2::TT_OS2;
use log::debug;
use servo_atoms::Atom;
use style::computed_values::font_stretch::T as FontStretch;
use style::computed_values::font_weight::T as FontWeight;
use style::values::computed::font::FontStyle;
use super::c_str_to_string;
use crate::font::{
FontHandleMethods, FontMetrics, FontTableMethods, FontTableTag, FractionalPixel, GPOS, GSUB,
KERN,
};
use crate::platform::font_context::FontContextHandle;
use crate::platform::font_template::FontTemplateData;
use crate::text::glyph::GlyphId;
use crate::text::util::fixed_to_float;
// This constant is not present in the freetype
// bindings due to bindgen not handling the way
// the macro is defined.

View file

@ -2,19 +2,17 @@
* 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/. */
use freetype::freetype::FT_Add_Default_Modules;
use freetype::freetype::FT_Done_Library;
use freetype::freetype::FT_Library;
use freetype::freetype::FT_Memory;
use freetype::freetype::FT_MemoryRec_;
use freetype::freetype::FT_New_Library;
use std::os::raw::{c_long, c_void};
use std::ptr;
use std::rc::Rc;
use freetype::freetype::{
FT_Add_Default_Modules, FT_Done_Library, FT_Library, FT_Memory, FT_MemoryRec_, FT_New_Library,
};
use freetype::succeeded;
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
use servo_allocator::libc_compat::{free, malloc, realloc};
use servo_allocator::usable_size;
use std::os::raw::{c_long, c_void};
use std::ptr;
use std::rc::Rc;
// We pass a |User| struct -- via an opaque |void*| -- to FreeType each time a new instance is
// created. FreeType passes it back to the ft_alloc/ft_realloc/ft_free callbacks. We use it to

View file

@ -2,19 +2,21 @@
* 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/. */
use super::c_str_to_string;
use crate::text::util::is_cjk;
use fontconfig_sys::{FcChar8, FcResultMatch, FcSetSystem};
use fontconfig_sys::{FcConfigGetCurrent, FcConfigGetFonts, FcConfigSubstitute};
use fontconfig_sys::{FcDefaultSubstitute, FcFontMatch, FcNameParse, FcPatternGetString};
use fontconfig_sys::{FcFontSetDestroy, FcMatchPattern, FcPatternCreate, FcPatternDestroy};
use fontconfig_sys::{FcFontSetList, FcObjectSetCreate, FcObjectSetDestroy, FcPatternAddString};
use fontconfig_sys::{FcObjectSetAdd, FcPatternGetInteger};
use libc::{c_char, c_int};
use log::debug;
use std::ffi::CString;
use std::ptr;
use fontconfig_sys::{
FcChar8, FcConfigGetCurrent, FcConfigGetFonts, FcConfigSubstitute, FcDefaultSubstitute,
FcFontMatch, FcFontSetDestroy, FcFontSetList, FcMatchPattern, FcNameParse, FcObjectSetAdd,
FcObjectSetCreate, FcObjectSetDestroy, FcPatternAddString, FcPatternCreate, FcPatternDestroy,
FcPatternGetInteger, FcPatternGetString, FcResultMatch, FcSetSystem,
};
use libc::{c_char, c_int};
use log::debug;
use super::c_str_to_string;
use crate::text::util::is_cjk;
static FC_FAMILY: &'static [u8] = b"family\0";
static FC_FILE: &'static [u8] = b"file\0";
static FC_INDEX: &'static [u8] = b"index\0";

View file

@ -2,12 +2,13 @@
* 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/. */
use serde::{Deserialize, Serialize};
use servo_atoms::Atom;
use std::fmt;
use std::fs::File;
use std::io::{Error, Read};
use std::path::PathBuf;
use serde::{Deserialize, Serialize};
use servo_atoms::Atom;
use webrender_api::NativeFontHandle;
/// Platform specific font representation for Linux.

View file

@ -2,13 +2,10 @@
* 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/. */
use crate::font::{
FontHandleMethods, FontMetrics, FontTableMethods, FontTableTag, FractionalPixel,
};
use crate::font::{GPOS, GSUB, KERN};
use crate::platform::font_template::FontTemplateData;
use crate::platform::macos::font_context::FontContextHandle;
use crate::text::glyph::GlyphId;
use std::ops::Range;
use std::sync::Arc;
use std::{fmt, ptr};
/// Implementation of Quartz (CoreGraphics) fonts.
use app_units::Au;
use byteorder::{BigEndian, ByteOrder};
@ -18,15 +15,21 @@ use core_foundation::string::UniChar;
use core_graphics::font::CGGlyph;
use core_graphics::geometry::CGRect;
use core_text::font::CTFont;
use core_text::font_descriptor::kCTFontDefaultOrientation;
use core_text::font_descriptor::{SymbolicTraitAccessors, TraitAccessors};
use core_text::font_descriptor::{
kCTFontDefaultOrientation, SymbolicTraitAccessors, TraitAccessors,
};
use log::debug;
use servo_atoms::Atom;
use std::ops::Range;
use std::sync::Arc;
use std::{fmt, ptr};
use style::values::computed::font::{FontStretch, FontStyle, FontWeight};
use crate::font::{
FontHandleMethods, FontMetrics, FontTableMethods, FontTableTag, FractionalPixel, GPOS, GSUB,
KERN,
};
use crate::platform::font_template::FontTemplateData;
use crate::platform::macos::font_context::FontContextHandle;
use crate::text::glyph::GlyphId;
const KERN_PAIR_LEN: usize = 6;
pub struct FontTable {

View file

@ -2,10 +2,11 @@
* 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/. */
use crate::text::util::unicode_plane;
use log::debug;
use ucd::{Codepoint, UnicodeBlock};
use crate::text::util::unicode_plane;
pub fn for_each_available_family<F>(mut callback: F)
where
F: FnMut(String),

View file

@ -2,6 +2,15 @@
* 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/. */
use std::borrow::ToOwned;
use std::collections::HashMap;
use std::fmt;
use std::fs::{self, File};
use std::io::{Error as IoError, Read};
use std::ops::Deref;
use std::path::Path;
use std::sync::{Arc, Mutex, RwLock};
use app_units::Au;
use core_foundation::array::CFArray;
use core_foundation::base::{CFType, TCFType};
@ -10,20 +19,11 @@ use core_foundation::string::CFString;
use core_graphics::data_provider::CGDataProvider;
use core_graphics::font::CGFont;
use core_text::font::CTFont;
use core_text::font_collection;
use core_text::font_descriptor;
use core_text::{font_collection, font_descriptor};
use serde::de::{Error, Visitor};
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use servo_atoms::Atom;
use servo_url::ServoUrl;
use std::borrow::ToOwned;
use std::collections::HashMap;
use std::fmt;
use std::fs::{self, File};
use std::io::{Error as IoError, Read};
use std::ops::Deref;
use std::path::Path;
use std::sync::{Arc, Mutex, RwLock};
use webrender_api::NativeFontHandle;
/// Platform specific font representation for mac.

View file

@ -4,22 +4,20 @@
#[cfg(any(target_os = "linux", target_os = "android"))]
pub use crate::platform::freetype::{font, font_context};
#[cfg(any(target_os = "linux", target_os = "android"))]
pub use crate::platform::freetype::{font_list, font_template};
#[cfg(target_os = "macos")]
pub use crate::platform::macos::{font, font_context, font_list, font_template};
#[cfg(target_os = "windows")]
pub use crate::platform::windows::{font, font_context, font_list, font_template};
#[cfg(target_os = "macos")]
pub use crate::platform::macos::{font, font_context, font_list, font_template};
#[cfg(any(target_os = "linux", target_os = "android"))]
mod freetype {
use libc::c_char;
use std::ffi::CStr;
use std::str;
use libc::c_char;
/// Creates a String from the given null-terminated buffer.
/// Panics if the buffer does not contain UTF-8.
unsafe fn c_str_to_string(s: *const c_char) -> String {

View file

@ -6,20 +6,14 @@
// information for an approach that we'll likely need to take when the
// renderer moves to a sandboxed process.
use crate::font::{FontHandleMethods, FontMetrics, FontTableMethods};
use crate::font::{FontTableTag, FractionalPixel};
use crate::platform::font_template::FontTemplateData;
use crate::platform::windows::font_context::FontContextHandle;
use crate::platform::windows::font_list::font_from_atom;
use crate::text::glyph::GlyphId;
use app_units::Au;
use dwrote::{Font, FontFace, FontFile};
use dwrote::{FontStretch, FontStyle};
use log::debug;
use servo_atoms::Atom;
use std::fmt;
use std::ops::Deref;
use std::sync::Arc;
use app_units::Au;
use dwrote::{Font, FontFace, FontFile, FontStretch, FontStyle};
use log::debug;
use servo_atoms::Atom;
use style::computed_values::font_stretch::T as StyleFontStretch;
use style::computed_values::font_weight::T as StyleFontWeight;
use style::values::computed::font::FontStyle as StyleFontStyle;
@ -27,6 +21,14 @@ use style::values::generics::font::FontStyle as GenericFontStyle;
use style::values::generics::NonNegative;
use style::values::specified::font::FontStretchKeyword;
use crate::font::{
FontHandleMethods, FontMetrics, FontTableMethods, FontTableTag, FractionalPixel,
};
use crate::platform::font_template::FontTemplateData;
use crate::platform::windows::font_context::FontContextHandle;
use crate::platform::windows::font_list::font_from_atom;
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 {
pt / 72. * 96.
@ -88,6 +90,7 @@ impl FontInfo {
use std::cmp::{max, min};
use std::collections::HashMap;
use std::io::Cursor;
use truetype::naming_table::{NameID, NamingTable};
use truetype::{Value, WindowsMetrics};

View file

@ -2,15 +2,17 @@
* 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/. */
use crate::text::util::unicode_plane;
use dwrote::{Font, FontCollection, FontDescriptor};
use lazy_static::lazy_static;
use servo_atoms::Atom;
use std::collections::HashMap;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Mutex;
use dwrote::{Font, FontCollection, FontDescriptor};
use lazy_static::lazy_static;
use servo_atoms::Atom;
use ucd::{Codepoint, UnicodeBlock};
use crate::text::util::unicode_plane;
lazy_static! {
static ref FONT_ATOM_COUNTER: AtomicUsize = AtomicUsize::new(1);
static ref FONT_ATOM_MAP: Mutex<HashMap<Atom, FontDescriptor>> = Mutex::new(HashMap::new());

View file

@ -2,13 +2,14 @@
* 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/. */
use crate::platform::windows::font_list::font_from_atom;
use std::{fmt, io};
use serde::{Deserialize, Serialize};
use servo_atoms::Atom;
use std::fmt;
use std::io;
use webrender_api::NativeFontHandle;
use crate::platform::windows::font_list::font_from_atom;
#[derive(Deserialize, Serialize)]
pub struct FontTemplateData {
// If you add members here, review the Debug impl below

View file

@ -2,6 +2,13 @@
* 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/. */
use std::cell::Cell;
use std::collections::HashMap;
use std::fs::File;
use std::io::prelude::*;
use std::path::PathBuf;
use std::rc::Rc;
use app_units::Au;
use gfx::font::{
fallback_font_families, FontDescriptor, FontFamilyDescriptor, FontFamilyName, FontSearchScope,
@ -11,18 +18,12 @@ use gfx::font_context::{FontContext, FontContextHandle, FontSource};
use gfx::font_template::FontTemplateDescriptor;
use servo_arc::Arc;
use servo_atoms::Atom;
use std::cell::Cell;
use std::collections::HashMap;
use std::fs::File;
use std::io::prelude::*;
use std::path::PathBuf;
use std::rc::Rc;
use style::properties::longhands::font_variant_caps::computed_value::T as FontVariantCaps;
use style::properties::style_structs::Font as FontStyleStruct;
use style::values::computed::font::{
FamilyName, FontFamily, FontFamilyList, FontFamilyNameSyntax, FontSize,
FamilyName, FontFamily, FontFamilyList, FontFamilyNameSyntax, FontSize, FontStretch,
FontWeight, SingleFontFamily,
};
use style::values::computed::font::{FontStretch, FontWeight, SingleFontFamily};
use style::values::generics::font::FontStyle;
use webrender_api::{FontInstanceKey, FontKey, IdNamespace};

View file

@ -6,12 +6,13 @@
#[cfg(not(target_os = "macos"))]
#[test]
fn test_font_template_descriptor() {
use gfx::font_context::FontContextHandle;
use gfx::font_template::{FontTemplate, FontTemplateDescriptor};
use servo_atoms::Atom;
use std::fs::File;
use std::io::prelude::*;
use std::path::PathBuf;
use gfx::font_context::FontContextHandle;
use gfx::font_template::{FontTemplate, FontTemplateDescriptor};
use servo_atoms::Atom;
use style::values::computed::font::{FontStretch, FontWeight};
use style::values::computed::Percentage;
use style::values::generics::font::FontStyle;

View file

@ -2,16 +2,16 @@
* 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/. */
use app_units::Au;
use euclid::default::Point2D;
use log::debug;
use range::{self, EachIndex, Range, RangeIndex};
use serde::{Deserialize, Serialize};
use std::cmp::{Ordering, PartialOrd};
use std::vec::Vec;
use std::{fmt, mem, u16};
use app_units::Au;
use euclid::default::Point2D;
pub use gfx_traits::ByteIndex;
use log::debug;
use range::{self, EachIndex, Range, RangeIndex};
use serde::{Deserialize, Serialize};
/// GlyphEntry is a port of Gecko's CompressedGlyph scheme for storing glyph data compactly.
///

View file

@ -4,45 +4,33 @@
#![allow(unsafe_code)]
use std::os::raw::{c_char, c_int, c_uint, c_void};
use std::{char, cmp, ptr};
use app_units::Au;
use euclid::default::Point2D;
// Eventually we would like the shaper to be pluggable, as many operating systems have their own
// shapers. For now, however, HarfBuzz is a hard dependency.
use harfbuzz_sys::hb_blob_t;
use harfbuzz_sys::{
hb_blob_create, hb_bool_t, hb_buffer_add_utf8, hb_buffer_create, hb_buffer_destroy,
hb_buffer_get_glyph_infos, hb_buffer_get_glyph_positions, hb_buffer_get_length,
hb_buffer_set_direction, hb_buffer_set_script, hb_buffer_t, hb_codepoint_t,
hb_face_create_for_tables, hb_face_destroy, hb_face_t, hb_feature_t, hb_font_create,
hb_font_destroy, hb_font_funcs_create, hb_font_funcs_set_glyph_h_advance_func,
hb_font_funcs_set_nominal_glyph_func, hb_font_funcs_t, hb_font_set_funcs, hb_font_set_ppem,
hb_font_set_scale, hb_font_t, hb_glyph_info_t, hb_glyph_position_t, hb_position_t, hb_shape,
hb_tag_t, HB_DIRECTION_LTR, HB_DIRECTION_RTL, HB_MEMORY_MODE_READONLY,
};
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, is_bidi_control};
use app_units::Au;
use euclid::default::Point2D;
// Eventually we would like the shaper to be pluggable, as many operating systems have their own
// shapers. For now, however, HarfBuzz is a hard dependency.
use harfbuzz_sys::hb_blob_t;
use harfbuzz_sys::hb_bool_t;
use harfbuzz_sys::hb_buffer_add_utf8;
use harfbuzz_sys::hb_buffer_destroy;
use harfbuzz_sys::hb_buffer_get_glyph_positions;
use harfbuzz_sys::hb_buffer_get_length;
use harfbuzz_sys::hb_face_destroy;
use harfbuzz_sys::hb_feature_t;
use harfbuzz_sys::hb_font_create;
use harfbuzz_sys::hb_font_funcs_create;
use harfbuzz_sys::hb_font_funcs_set_glyph_h_advance_func;
use harfbuzz_sys::hb_font_funcs_set_nominal_glyph_func;
use harfbuzz_sys::hb_font_set_funcs;
use harfbuzz_sys::hb_font_set_ppem;
use harfbuzz_sys::hb_font_set_scale;
use harfbuzz_sys::hb_glyph_info_t;
use harfbuzz_sys::hb_glyph_position_t;
use harfbuzz_sys::{hb_blob_create, hb_face_create_for_tables};
use harfbuzz_sys::{hb_buffer_create, hb_font_destroy};
use harfbuzz_sys::{hb_buffer_get_glyph_infos, hb_shape};
use harfbuzz_sys::{hb_buffer_set_direction, hb_buffer_set_script};
use harfbuzz_sys::{hb_buffer_t, hb_codepoint_t, hb_font_funcs_t};
use harfbuzz_sys::{hb_face_t, hb_font_t};
use harfbuzz_sys::{hb_position_t, hb_tag_t};
use harfbuzz_sys::{HB_DIRECTION_LTR, HB_DIRECTION_RTL, HB_MEMORY_MODE_READONLY};
use lazy_static::lazy_static;
use log::debug;
use std::os::raw::{c_char, c_int, c_uint, c_void};
use std::{char, cmp, ptr};
const NO_GLYPH: i32 = -1;
const LIGA: u32 = ot_tag!('l', 'i', 'g', 'a');

View file

@ -7,11 +7,10 @@
//!
//! Currently, only harfbuzz bindings are implemented.
pub use self::harfbuzz::Shaper;
use crate::font::ShapingOptions;
use crate::text::glyph::GlyphStore;
pub use self::harfbuzz::Shaper;
pub mod harfbuzz;
pub trait ShaperMethods {

View file

@ -2,23 +2,24 @@
* 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/. */
use crate::font::{Font, FontHandleMethods, FontMetrics, ShapingFlags};
use crate::font::{RunMetrics, ShapingOptions};
use crate::platform::font_template::FontTemplateData;
use crate::text::glyph::{ByteIndex, GlyphStore};
use app_units::Au;
use log::debug;
use range::Range;
use serde::{Deserialize, Serialize};
use std::cell::Cell;
use std::cmp::{max, Ordering};
use std::slice::Iter;
use std::sync::Arc;
use app_units::Au;
use log::debug;
use range::Range;
use serde::{Deserialize, Serialize};
use style::str::char_is_whitespace;
use unicode_bidi as bidi;
use webrender_api::FontInstanceKey;
use xi_unicode::LineBreakLeafIter;
use crate::font::{Font, FontHandleMethods, FontMetrics, RunMetrics, ShapingFlags, ShapingOptions};
use crate::platform::font_template::FontTemplateData;
use crate::text::glyph::{ByteIndex, GlyphStore};
thread_local! {
static INDEX_OF_FIRST_GLYPH_RUN_CACHE: Cell<Option<(*const TextRun, ByteIndex, usize)>> =
Cell::new(None)