mirror of
https://github.com/love2d/love.git
synced 2026-08-18 11:44:15 +02:00
font rendering: reimplement tab-as-spaces support.
This commit is contained in:
@@ -61,7 +61,6 @@ Font::Font(love::font::Rasterizer *r, const SamplerState &s)
|
||||
, textureHeight(128)
|
||||
, samplerState()
|
||||
, dpiScale(r->getDPIScale())
|
||||
, useSpacesAsTab(false)
|
||||
, textureCacheID(0)
|
||||
{
|
||||
samplerState.minFilter = s.minFilter;
|
||||
@@ -92,10 +91,6 @@ Font::Font(love::font::Rasterizer *r, const SamplerState &s)
|
||||
if (pixelFormat == PIXELFORMAT_LA8_UNORM && !gfx->isPixelFormatSupported(pixelFormat, PIXELFORMATUSAGEFLAGS_SAMPLE))
|
||||
pixelFormat = PIXELFORMAT_RGBA8_UNORM;
|
||||
|
||||
uint32 tab = '\t';
|
||||
if (!r->hasGlyph(tab)) // No tab character in the Rasterizer.
|
||||
useSpacesAsTab = true;
|
||||
|
||||
loadVolatile();
|
||||
++fontCount;
|
||||
}
|
||||
@@ -232,24 +227,6 @@ void Font::unloadVolatile()
|
||||
love::font::GlyphData *Font::getRasterizerGlyphData(love::font::TextShaper::GlyphIndex glyphindex, float &dpiscale)
|
||||
{
|
||||
const auto &r = shaper->getRasterizers()[glyphindex.rasterizerIndex];
|
||||
|
||||
// Use spaces for the tab 'glyph'. FIXME
|
||||
if (/*glyph == '\t' &&*/ false && useSpacesAsTab)
|
||||
{
|
||||
love::font::GlyphData *spacegd = r->getGlyphData(32);
|
||||
PixelFormat fmt = spacegd->getFormat();
|
||||
|
||||
love::font::GlyphMetrics gm = {};
|
||||
gm.advance = spacegd->getAdvance() * SPACES_PER_TAB;
|
||||
gm.bearingX = spacegd->getBearingX();
|
||||
gm.bearingY = spacegd->getBearingY();
|
||||
|
||||
spacegd->release();
|
||||
|
||||
dpiscale = r->getDPIScale();
|
||||
return new love::font::GlyphData('\t', gm, fmt);
|
||||
}
|
||||
|
||||
dpiscale = r->getDPIScale();
|
||||
return r->getGlyphDataForIndex(glyphindex.index);
|
||||
}
|
||||
|
||||
@@ -201,8 +201,6 @@ private:
|
||||
int textureX, textureY;
|
||||
int rowHeight;
|
||||
|
||||
bool useSpacesAsTab;
|
||||
|
||||
// ID which is incremented when the texture cache is invalidated.
|
||||
uint32 textureCacheID;
|
||||
|
||||
@@ -211,9 +209,6 @@ private:
|
||||
// use, for edge antialiasing.
|
||||
static const int TEXTURE_PADDING = 2;
|
||||
|
||||
// This will be used if the Rasterizer doesn't have a tab character itself.
|
||||
static const int SPACES_PER_TAB = 4;
|
||||
|
||||
static StringMap<AlignMode, ALIGN_MAX_ENUM>::Entry alignModeEntries[];
|
||||
static StringMap<AlignMode, ALIGN_MAX_ENUM> alignModes;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user