Skip to content

Commit

Permalink
Add missing note names.
Browse files Browse the repository at this point in the history
  • Loading branch information
guylamar2006 authored Dec 1, 2024
1 parent 3519b4d commit 162fde0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions neothesia-core/src/render/keyboard/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,17 @@ fn rebuild_text_cache(&mut self, font_system: &mut glyphon::FontSystem) {

let size = w * 0.7;

let note_names = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"];
let note_index = (key.id() + range_start) % 12;
let note_name = note_names[note_index];
let oct_number = (key.id() + range_start) / 12;

let mut buffer = glyphon::Buffer::new(font_system, glyphon::Metrics::new(size, size));
buffer.set_size(font_system, Some(w), Some(h));
buffer.set_wrap(font_system, glyphon::Wrap::None);
buffer.set_text(
font_system,
&format!("C{}", oct_number as i8 - 1),
&format!("{}{}", note_name, oct_number as i8 - 1),
glyphon::Attrs::new().family(glyphon::Family::SansSerif),
glyphon::Shaping::Basic,
);
Expand All @@ -165,7 +168,6 @@ fn rebuild_text_cache(&mut self, font_system: &mut glyphon::FontSystem) {
});
}
}

#[profiling::function]
pub fn update(&mut self, quads: &mut QuadPipeline, layer: usize, text: &mut TextRenderer) {
if self.cache.is_empty() {
Expand Down

0 comments on commit 162fde0

Please sign in to comment.