Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TextNode* Font::getTextNode(std::string s, glm::vec3 color, float font_size)
- {
- Mesh* textmesh = new Mesh();
- glm::vec2 current_pos(0.f);
- float sizeRatio = font_size / m_defaultLineHeight;
- for(char c : s){
- if(c == '\n')
- {
- current_pos.x = 0.f; // left alignment -> TODO : be able to center or align right
- current_pos.y += font_size;
- }
- else
- {
- CharInfo charInfo = m_charTable[c];
- textmesh->addRectangle2D((current_pos + charInfo.offset)*sizeRatio,
- charInfo.dim * sizeRatio,
- charInfo.pos/m_scale,
- charInfo.dim/m_scale);
- current_pos.x += charInfo.xadvance;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement