#include "ui/Font.hpp" #include namespace dp::ui { float FontSpec::lineHeight() const { struct Pt { float size, height; }; static const Pt table[] = {{9, 11}, {10, 12}, {11, 13}, {12, 16}, {13, 18}, {14, 19}, {15, 20}, {16, 21}, {17, 22}, {18, 23}, {20, 25}, {22, 28}, {24, 29}, {28, 34}, {34, 41}, {40, 48}}; constexpr int n = sizeof(table) / sizeof(table[0]); if (size <= table[0].size) return std::round(size * 1.22f); for (int i = 1; i < n; ++i) { if (size <= table[i].size) { const float t = (size - table[i - 1].size) / (table[i].size - table[i - 1].size); return table[i - 1].height + t * (table[i].height - table[i - 1].height); } } return std::round(size * 1.2f); } std::string FontSpec::key() const { return std::to_string(static_cast(size * 100)) + (mono ? "m" : "s") + std::to_string(static_cast(weight)) + (italic ? "i" : "n"); } } // namespace dp::ui