Skip to content

Commit

Permalink
update BitmapFont to v1.1.3
Browse files Browse the repository at this point in the history
fixes some basic code issues including explict casting.
  • Loading branch information
Hapaxia committed Jan 23, 2025
1 parent 7fd0b32 commit 1f018a3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/SelbaWard/BitmapFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,8 @@ const BitmapFont::Glyph BitmapFont::priv_getGlyphWithDefaultTextureRect(std::siz
Glyph defaultGlyph;
defaultGlyph.useDefaultTextureRect = false;
defaultGlyph.textureRect = m_defaultTextureRect;
defaultGlyph.textureRect.position.x = m_defaultTextureRect.size.x * (glyphIndex % m_numberOfTilesPerRow);
defaultGlyph.textureRect.position.y = m_defaultTextureRect.size.y * (glyphIndex / m_numberOfTilesPerRow);
defaultGlyph.textureRect.position.x = m_defaultTextureRect.size.x * static_cast<int>(glyphIndex % m_numberOfTilesPerRow);
defaultGlyph.textureRect.position.y = m_defaultTextureRect.size.y * static_cast<int>(glyphIndex / m_numberOfTilesPerRow);
defaultGlyph.width = m_glyphs[glyphIndex].width;
defaultGlyph.baseline = m_glyphs[glyphIndex].baseline;
defaultGlyph.startX = m_glyphs[glyphIndex].startX;
Expand Down
12 changes: 6 additions & 6 deletions src/SelbaWard/BitmapFont.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@
namespace selbaward
{

// SW Bitmap Font v1.1.2
// SW Bitmap Font v1.1.3
class BitmapFont
{
public:
struct Glyph
{
bool useDefaultTextureRect{ true };
sf::IntRect textureRect;
int width; // zero and below represent counting from full texture rect width e.g. 0 is full width, -1 is 1 less than full width.
int baseline; // negative numbers represent counting from bottom e.g. -1 is bottom line, -2 is 1 above bottom.
int startX; // negative numbers represent actual negative values
sf::IntRect textureRect{};
int width{}; // zero and below represent counting from full texture rect width e.g. 0 is full width, -1 is 1 less than full width.
int baseline{}; // negative numbers represent counting from bottom e.g. -1 is bottom line, -2 is 1 above bottom.
int startX{}; // negative numbers represent actual negative values
};

BitmapFont();
Expand Down Expand Up @@ -113,7 +113,7 @@ class BitmapFont
bool m_useExternalTexture;
sf::Texture m_texture;
const sf::Texture* m_mExternalTexture;
unsigned int m_numberOfTilesPerRow;
std::size_t m_numberOfTilesPerRow;
sf::Vector2u m_tileSize;
sf::IntRect m_defaultTextureRect;
mutable std::map<std::string, int> m_kernings;
Expand Down

0 comments on commit 1f018a3

Please sign in to comment.