mirror of
https://github.com/servo/servo.git
synced 2025-08-12 08:55:32 +01:00
Strict import formatting (grouping and granularity) (#30325)
* strict imports formatting * Reformat all imports
This commit is contained in:
parent
413da4ca69
commit
aad2dccc9c
802 changed files with 6861 additions and 6395 deletions
|
@ -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();
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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};
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue