diff --git a/fonts/clean12.txf b/fonts/clean12.txf deleted file mode 100644 index 8bef4e16b..000000000 Binary files a/fonts/clean12.txf and /dev/null differ diff --git a/fonts/clean16.txf b/fonts/clean16.txf deleted file mode 100644 index b1b164bcb..000000000 Binary files a/fonts/clean16.txf and /dev/null differ diff --git a/fonts/cleanbold12.txf b/fonts/cleanbold12.txf deleted file mode 100644 index d6385cb78..000000000 Binary files a/fonts/cleanbold12.txf and /dev/null differ diff --git a/fonts/cleanbold16.txf b/fonts/cleanbold16.txf deleted file mode 100644 index b70a63296..000000000 Binary files a/fonts/cleanbold16.txf and /dev/null differ diff --git a/fonts/default.txf b/fonts/default.txf deleted file mode 100644 index 6fd9bb62f..000000000 Binary files a/fonts/default.txf and /dev/null differ diff --git a/fonts/helv10.txf b/fonts/helv10.txf deleted file mode 100644 index 5f94952fe..000000000 Binary files a/fonts/helv10.txf and /dev/null differ diff --git a/fonts/helv12.txf b/fonts/helv12.txf deleted file mode 100644 index db00ea404..000000000 Binary files a/fonts/helv12.txf and /dev/null differ diff --git a/fonts/helv18.txf b/fonts/helv18.txf deleted file mode 100644 index 457435c3f..000000000 Binary files a/fonts/helv18.txf and /dev/null differ diff --git a/fonts/helv24.txf b/fonts/helv24.txf deleted file mode 100644 index ef27c6ece..000000000 Binary files a/fonts/helv24.txf and /dev/null differ diff --git a/fonts/helvbold12.txf b/fonts/helvbold12.txf deleted file mode 100644 index 07d4dc60c..000000000 Binary files a/fonts/helvbold12.txf and /dev/null differ diff --git a/fonts/helvbold18.txf b/fonts/helvbold18.txf deleted file mode 100644 index 1100c9fae..000000000 Binary files a/fonts/helvbold18.txf and /dev/null differ diff --git a/fonts/helvbold24.txf b/fonts/helvbold24.txf deleted file mode 100644 index bc8df1e9e..000000000 Binary files a/fonts/helvbold24.txf and /dev/null differ diff --git a/fonts/sans10.txf b/fonts/sans10.txf deleted file mode 100644 index fee47a05f..000000000 Binary files a/fonts/sans10.txf and /dev/null differ diff --git a/fonts/sans10_ru.txf b/fonts/sans10_ru.txf deleted file mode 100644 index 14792180e..000000000 Binary files a/fonts/sans10_ru.txf and /dev/null differ diff --git a/fonts/sans12.txf b/fonts/sans12.txf deleted file mode 100644 index bf649867d..000000000 Binary files a/fonts/sans12.txf and /dev/null differ diff --git a/fonts/sans12_be.txf b/fonts/sans12_be.txf deleted file mode 100644 index 47e5bb6a5..000000000 Binary files a/fonts/sans12_be.txf and /dev/null differ diff --git a/fonts/sans12_bg.txf b/fonts/sans12_bg.txf deleted file mode 100644 index 07c187e11..000000000 Binary files a/fonts/sans12_bg.txf and /dev/null differ diff --git a/fonts/sans12_ja.txf b/fonts/sans12_ja.txf deleted file mode 100644 index 4e40a3be0..000000000 Binary files a/fonts/sans12_ja.txf and /dev/null differ diff --git a/fonts/sans12_ko.txf b/fonts/sans12_ko.txf deleted file mode 100644 index 7378b1b01..000000000 Binary files a/fonts/sans12_ko.txf and /dev/null differ diff --git a/fonts/sans12_ru.txf b/fonts/sans12_ru.txf deleted file mode 100644 index 47e5bb6a5..000000000 Binary files a/fonts/sans12_ru.txf and /dev/null differ diff --git a/fonts/sans12_uk.txf b/fonts/sans12_uk.txf deleted file mode 100644 index 47e5bb6a5..000000000 Binary files a/fonts/sans12_uk.txf and /dev/null differ diff --git a/fonts/sans12_zh_CN.txf b/fonts/sans12_zh_CN.txf deleted file mode 100644 index 049ec4f8c..000000000 Binary files a/fonts/sans12_zh_CN.txf and /dev/null differ diff --git a/fonts/sans12_zh_TW.txf b/fonts/sans12_zh_TW.txf deleted file mode 100644 index ed31ee24f..000000000 Binary files a/fonts/sans12_zh_TW.txf and /dev/null differ diff --git a/fonts/sans14.txf b/fonts/sans14.txf deleted file mode 100644 index 4f89d608e..000000000 Binary files a/fonts/sans14.txf and /dev/null differ diff --git a/fonts/sans14_be.txf b/fonts/sans14_be.txf deleted file mode 100644 index 81250a611..000000000 Binary files a/fonts/sans14_be.txf and /dev/null differ diff --git a/fonts/sans14_ja.txf b/fonts/sans14_ja.txf deleted file mode 100644 index b6b8ed82d..000000000 Binary files a/fonts/sans14_ja.txf and /dev/null differ diff --git a/fonts/sans14_ko.txf b/fonts/sans14_ko.txf deleted file mode 100644 index 34d876a03..000000000 Binary files a/fonts/sans14_ko.txf and /dev/null differ diff --git a/fonts/sans14_ru.txf b/fonts/sans14_ru.txf deleted file mode 100644 index 81250a611..000000000 Binary files a/fonts/sans14_ru.txf and /dev/null differ diff --git a/fonts/sans14_uk.txf b/fonts/sans14_uk.txf deleted file mode 100644 index 81250a611..000000000 Binary files a/fonts/sans14_uk.txf and /dev/null differ diff --git a/fonts/sans14_zh_CN.txf b/fonts/sans14_zh_CN.txf deleted file mode 100644 index ac50ab1ed..000000000 Binary files a/fonts/sans14_zh_CN.txf and /dev/null differ diff --git a/fonts/sans14_zh_TW.txf b/fonts/sans14_zh_TW.txf deleted file mode 100644 index d0fda61a6..000000000 Binary files a/fonts/sans14_zh_TW.txf and /dev/null differ diff --git a/fonts/sans20.txf b/fonts/sans20.txf deleted file mode 100644 index f38a3439b..000000000 Binary files a/fonts/sans20.txf and /dev/null differ diff --git a/fonts/sansbold10.txf b/fonts/sansbold10.txf deleted file mode 100644 index be40a9147..000000000 Binary files a/fonts/sansbold10.txf and /dev/null differ diff --git a/fonts/sansbold12.txf b/fonts/sansbold12.txf deleted file mode 100644 index 4c6eb0cf9..000000000 Binary files a/fonts/sansbold12.txf and /dev/null differ diff --git a/fonts/sansbold14.txf b/fonts/sansbold14.txf deleted file mode 100644 index a220007b4..000000000 Binary files a/fonts/sansbold14.txf and /dev/null differ diff --git a/fonts/sansbold20.txf b/fonts/sansbold20.txf deleted file mode 100644 index 8ffacf86a..000000000 Binary files a/fonts/sansbold20.txf and /dev/null differ diff --git a/fonts/sansbold20_be.txf b/fonts/sansbold20_be.txf deleted file mode 100644 index 2d18fee66..000000000 Binary files a/fonts/sansbold20_be.txf and /dev/null differ diff --git a/fonts/sansbold20_bg.txf b/fonts/sansbold20_bg.txf deleted file mode 100644 index 8dd53a2e6..000000000 Binary files a/fonts/sansbold20_bg.txf and /dev/null differ diff --git a/fonts/sansbold20_ja.txf b/fonts/sansbold20_ja.txf deleted file mode 100644 index d4cae1ca4..000000000 Binary files a/fonts/sansbold20_ja.txf and /dev/null differ diff --git a/fonts/sansbold20_ko.txf b/fonts/sansbold20_ko.txf deleted file mode 100644 index 036ac00c2..000000000 Binary files a/fonts/sansbold20_ko.txf and /dev/null differ diff --git a/fonts/sansbold20_ru.txf b/fonts/sansbold20_ru.txf deleted file mode 100644 index 2d18fee66..000000000 Binary files a/fonts/sansbold20_ru.txf and /dev/null differ diff --git a/fonts/sansbold20_uk.txf b/fonts/sansbold20_uk.txf deleted file mode 100644 index 2d18fee66..000000000 Binary files a/fonts/sansbold20_uk.txf and /dev/null differ diff --git a/fonts/sansbold20_zh_CN.txf b/fonts/sansbold20_zh_CN.txf deleted file mode 100644 index 91589e543..000000000 Binary files a/fonts/sansbold20_zh_CN.txf and /dev/null differ diff --git a/fonts/sansbold20_zh_TW.txf b/fonts/sansbold20_zh_TW.txf deleted file mode 100644 index df006f511..000000000 Binary files a/fonts/sansbold20_zh_TW.txf and /dev/null differ diff --git a/src/celtxf/CMakeLists.txt b/src/celtxf/CMakeLists.txt deleted file mode 100644 index ce307bbe0..000000000 --- a/src/celtxf/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -set(CELTFX_SOURCES - texturefont.cpp - texturefont.h -) - -add_library(celtxf STATIC ${CELTFX_SOURCES}) - -#[[ -add_library(celtxf SHARED ${CELTFX_SOURCES}) -set_target_properties(celtxf PROPERTIES - VERSION ${VERSION} - SOVERSION ${VERSION} -) -]]# - -add_dependencies(celtxf celutil) -target_link_libraries(celtxf celutil) - -#install(TARGETS celtxf LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/src/celtxf/texturefont.cpp b/src/celtxf/texturefont.cpp deleted file mode 100644 index a860563eb..000000000 --- a/src/celtxf/texturefont.cpp +++ /dev/null @@ -1,468 +0,0 @@ -// texturefont.cpp -// -// Copyright (C) 2001, Chris Laurel -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "texturefont.h" - -using namespace std; - -TextureFont::TextureFont(const Renderer *r) : - renderer(r) -{ -} - -TextureFont::~TextureFont() -{ - if (texName != 0) - glDeleteTextures(1, (const GLuint*) &texName); - - delete[] fontImage; - delete[] glyphLookup; -} - - -struct FontVertex -{ - FontVertex(float _x, float _y, float _u, float _v) : - x(_x), y(_y), u(_u), v(_v) - {} - float x, y; - float u, v; -}; - - -/** Render a single character of the font, adding the specified offset - * to the location. - */ -float TextureFont::render(wchar_t ch, float xoffset, float yoffset) const -{ - const Glyph* glyph = getGlyph(ch); - if (glyph == nullptr) glyph = getGlyph((wchar_t)'?'); - if (glyph != nullptr) - { - const float x1 = glyph->xoff + xoffset; - const float y1 = glyph->yoff + yoffset; - const float x2 = glyph->xoff + glyph->width + xoffset; - const float y2 = glyph->yoff + glyph->height + yoffset; - FontVertex vertices[4] = { - {x1, y1, glyph->texCoords[0].u, glyph->texCoords[0].v}, - {x2, y1, glyph->texCoords[1].u, glyph->texCoords[1].v}, - {x2, y2, glyph->texCoords[2].u, glyph->texCoords[2].v}, - {x1, y2, glyph->texCoords[3].u, glyph->texCoords[3].v} - }; - glEnableVertexAttribArray(CelestiaGLProgram::VertexCoordAttributeIndex); - glEnableVertexAttribArray(CelestiaGLProgram::TextureCoord0AttributeIndex); - glVertexAttribPointer(CelestiaGLProgram::VertexCoordAttributeIndex, - 2, GL_FLOAT, GL_FALSE, sizeof(FontVertex), &vertices[0].x); - glVertexAttribPointer(CelestiaGLProgram::TextureCoord0AttributeIndex, - 2, GL_FLOAT, GL_FALSE, sizeof(FontVertex), &vertices[0].u); - glDrawArrays(GL_TRIANGLE_FAN, 0, 4); - glDisableVertexAttribArray(CelestiaGLProgram::VertexCoordAttributeIndex); - glDisableVertexAttribArray(CelestiaGLProgram::TextureCoord0AttributeIndex); - return glyph->advance; - } - return 0; -} - - -/** Render a string with the specified offset. Do *not* automatically update - * the modelview transform. - */ -float TextureFont::render(const string& s, float xoffset, float yoffset) const -{ - int len = s.length(); - bool validChar = true; - int i = 0; - float width = 0; - - while (i < len && validChar) { - wchar_t ch = 0; - validChar = UTF8Decode(s, i, ch); - i += UTF8EncodedSize(ch); - - render(ch, xoffset, yoffset); - - const Glyph* glyph = getGlyph(ch); - if (glyph == nullptr) - glyph = getGlyph((wchar_t)'?'); - xoffset += glyph->advance; - width += glyph->advance; - } - return width; -} - - -int TextureFont::getWidth(const string& s) const -{ - int width = 0; - int len = s.length(); - bool validChar = true; - int i = 0; - - while (i < len && validChar) - { - wchar_t ch = 0; - validChar = UTF8Decode(s, i, ch); - i += UTF8EncodedSize(ch); - - const Glyph* g = getGlyph(ch); - if (g != nullptr) - width += g->advance; - } - - return width; -} - - -int TextureFont::getHeight() const -{ - return maxAscent + maxDescent; -} - -int TextureFont::getMaxWidth() const -{ - return maxWidth; -} - -int TextureFont::getMaxAscent() const -{ - return maxAscent; -} - -void TextureFont::setMaxAscent(int _maxAscent) -{ - maxAscent = _maxAscent; -} - -int TextureFont::getMaxDescent() const -{ - return maxDescent; -} - -void TextureFont::setMaxDescent(int _maxDescent) -{ - maxDescent = _maxDescent; -} - - -int TextureFont::getTextureName() const -{ - return texName; -} - - -void TextureFont::bind() -{ - auto *prog = renderer->getShaderManager().getShader("text"); - if (prog == nullptr) - return; - - if (texName != 0) - { - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, texName); - prog->use(); - prog->samplerParam("atlasTex") = 0; - } -} - -void TextureFont::unbind() -{ - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, 0); - glUseProgram(0); -} - -void TextureFont::addGlyph(const TextureFont::Glyph& g) -{ - glyphs.push_back(g); - if (g.width > maxWidth) - maxWidth = g.width; -} - - -const TextureFont::Glyph* TextureFont::getGlyph(wchar_t ch) const -{ - if (ch >= (wchar_t)glyphLookupTableSize) - return nullptr; - - return glyphLookup[ch]; -} - - -bool TextureFont::buildTexture() -{ - assert(fontImage != nullptr); - - if (texName != 0) - glDeleteTextures(1, (const GLuint*) &texName); - glGenTextures(1, (GLuint*) &texName); - if (texName == 0) - { - DPRINTF(LOG_LEVEL_ERROR, "Failed to allocate texture object for font.\n"); - return false; - } - - glBindTexture(GL_TEXTURE_2D, texName); - - // Don't build mipmaps . . . should really make them an option. - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, - texWidth, texHeight, - 0, - GL_ALPHA, GL_UNSIGNED_BYTE, - fontImage); - - return true; -} - - -void TextureFont::rebuildGlyphLookupTable() -{ - if (glyphs.size() == 0) - return; - - // Find the largest glyph id - int maxID = glyphs[0].__id; - vector::const_iterator iter; - for (iter = glyphs.begin(); iter != glyphs.end(); iter++) - { - if (iter->__id > maxID) - maxID = iter->__id; - } - - // If there was already a lookup table, delete it. - delete[] glyphLookup; - - DPRINTF(LOG_LEVEL_INFO, "texturefont: allocating glyph lookup table with %d entries.\n", - maxID + 1); - glyphLookup = new const Glyph*[maxID + 1]; - for (int i = 0; i <= maxID; i++) - glyphLookup[i] = nullptr; - - // Fill the table with glyph pointers - for (iter = glyphs.begin(); iter != glyphs.end(); iter++) - glyphLookup[iter->__id] = &(*iter); - glyphLookupTableSize = (unsigned int) maxID + 1; -} - - -static uint32_t readUint32(istream& in, bool swap) -{ - uint32_t x; - in.read(reinterpret_cast(&x), sizeof x); - return swap ? bswap_32(x) : x; -} - -static uint16_t readUint16(istream& in, bool swap) -{ - uint16_t x; - in.read(reinterpret_cast(&x), sizeof x); - return swap ? bswap_16(x) : x; -} - -static uint8_t readUint8(istream& in) -{ - uint8_t x; - in.read(reinterpret_cast(&x), sizeof x); - return x; -} - -/* Not currently used -static int32_t readInt32(istream& in, bool swap) -{ - int32_t x; - in.read(reinterpret_cast(&x), sizeof x); - return swap ? static_cast(bswap_32(static_cast(x))) : x; -}*/ - -static int16_t readInt16(istream& in, bool swap) -{ - int16_t x; - in.read(reinterpret_cast(&x), sizeof x); - return swap ? static_cast(bswap_16(static_cast(x))) : x; -} - -static int8_t readInt8(istream& in) -{ - int8_t x; - in.read(reinterpret_cast(&x), sizeof x); - return x; -} - - -TextureFont* TextureFont::load(const Renderer *r, istream& in) -{ - char header[4]; - - in.read(header, sizeof header); - if (!in.good() || strncmp(header, "\377txf", 4) != 0) - { - DPRINTF(LOG_LEVEL_ERROR, "Stream is not a texture font!.\n"); - return nullptr; - } - - uint32_t endiannessTest = 0; - in.read(reinterpret_cast(&endiannessTest), sizeof endiannessTest); - if (!in.good()) - { - DPRINTF(LOG_LEVEL_ERROR, "Error reading endianness bytes in txf header.\n"); - return nullptr; - } - - bool byteSwap; - if (endiannessTest == 0x78563412) - byteSwap = true; - else if (endiannessTest == 0x12345678) - byteSwap = false; - else - { - DPRINTF(LOG_LEVEL_ERROR, "Stream is not a texture font!.\n"); - return nullptr; - } - - int format = readUint32(in, byteSwap); - unsigned int texWidth = readUint32(in, byteSwap); - unsigned int texHeight = readUint32(in, byteSwap); - unsigned int maxAscent = readUint32(in, byteSwap); - unsigned int maxDescent = readUint32(in, byteSwap); - unsigned int nGlyphs = readUint32(in, byteSwap); - - if (!in) - { - DPRINTF(LOG_LEVEL_ERROR, "Texture font stream is incomplete"); - return nullptr; - } - - DPRINTF(LOG_LEVEL_INFO, "Font contains %d glyphs.\n", nGlyphs); - - auto* font = new TextureFont(r); - assert(font != nullptr); - - font->setMaxAscent(maxAscent); - font->setMaxDescent(maxDescent); - - float dx = 0.5f / texWidth; - float dy = 0.5f / texHeight; - - for (unsigned int i = 0; i < nGlyphs; i++) - { - uint16_t __id = readUint16(in, byteSwap); - TextureFont::Glyph glyph(__id); - - glyph.width = readUint8(in); - glyph.height = readUint8(in); - glyph.xoff = readInt8(in); - glyph.yoff = readInt8(in); - glyph.advance = readInt8(in); - readInt8(in); - glyph.x = readInt16(in, byteSwap); - glyph.y = readInt16(in, byteSwap); - - if (!in) - { - DPRINTF(LOG_LEVEL_ERROR, "Error reading glyph %ud from texture font stream.\n", i); - delete font; - return nullptr; - } - - float fWidth = texWidth; - float fHeight = texHeight; - glyph.texCoords[0].u = glyph.x / fWidth + dx; - glyph.texCoords[0].v = glyph.y / fHeight + dy; - glyph.texCoords[1].u = (glyph.x + glyph.width) / fWidth + dx; - glyph.texCoords[1].v = glyph.y / fHeight + dy; - glyph.texCoords[2].u = (glyph.x + glyph.width) / fWidth + dx; - glyph.texCoords[2].v = (glyph.y + glyph.height) / fHeight + dy; - glyph.texCoords[3].u = glyph.x / fWidth + dx; - glyph.texCoords[3].v = (glyph.y + glyph.height) / fHeight + dy; - - font->addGlyph(glyph); - } - - font->texWidth = texWidth; - font->texHeight = texHeight; - if (format == TxfByte) - { - auto* fontImage = new unsigned char[texWidth * texHeight]; - - DPRINTF(LOG_LEVEL_INFO, "Reading %d x %d 8-bit font image.\n", texWidth, texHeight); - - in.read(reinterpret_cast(fontImage), texWidth * texHeight); - if (in.gcount() != (signed)(texWidth * texHeight)) - { - DPRINTF(LOG_LEVEL_ERROR, "Missing bitmap data in font stream.\n"); - delete font; - delete[] fontImage; - return nullptr; - } - - font->fontImage = fontImage; - } - else - { - int rowBytes = (texWidth + 7) >> 3; - auto* fontBits = new unsigned char[rowBytes * texHeight]; - auto* fontImage = new unsigned char[texWidth * texHeight]; - - DPRINTF(LOG_LEVEL_INFO, "Reading %d x %d 1-bit font image.\n", texWidth, texHeight); - - in.read(reinterpret_cast(fontBits), rowBytes * texHeight); - if (in.gcount() != (signed)(rowBytes * texHeight)) - { - DPRINTF(LOG_LEVEL_ERROR, "Missing bitmap data in font stream.\n"); - delete font; - delete[] fontImage; - delete[] fontBits; - return nullptr; - } - - for (unsigned int y = 0; y < texHeight; y++) - { - for (unsigned int x = 0; x < texWidth; x++) - { - if ((fontBits[y * rowBytes + (x >> 3)] & (1 << (x & 0x7))) != 0) - fontImage[y * texWidth + x] = 0xff; - else - fontImage[y * texWidth + x] = 0x0; - } - } - - font->fontImage = fontImage; - delete[] fontBits; - } - - font->rebuildGlyphLookupTable(); - - return font; -} - - -TextureFont* LoadTextureFont(const Renderer *r, const fs::path& filename) -{ - fs::path localeFilename = LocaleFilename(filename); - ifstream in(localeFilename.string(), ios::in | ios::binary); - if (!in.good()) - { - DPRINTF(LOG_LEVEL_ERROR, "Could not open font file %s\n", filename); - return nullptr; - } - - return TextureFont::load(r, in); -} diff --git a/src/celtxf/texturefont.h b/src/celtxf/texturefont.h deleted file mode 100644 index 3f3343642..000000000 --- a/src/celtxf/texturefont.h +++ /dev/null @@ -1,111 +0,0 @@ -// texturefont.h -// -// Copyright (C) 2001, Chris Laurel -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. - -#ifndef _TEXTUREFONT_H_ -#define _TEXTUREFONT_H_ - -#include -#include -#include -#include - -class Renderer; - -class TextureFont -{ - TextureFont(const Renderer*); - - public: - TextureFont() = delete; - ~TextureFont(); - - float render(wchar_t ch, float xoffset = 0.0f, float yoffset = 0.0f) const; - float render(const std::string& s, float xoffset = 0.0f, float yoffset = 0.0f) const; - - int getWidth(const std::string&) const; - int getWidth(int c) const; - int getMaxWidth() const; - int getHeight() const; - - int getMaxAscent() const; - void setMaxAscent(int); - int getMaxDescent() const; - void setMaxDescent(int); - - short getAdvance(wchar_t c) - { - const Glyph* glyph = getGlyph(c); - if (glyph == nullptr) - glyph = getGlyph((wchar_t) '?'); - return glyph->advance; - } - - int getTextureName() const; - - void bind(); - void unbind(); - void flush() {}; - - bool buildTexture(); - - public: - struct TexCoord - { - float u, v; - }; - - struct Glyph - { - Glyph(unsigned short _id) : __id(_id) {}; - - unsigned short __id; - unsigned short width; - unsigned short height; - short x; - short xoff; - short y; - short yoff; - short advance; - TexCoord texCoords[4]; - }; - - enum - { - TxfByte = 0, - TxfBitmap = 1, - }; - - private: - void addGlyph(const Glyph&); - const TextureFont::Glyph* getGlyph(wchar_t) const; - void rebuildGlyphLookupTable(); - - private: - const Renderer *renderer; - int maxAscent{ 0 }; - int maxDescent{ 0 }; - int maxWidth{ 0 }; - - int texWidth{ 0 }; - int texHeight{ 0 }; - unsigned char* fontImage{ nullptr }; - unsigned int texName{ 0 }; - - std::vector glyphs; - - const Glyph** glyphLookup{ nullptr }; - unsigned int glyphLookupTableSize{ 0 }; - - public: - static TextureFont* load(const Renderer*, std::istream& in); -}; - -TextureFont* LoadTextureFont(const Renderer*, const fs::path&); - -#endif // _TEXTUREFONT_H_