gui and Font update
This commit is contained in:
+11
-8
@@ -4,16 +4,19 @@
|
||||
|
||||
using glm::vec4;
|
||||
|
||||
Font::Font(std::vector<Texture*> pages, int lineHeight) : lineHeight_(lineHeight), pages(pages) {
|
||||
Font::Font(std::vector<std::unique_ptr<Texture>> pages, int lineHeight, int yoffset)
|
||||
: lineHeight(lineHeight), yoffset(yoffset), pages(std::move(pages)) {
|
||||
}
|
||||
|
||||
Font::~Font(){
|
||||
for (Texture* texture : pages)
|
||||
delete texture;
|
||||
}
|
||||
|
||||
int Font::lineHeight() const {
|
||||
return lineHeight_;
|
||||
int Font::getYOffset() const {
|
||||
return yoffset;
|
||||
}
|
||||
|
||||
int Font::getLineHeight() const {
|
||||
return lineHeight;
|
||||
}
|
||||
|
||||
bool Font::isPrintableChar(int c) {
|
||||
@@ -48,11 +51,11 @@ void Font::draw(Batch2D* batch, std::wstring text, int x, int y, int style) {
|
||||
if (isPrintableChar(c)){
|
||||
int charpage = c >> 8;
|
||||
if (charpage == page){
|
||||
Texture* texture = pages[charpage];
|
||||
Texture* texture = pages[charpage].get();
|
||||
if (texture == nullptr){
|
||||
texture = pages[0];
|
||||
texture = pages[0].get();
|
||||
}
|
||||
batch->texture(pages[charpage]);
|
||||
batch->texture(texture);
|
||||
|
||||
switch (style){
|
||||
case STYLE_SHADOW:
|
||||
|
||||
+7
-4
@@ -1,6 +1,7 @@
|
||||
#ifndef GRAPHICS_FONT_H_
|
||||
#define GRAPHICS_FONT_H_
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "../typedefs.h"
|
||||
@@ -13,13 +14,15 @@ const uint STYLE_SHADOW = 1;
|
||||
const uint STYLE_OUTLINE = 2;
|
||||
|
||||
class Font {
|
||||
int lineHeight_;
|
||||
int lineHeight;
|
||||
int yoffset;
|
||||
public:
|
||||
std::vector<Texture*> pages;
|
||||
Font(std::vector<Texture*> pages, int lineHeight);
|
||||
std::vector<std::unique_ptr<Texture>> pages;
|
||||
Font(std::vector<std::unique_ptr<Texture>> pages, int lineHeight, int yoffset);
|
||||
~Font();
|
||||
|
||||
int lineHeight() const;
|
||||
int getLineHeight() const;
|
||||
int getYOffset() const;
|
||||
int calcWidth(std::wstring text);
|
||||
// int getGlyphWidth(char c);
|
||||
bool isPrintableChar(int c);
|
||||
|
||||
Reference in New Issue
Block a user