Utility/AbstractTextDrawer: Add GetLineGlyphCount

This commit is contained in:
Lynix 2018-04-15 02:27:49 +02:00
parent 3362a4f160
commit 69c61ba746
2 changed files with 26 additions and 0 deletions

View File

@ -34,6 +34,7 @@ namespace Nz
virtual std::size_t GetGlyphCount() const = 0;
virtual const Line& GetLine(std::size_t index) const = 0;
virtual std::size_t GetLineCount() const = 0;
inline std::size_t GetLineGlyphCount(std::size_t index) const;
struct Glyph
{
@ -53,4 +54,6 @@ namespace Nz
};
}
#include <Nazara/Utility/AbstractTextDrawer.inl>
#endif // NAZARA_ABSTRACTTEXTDRAWER_HPP

View File

@ -0,0 +1,23 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Engine - Utility module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Utility/AbstractTextDrawer.hpp>
#include <Nazara/Utility/Debug.hpp>
namespace Nz
{
inline std::size_t AbstractTextDrawer::GetLineGlyphCount(std::size_t index) const
{
std::size_t lineCount = GetLineCount();
const auto& lineInfo = GetLine(index);
if (index == lineCount - 1)
return GetGlyphCount() - lineInfo.glyphIndex;
const auto& nextLineInfo = GetLine(index + 1);
return nextLineInfo.glyphIndex - lineInfo.glyphIndex;
}
}
#include <Nazara/Utility/DebugOff.hpp>