From c13e53153fd945aca5d3a591486b76335ec8566b Mon Sep 17 00:00:00 2001 From: Jeremie Roy Date: Wed, 22 May 2013 17:13:17 +0200 Subject: [PATCH] add max advance to fontInfo --- examples/common/font/font_manager.cpp | 4 +++- examples/common/font/font_manager.h | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/examples/common/font/font_manager.cpp b/examples/common/font/font_manager.cpp index 68d0ae4a2..caecb7b5e 100644 --- a/examples/common/font/font_manager.cpp +++ b/examples/common/font/font_manager.cpp @@ -165,6 +165,7 @@ FontInfo TrueTypeFont::getFontInfo() outFontInfo.ascender = metrics.ascender / 64.0f; outFontInfo.descender = metrics.descender / 64.0f; outFontInfo.lineGap = (metrics.height - metrics.ascender + metrics.descender) / 64.0f; + outFontInfo.maxAdvanceWidth = metrics.max_advance/ 64.0f; outFontInfo.underlinePosition = FT_MulFix(holder->face->underline_position, metrics.y_scale) / 64.0f; outFontInfo.underlineThickness = FT_MulFix(holder->face->underline_thickness, metrics.y_scale) / 64.0f; @@ -647,6 +648,7 @@ FontHandle FontManager::createScaledFontToPixelSize(FontHandle _baseFontHandle, newFontInfo.ascender = (newFontInfo.ascender * newFontInfo.scale); newFontInfo.descender = (newFontInfo.descender * newFontInfo.scale); newFontInfo.lineGap = (newFontInfo.lineGap * newFontInfo.scale); + newFontInfo.maxAdvanceWidth = (newFontInfo.maxAdvanceWidth * newFontInfo.scale); newFontInfo.underlineThickness = (newFontInfo.underlineThickness * newFontInfo.scale); newFontInfo.underlinePosition = (newFontInfo.underlinePosition * newFontInfo.scale); @@ -782,7 +784,7 @@ bool FontManager::preloadGlyph(FontHandle _handle, CodePoint _codePoint) return false; } -const FontInfo& FontManager::getFontInfo(FontHandle _handle) +const FontInfo& FontManager::getFontInfo(FontHandle _handle) const { BX_CHECK(bgfx::invalidHandle != _handle.idx, "Invalid handle used"); return m_cachedFonts[_handle.idx].fontInfo; diff --git a/examples/common/font/font_manager.h b/examples/common/font/font_manager.h index 0724a9d88..eec4d7377 100644 --- a/examples/common/font/font_manager.h +++ b/examples/common/font/font_manager.h @@ -7,6 +7,7 @@ #define __FONT_MANAGER_H__ #include +#include class Atlas; @@ -29,6 +30,8 @@ struct FontInfo float descender; /// The spacing in pixels between one row's descent and the next row's ascent. float lineGap; + /// This field gives the maximum horizontal cursor advance for all glyphs in the font. + float maxAdvanceWidth; /// The thickness of the under/hover/strike-trough line in pixels. float underlineThickness; /// The position of the underline relatively to the baseline. @@ -169,7 +172,7 @@ public: /// Return the font descriptor of a font. /// /// @remark the handle is required to be valid - const FontInfo& getFontInfo(FontHandle _handle); + const FontInfo& getFontInfo(FontHandle _handle) const; /// Return the rendering informations about the glyph region. Load the /// glyph from a TrueType font if possible