Basic implementation of canvas.fillText

This commit is contained in:
Utsav Oza 2020-05-23 22:03:04 +05:30
parent 726f7d7209
commit f161ab8e57
2 changed files with 61 additions and 4 deletions

View file

@ -13,6 +13,9 @@ use canvas_traits::canvas::*;
use cssparser::RGBA;
use euclid::default::{Point2D, Rect, Size2D, Transform2D, Vector2D};
use euclid::Angle;
use font_kit::family_name::FamilyName;
use font_kit::properties::Properties;
use font_kit::source::SystemSource;
use lyon_geom::Arc;
use raqote::PathOp;
use std::marker::PhantomData;
@ -513,6 +516,32 @@ impl GenericDrawTarget for raqote::DrawTarget {
),
}
}
fn fill_text(
&mut self,
text: String,
x: f64,
y: f64,
max_width: Option<f64>,
pattern: canvas_data::Pattern,
draw_options: &DrawOptions,
) {
let font = SystemSource::new()
.select_best_match(&[FamilyName::SansSerif], &Properties::new())
.unwrap()
.load()
.unwrap();
self.draw_text(
&font,
24.,
&text,
Point2D::new(x as f32, y as f32),
&pattern.source(),
draw_options.as_raqote(),
);
}
fn fill_rect(
&mut self,
rect: &Rect<f32>,