#include "fsCFont.h"
#include <vector>
#include <raylib.h>
#include <fsCore/src/fsCResourceName.h>
namespace
{
// LoadFont() (codepoints=NULL) only ever loads the standard 95 ASCII printable glyphs
// (32-126), so any other character - accented Latin letters used by fr/de locales,
// typographic bullets/dashes/quotes used in game UI copy - silently has no glyph and
// falls back to whatever raylib substitutes for a missing glyph. Request a wider,
// still-bounded set explicitly instead.
std::vector<int> defaultCodepointsGet()
{
std::vector<int> codepoints;
for (int codepoint = 32; codepoint <= 126; ++codepoint)
{
codepoints.push_back(codepoint);
}
for (int codepoint = 160; codepoint <= 255; ++codepoint)
{
codepoints.push_back(codepoint);
}
// Bullet (used by GUI help-list style content), en/em dash, curly quotes.
const int extras[] = { 0x2022, 0x25CF, 0x2013, 0x2014, 0x2018, 0x2019, 0x201C, 0x201D };
for (int codepoint : extras)
{
codepoints.push_back(codepoint);<--- Consider using std::copy algorithm instead of a raw loop.
}
return codepoints;
}
}
void fsCFont::initialiseDo(const fsSFontParams& pParams)
{
const fsF32 fontSize = pParams.mTrueFontSize ? static_cast<fsF32>(pParams.mTrueFontSize) : static_cast<fsF32>(pParams.mFontSize) * 2.6f;
mPointSize = fontSize;
const std::vector<int> codepoints = defaultCodepointsGet();
mFont = LoadFontEx(pParams.mFileName.nameGet().utf8Get(), static_cast<int>(fontSize), codepoints.data(), static_cast<int>(codepoints.size()));
// GenTextureMipmaps(&mFont.texture);
SetTextureFilter(mFont.texture, TEXTURE_FILTER_TRILINEAR);
}
fsCFont::fsCFont()
{
}
fsCFont::~fsCFont()
{
}