Skip to content

added measure_char for convenience #958

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,13 @@ pub fn load_ttf_font_from_bytes(bytes: &[u8]) -> Result<Font, Error> {

/// Draw text with given font_size
/// Returns text size
pub fn draw_text(text: impl AsRef<str>, x: f32, y: f32, font_size: f32, color: Color) -> TextDimensions {
pub fn draw_text(
text: impl AsRef<str>,
x: f32,
y: f32,
font_size: f32,
color: Color,
) -> TextDimensions {
draw_text_ex(
text,
x,
Expand Down Expand Up @@ -467,6 +473,15 @@ pub fn get_text_center(
crate::Vec2::new(x_center, y_center)
}

pub fn measure_char(
chr: char,
font: Option<&Font>,
font_size: u16,
font_scale: f32,
) -> TextDimensions {
measure_text(chr.to_string().as_str(), font, font_size, font_scale)
}

pub fn measure_text(
text: impl AsRef<str>,
font: Option<&Font>,
Expand Down
Loading