From 347f8cc9865d0530b5754db7936be65cd5b3d4e6 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 15 Apr 2018 02:34:21 +0200 Subject: [PATCH] Utility/Font: Fix handling of whitespace glyphs --- ChangeLog.md | 2 ++ src/Nazara/Utility/Font.cpp | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index c724b0117..6b1641293 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -86,6 +86,8 @@ Nazara Engine: - Fixed Billboard bounding volume - Fixed Directory::GetResultSize and Directory::IsResultDirectory on Posix systems - Graphics module now register "White2D" and "WhiteCubemap" textures to the TextureLibrary (respectively a 1x1 texture 2D and a 1x1 texture cubemap) +- Added AbstractTextDrawer::GetLineGlyphCount, which returns the number of glyph part of the line +- Fixed Font handling of whitespace glyphs (which were triggering an error) Nazara Development Kit: - Added ImageWidget (#139) diff --git a/src/Nazara/Utility/Font.cpp b/src/Nazara/Utility/Font.cpp index 63cc28495..a0264b9ee 100644 --- a/src/Nazara/Utility/Font.cpp +++ b/src/Nazara/Utility/Font.cpp @@ -514,8 +514,16 @@ namespace Nz FontGlyph fontGlyph; if (ExtractGlyph(characterSize, character, style, &fontGlyph)) { - glyph.atlasRect.width = fontGlyph.image.GetWidth(); - glyph.atlasRect.height = fontGlyph.image.GetHeight(); + if (fontGlyph.image.IsValid()) + { + glyph.atlasRect.width = fontGlyph.image.GetWidth(); + glyph.atlasRect.height = fontGlyph.image.GetHeight(); + } + else + { + glyph.atlasRect.width = 0; + glyph.atlasRect.height = 0; + } // Insertion du rectangle dans l'un des atlas if (glyph.atlasRect.width > 0 && glyph.atlasRect.height > 0) // Si l'image contient quelque chose