This commit is contained in:
Chad Brokaw 2021-08-04 05:01:42 -04:00
parent 7596ee8b03
commit 204fcf5e2c
4 changed files with 17 additions and 6 deletions

View File

@ -17,7 +17,11 @@ impl<C: FontCollection, B: Brush> LayoutContext<C, B> {
}
}
pub fn new_layout<'a>(&'a mut self, fonts: &'a mut C, text: &'a str) -> LayoutBuilder<'a, C, B> {
pub fn new_layout<'a>(
&'a mut self,
fonts: &'a mut C,
text: &'a str,
) -> LayoutBuilder<'a, C, B> {
fonts.begin_session();
LayoutBuilder {
state: &mut self.state,
@ -116,7 +120,10 @@ impl<C: FontCollection, B: Brush> LayoutState<C, B> {
}
}
fn convert_attr<C: FontCollection, B: Brush>(attr: &Attribute<B>, fonts: &mut C) -> AttributeKind<C::Family, B> {
fn convert_attr<C: FontCollection, B: Brush>(
attr: &Attribute<B>,
fonts: &mut C,
) -> AttributeKind<C::Family, B> {
match attr {
Attribute::FontFamily(family) => AttributeKind::Family(match family {
FontFamily::Named(name) => fonts

View File

@ -1,9 +1,9 @@
use super::font::FontFamilyHandle;
use super::{Brush, Color};
use core::fmt::Debug;
use fount::{FamilyId, GenericFamily, Locale};
use swash::text::Script;
use swash::{Attributes, Stretch, Style, Weight};
use super::{Brush, Color};
#[derive(Clone, Debug)]
pub struct SpanData<F: Clone + PartialEq + Debug, B: Brush> {

View File

@ -81,7 +81,7 @@ pub enum Color<B: Brush = ()> {
/// 32-bit color in RGBA order.
Solid([u8; 4]),
/// Custom brush.
Brush(B)
Brush(B),
}
/// Trait for types that represent custom rendering styles.

View File

@ -1,6 +1,6 @@
use super::font::*;
use super::itemize::*;
use super::{Glyph, Layout, Run, Brush};
use super::{Brush, Glyph, Layout, Run};
use fount::Locale;
use swash::shape::{self, ShapeContext};
use swash::text::cluster::CharCluster;
@ -84,7 +84,11 @@ pub struct FontSelector<'a, C: FontCollection, B: Brush> {
}
impl<'a, C: FontCollection, B: Brush> FontSelector<'a, C, B> {
pub fn new(fonts: &'a mut C, spans: &'a [SpanData<C::Family, B>], first_item: &ItemData) -> Self {
pub fn new(
fonts: &'a mut C,
spans: &'a [SpanData<C::Family, B>],
first_item: &ItemData,
) -> Self {
let first_span = &spans[0];
let attrs = first_span.attributes();
Self {