diff --git a/components/fonts/font.rs b/components/fonts/font.rs index 2677e5ef9cb..5a787fd6ea4 100644 --- a/components/fonts/font.rs +++ b/components/fonts/font.rs @@ -13,7 +13,7 @@ use std::{iter, str}; use app_units::Au; use bitflags::bitflags; -use euclid::default::{Point2D, Rect, Size2D}; +use euclid::default::{Point2D, Rect}; use euclid::num::Zero; use fonts_traits::FontDescriptor; use log::debug; @@ -33,21 +33,21 @@ use unicode_script::Script; use webrender_api::{FontInstanceFlags, FontInstanceKey, FontVariation}; use crate::platform::font::{FontTable, PlatformFont}; -pub use crate::platform::font_list::fallback_font_families; +use crate::platform::font_list::fallback_font_families; use crate::{ ByteIndex, EmojiPresentationPreference, FallbackFontSelectionOptions, FontContext, FontData, FontDataAndIndex, FontDataError, FontIdentifier, FontTemplateDescriptor, FontTemplateRef, FontTemplateRefMethods, GlyphData, GlyphId, GlyphStore, LocalFontIdentifier, Shaper, }; -pub const GPOS: Tag = Tag::new(b"GPOS"); -pub const GSUB: Tag = Tag::new(b"GSUB"); -pub const KERN: Tag = Tag::new(b"kern"); -pub const SBIX: Tag = Tag::new(b"sbix"); -pub const CBDT: Tag = Tag::new(b"CBDT"); -pub const COLR: Tag = Tag::new(b"COLR"); -pub const BASE: Tag = Tag::new(b"BASE"); -pub const LIGA: Tag = Tag::new(b"liga"); +pub(crate) const GPOS: Tag = Tag::new(b"GPOS"); +pub(crate) const GSUB: Tag = Tag::new(b"GSUB"); +pub(crate) const KERN: Tag = Tag::new(b"kern"); +pub(crate) const SBIX: Tag = Tag::new(b"sbix"); +pub(crate) const CBDT: Tag = Tag::new(b"CBDT"); +pub(crate) const COLR: Tag = Tag::new(b"COLR"); +pub(crate) const BASE: Tag = Tag::new(b"BASE"); +pub(crate) const LIGA: Tag = Tag::new(b"liga"); pub const LAST_RESORT_GLYPH_ADVANCE: FractionalPixel = 10.0; @@ -140,9 +140,9 @@ pub trait PlatformFontMethods: Sized { } // Used to abstract over the shaper's choice of fixed int representation. -pub type FractionalPixel = f64; +pub(crate) type FractionalPixel = f64; -pub trait FontTableMethods { +pub(crate) trait FontTableMethods { fn buffer(&self) -> &[u8]; } @@ -212,8 +212,8 @@ impl malloc_size_of::MallocSizeOf for CachedShapeData { } pub struct Font { - pub handle: PlatformFont, - pub template: FontTemplateRef, + pub(crate) handle: PlatformFont, + pub(crate) template: FontTemplateRef, pub metrics: FontMetrics, pub descriptor: FontDescriptor, @@ -223,12 +223,12 @@ pub struct Font { shaper: OnceLock, cached_shape_data: RwLock, - pub font_instance_key: OnceLock, + pub(crate) font_instance_key: OnceLock, /// If this is a synthesized small caps font, then this font reference is for /// the version of the font used to replace lowercase ASCII letters. It's up /// to the consumer of this font to properly use this reference. - pub synthesized_small_caps: Option, + pub(crate) synthesized_small_caps: Option, /// Whether or not this font supports color bitmaps or a COLR table. This is /// essentially equivalent to whether or not we use it for emoji presentation. @@ -294,11 +294,11 @@ impl Font { self.template.identifier() } - pub fn webrender_font_instance_flags(&self) -> FontInstanceFlags { + pub(crate) fn webrender_font_instance_flags(&self) -> FontInstanceFlags { self.handle.webrender_font_instance_flags() } - pub fn has_color_bitmap_or_colr_table(&self) -> bool { + pub(crate) fn has_color_bitmap_or_colr_table(&self) -> bool { *self.has_color_bitmap_or_colr_table.get_or_init(|| { self.table_for_tag(SBIX).is_some() || self.table_for_tag(CBDT).is_some() || @@ -330,7 +330,7 @@ impl Font { Ok(data_and_index) } - pub fn variations(&self) -> &[FontVariation] { + pub(crate) fn variations(&self) -> &[FontVariation] { self.handle.variations() } } @@ -471,7 +471,7 @@ impl Font { glyphs.finalize_changes(); } - pub fn table_for_tag(&self, tag: Tag) -> Option { + pub(crate) fn table_for_tag(&self, tag: Tag) -> Option { let result = self.handle.table_for_tag(tag); let status = if result.is_some() { "Found" @@ -507,11 +507,15 @@ impl Font { glyph_index } - pub fn has_glyph_for(&self, codepoint: char) -> bool { + pub(crate) fn has_glyph_for(&self, codepoint: char) -> bool { self.glyph_index(codepoint).is_some() } - pub fn glyph_h_kerning(&self, first_glyph: GlyphId, second_glyph: GlyphId) -> FractionalPixel { + pub(crate) fn glyph_h_kerning( + &self, + first_glyph: GlyphId, + second_glyph: GlyphId, + ) -> FractionalPixel { self.handle.glyph_h_kerning(first_glyph, second_glyph) } @@ -564,7 +568,7 @@ pub struct FontGroup { } impl FontGroup { - pub fn new(style: &FontStyleStruct, descriptor: FontDescriptor) -> FontGroup { + pub(crate) fn new(style: &FontStyleStruct, descriptor: FontDescriptor) -> FontGroup { let families: SmallVec<[FontGroupFamily; 8]> = style .font_family .families @@ -829,41 +833,6 @@ impl FontGroupFamily { } } -pub struct RunMetrics { - // may be negative due to negative width (i.e., kerning of '.' in 'P.T.') - pub advance_width: Au, - pub ascent: Au, // nonzero - pub descent: Au, // nonzero - // this bounding box is relative to the left origin baseline. - // so, bounding_box.position.y = -ascent - pub bounding_box: Rect, -} - -impl RunMetrics { - pub fn new(advance: Au, ascent: Au, descent: Au) -> RunMetrics { - let bounds = Rect::new( - Point2D::new(Au::zero(), -ascent), - Size2D::new(advance, ascent + descent), - ); - - // TODO(Issue #125): support loose and tight bounding boxes; using the - // ascent+descent and advance is sometimes too generous and - // looking at actual glyph extents can yield a tighter box. - - RunMetrics { - advance_width: advance, - bounding_box: bounds, - ascent, - descent, - } - } -} - -/// Get the number of nanoseconds spent shaping text across all threads. -pub fn get_and_reset_text_shaping_performance_counter() -> usize { - TEXT_SHAPING_PERFORMANCE_COUNTER.swap(0, Ordering::SeqCst) -} - /// The scope within which we will look for a font. #[derive(Clone, Debug, Deserialize, Eq, Hash, MallocSizeOf, PartialEq, Serialize)] pub enum FontSearchScope { @@ -877,8 +846,8 @@ pub enum FontSearchScope { /// The font family parameters for font selection. #[derive(Clone, Debug, Deserialize, Eq, Hash, MallocSizeOf, PartialEq, Serialize)] pub struct FontFamilyDescriptor { - pub family: SingleFontFamily, - pub scope: FontSearchScope, + pub(crate) family: SingleFontFamily, + pub(crate) scope: FontSearchScope, } impl FontFamilyDescriptor { diff --git a/components/fonts/font_context.rs b/components/fonts/font_context.rs index 01e79e8eb7a..9b124cde24f 100644 --- a/components/fonts/font_context.rs +++ b/components/fonts/font_context.rs @@ -45,7 +45,7 @@ use crate::{FontData, LowercaseFontFamilyName, PlatformFontMethods, SystemFontSe static SMALL_CAPS_SCALE_FACTOR: f32 = 0.8; // Matches FireFox (see gfxFont.h) -pub type FontParameters = (FontKey, Au, Vec); +pub(crate) type FontParameters = (FontKey, Au, Vec); #[derive(MallocSizeOf)] struct FontGroupRef(#[conditional_malloc_size_of] Arc>); @@ -749,7 +749,7 @@ impl FontContext { } } -pub type ScriptWebFontLoadFinishedCallback = +pub(crate) type ScriptWebFontLoadFinishedCallback = Box) + Send>; pub(crate) enum WebFontLoadInitiator { diff --git a/components/fonts/font_store.rs b/components/fonts/font_store.rs index 869a6def9ca..99c925f6960 100644 --- a/components/fonts/font_store.rs +++ b/components/fonts/font_store.rs @@ -17,7 +17,7 @@ use style::stylesheets::DocumentStyleSheet; use style::values::computed::{FontStyle, FontWeight}; #[derive(Default, MallocSizeOf)] -pub struct FontStore { +pub(crate) struct FontStore { pub(crate) families: HashMap, web_fonts_loading_for_stylesheets: Vec<(DocumentStyleSheet, usize)>, web_fonts_loading_for_script: usize, diff --git a/components/fonts/glyph.rs b/components/fonts/glyph.rs index f5457c1127a..f03fa85f22f 100644 --- a/components/fonts/glyph.rs +++ b/components/fonts/glyph.rs @@ -11,7 +11,7 @@ use std::{fmt, mem}; use app_units::Au; use euclid::default::Point2D; use euclid::num::Zero; -pub use fonts_traits::ByteIndex; +pub(crate) use fonts_traits::ByteIndex; use itertools::Either; use log::debug; use malloc_size_of_derive::MallocSizeOf; @@ -27,7 +27,7 @@ use serde::{Deserialize, Serialize}; /// glyph offsets), we pack the glyph count into GlyphEntry, and store the other glyph information /// in DetailedGlyphStore. #[derive(Clone, Copy, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize)] -pub struct GlyphEntry { +pub(crate) struct GlyphEntry { value: u32, } @@ -72,7 +72,7 @@ impl GlyphEntry { } /// The id of a particular glyph within a font -pub type GlyphId = u32; +pub(crate) type GlyphId = u32; // TODO: make this more type-safe. @@ -316,7 +316,7 @@ impl<'a> DetailedGlyphStore { // This struct is used by GlyphStore clients to provide new glyph data. // It should be allocated on the stack and passed by reference to GlyphStore. #[derive(Clone, Copy, Debug)] -pub struct GlyphData { +pub(crate) struct GlyphData { id: GlyphId, advance: Au, offset: Point2D, @@ -326,7 +326,7 @@ pub struct GlyphData { impl GlyphData { /// Creates a new entry for one glyph. - pub fn new( + pub(crate) fn new( id: GlyphId, advance: Au, offset: Option>, @@ -367,7 +367,6 @@ impl GlyphInfo<'_> { } #[inline(always)] - // FIXME: Resolution conflicts with IteratorUtil trait so adding trailing _ pub fn advance(self) -> Au { match self { GlyphInfo::Simple(store, entry_i) => store.entry_buffer[entry_i.to_usize()].advance(), @@ -463,7 +462,7 @@ impl GlyphStore { /// Initializes the glyph store, but doesn't actually shape anything. /// /// Use the `add_*` methods to store glyph data. - pub fn new( + pub(crate) fn new( length: usize, is_whitespace: bool, ends_with_whitespace: bool, @@ -510,7 +509,7 @@ impl GlyphStore { self.total_word_separators } - pub fn finalize_changes(&mut self) { + pub(crate) fn finalize_changes(&mut self) { self.detail_store.ensure_sorted(); self.cache_total_advance_and_word_separators() } @@ -530,7 +529,12 @@ impl GlyphStore { } /// Adds a single glyph. - pub fn add_glyph_for_byte_index(&mut self, i: ByteIndex, character: char, data: &GlyphData) { + pub(crate) fn add_glyph_for_byte_index( + &mut self, + i: ByteIndex, + character: char, + data: &GlyphData, + ) { let glyph_is_compressible = is_simple_glyph_id(data.id) && is_simple_advance(data.advance) && data.offset == Point2D::zero() && @@ -567,7 +571,11 @@ impl GlyphStore { self.entry_buffer[i.to_usize()] = entry; } - pub fn add_glyphs_for_byte_index(&mut self, i: ByteIndex, data_for_glyphs: &[GlyphData]) { + pub(crate) fn add_glyphs_for_byte_index( + &mut self, + i: ByteIndex, + data_for_glyphs: &[GlyphData], + ) { assert!(i < self.len()); assert!(!data_for_glyphs.is_empty()); @@ -641,32 +649,6 @@ impl GlyphStore { }) } - // Scan the glyphs for a given range until we reach a given advance. Returns the index - // and advance of the glyph in the range at the given advance, if reached. Otherwise, returns the - // the number of glyphs and the advance for the given range. - #[inline] - pub fn range_index_of_advance( - &self, - range: &Range, - advance: Au, - extra_word_spacing: Au, - ) -> (usize, Au) { - let mut index = 0; - let mut current_advance = Au::zero(); - for glyph in self.iter_glyphs_for_byte_range(range) { - if glyph.char_is_word_separator() { - current_advance += glyph.advance() + extra_word_spacing - } else { - current_advance += glyph.advance() - } - if current_advance > advance { - break; - } - index += 1; - } - (index, current_advance) - } - #[inline] pub fn advance_for_byte_range(&self, range: &Range, extra_word_spacing: Au) -> Au { if range.begin() == ByteIndex(0) && range.end() == self.len() { @@ -677,7 +659,7 @@ impl GlyphStore { } #[inline] - pub fn advance_for_byte_range_simple_glyphs( + pub(crate) fn advance_for_byte_range_simple_glyphs( &self, range: &Range, extra_word_spacing: Au, @@ -692,20 +674,10 @@ impl GlyphStore { }) } - pub fn char_is_word_separator(&self, i: ByteIndex) -> bool { + pub(crate) fn char_is_word_separator(&self, i: ByteIndex) -> bool { assert!(i < self.len()); self.entry_buffer[i.to_usize()].char_is_word_separator() } - - pub fn word_separator_count_in_range(&self, range: &Range) -> u32 { - let mut spaces = 0; - for index in range.each_index() { - if self.char_is_word_separator(index) { - spaces += 1 - } - } - spaces - } } impl fmt::Debug for GlyphStore { @@ -751,16 +723,6 @@ pub struct GlyphRun { } impl GlyphRun { - pub fn compare(&self, key: &ByteIndex) -> Ordering { - if *key < self.range.begin() { - Ordering::Greater - } else if *key >= self.range.end() { - Ordering::Less - } else { - Ordering::Equal - } - } - #[inline] pub fn is_single_preserved_newline(&self) -> bool { self.glyph_store.is_single_preserved_newline diff --git a/components/fonts/lib.rs b/components/fonts/lib.rs index 19080c456f5..bbaeeba66f3 100644 --- a/components/fonts/lib.rs +++ b/components/fonts/lib.rs @@ -9,23 +9,31 @@ mod font_context; mod font_store; mod glyph; #[allow(unsafe_code)] -pub mod platform; +pub mod platform; // Public because integration tests need this mod shapers; mod system_font_service; -pub use font::*; -pub use font_context::*; -pub use font_store::*; -pub use fonts_traits::{LocalFontIdentifier, *}; -pub use glyph::*; -pub use shapers::*; -pub use system_font_service::*; +pub(crate) use font::*; +// These items are not meant to be part of the public API but are used for integration tests +pub use font::{Font, FontFamilyDescriptor, FontSearchScope, PlatformFontMethods}; +pub use font::{ + FontBaseline, FontGroup, FontMetrics, FontRef, LAST_RESORT_GLYPH_ADVANCE, ShapingFlags, + ShapingOptions, +}; +pub use font_context::{FontContext, FontContextWebFontMethods}; +pub use font_store::FontTemplates; +pub use fonts_traits::*; +pub(crate) use glyph::*; +pub use glyph::{GlyphInfo, GlyphRun, GlyphStore}; +pub use platform::font_list::fallback_font_families; +pub(crate) use shapers::*; +pub use system_font_service::SystemFontService; use unicode_properties::{EmojiStatus, UnicodeEmoji, emoji}; /// 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)] -pub enum EmojiPresentationPreference { +pub(crate) enum EmojiPresentationPreference { None, Text, Emoji, @@ -33,8 +41,8 @@ pub enum EmojiPresentationPreference { #[derive(Clone, Copy, Debug)] pub struct FallbackFontSelectionOptions { - pub character: char, - pub presentation_preference: EmojiPresentationPreference, + pub(crate) character: char, + pub(crate) presentation_preference: EmojiPresentationPreference, } impl Default for FallbackFontSelectionOptions { @@ -47,7 +55,7 @@ impl Default for FallbackFontSelectionOptions { } impl FallbackFontSelectionOptions { - pub fn new(character: char, next_character: Option) -> Self { + pub(crate) fn new(character: char, next_character: Option) -> Self { let presentation_preference = match next_character { Some(next_character) if emoji::is_emoji_presentation_selector(next_character) => { EmojiPresentationPreference::Emoji diff --git a/components/fonts/platform/freetype/android/font_list.rs b/components/fonts/platform/freetype/android/font_list.rs index cfa86b5f91a..f8bf939eebd 100644 --- a/components/fonts/platform/freetype/android/font_list.rs +++ b/components/fonts/platform/freetype/android/font_list.rs @@ -413,7 +413,7 @@ impl FontList { } // Functions used by SystemFontSerivce -pub fn for_each_available_family(mut callback: F) +pub(crate) fn for_each_available_family(mut callback: F) where F: FnMut(String), { @@ -425,7 +425,7 @@ where } } -pub fn for_each_variation(family_name: &str, mut callback: F) +pub(crate) fn for_each_variation(family_name: &str, mut callback: F) where F: FnMut(FontTemplate), { @@ -534,7 +534,9 @@ pub fn fallback_font_families(options: FallbackFontSelectionOptions) -> Vec<&'st families } -pub fn default_system_generic_font_family(generic: GenericFontFamily) -> LowercaseFontFamilyName { +pub(crate) fn default_system_generic_font_family( + generic: GenericFontFamily, +) -> LowercaseFontFamilyName { match generic { GenericFontFamily::None | GenericFontFamily::Serif => "serif", GenericFontFamily::SansSerif => "sans-serif", diff --git a/components/fonts/platform/freetype/font_list.rs b/components/fonts/platform/freetype/font_list.rs index 030b786fb27..585daa84177 100644 --- a/components/fonts/platform/freetype/font_list.rs +++ b/components/fonts/platform/freetype/font_list.rs @@ -34,7 +34,7 @@ use crate::{ LowercaseFontFamilyName, }; -pub fn for_each_available_family(mut callback: F) +pub(crate) fn for_each_available_family(mut callback: F) where F: FnMut(String), { @@ -69,7 +69,7 @@ where } } -pub fn for_each_variation(family_name: &str, mut callback: F) +pub(crate) fn for_each_variation(family_name: &str, mut callback: F) where F: FnMut(FontTemplate), { @@ -180,7 +180,9 @@ pub fn fallback_font_families(options: FallbackFontSelectionOptions) -> Vec<&'st families } -pub fn default_system_generic_font_family(generic: GenericFontFamily) -> LowercaseFontFamilyName { +pub(crate) fn default_system_generic_font_family( + generic: GenericFontFamily, +) -> LowercaseFontFamilyName { let generic_string = match generic { GenericFontFamily::None | GenericFontFamily::Serif => "serif", GenericFontFamily::SansSerif => "sans-serif", diff --git a/components/fonts/platform/freetype/library_handle.rs b/components/fonts/platform/freetype/library_handle.rs index caadc280941..f11768623fb 100644 --- a/components/fonts/platform/freetype/library_handle.rs +++ b/components/fonts/platform/freetype/library_handle.rs @@ -53,7 +53,7 @@ extern "C" fn ft_realloc( /// dropped during execution. #[derive(Clone, Debug)] pub(crate) struct FreeTypeLibraryHandle { - pub freetype_library: FT_Library, + pub(crate) freetype_library: FT_Library, freetype_memory: FT_Memory, } diff --git a/components/fonts/platform/freetype/ohos/font_list.rs b/components/fonts/platform/freetype/ohos/font_list.rs index e35bce5b226..f3776f951b7 100644 --- a/components/fonts/platform/freetype/ohos/font_list.rs +++ b/components/fonts/platform/freetype/ohos/font_list.rs @@ -425,7 +425,7 @@ impl FontList { } // Functions used by SystemFontService -pub fn for_each_available_family(mut callback: F) +pub(crate) fn for_each_available_family(mut callback: F) where F: FnMut(String), { @@ -437,7 +437,7 @@ where } } -pub fn for_each_variation(family_name: &str, mut callback: F) +pub(crate) fn for_each_variation(family_name: &str, mut callback: F) where F: FnMut(FontTemplate), { @@ -565,7 +565,9 @@ pub fn fallback_font_families(options: FallbackFontSelectionOptions) -> Vec<&'st families } -pub fn default_system_generic_font_family(generic: GenericFontFamily) -> LowercaseFontFamilyName { +pub(crate) fn default_system_generic_font_family( + generic: GenericFontFamily, +) -> LowercaseFontFamilyName { let default_font = "HarmonyOS Sans".into(); match generic { GenericFontFamily::Monospace => { diff --git a/components/fonts/platform/macos/font.rs b/components/fonts/platform/macos/font.rs index 4d7ef164b7e..206e3c9b15e 100644 --- a/components/fonts/platform/macos/font.rs +++ b/components/fonts/platform/macos/font.rs @@ -42,7 +42,7 @@ fn pt_to_px(pt: f64) -> f64 { } impl FontTable { - pub fn wrap(data: CFData) -> FontTable { + pub(crate) fn wrap(data: CFData) -> FontTable { FontTable { data } } } diff --git a/components/fonts/platform/macos/font_list.rs b/components/fonts/platform/macos/font_list.rs index ac41ffefad7..b910a795aed 100644 --- a/components/fonts/platform/macos/font_list.rs +++ b/components/fonts/platform/macos/font_list.rs @@ -16,7 +16,7 @@ use crate::{ FontTemplateDescriptor, LowercaseFontFamilyName, }; -pub fn for_each_available_family(mut callback: F) +pub(crate) fn for_each_available_family(mut callback: F) where F: FnMut(String), { @@ -26,7 +26,7 @@ where } } -pub fn for_each_variation(family_name: &str, mut callback: F) +pub(crate) fn for_each_variation(family_name: &str, mut callback: F) where F: FnMut(FontTemplate), { @@ -175,7 +175,9 @@ pub fn fallback_font_families(options: FallbackFontSelectionOptions) -> Vec<&'st families } -pub fn default_system_generic_font_family(generic: GenericFontFamily) -> LowercaseFontFamilyName { +pub(crate) fn default_system_generic_font_family( + generic: GenericFontFamily, +) -> LowercaseFontFamilyName { match generic { GenericFontFamily::None | GenericFontFamily::Serif => "Times", GenericFontFamily::SansSerif => "Helvetica", diff --git a/components/fonts/platform/windows/font.rs b/components/fonts/platform/windows/font.rs index 9e2cc277835..08bebd66d0e 100644 --- a/components/fonts/platform/windows/font.rs +++ b/components/fonts/platform/windows/font.rs @@ -49,7 +49,7 @@ pub struct FontTable { } impl FontTable { - pub fn wrap(data: &[u8]) -> FontTable { + pub(crate) fn wrap(data: &[u8]) -> FontTable { FontTable { data: data.to_vec(), } diff --git a/components/fonts/platform/windows/font_list.rs b/components/fonts/platform/windows/font_list.rs index cbf6560af47..24cb4efdf4c 100644 --- a/components/fonts/platform/windows/font_list.rs +++ b/components/fonts/platform/windows/font_list.rs @@ -16,7 +16,7 @@ use crate::{ FontTemplateDescriptor, LowercaseFontFamilyName, }; -pub fn for_each_available_family(mut callback: F) +pub(crate) fn for_each_available_family(mut callback: F) where F: FnMut(String), { @@ -28,7 +28,7 @@ where } } -pub fn for_each_variation(family_name: &str, mut callback: F) +pub(crate) fn for_each_variation(family_name: &str, mut callback: F) where F: FnMut(FontTemplate), { @@ -338,7 +338,9 @@ fn font_template_descriptor_from_font(font: &Font) -> FontTemplateDescriptor { FontTemplateDescriptor::new(weight, stretch, style) } -pub fn default_system_generic_font_family(generic: GenericFontFamily) -> LowercaseFontFamilyName { +pub(crate) fn default_system_generic_font_family( + generic: GenericFontFamily, +) -> LowercaseFontFamilyName { match generic { GenericFontFamily::None | GenericFontFamily::Serif => "Times New Roman", GenericFontFamily::SansSerif => "Arial", diff --git a/components/fonts/shapers/harfbuzz.rs b/components/fonts/shapers/harfbuzz.rs index 0da7c3d1619..b1fcb3fad97 100644 --- a/components/fonts/shapers/harfbuzz.rs +++ b/components/fonts/shapers/harfbuzz.rs @@ -38,7 +38,7 @@ use crate::{ const HB_OT_TAG_DEFAULT_SCRIPT: hb_tag_t = u32::from_be_bytes(Tag::new(b"DFLT").to_be_bytes()); const HB_OT_TAG_DEFAULT_LANGUAGE: hb_tag_t = u32::from_be_bytes(Tag::new(b"dflt").to_be_bytes()); -pub struct ShapedGlyphData { +pub(crate) struct ShapedGlyphData { count: usize, buffer: *mut hb_buffer_t, glyph_infos: *mut hb_glyph_info_t, @@ -131,7 +131,7 @@ impl HarfBuzzShapedGlyphData for ShapedGlyphData { } #[derive(Debug)] -pub struct Shaper { +pub(crate) struct Shaper { hb_face: *mut hb_face_t, hb_font: *mut hb_font_t, font: *const Font, @@ -156,7 +156,7 @@ impl Drop for Shaper { } impl Shaper { - pub fn new(font: &Font) -> Shaper { + pub(crate) fn new(font: &Font) -> Shaper { unsafe { let hb_face: *mut hb_face_t = hb_face_create_for_tables( Some(font_table_func), @@ -272,13 +272,13 @@ impl Shaper { unsafe { &(*self.font) } } - pub fn shape_text(&self, text: &str, options: &ShapingOptions, glyphs: &mut GlyphStore) { + pub(crate) fn shape_text(&self, text: &str, options: &ShapingOptions, glyphs: &mut GlyphStore) { let glyph_data = self.shaped_glyph_data(text, options); let font = self.font(); super::shape_text_harfbuzz(&glyph_data, font, text, options, glyphs); } - pub fn baseline(&self) -> Option { + pub(crate) fn baseline(&self) -> Option { unsafe { (*self.font).table_for_tag(BASE)? }; let mut hanging_baseline = 0; diff --git a/components/fonts/shapers/mod.rs b/components/fonts/shapers/mod.rs index c2b0bf78b8a..c8f6fb26d83 100644 --- a/components/fonts/shapers/mod.rs +++ b/components/fonts/shapers/mod.rs @@ -9,7 +9,7 @@ use app_units::Au; use base::text::is_bidi_control; use euclid::default::Point2D; use fonts_traits::ByteIndex; -pub use harfbuzz::{ShapedGlyphData, Shaper}; +pub(crate) use harfbuzz::Shaper; use log::debug; use num_traits::Zero as _;