Clean up the `text` module inside `canvas` a bit
This commit is contained in:
parent
e864536b31
commit
6d6b5191bb
|
@ -26,24 +26,40 @@ use pathfinder_geometry::rect::RectF;
|
|||
use pathfinder_geometry::transform2d::Transform2F;
|
||||
use pathfinder_renderer::paint::{Paint, PaintId};
|
||||
use pathfinder_renderer::scene::{ClipPath, ClipPathId, DrawPath, RenderTarget, Scene};
|
||||
use skribo::FontCollection;
|
||||
use std::borrow::Cow;
|
||||
use std::default::Default;
|
||||
use std::f32::consts::PI;
|
||||
use std::fmt::{Debug, Error as FmtError, Formatter};
|
||||
use std::mem;
|
||||
use std::sync::Arc;
|
||||
use text::FontCollection;
|
||||
|
||||
pub use text::CanvasFontContext;
|
||||
|
||||
#[cfg(feature = "pf-text")]
|
||||
pub use text::TextMetrics;
|
||||
pub use text::CanvasFontContext;
|
||||
|
||||
const HAIRLINE_STROKE_WIDTH: f32 = 0.0333;
|
||||
const DEFAULT_FONT_SIZE: f32 = 10.0;
|
||||
|
||||
#[cfg_attr(not(feature = "pf-text"), path = "text_no_text.rs")]
|
||||
#[cfg(feature = "pf-text")]
|
||||
mod text;
|
||||
|
||||
// For users who don't want text capability, include a tiny convenience stub.
|
||||
#[cfg(not(feature = "pf-text"))]
|
||||
mod text {
|
||||
#[derive(Clone)]
|
||||
pub struct CanvasFontContext;
|
||||
|
||||
impl CanvasFontContext {
|
||||
pub fn from_system_source() -> Self {
|
||||
CanvasFontContext
|
||||
}
|
||||
}
|
||||
|
||||
pub struct FontCollection;
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
|
|
|
@ -8,21 +8,21 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use pathfinder_geometry::vector::Vector2F;
|
||||
use pathfinder_geometry::transform2d::Transform2F;
|
||||
use pathfinder_renderer::paint::PaintId;
|
||||
use std::sync::Arc;
|
||||
use std::iter;
|
||||
use crate::{CanvasRenderingContext2D, TextAlign};
|
||||
use font_kit::family_name::FamilyName;
|
||||
use font_kit::handle::Handle;
|
||||
use font_kit::hinting::HintingOptions;
|
||||
use font_kit::loaders::default::Font;
|
||||
use font_kit::properties::Properties;
|
||||
use font_kit::source::{Source, SystemSource};
|
||||
use font_kit::sources::mem::MemSource;
|
||||
pub use skribo::{FontCollection, FontFamily, Layout, TextStyle};
|
||||
use pathfinder_geometry::transform2d::Transform2F;
|
||||
use pathfinder_geometry::vector::Vector2F;
|
||||
use pathfinder_renderer::paint::PaintId;
|
||||
use pathfinder_text::{SceneExt, TextRenderMode};
|
||||
pub use font_kit::loaders::default::Font;
|
||||
pub use crate::{CanvasRenderingContext2D, TextAlign};
|
||||
use skribo::{FontCollection, FontFamily, Layout, TextStyle};
|
||||
use std::iter;
|
||||
use std::sync::Arc;
|
||||
|
||||
impl CanvasRenderingContext2D {
|
||||
pub fn fill_text(&mut self, string: &str, position: Vector2F) {
|
||||
|
@ -133,6 +133,7 @@ pub struct TextMetrics {
|
|||
pub width: f32,
|
||||
}
|
||||
|
||||
#[cfg(feature = "pf-text")]
|
||||
#[derive(Clone)]
|
||||
pub struct CanvasFontContext {
|
||||
#[allow(dead_code)]
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
// pathfinder/canvas/src/text_no_text.rs
|
||||
//
|
||||
// Copyright © 2019 The Pathfinder Project Developers.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct CanvasFontContext;
|
||||
|
||||
impl CanvasFontContext {
|
||||
pub fn from_system_source() -> Self {
|
||||
CanvasFontContext
|
||||
}
|
||||
}
|
||||
|
||||
pub struct FontCollection;
|
Loading…
Reference in New Issue