mirror of
https://github.com/love2d/love.git
synced 2026-08-12 08:30:56 +02:00
Improve compatibility check (I still can't believe robin was right)
This commit is contained in:
@@ -73,4 +73,4 @@ namespace freetype
|
||||
} // font
|
||||
} // love
|
||||
|
||||
#endif // LOVE_FONT_FREETYPE_FONT_H
|
||||
#endif // LOVE_FONT_FREETYPE_FONT_H
|
||||
|
||||
@@ -51,10 +51,15 @@ namespace freetype
|
||||
metrics.ascent = s.ascender >> 6;
|
||||
metrics.descent = s.descender >> 6;
|
||||
metrics.height = s.height >> 6;
|
||||
|
||||
ref = WeakReference::obtain(this);
|
||||
}
|
||||
|
||||
TrueTypeRasterizer::~TrueTypeRasterizer()
|
||||
{
|
||||
ref->destroy();
|
||||
ref->release();
|
||||
|
||||
FT_Done_Face(face);
|
||||
data->release();
|
||||
}
|
||||
@@ -116,4 +121,4 @@ namespace freetype
|
||||
|
||||
} // freetype
|
||||
} // font
|
||||
} // love
|
||||
} // love
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
// LOVE
|
||||
#include <filesystem/File.h>
|
||||
#include <font/Rasterizer.h>
|
||||
#include <common/WeakReference.h>
|
||||
|
||||
// TrueType2
|
||||
#include <ft2build.h>
|
||||
@@ -51,6 +52,8 @@ namespace freetype
|
||||
|
||||
// File data
|
||||
Data * data;
|
||||
|
||||
WeakReference * ref;
|
||||
|
||||
public:
|
||||
TrueTypeRasterizer(FT_Library library, Data * data, int size);
|
||||
@@ -67,4 +70,4 @@ namespace freetype
|
||||
} // font
|
||||
} // love
|
||||
|
||||
#endif // LOVE_FONT_FREETYPE_TRUE_TYPE_RASTERIZER_H
|
||||
#endif // LOVE_FONT_FREETYPE_TRUE_TYPE_RASTERIZER_H
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace freetype
|
||||
int size = luaL_checkint(L, 2);
|
||||
t = instance->newRasterizer(d, size);
|
||||
}
|
||||
|
||||
|
||||
luax_newtype(L, "Rasterizer", FONT_RASTERIZER_T, t);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -40,9 +40,9 @@ namespace opengl
|
||||
{
|
||||
|
||||
Font::Font(love::font::Rasterizer * r, const Image::Filter& filter)
|
||||
: rasterizer(r), height(r->getHeight()), lineHeight(1), mSpacing(1), filter(filter)
|
||||
: height(r->getHeight()), lineHeight(1), mSpacing(1), filter(filter)
|
||||
{
|
||||
r->retain();
|
||||
rasterizer = WeakReference::obtain(r);
|
||||
love::font::GlyphData * gd = r->getGlyphData(32);
|
||||
type = (gd->getFormat() == love::font::GlyphData::FORMAT_LUMINANCE_ALPHA ? FONT_TRUETYPE : FONT_IMAGE);
|
||||
delete gd;
|
||||
@@ -51,6 +51,7 @@ namespace opengl
|
||||
|
||||
Font::~Font()
|
||||
{
|
||||
rasterizer->destroy();
|
||||
rasterizer->release();
|
||||
unloadVolatile();
|
||||
}
|
||||
@@ -83,13 +84,15 @@ namespace opengl
|
||||
|
||||
Font::Glyph * Font::addGlyph(int glyph)
|
||||
{
|
||||
if (!rasterizer->isValid) return 0;
|
||||
love::font::Rasterizer *r = (love::font::Rasterizer*) rasterizer->getData();
|
||||
Glyph * g = new Glyph;
|
||||
g->list = glGenLists(1);
|
||||
if (g->list == 0) { // opengl failed to generate the list
|
||||
delete g;
|
||||
return NULL;
|
||||
}
|
||||
love::font::GlyphData *gd = rasterizer->getGlyphData(glyph);
|
||||
love::font::GlyphData *gd = r->getGlyphData(glyph);
|
||||
g->spacing = gd->getAdvance();
|
||||
int w = gd->getWidth();
|
||||
int h = gd->getHeight();
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
// LOVE
|
||||
#include <common/Object.h>
|
||||
#include <common/WeakReference.h>
|
||||
#include <font/Rasterizer.h>
|
||||
#include <graphics/Image.h>
|
||||
|
||||
@@ -56,7 +57,7 @@ namespace opengl
|
||||
int spacing;
|
||||
};
|
||||
|
||||
love::font::Rasterizer * rasterizer;
|
||||
WeakReference *rasterizer;
|
||||
|
||||
int height;
|
||||
float lineHeight;
|
||||
|
||||
@@ -321,6 +321,7 @@ function love.init()
|
||||
for i, v in ipairs(love._version_compat) do
|
||||
if c.version == v then
|
||||
compat = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if not compat then
|
||||
|
||||
@@ -544,6 +544,7 @@ const unsigned char boot_lua[] =
|
||||
0x09, 0x09, 0x69, 0x66, 0x20, 0x63, 0x2e, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x3d, 0x20,
|
||||
0x76, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a,
|
||||
0x09, 0x09, 0x09, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x74, 0x20, 0x3d, 0x20, 0x74, 0x72, 0x75, 0x65, 0x0a,
|
||||
0x09, 0x09, 0x09, 0x62, 0x72, 0x65, 0x61, 0x6b, 0x0a,
|
||||
0x09, 0x09, 0x65, 0x6e, 0x64, 0x0a,
|
||||
0x09, 0x65, 0x6e, 0x64, 0x0a,
|
||||
0x09, 0x69, 0x66, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x74, 0x20, 0x74, 0x68, 0x65,
|
||||
|
||||
Reference in New Issue
Block a user