@@ -213,7 +213,7 @@ impl Font {
213
213
/// # use macroquad::prelude::*;
214
214
/// # #[macroquad::main("test")]
215
215
/// # async fn main() {
216
- /// let font = Font::default ();
216
+ /// let mut font = get_default_font ();
217
217
/// font.set_filter(FilterMode::Linear);
218
218
/// # }
219
219
/// ```
@@ -228,6 +228,12 @@ impl Font {
228
228
// }
229
229
}
230
230
231
+ impl Default for Font {
232
+ fn default ( ) -> Self {
233
+ get_default_font ( )
234
+ }
235
+ }
236
+
231
237
/// Arguments for "draw_text_ex" function such as font, font_size etc
232
238
#[ derive( Debug , Clone ) ]
233
239
pub struct TextParams < ' a > {
@@ -418,12 +424,16 @@ pub fn draw_multiline_text_ex(
418
424
let line_distance = match line_distance_factor {
419
425
Some ( distance) => distance,
420
426
None => {
421
- let mut font_line_distance = 1.0 ;
422
- if let Some ( font) = params. font {
423
- if let Some ( metrics) = font. font . horizontal_line_metrics ( 1.0 ) {
424
- font_line_distance = metrics. new_line_size ;
425
- }
427
+ let mut font_line_distance = 0.0 ;
428
+ let font = if let Some ( font) = params. font {
429
+ font
430
+ } else {
431
+ & get_default_font ( )
432
+ } ;
433
+ if let Some ( metrics) = font. font . horizontal_line_metrics ( 1.0 ) {
434
+ font_line_distance = metrics. new_line_size ;
426
435
}
436
+
427
437
font_line_distance
428
438
}
429
439
} ;
@@ -475,6 +485,12 @@ impl FontsStorage {
475
485
}
476
486
}
477
487
488
+ /// Returns macroquads default font.
489
+ pub fn get_default_font ( ) -> Font {
490
+ let context = get_context ( ) ;
491
+ context. fonts_storage . default_font . clone ( )
492
+ }
493
+
478
494
/// From given font size in world space gives
479
495
/// (font_size, font_scale and font_aspect) params to make rasterized font
480
496
/// looks good in currently active camera
0 commit comments