add WguiFontSystem, remove FONT_SYSTEM singleton, custom fonts, add Light font weight
there are a few gzip-compressed ttf as for now, looks like variable fonts aren't parsed properly by cosmic_text. Not sure why. Also, we probably need to have a fallback for CJK characters in the future, or just fallback to the built-in ones in the OS.
This commit is contained in:
@@ -15,8 +15,8 @@ use wgui::{
|
||||
event::{self, EventCallback},
|
||||
i18n::Translation,
|
||||
layout::Layout,
|
||||
parser::{parse_color_hex, CustomAttribsInfoOwned},
|
||||
widget::{label::WidgetLabel, EventResult},
|
||||
parser::{CustomAttribsInfoOwned, parse_color_hex},
|
||||
widget::{EventResult, label::WidgetLabel},
|
||||
};
|
||||
|
||||
use crate::state::AppState;
|
||||
@@ -123,13 +123,13 @@ pub(super) fn setup_custom_label<S: 'static>(
|
||||
|
||||
let pretty_tz = maybe_pretty_tz.as_ref().map_or("Local", |x| x.as_str());
|
||||
|
||||
let mut i18n = layout.state.globals.i18n();
|
||||
let mut globals = layout.state.globals.get();
|
||||
layout
|
||||
.state
|
||||
.widgets
|
||||
.get_as::<WidgetLabel>(attribs.widget_id)
|
||||
.unwrap()
|
||||
.set_text_simple(&mut i18n, Translation::from_raw_text(pretty_tz));
|
||||
.set_text_simple(&mut globals, Translation::from_raw_text(pretty_tz));
|
||||
|
||||
// does not need to be dynamic
|
||||
return;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::{cell::RefCell, rc::Rc, sync::Arc};
|
||||
|
||||
use button::setup_custom_button;
|
||||
use glam::{vec2, Affine2, Vec2};
|
||||
use glam::{Affine2, Vec2, vec2};
|
||||
use label::setup_custom_label;
|
||||
use vulkano::{command_buffer::CommandBufferUsage, image::view::ImageView};
|
||||
use wgui::{
|
||||
@@ -15,14 +15,14 @@ use wgui::{
|
||||
layout::{Layout, LayoutParams, WidgetID},
|
||||
parser::ParserState,
|
||||
renderer_vk::context::Context as WguiContext,
|
||||
widget::{label::WidgetLabel, rectangle::WidgetRectangle, EventResult},
|
||||
widget::{EventResult, label::WidgetLabel, rectangle::WidgetRectangle},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
backend::input::{Haptics, HoverResult, PointerHit, PointerMode},
|
||||
graphics::{CommandBuffers, ExtentExt},
|
||||
state::AppState,
|
||||
windowing::backend::{ui_transform, FrameMeta, OverlayBackend, ShouldRender},
|
||||
windowing::backend::{FrameMeta, OverlayBackend, ShouldRender, ui_transform},
|
||||
};
|
||||
|
||||
use super::{timer::GuiTimer, timestep::Timestep};
|
||||
@@ -237,13 +237,21 @@ impl<S: 'static> OverlayBackend for GuiPanel<S> {
|
||||
wgui::gfx::cmd::WGfxClearMode::Clear([0.0, 0.0, 0.0, 0.0]),
|
||||
)?;
|
||||
|
||||
let globals = self.layout.state.globals.clone(); // sorry
|
||||
let mut globals = globals.get();
|
||||
|
||||
let primitives = wgui::drawing::draw(&mut wgui::drawing::DrawParams {
|
||||
globals: &mut globals,
|
||||
layout: &mut self.layout,
|
||||
debug_draw: false,
|
||||
alpha,
|
||||
})?;
|
||||
self.context
|
||||
.draw(&mut app.wgui_shared, &mut cmd_buf, &primitives)?;
|
||||
self.context.draw(
|
||||
&globals.font_system,
|
||||
&mut app.wgui_shared,
|
||||
&mut cmd_buf,
|
||||
&primitives,
|
||||
)?;
|
||||
cmd_buf.end_rendering()?;
|
||||
buf.push(cmd_buf.build()?);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user