Struct fonts::font_context::FontContext
source · pub struct FontContext<S: FontSource> {
font_source: ReentrantMutex<S>,
resource_threads: ReentrantMutex<CoreResourceThread>,
cache: CachingFontSource<S>,
web_fonts: Arc<RwLock<FontStore>>,
webrender_font_store: Arc<RwLock<WebRenderFontStore>>,
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 font cache thread where required.
Fields§
§font_source: ReentrantMutex<S>
§resource_threads: ReentrantMutex<CoreResourceThread>
§cache: CachingFontSource<S>
§web_fonts: Arc<RwLock<FontStore>>
§webrender_font_store: Arc<RwLock<WebRenderFontStore>>
§have_removed_web_fonts: AtomicBool
Implementations§
source§impl<S: FontSource> FontContext<S>
impl<S: FontSource> FontContext<S>
pub fn new(font_source: S, resource_threads: ResourceThreads) -> FontContext<S>
pub fn web_fonts_still_loading(&self) -> usize
sourcefn handle_web_font_load_finished(
&self,
finished_callback: &WebFontLoadFinishedCallback,
succeeded: bool,
)
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.
sourcepub fn font_group(
&self,
style: ServoArc<FontStyleStruct>,
) -> Arc<RwLock<FontGroup>>
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
.
sourcepub fn font_group_with_size(
&self,
style: ServoArc<FontStyleStruct>,
size: Au,
) -> Arc<RwLock<FontGroup>>
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.
sourcepub fn font(
&self,
font_template: FontTemplateRef,
font_descriptor: &FontDescriptor,
) -> Option<FontRef>
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
.
fn get_font_maybe_synthesizing_small_caps( &self, font_template: FontTemplateRef, font_descriptor: &FontDescriptor, synthesize_small_caps: bool, ) -> Option<FontRef>
fn matching_web_font_templates( &self, descriptor_to_match: &FontDescriptor, family_descriptor: &FontFamilyDescriptor, ) -> Option<Vec<FontTemplateRef>>
sourcepub fn matching_templates(
&self,
descriptor_to_match: &FontDescriptor,
family_descriptor: &FontFamilyDescriptor,
) -> Vec<FontTemplateRef>
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::FontCacheThread
for a matching system font.
sourcefn create_font(
&self,
font_template: FontTemplateRef,
font_descriptor: FontDescriptor,
synthesized_small_caps: Option<FontRef>,
) -> Result<FontRef, &'static str>
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.
Trait Implementations§
source§impl<S: FontSource> MallocSizeOf for FontContext<S>
impl<S: FontSource> MallocSizeOf for FontContext<S>
source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
Auto Trait Implementations§
impl<S> !Freeze for FontContext<S>
impl<S> !RefUnwindSafe for FontContext<S>
impl<S> Send for FontContext<S>where
S: Send,
impl<S> Sync for FontContext<S>where
S: Send,
impl<S> Unpin for FontContext<S>where
S: Unpin,
impl<S> !UnwindSafe for FontContext<S>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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