Skip to content

Commit

Permalink
Removed typeface crate and moved font to shared crate
Browse files Browse the repository at this point in the history
  • Loading branch information
jaytaph committed Dec 19, 2024
1 parent e526020 commit 01d28a3
Show file tree
Hide file tree
Showing 22 changed files with 19 additions and 356 deletions.
11 changes: 0 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/gosub_cairo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ license = "MIT"

[dependencies]
gosub_shared = { path = "../gosub_shared" }
gosub_typeface = { path = "../gosub_typeface" }
gosub_svg = { path = "../gosub_svg", features = ["resvg"] }
image = "0.25.2"
smallvec = "1.13.2"
Expand Down
2 changes: 1 addition & 1 deletion crates/gosub_cairo/src/debug/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::elements::transform::GsTransform;
use crate::Scene;
use gosub_shared::render_backend::{Brush as _, Color as _, Transform as _};
use gosub_shared::types::Point;
use gosub_typeface::ROBOTO_FONT;
use gosub_shared::ROBOTO_FONT;
use peniko::{Blob, Font};
use std::sync::{Arc, LazyLock};

Expand Down
4 changes: 2 additions & 2 deletions crates/gosub_cairo/src/elements/text.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::CairoBackend;
use gosub_shared::font::{Glyph, GlyphID};
use gosub_shared::render_backend::geo::FP;
use gosub_shared::render_backend::layout::{Decoration, TextLayout};
use gosub_shared::render_backend::{RenderText, Text as TText};
use gosub_typeface::font::{Glyph, GlyphID};
use peniko::Font;
use skrifa::instance::NormalizedCoord;
use std::cell::RefCell;
Expand All @@ -12,7 +12,7 @@ use std::rc::Rc;
use crate::elements::brush::GsBrush;
use crate::elements::color::GsColor;
use freetype::{Face, Library};
use gosub_typeface::ROBOTO_FONT;
use gosub_shared::ROBOTO_FONT;
use kurbo::Stroke;
use log::info;
use once_cell::sync::Lazy;
Expand Down
2 changes: 1 addition & 1 deletion crates/gosub_html5/benches/tree_construction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use gosub_html5::document::builder::DocumentBuilderImpl;
use gosub_html5::document::document_impl::DocumentImpl;
use gosub_html5::document::fragment::DocumentFragmentImpl;
use gosub_html5::parser::Html5Parser;
use gosub_shared::traits::config::{HasCssSystem, HasDocument, HasHtmlParser};
use gosub_html5::testing::tree_construction;
use gosub_html5::testing::tree_construction::Harness;
use gosub_shared::traits::config::{HasCssSystem, HasDocument, HasHtmlParser};

#[derive(Clone, Debug, PartialEq)]
struct Config;
Expand Down
2 changes: 1 addition & 1 deletion crates/gosub_html5/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ pub mod dom;
pub mod errors;
pub mod node;
pub mod parser;
pub mod testing;
pub mod tokenizer;
#[allow(dead_code)]
pub mod writer;
pub mod testing;

/// Parses the given HTML string and returns a handle to the resulting DOM tree.
pub fn html_compile<C: HasDocument>(html: &str) -> DocumentHandle<C> {
Expand Down
2 changes: 1 addition & 1 deletion crates/gosub_html5/src/testing/tree_construction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ mod generator;
pub mod parser;
pub mod result;

use generator::TreeOutputGenerator;
use crate::node::{HTML_NAMESPACE, MATHML_NAMESPACE, SVG_NAMESPACE};
use generator::TreeOutputGenerator;
use gosub_shared::byte_stream::{ByteStream, Config, Encoding, Location};
use gosub_shared::document::DocumentHandle;
use gosub_shared::node::NodeId;
Expand Down
1 change: 0 additions & 1 deletion crates/gosub_shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ derive_more = {version = "1.0.0", features = ["display"]}
log = "0.4.22"
raw-window-handle = "0.6.2"
smallvec = "1.13.2"
gosub_typeface = { path = "../gosub_typeface"}
image = "0.25.5"


Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions crates/gosub_shared/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ pub mod async_executor;
pub mod byte_stream;
pub mod document;
pub mod errors;
pub mod font;
pub mod node;
pub mod render_backend;
pub mod timing;
pub mod traits;
pub mod types;

pub const ROBOTO_FONT: &[u8] = include_bytes!("../resources/fonts/Roboto-Regular.ttf");
2 changes: 1 addition & 1 deletion crates/gosub_shared/src/render_backend/layout.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::fmt::Debug;

use super::geo::{Point, Rect, Size, SizeU32};
use crate::font::{Font, Glyph};
use crate::traits::config::HasLayouter;
use crate::types::Result;
use gosub_typeface::font::{Font, Glyph};

pub trait LayoutTree<C: HasLayouter<LayoutTree = Self>>: Sized + Debug + 'static {
type NodeId: Debug + Copy + Clone + From<u64> + Into<u64> + PartialEq;
Expand Down
1 change: 0 additions & 1 deletion crates/gosub_taffy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ license = "MIT"

[dependencies]
gosub_shared = { path = "../gosub_shared" }
gosub_typeface = { path = "../gosub_typeface" }
taffy = "0.6.3"
anyhow = "1.0.94"
regex = "1.11.1"
Expand Down
5 changes: 3 additions & 2 deletions crates/gosub_taffy/src/compute/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,20 @@ use taffy::{
RunMode, Size,
};

use gosub_shared::font::Glyph;
use gosub_shared::render_backend::geo;
use gosub_shared::render_backend::layout::{Decoration, DecorationStyle, HasTextLayout, LayoutNode, LayoutTree};
use gosub_shared::traits::config::HasLayouter;
use gosub_shared::traits::css3::{CssProperty, CssValue};
use gosub_typeface::font::Glyph;
use gosub_shared::ROBOTO_FONT;

use crate::text::{Font, TextLayout};
use crate::{Display, LayoutDocument, TaffyLayouter};

static FONT_CX: LazyLock<Mutex<FontContext>> = LazyLock::new(|| {
let mut ctx = FontContext::default();

let fonts = ctx.collection.register_fonts(gosub_typeface::ROBOTO_FONT.to_vec());
let fonts = ctx.collection.register_fonts(ROBOTO_FONT.to_vec());

ctx.collection
.append_fallbacks(FallbackKey::new(Script::from("Latn"), None), fonts.iter().map(|f| f.0));
Expand Down
4 changes: 2 additions & 2 deletions crates/gosub_taffy/src/text.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use gosub_shared::font::Font as TFont;
use gosub_shared::font::Glyph;
use gosub_shared::render_backend::layout::{Decoration, TextLayout as TLayout};
use gosub_shared::render_backend::Size;
use gosub_typeface::font::Font as TFont;
use gosub_typeface::font::Glyph;
use parley::Font as PFont;

#[derive(Debug, Clone)]
Expand Down
10 changes: 0 additions & 10 deletions crates/gosub_typeface/Cargo.toml

This file was deleted.

Loading

0 comments on commit 01d28a3

Please sign in to comment.