Produce FontMatches inside of Buffer

This commit is contained in:
Jeremy Soller 2022-10-25 16:13:07 -06:00
parent 085231c153
commit 59a4f8a4c1
No known key found for this signature in database
GPG key ID: 87F211AF2BE4C2FE
5 changed files with 20 additions and 24 deletions

View file

@ -7,7 +7,7 @@ use std::{
};
use unicode_segmentation::UnicodeSegmentation;
use crate::{LayoutGlyph, LayoutLine, FontMatches, FontShapeLine};
use crate::{Attrs, LayoutGlyph, LayoutLine, FontMatches, FontShapeLine, FontSystem};
/// An action to perform on a [TextBuffer]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
@ -238,6 +238,7 @@ impl TextBufferLine {
/// A buffer of text that is shaped and laid out
pub struct TextBuffer<'a> {
font_matches: FontMatches<'a>,
attrs: Attrs<'a>,
lines: Vec<TextBufferLine>,
metrics: TextMetrics,
width: i32,
@ -250,11 +251,14 @@ pub struct TextBuffer<'a> {
impl<'a> TextBuffer<'a> {
pub fn new(
font_matches: FontMatches<'a>,
font_system: &'a FontSystem<'a>,
attrs: Attrs<'a>,
metrics: TextMetrics,
) -> Self {
let font_matches = font_system.matches_attrs(&attrs);
let mut buffer = Self {
font_matches,
attrs,
lines: Vec::new(),
metrics,
width: 0,