Struct fonts::FontContext

source ·
pub struct FontContext {
    system_font_service_proxy: Arc<SystemFontServiceProxy>,
    resource_threads: Mutex<CoreResourceThread>,
    compositor_api: Mutex<CrossProcessCompositorApi>,
    fonts: RwLock<HashMap<FontCacheKey, Option<FontRef>>>,
    resolved_font_groups: RwLock<HashMap<FontGroupCacheKey, Arc<RwLock<FontGroup>>, BuildHasherDefault<FnvHasher>>>,
    web_fonts: Arc<RwLock<FontStore>>,
    webrender_font_keys: RwLock<HashMap<FontIdentifier, FontKey>>,
    webrender_font_instance_keys: RwLock<HashMap<(FontKey, Au), FontInstanceKey>>,
    font_data: RwLock<HashMap<FontIdentifier, FontData>>,
    have_removed_web_fonts: AtomicBool,
}
Expand description

The FontContext represents the per-thread/thread state necessary for working with fonts. It is the public API used by the layout and paint code. It talks directly to the system font service where required.

Fields§

§system_font_service_proxy: Arc<SystemFontServiceProxy>§resource_threads: Mutex<CoreResourceThread>§compositor_api: Mutex<CrossProcessCompositorApi>

A sender that can send messages and receive replies from the compositor.

§fonts: RwLock<HashMap<FontCacheKey, Option<FontRef>>>

The actual instances of fonts ie a FontTemplate combined with a size and other font properties, along with the font data and a platform font instance.

§resolved_font_groups: RwLock<HashMap<FontGroupCacheKey, Arc<RwLock<FontGroup>>, BuildHasherDefault<FnvHasher>>>

A caching map between the specification of a font in CSS style and resolved FontGroup which contains information about all fonts that can be selected with that style.

§web_fonts: Arc<RwLock<FontStore>>§webrender_font_keys: RwLock<HashMap<FontIdentifier, FontKey>>

A collection of WebRender FontKeys generated for the web fonts that this FontContext controls.

§webrender_font_instance_keys: RwLock<HashMap<(FontKey, Au), FontInstanceKey>>

A collection of WebRender FontInstanceKeys generated for the web fonts that this FontContext controls.

§font_data: RwLock<HashMap<FontIdentifier, FontData>>

The data for each web font FontIdentifier. This data might be used by more than one FontTemplate as each identifier refers to a URL.

§have_removed_web_fonts: AtomicBool

Implementations§

source§

impl FontContext

source

pub fn new( system_font_service_proxy: Arc<SystemFontServiceProxy>, compositor_api: CrossProcessCompositorApi, resource_threads: ResourceThreads, ) -> Self

source

pub fn web_fonts_still_loading(&self) -> usize

source

fn get_font_data(&self, identifier: &FontIdentifier) -> Option<FontData>

source

fn handle_web_font_load_finished( &self, finished_callback: &WebFontLoadFinishedCallback, succeeded: bool, )

Handle the situation where a web font finishes loading, specifying if the load suceeded or failed.

source

pub fn font_group( &self, style: ServoArc<FontStyleStruct>, ) -> Arc<RwLock<FontGroup>>

Returns a FontGroup representing fonts which can be used for layout, given the style. Font groups are cached, so subsequent calls with the same style will return a reference to an existing FontGroup.

source

pub fn font_group_with_size( &self, style: ServoArc<FontStyleStruct>, size: Au, ) -> Arc<RwLock<FontGroup>>

Like Self::font_group, but overriding the size found in the FontStyleStruct with the given size in pixels.

source

pub fn font( &self, font_template: FontTemplateRef, font_descriptor: &FontDescriptor, ) -> Option<FontRef>

Returns a font matching the parameters. Fonts are cached, so repeated calls will return a reference to the same underlying Font.

source

fn get_font_maybe_synthesizing_small_caps( &self, font_template: FontTemplateRef, font_descriptor: &FontDescriptor, synthesize_small_caps: bool, ) -> Option<FontRef>

source

fn matching_web_font_templates( &self, descriptor_to_match: &FontDescriptor, family_descriptor: &FontFamilyDescriptor, ) -> Option<Vec<FontTemplateRef>>

source

pub fn matching_templates( &self, descriptor_to_match: &FontDescriptor, family_descriptor: &FontFamilyDescriptor, ) -> Vec<FontTemplateRef>

Try to find matching templates in this FontContext, first looking in the list of web fonts and falling back to asking the super::SystemFontService for a matching system font.

source

fn create_font( &self, font_template: FontTemplateRef, font_descriptor: FontDescriptor, synthesized_small_caps: Option<FontRef>, ) -> Result<FontRef, &'static str>

Create a Font for use in layout calculations, from a FontTemplateData returned by the cache thread and a FontDescriptor which contains the styling parameters.

source

pub(crate) fn create_font_instance_key(&self, font: &Font) -> FontInstanceKey

source

fn create_web_font_instance( &self, font_template: FontTemplateRef, pt_size: Au, flags: FontInstanceFlags, ) -> FontInstanceKey

source

fn invalidate_font_groups_after_web_font_load(&self)

source§

impl FontContext

Trait Implementations§

source§

impl MallocSizeOf for FontContext

source§

fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize

Measure the heap usage of all descendant heap-allocated structures, but not the space taken up by the value itself.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> MaybeBoxed<Box<T>> for T

source§

fn maybe_boxed(self) -> Box<T>

Convert
source§

impl<T> MaybeBoxed<T> for T

source§

fn maybe_boxed(self) -> T

Convert
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
source§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T