mirror of
https://github.com/lisk77/comet.git
synced 2025-10-23 21:38:50 +00:00
feat: \t
is now usable in a text
This commit is contained in:
parent
9640cdf92a
commit
d4a1bde4dc
1 changed files with 14 additions and 2 deletions
|
@ -45,7 +45,7 @@ pub struct Renderer2D<'a> {
|
||||||
|
|
||||||
impl<'a> Renderer2D<'a> {
|
impl<'a> Renderer2D<'a> {
|
||||||
pub fn new(window: Arc<Window>, clear_color: Option<impl Color>) -> Renderer2D<'a> {
|
pub fn new(window: Arc<Window>, clear_color: Option<impl Color>) -> Renderer2D<'a> {
|
||||||
let size = PhysicalSize::<u32>::new(1920, 1080);
|
let size = window.inner_size();//PhysicalSize::<u32>::new(1920, 1080);
|
||||||
|
|
||||||
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
|
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
|
||||||
backends: wgpu::Backends::PRIMARY,
|
backends: wgpu::Backends::PRIMARY,
|
||||||
|
@ -592,7 +592,19 @@ impl<'a> Renderer2D<'a> {
|
||||||
let scale_factor = size / self.graphic_resource_manager.fonts().iter().find(|f| f.name() == font).unwrap().size();
|
let scale_factor = size / self.graphic_resource_manager.fonts().iter().find(|f| f.name() == font).unwrap().size();
|
||||||
|
|
||||||
let line_height = (self.graphic_resource_manager.fonts().iter().find(|f| f.name() == font).unwrap().line_height() / self.config.height as f32) * scale_factor;
|
let line_height = (self.graphic_resource_manager.fonts().iter().find(|f| f.name() == font).unwrap().line_height() / self.config.height as f32) * scale_factor;
|
||||||
let lines = text.split("\n").collect::<Vec<&str>>();
|
let lines = text
|
||||||
|
.split("\n")
|
||||||
|
.map(|s| {
|
||||||
|
s.split("").map(|escape| {
|
||||||
|
match escape {
|
||||||
|
_ if escape == "\t" => {
|
||||||
|
" "
|
||||||
|
}
|
||||||
|
_ => escape
|
||||||
|
}
|
||||||
|
}).collect::<String>()
|
||||||
|
})
|
||||||
|
.collect::<Vec<String>>();
|
||||||
|
|
||||||
let mut x_offset = 0.0;
|
let mut x_offset = 0.0;
|
||||||
let mut y_offset = 0.0;
|
let mut y_offset = 0.0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue