mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +02:00
Use unsigned ints instead of unsigned shorts to represent UTF8 font glyphs
This commit is contained in:
@@ -160,7 +160,7 @@ void Font::createTexture()
|
||||
setMipmapSharpness(mipmapsharpness);
|
||||
}
|
||||
|
||||
Font::Glyph *Font::addGlyph(const int glyph)
|
||||
Font::Glyph *Font::addGlyph(unsigned int glyph)
|
||||
{
|
||||
love::font::GlyphData *gd = rasterizer->getGlyphData(glyph);
|
||||
int w = gd->getWidth();
|
||||
@@ -233,7 +233,7 @@ Font::Glyph *Font::addGlyph(const int glyph)
|
||||
return g;
|
||||
}
|
||||
|
||||
Font::Glyph *Font::findGlyph(const int glyph)
|
||||
Font::Glyph *Font::findGlyph(unsigned int glyph)
|
||||
{
|
||||
Glyph *g = glyphs[glyph];
|
||||
if (!g)
|
||||
@@ -273,7 +273,7 @@ void Font::print(const std::string &text, float x, float y, float letter_spacing
|
||||
|
||||
while (i != end)
|
||||
{
|
||||
int g = *i++;
|
||||
unsigned int g = *i++;
|
||||
|
||||
if (g == '\n')
|
||||
{
|
||||
@@ -380,7 +380,7 @@ int Font::getWidth(const std::string &str)
|
||||
utf8::iterator<std::string::const_iterator> end(line.end(), line.begin(), line.end());
|
||||
while (i != end)
|
||||
{
|
||||
int c = *i++;
|
||||
unsigned int c = *i++;
|
||||
g = findGlyph(c);
|
||||
width += static_cast<int>(g->spacing * mSpacing);
|
||||
}
|
||||
@@ -402,7 +402,7 @@ int Font::getWidth(const char *str)
|
||||
return this->getWidth(std::string(str));
|
||||
}
|
||||
|
||||
int Font::getWidth(const char character)
|
||||
int Font::getWidth(unsigned int character)
|
||||
{
|
||||
Glyph *g = findGlyph(character);
|
||||
return g->spacing;
|
||||
@@ -574,7 +574,7 @@ bool Font::loadVolatile()
|
||||
void Font::unloadVolatile()
|
||||
{
|
||||
// nuke everything from orbit
|
||||
std::map<int, Glyph *>::iterator it = glyphs.begin();
|
||||
std::map<unsigned int, Glyph *>::iterator it = glyphs.begin();
|
||||
Glyph *g;
|
||||
while (it != glyphs.end())
|
||||
{
|
||||
|
||||
@@ -78,17 +78,17 @@ public:
|
||||
/**
|
||||
* Returns the width of the passed string.
|
||||
*
|
||||
* @param line A line of text.
|
||||
* @param str A string of text.
|
||||
**/
|
||||
int getWidth(const std::string &line);
|
||||
int getWidth(const char *line);
|
||||
int getWidth(const std::string &str);
|
||||
int getWidth(const char *str);
|
||||
|
||||
/**
|
||||
* Returns the width of the passed character.
|
||||
*
|
||||
* @param character A character.
|
||||
**/
|
||||
int getWidth(const char character);
|
||||
int getWidth(unsigned int character);
|
||||
|
||||
/**
|
||||
* Returns the maximal width of a wrapped string
|
||||
@@ -191,7 +191,7 @@ private:
|
||||
int texture_height;
|
||||
|
||||
std::vector<GLuint> textures; // vector of packed textures
|
||||
std::map<int, Glyph *> glyphs; // maps glyphs to quad information
|
||||
std::map<unsigned int, Glyph *> glyphs; // maps glyphs to quad information
|
||||
FontType type;
|
||||
Image::Filter filter;
|
||||
|
||||
@@ -214,8 +214,8 @@ private:
|
||||
|
||||
bool initializeTexture(GLint format);
|
||||
void createTexture();
|
||||
Glyph *addGlyph(const int glyph);
|
||||
Glyph *findGlyph (const int glyph);
|
||||
Glyph *addGlyph(unsigned int glyph);
|
||||
Glyph *findGlyph(unsigned int glyph);
|
||||
}; // Font
|
||||
|
||||
} // opengl
|
||||
|
||||
Reference in New Issue
Block a user