Dawn/src/dawn/ui/UILabel.cpp

37 lines
816 B
C++

// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "UILabel.hpp"
using namespace Dawn;
void UILabel::getSelfQuads(const glm::vec2 t, UICanvas &ctx) {
std::vector<struct UIShaderQuad> quads;
if(this->texture == nullptr) return;
const std::wstring text = L"He";
glm::vec2 position = t;
glm::vec4 quad;
for(wchar_t c : text) {
auto info = texture->getCharacterData(c);
ctx.addQuad(
{
position.x,
position.y,
position.x + info.size.x,
position.y + info.size.y
},
info.quad,
COLOR_WHITE,
texture->texture
);
position += info.advance;
}
}
void UILabel::setFont(std::shared_ptr<TrueTypeTexture> texture) {
this->texture = texture;
}