haussmann/
font.rs

1// This file is part of "haussmann"
2// Under the MIT License
3// Copyright (c) 2023 Antonin Hérault
4
5use std::collections::HashMap;
6
7/// Font family with a name for the whole family.
8///
9/// Each font from `fonts` is the font associated to each font's weight.
10#[derive(Debug, Clone)]
11pub struct FontFamily {
12    /// The name of the font family.
13    pub name: String,
14    /// Font for each available [`FontWeight`].
15    pub fonts: HashMap<FontWeight, TTFFont>,
16}
17
18/// Named local TTF font.
19#[derive(Debug, Clone, Eq, PartialEq)]
20pub struct TTFFont {
21    /// The font's name identifier.
22    pub name: String,
23    /// The path of the TTF file.
24    pub path: String,
25}
26
27/// The weight for a font.
28#[allow(missing_docs)]
29#[derive(Debug, Clone, Eq, PartialEq)]
30pub enum FontWeight {
31    Black = 900,
32    ExtraBold = 800,
33    Bold = 700,
34    SemiBold = 600,
35    Medium = 500,
36    Regular = 400,
37    Light = 300,
38    ExtraLight = 200,
39    Thin = 100,
40}
41
42impl Default for FontWeight {
43    fn default() -> Self {
44        FontWeight::Regular
45    }
46}