mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-10 09:47:43 +00:00
CRasterFont: Collapse loop into a std::find_if in InternalGetGlyph()
Same behavior, less code.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#include "Runtime/GuiSys/CRasterFont.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "Runtime/CSimplePool.hpp"
|
||||
#include "Runtime/Graphics/CTexture.hpp"
|
||||
#include "Runtime/GuiSys/CDrawStringOptions.hpp"
|
||||
@@ -84,6 +86,17 @@ CRasterFont::CRasterFont(urde::CInputStream& in, urde::IObjectStore& store) {
|
||||
x0_initialized = true;
|
||||
}
|
||||
|
||||
const CGlyph* CRasterFont::InternalGetGlyph(char16_t chr) const {
|
||||
const auto iter =
|
||||
std::find_if(xc_glyphs.cbegin(), xc_glyphs.cend(), [chr](const auto& entry) { return entry.first == chr; });
|
||||
|
||||
if (iter == xc_glyphs.cend()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return &iter->second;
|
||||
}
|
||||
|
||||
void CRasterFont::SinglePassDrawString(const CDrawStringOptions& opts, int x, int y, int& xout, int& yout,
|
||||
CTextRenderBuffer* renderBuf, const char16_t* str, s32 length) const {
|
||||
if (!x0_initialized)
|
||||
|
||||
Reference in New Issue
Block a user