mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-17 23:38:06 +08:00
Move font cache to text folder as static var
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use graphene_core_shaders::Ctx;
|
||||
|
||||
use crate::{
|
||||
@@ -11,7 +9,6 @@ use crate::{
|
||||
ui_context::{UIContext, UIRuntimeResponse},
|
||||
},
|
||||
table::Table,
|
||||
text::FontCache,
|
||||
transform::ApplyTransform,
|
||||
};
|
||||
|
||||
@@ -22,12 +19,12 @@ pub mod types;
|
||||
pub mod ui_context;
|
||||
|
||||
#[node_macro::node(skip_impl)]
|
||||
pub fn generate_nodes(_: impl Ctx, node_graph_overlay_data: NodeGraphOverlayData, font_cache: Arc<FontCache>) -> Table<Graphic> {
|
||||
pub fn generate_nodes(_: impl Ctx, node_graph_overlay_data: NodeGraphOverlayData) -> Table<Graphic> {
|
||||
let mut nodes_and_wires = Table::new();
|
||||
let layers = draw_layers(&node_graph_overlay_data.nodes_to_render, font_cache.as_ref());
|
||||
let layers = draw_layers(&node_graph_overlay_data.nodes_to_render);
|
||||
nodes_and_wires.extend(layers);
|
||||
|
||||
let nodes = draw_nodes(&node_graph_overlay_data.nodes_to_render, font_cache.as_ref());
|
||||
let nodes = draw_nodes(&node_graph_overlay_data.nodes_to_render);
|
||||
nodes_and_wires.extend(nodes);
|
||||
|
||||
nodes_and_wires
|
||||
|
||||
@@ -5,17 +5,18 @@ use kurbo::{BezPath, Rect, RoundedRect, Shape};
|
||||
use crate::{
|
||||
Graphic,
|
||||
bounds::{BoundingBox, RenderBoundingBox},
|
||||
consts::SOURCE_SANS_FONT_DATA,
|
||||
node_graph_overlay::{
|
||||
consts::*,
|
||||
types::{FrontendGraphDataType, FrontendNodeToRender},
|
||||
},
|
||||
table::{Table, TableRow},
|
||||
text::{self, FontCache, TextAlign, TypesettingConfig},
|
||||
text::{self, TextAlign, TypesettingConfig},
|
||||
transform::ApplyTransform,
|
||||
vector::{Vector, style::Fill},
|
||||
};
|
||||
|
||||
pub fn draw_nodes(nodes: &Vec<FrontendNodeToRender>, _font_cache: &FontCache) -> Table<Graphic> {
|
||||
pub fn draw_nodes(nodes: &Vec<FrontendNodeToRender>) -> Table<Graphic> {
|
||||
let mut node_table = Table::new();
|
||||
for node_to_render in nodes {
|
||||
if let Some(frontend_node) = node_to_render.node_or_layer.node.as_ref() {
|
||||
@@ -94,7 +95,7 @@ pub fn draw_nodes(nodes: &Vec<FrontendNodeToRender>, _font_cache: &FontCache) ->
|
||||
node_table
|
||||
}
|
||||
|
||||
pub fn draw_layers(nodes: &Vec<FrontendNodeToRender>, font_cache: &FontCache) -> Table<Graphic> {
|
||||
pub fn draw_layers(nodes: &Vec<FrontendNodeToRender>) -> Table<Graphic> {
|
||||
let mut layer_table = Table::new();
|
||||
for node_to_render in nodes {
|
||||
if let Some(frontend_layer) = node_to_render.node_or_layer.layer.as_ref() {
|
||||
@@ -120,7 +121,7 @@ pub fn draw_layers(nodes: &Vec<FrontendNodeToRender>, font_cache: &FontCache) ->
|
||||
align: TextAlign::Left,
|
||||
};
|
||||
|
||||
let font_blob = Some(text::load_font(font_cache.source_sans_pro()));
|
||||
let font_blob = Some(text::load_font(SOURCE_SANS_FONT_DATA));
|
||||
let mut text_table = crate::text::to_path(&node_to_render.metadata.display_name, font_blob, typesetting, false);
|
||||
|
||||
let text_width = if let RenderBoundingBox::Rectangle(bbox) = text_table.bounding_box(DAffine2::default(), true) {
|
||||
|
||||
Reference in New Issue
Block a user