use crate::text::Font;
use std::collections::HashMap;
#[derive(Debug, Clone)]
pub struct StandardFontMetrics {
pub name: &'static str,
pub family: &'static str,
pub weight: u16,
pub italic: bool,
pub fixed_pitch: bool,
pub ascender: i32,
pub descender: i32,
pub cap_height: i32,
pub x_height: i32,
pub default_width: i32,
pub widths: [i32; 256],
pub kerning: Option<HashMap<(u8, u8), i32>>,
}
impl StandardFontMetrics {
pub fn get_char_width(&self, ch: u8) -> i32 {
self.widths[ch as usize]
}
pub fn get_string_width(&self, text: &str) -> i32 {
text.bytes().map(|ch| self.get_char_width(ch)).sum()
}
pub fn get_kerning(&self, left: u8, right: u8) -> i32 {
self.kerning
.as_ref()
.and_then(|k| k.get(&(left, right)))
.copied()
.unwrap_or(0)
}
pub fn to_user_space(&self, font_units: i32, font_size: f64) -> f64 {
(font_units as f64 * font_size) / 1000.0
}
pub fn get_line_height(&self, font_size: f64) -> f64 {
self.to_user_space(self.ascender - self.descender, font_size)
}
}
pub fn get_standard_font_metrics(font: &Font) -> Option<&'static StandardFontMetrics> {
match font {
Font::Helvetica => Some(&HELVETICA_METRICS),
Font::HelveticaBold => Some(&HELVETICA_BOLD_METRICS),
Font::HelveticaOblique => Some(&HELVETICA_OBLIQUE_METRICS),
Font::HelveticaBoldOblique => Some(&HELVETICA_BOLD_OBLIQUE_METRICS),
Font::TimesRoman => Some(&TIMES_ROMAN_METRICS),
Font::TimesBold => Some(&TIMES_BOLD_METRICS),
Font::TimesItalic => Some(&TIMES_ITALIC_METRICS),
Font::TimesBoldItalic => Some(&TIMES_BOLD_ITALIC_METRICS),
Font::Courier => Some(&COURIER_METRICS),
Font::CourierBold => Some(&COURIER_BOLD_METRICS),
Font::CourierOblique => Some(&COURIER_OBLIQUE_METRICS),
Font::CourierBoldOblique => Some(&COURIER_BOLD_OBLIQUE_METRICS),
Font::Symbol => Some(&SYMBOL_METRICS),
Font::ZapfDingbats => Some(&ZAPF_DINGBATS_METRICS),
Font::Custom(_) => None,
}
}
pub static HELVETICA_METRICS: StandardFontMetrics = StandardFontMetrics {
name: "Helvetica",
family: "Helvetica",
weight: 400,
italic: false,
fixed_pitch: false,
ascender: 718,
descender: -207,
cap_height: 718,
x_height: 523,
default_width: 278,
widths: [
278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278,
278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278,
278, 278, 355, 556, 556, 889, 667, 191, 333, 333, 389, 584, 278, 333, 278, 278, 556, 556,
556, 556, 556, 556, 556, 556, 556, 556, 278, 278, 584, 584, 584, 556,
1015, 667, 667, 722, 722, 667, 611, 778, 722, 278, 500, 667, 556, 833, 722, 778, 667, 778,
722, 667, 611, 722, 667, 944, 667, 667, 611, 278, 278, 278, 469, 556,
333, 556, 556, 500, 556, 556, 278, 556, 556, 222, 222, 500, 222, 833, 556, 556, 556, 556,
333, 500, 278, 556, 500, 722, 500, 500, 500, 334, 260, 334, 584, 278,
556, 278, 333, 556, 556, 556, 556, 260, 556, 333, 737, 370, 556, 584, 278, 737, 333, 333,
333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 278, 333, 333, 278, 333, 556, 556, 556,
556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556,
556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 278, 333, 556, 556, 556, 556, 260, 556,
333, 737, 370, 556, 584, 333, 737, 552, 400, 549, 333, 333, 333, 333, 333, 333, 333, 333,
333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333,
333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333,
333, 333,
],
kerning: None, };
pub static HELVETICA_BOLD_METRICS: StandardFontMetrics = StandardFontMetrics {
name: "Helvetica-Bold",
family: "Helvetica",
weight: 700,
italic: false,
fixed_pitch: false,
ascender: 718,
descender: -207,
cap_height: 718,
x_height: 532,
default_width: 278,
widths: [
278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278,
278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 333, 474, 556,
556, 889, 722, 238, 333, 333, 389, 584, 278, 333, 278, 278, 556, 556, 556, 556, 556, 556,
556, 556, 556, 556, 333, 333, 584, 584, 584, 611, 975, 722, 722, 722, 722, 667, 611, 778,
722, 278, 556, 722, 611, 833, 722, 778, 667, 778, 722, 667, 611, 722, 667, 944, 667, 667,
611, 333, 278, 333, 584, 556, 333, 556, 611, 556, 611, 556, 333, 611, 611, 278, 278, 556,
278, 889, 611, 611, 611, 611, 389, 556, 333, 611, 556, 778, 556, 556, 500, 389, 280, 389,
584, 278, 556, 278, 333, 556, 556, 556, 556, 280, 556, 333, 737, 370, 556, 584, 278, 737, 333, 333,
333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 278, 333, 333, 278, 333, 556, 556, 556,
556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556,
556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 278, 333, 556, 556, 556, 556, 280, 556,
333, 737, 370, 556, 584, 333, 737, 552, 400, 549, 333, 333, 333, 333, 333, 333, 333, 333,
333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333,
333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333,
333, 333,
],
kerning: None,
};
pub static HELVETICA_OBLIQUE_METRICS: StandardFontMetrics = StandardFontMetrics {
name: "Helvetica-Oblique",
family: "Helvetica",
weight: 400,
italic: true,
fixed_pitch: false,
ascender: 718,
descender: -207,
cap_height: 718,
x_height: 523,
default_width: 278,
widths: HELVETICA_METRICS.widths, kerning: None,
};
pub static HELVETICA_BOLD_OBLIQUE_METRICS: StandardFontMetrics = StandardFontMetrics {
name: "Helvetica-BoldOblique",
family: "Helvetica",
weight: 700,
italic: true,
fixed_pitch: false,
ascender: 718,
descender: -207,
cap_height: 718,
x_height: 532,
default_width: 278,
widths: HELVETICA_BOLD_METRICS.widths, kerning: None,
};
pub static TIMES_ROMAN_METRICS: StandardFontMetrics = StandardFontMetrics {
name: "Times-Roman",
family: "Times",
weight: 400,
italic: false,
fixed_pitch: false,
ascender: 683,
descender: -217,
cap_height: 662,
x_height: 450,
default_width: 250,
widths: [
250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 333, 408, 500,
500, 833, 778, 180, 333, 333, 500, 564, 250, 333, 250, 278, 500, 500, 500, 500, 500, 500,
500, 500, 500, 500, 278, 278, 564, 564, 564, 444, 921, 722, 667, 667, 722, 611, 556, 722,
722, 333, 389, 722, 611, 889, 722, 722, 556, 722, 667, 556, 611, 722, 722, 944, 722, 722,
611, 333, 278, 333, 469, 500, 333, 444, 500, 444, 500, 444, 333, 500, 500, 278, 278, 500,
278, 778, 500, 500, 500, 500, 333, 389, 278, 500, 500, 722, 500, 500, 444, 480, 200, 480,
541, 250, 500, 250, 333, 500, 500, 500, 500, 200, 500, 333, 760, 276, 500, 564, 250, 760, 333, 333,
333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 250, 333, 333, 250, 333, 500, 500, 500,
500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500,
500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 250, 333, 500, 500, 500, 500, 200, 500,
333, 760, 276, 500, 564, 333, 760, 549, 400, 549, 333, 333, 333, 333, 333, 333, 333, 333,
333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333,
333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333,
333, 333,
],
kerning: None,
};
pub static TIMES_BOLD_METRICS: StandardFontMetrics = StandardFontMetrics {
name: "Times-Bold",
family: "Times",
weight: 700,
italic: false,
fixed_pitch: false,
ascender: 683,
descender: -217,
cap_height: 676,
x_height: 461,
default_width: 250,
widths: [
250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 333, 555, 500,
500, 1000, 833, 278, 333, 333, 500, 570, 250, 333, 250, 278, 500, 500, 500, 500, 500, 500,
500, 500, 500, 500, 333, 333, 570, 570, 570, 500, 930, 722, 667, 722, 722, 667, 611, 778,
778, 389, 500, 778, 667, 944, 722, 778, 611, 778, 722, 556, 667, 722, 722, 1000, 722, 722,
667, 333, 278, 333, 581, 500, 333, 500, 556, 444, 556, 444, 333, 500, 556, 278, 333, 556,
278, 833, 556, 500, 556, 556, 444, 389, 333, 556, 500, 722, 500, 500, 444, 394, 220, 394,
520, 250, 500, 250, 333, 500, 500, 500, 500, 220, 500, 333, 747, 300, 500, 570, 250, 747, 333, 333,
333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 250, 333, 333, 250, 333, 500, 500, 500,
500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500,
500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 250, 333, 500, 500, 500, 500, 220, 500,
333, 747, 300, 500, 570, 333, 747, 549, 400, 549, 333, 333, 333, 333, 333, 333, 333, 333,
333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333,
333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333,
333, 333,
],
kerning: None,
};
pub static TIMES_ITALIC_METRICS: StandardFontMetrics = StandardFontMetrics {
name: "Times-Italic",
family: "Times",
weight: 400,
italic: true,
fixed_pitch: false,
ascender: 683,
descender: -217,
cap_height: 653,
x_height: 441,
default_width: 250,
widths: [
250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 333, 420, 500,
500, 833, 778, 214, 333, 333, 500, 675, 250, 333, 250, 278, 500, 500, 500, 500, 500, 500,
500, 500, 500, 500, 333, 333, 675, 675, 675, 500, 920, 611, 611, 667, 722, 611, 611, 722,
722, 333, 444, 667, 556, 833, 667, 722, 611, 722, 611, 500, 556, 722, 611, 833, 611, 556,
556, 389, 278, 389, 422, 500, 333, 500, 500, 444, 500, 444, 278, 500, 500, 278, 278, 444,
278, 722, 500, 500, 500, 500, 389, 389, 278, 500, 444, 667, 444, 444, 389, 400, 275, 400,
541, 250, 500, 250, 333, 500, 500, 500, 500, 275, 500, 333, 760, 276, 500, 675, 250, 760, 333, 333,
333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 250, 333, 333, 250, 333, 500, 500, 500,
500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500,
500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 250, 333, 500, 500, 500, 500, 275, 500,
333, 760, 276, 500, 675, 333, 760, 549, 400, 549, 333, 333, 333, 333, 333, 333, 333, 333,
333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333,
333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333,
333, 333,
],
kerning: None,
};
pub static TIMES_BOLD_ITALIC_METRICS: StandardFontMetrics = StandardFontMetrics {
name: "Times-BoldItalic",
family: "Times",
weight: 700,
italic: true,
fixed_pitch: false,
ascender: 683,
descender: -217,
cap_height: 669,
x_height: 462,
default_width: 250,
widths: [
250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 389, 555, 500,
500, 833, 778, 278, 333, 333, 500, 570, 250, 333, 250, 278, 500, 500, 500, 500, 500, 500,
500, 500, 500, 500, 333, 333, 570, 570, 570, 500, 832, 667, 667, 667, 722, 667, 667, 722,
778, 389, 500, 667, 611, 889, 722, 722, 611, 722, 667, 556, 611, 722, 667, 889, 667, 611,
611, 333, 278, 333, 570, 500, 333, 500, 500, 444, 500, 444, 333, 500, 556, 278, 278, 500,
278, 778, 556, 500, 500, 500, 389, 389, 278, 556, 444, 667, 500, 444, 389, 348, 220, 348,
570, 250, 500, 250, 333, 500, 500, 500, 500, 220, 500, 333, 747, 300, 500, 570, 250, 747, 333, 333,
333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 250, 333, 333, 250, 333, 500, 500, 500,
500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500,
500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 250, 333, 500, 500, 500, 500, 220, 500,
333, 747, 300, 500, 570, 333, 747, 549, 400, 549, 333, 333, 333, 333, 333, 333, 333, 333,
333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333,
333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333,
333, 333,
],
kerning: None,
};
pub static COURIER_METRICS: StandardFontMetrics = StandardFontMetrics {
name: "Courier",
family: "Courier",
weight: 400,
italic: false,
fixed_pitch: true,
ascender: 629,
descender: -157,
cap_height: 562,
x_height: 426,
default_width: 600,
widths: [600; 256], kerning: None,
};
pub static COURIER_BOLD_METRICS: StandardFontMetrics = StandardFontMetrics {
name: "Courier-Bold",
family: "Courier",
weight: 700,
italic: false,
fixed_pitch: true,
ascender: 629,
descender: -157,
cap_height: 562,
x_height: 439,
default_width: 600,
widths: [600; 256],
kerning: None,
};
pub static COURIER_OBLIQUE_METRICS: StandardFontMetrics = StandardFontMetrics {
name: "Courier-Oblique",
family: "Courier",
weight: 400,
italic: true,
fixed_pitch: true,
ascender: 629,
descender: -157,
cap_height: 562,
x_height: 426,
default_width: 600,
widths: [600; 256],
kerning: None,
};
pub static COURIER_BOLD_OBLIQUE_METRICS: StandardFontMetrics = StandardFontMetrics {
name: "Courier-BoldOblique",
family: "Courier",
weight: 700,
italic: true,
fixed_pitch: true,
ascender: 629,
descender: -157,
cap_height: 562,
x_height: 439,
default_width: 600,
widths: [600; 256],
kerning: None,
};
pub static SYMBOL_METRICS: StandardFontMetrics = StandardFontMetrics {
name: "Symbol",
family: "Symbol",
weight: 400,
italic: false,
fixed_pitch: false,
ascender: 692,
descender: -216,
cap_height: 692,
x_height: 500,
default_width: 250,
widths: [
250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 333, 713, 500,
549, 833, 778, 439, 333, 333, 500, 549, 250, 549, 250, 278, 500, 500, 500, 500, 500, 500,
500, 500, 500, 500, 278, 278, 549, 549, 549, 444, 549, 722, 667, 722, 612, 611, 763, 603,
722, 333, 631, 722, 686, 889, 722, 722, 768, 741, 556, 592, 611, 690, 439, 768, 645, 795,
611, 333, 863, 333, 658, 500, 500, 631, 549, 549, 494, 439, 521, 411, 603, 329, 603, 549,
549, 576, 521, 549, 549, 521, 549, 603, 439, 576, 713, 686, 493, 686, 494, 480, 200, 480,
549, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 620, 247, 549,
167, 713, 500, 753, 753, 753, 753, 1042, 987, 603, 987, 603, 400, 549, 411, 549, 549, 713,
494, 460, 549, 549, 549, 549, 1000, 603, 1000, 658, 823, 686, 795, 987, 768, 768, 823, 768,
768, 713, 713, 713, 713, 713, 713, 713, 768, 713, 790, 790, 890, 823, 549, 250, 713, 603,
603, 1042, 987, 603, 987, 603, 494, 329, 790, 790, 786, 713, 384, 384, 384, 384, 384, 384,
494, 494, 494, 494, 250, 329, 274, 686, 686, 686, 384, 384, 384, 384, 384, 384, 494, 494,
494, 250,
],
kerning: None,
};
pub static ZAPF_DINGBATS_METRICS: StandardFontMetrics = StandardFontMetrics {
name: "ZapfDingbats",
family: "ZapfDingbats",
weight: 400,
italic: false,
fixed_pitch: false,
ascender: 692,
descender: -200,
cap_height: 692,
x_height: 500,
default_width: 278,
widths: [
278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278,
278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 974, 961, 974,
980, 719, 789, 790, 791, 690, 960, 939, 549, 855, 911, 933, 911, 945, 974, 755, 846, 762,
761, 571, 677, 763, 760, 759, 754, 494, 552, 537, 577, 692, 786, 788, 788, 790, 793, 794,
816, 823, 789, 841, 823, 833, 816, 831, 923, 744, 723, 749, 790, 792, 695, 776, 768, 792,
759, 707, 708, 682, 701, 826, 815, 789, 789, 707, 687, 696, 689, 786, 787, 713, 791, 785,
791, 873, 761, 762, 762, 759, 759, 892, 892, 788, 784, 438, 138, 277, 415, 392, 392, 668,
668, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278,
278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 732, 544, 544,
910, 667, 760, 760, 776, 595, 694, 626, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788,
788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788,
788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 894, 838, 1016, 458, 748, 924,
748, 918, 927, 928, 928, 924, 937, 460, 771, 841, 402, 509, 405, 322, 498, 300, 421, 393,
844, 488, 669, 274, 438, 105, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788,
788, 278,
],
kerning: None,
};
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_helvetica_metrics() {
let metrics = &HELVETICA_METRICS;
assert_eq!(metrics.name, "Helvetica");
assert_eq!(metrics.weight, 400);
assert!(!metrics.italic);
assert!(!metrics.fixed_pitch);
assert_eq!(metrics.get_char_width(b' '), 278); assert_eq!(metrics.get_char_width(b'A'), 667); assert_eq!(metrics.get_char_width(b'a'), 556); assert_eq!(metrics.get_char_width(b'0'), 556);
assert_eq!(
metrics.get_string_width("Hello"),
722 + 556 + 222 + 222 + 556
); }
#[test]
fn test_times_metrics() {
let metrics = &TIMES_ROMAN_METRICS;
assert_eq!(metrics.name, "Times-Roman");
assert!(!metrics.fixed_pitch);
assert_eq!(metrics.get_char_width(b' '), 250); assert_eq!(metrics.get_char_width(b'A'), 722); assert_eq!(metrics.get_char_width(b'a'), 444); }
#[test]
fn test_courier_metrics() {
let metrics = &COURIER_METRICS;
assert_eq!(metrics.name, "Courier");
assert!(metrics.fixed_pitch);
assert_eq!(metrics.get_char_width(b' '), 600);
assert_eq!(metrics.get_char_width(b'A'), 600);
assert_eq!(metrics.get_char_width(b'a'), 600);
assert_eq!(metrics.get_char_width(b'i'), 600);
assert_eq!(metrics.get_char_width(b'W'), 600);
}
#[test]
fn test_user_space_conversion() {
let metrics = &HELVETICA_METRICS;
let font_size = 12.0;
let width_units = metrics.get_char_width(b'A'); let width_user = metrics.to_user_space(width_units, font_size);
assert_eq!(width_user, 667.0 * 12.0 / 1000.0);
let line_height = metrics.get_line_height(font_size);
assert_eq!(line_height, (718 - (-207)) as f64 * 12.0 / 1000.0);
}
#[test]
fn test_get_standard_font_metrics() {
assert!(get_standard_font_metrics(&Font::Helvetica).is_some());
assert!(get_standard_font_metrics(&Font::HelveticaBold).is_some());
assert!(get_standard_font_metrics(&Font::TimesRoman).is_some());
assert!(get_standard_font_metrics(&Font::Courier).is_some());
assert!(get_standard_font_metrics(&Font::Symbol).is_some());
assert!(get_standard_font_metrics(&Font::ZapfDingbats).is_some());
assert!(get_standard_font_metrics(&Font::Custom("Arial".to_string())).is_none());
}
#[test]
fn test_font_families() {
assert_eq!(HELVETICA_METRICS.family, "Helvetica");
assert_eq!(HELVETICA_BOLD_METRICS.family, "Helvetica");
assert_eq!(TIMES_ROMAN_METRICS.family, "Times");
assert_eq!(COURIER_METRICS.family, "Courier");
}
#[test]
fn test_font_weights() {
assert_eq!(HELVETICA_METRICS.weight, 400); assert_eq!(HELVETICA_BOLD_METRICS.weight, 700); assert_eq!(TIMES_BOLD_METRICS.weight, 700); }
#[test]
fn test_italic_flags() {
assert!(!HELVETICA_METRICS.italic);
assert!(HELVETICA_OBLIQUE_METRICS.italic);
assert!(!TIMES_ROMAN_METRICS.italic);
assert!(TIMES_ITALIC_METRICS.italic);
}
}