Skip to content

Commit

Permalink
Scale line height with font (cleaner tooltip look when scaling)
Browse files Browse the repository at this point in the history
Use sane limits for scaling range
  • Loading branch information
xkanzeon committed Jul 16, 2023
1 parent bd16e7f commit 0b75e15
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
3 changes: 1 addition & 2 deletions d2gl/src/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,10 @@ struct D2GLApp {

struct {
bool active = false;
Range<float> scale = { 1.0f, 0.1f, 2.0f };
Range<float> scale = { 1.0f, 0.5f, 1.2f };
} hd_text;

bool hd_cursor = false;
// bool hd_text = false;
bool motion_prediction = false;
bool skip_intro = false;
bool no_pickup = false;
Expand Down
3 changes: 2 additions & 1 deletion d2gl/src/modules/hd_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ HDText::HDText()
wchar_t color = g_initial_colors.find(id) != g_initial_colors.end() ? g_initial_colors.at(id) : 0;
const auto offset = glm::vec2(std::stof(info[7]), std::stof(info[8]));
float font_size = std::stof(info[2]) * App.hd_text.scale.value;
float line_height = std::stof(info[5]) * App.hd_text.scale.value;

FontCreateInfo font_ci = { name, font_size, std::stof(info[3]), std::stof(info[4]), std::stof(info[5]), std::stof(info[6]), offset, std::stof(info[9]), color, bordered };
FontCreateInfo font_ci = { name, font_size, std::stof(info[3]), std::stof(info[4]), line_height, std::stof(info[6]), offset, std::stof(info[9]), color, bordered };
m_fonts[id] = std::make_unique<Font>(glyph_sets[name], font_ci);
}

Expand Down
2 changes: 1 addition & 1 deletion d2gl/src/modules/hd_text/font.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class Font {
inline wchar_t getColor() { return m_color; }
inline float getFontSize() { return m_size; }
inline float getWeight() { return m_weight; }
inline float getLineHeight() { return m_size * m_line_height; }
inline float getLineHeight() { return m_size * m_line_height * App.hd_text.scale.value; }
inline float getLetterSpacing() { return m_size * m_letter_spacing; }
inline glm::vec2 getTextOffset() { return m_size * m_offset; }
inline int getLineCount() { return m_line_count; }
Expand Down

0 comments on commit 0b75e15

Please sign in to comment.