mirror of
https://github.com/love2d/love.git
synced 2026-08-16 16:20:42 +02:00
Automated formatting fix
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 LOVE Development Team
|
||||
*
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
|
||||
@@ -30,7 +30,8 @@ namespace font
|
||||
GlyphData::GlyphData(unsigned short glyph, GlyphMetrics glyphMetrics, GlyphData::Format f)
|
||||
: glyph(glyph), metrics(glyphMetrics), data(0), format(f)
|
||||
{
|
||||
if (metrics.width && metrics.height) {
|
||||
if (metrics.width && metrics.height)
|
||||
{
|
||||
switch (f) {
|
||||
case GlyphData::FORMAT_LUMINANCE_ALPHA:
|
||||
data = new unsigned char[metrics.width * metrics.height * 2];
|
||||
@@ -116,6 +117,6 @@ namespace font
|
||||
{
|
||||
return format;
|
||||
}
|
||||
|
||||
|
||||
} // font
|
||||
} // love
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 LOVE Development Team
|
||||
*
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
@@ -47,14 +47,14 @@ namespace font
|
||||
**/
|
||||
class GlyphData : public Data
|
||||
{
|
||||
|
||||
|
||||
public:
|
||||
enum Format
|
||||
{
|
||||
FORMAT_LUMINANCE_ALPHA,
|
||||
FORMAT_RGBA
|
||||
};
|
||||
|
||||
|
||||
GlyphData(unsigned short glyph, GlyphMetrics glyphMetrics, Format f);
|
||||
virtual ~GlyphData();
|
||||
|
||||
@@ -106,22 +106,22 @@ namespace font
|
||||
* Gets the max y value of the glyph.
|
||||
**/
|
||||
int getMaxY() const;
|
||||
|
||||
|
||||
/**
|
||||
* Gets the format of the glyph data.
|
||||
**/
|
||||
Format getFormat() const;
|
||||
|
||||
|
||||
private:
|
||||
// The glyph itself
|
||||
unsigned short glyph;
|
||||
|
||||
|
||||
// Glyph metrics
|
||||
GlyphMetrics metrics;
|
||||
|
||||
|
||||
// Glyph texture data
|
||||
unsigned char * data;
|
||||
|
||||
|
||||
// The format the data's in
|
||||
Format format;
|
||||
|
||||
|
||||
@@ -72,7 +72,8 @@ namespace font
|
||||
if (gm.width == 0) return g;
|
||||
unsigned char * gd = (unsigned char*)g->getData();
|
||||
love::image::pixel * pixels = (love::image::pixel *)(imageData->getData());
|
||||
for (unsigned int i = 0; i < widths[glyph]*getHeight(); i++) {
|
||||
for (unsigned int i = 0; i < widths[glyph]*getHeight(); i++)
|
||||
{
|
||||
love::image::pixel p = pixels[ positions[glyph] + (i % widths[glyph]) + (imageData->getWidth() * (i / widths[glyph])) ];
|
||||
gd[i*4] = p.r;
|
||||
gd[i*4+1] = p.g;
|
||||
@@ -99,27 +100,27 @@ namespace font
|
||||
unsigned int start = 0;
|
||||
unsigned int end = 0;
|
||||
|
||||
for(unsigned int i = 0; i < length; ++i)
|
||||
for (unsigned int i = 0; i < length; ++i)
|
||||
{
|
||||
if(i >= MAX_CHARS)
|
||||
if (i >= MAX_CHARS)
|
||||
break;
|
||||
|
||||
start = end;
|
||||
|
||||
// Finds out where the first character starts
|
||||
while(start < imgw && equal(pixels[start], spacer))
|
||||
while (start < imgw && equal(pixels[start], spacer))
|
||||
++start;
|
||||
|
||||
if(i > 0)
|
||||
if (i > 0)
|
||||
spacing[glyphs[i - 1]] = (start > end) ? (start - end) : 0;
|
||||
|
||||
end = start;
|
||||
|
||||
// Find where glyph ends.
|
||||
while(end < imgw && !equal(pixels[end], spacer))
|
||||
while (end < imgw && !equal(pixels[end], spacer))
|
||||
++end;
|
||||
|
||||
if(start >= end)
|
||||
if (start >= end)
|
||||
break;
|
||||
|
||||
unsigned c = glyphs[i];
|
||||
@@ -129,9 +130,9 @@ namespace font
|
||||
}
|
||||
|
||||
// Replace spacer color with an empty pixel
|
||||
for(unsigned int i = 0; i < imgs; ++i)
|
||||
for (unsigned int i = 0; i < imgs; ++i)
|
||||
{
|
||||
if(equal(pixels[i], spacer))
|
||||
if (equal(pixels[i], spacer))
|
||||
{
|
||||
pixels[i].r = 0;
|
||||
pixels[i].g = 0;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 LOVE Development Team
|
||||
*
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
@@ -38,7 +38,7 @@ namespace font
|
||||
private:
|
||||
// Load all the glyph positions into memory
|
||||
void load();
|
||||
|
||||
|
||||
// The image data
|
||||
love::image::ImageData * imageData;
|
||||
// The glyphs in the font
|
||||
@@ -51,7 +51,7 @@ namespace font
|
||||
unsigned int * widths;
|
||||
// The spacing of each glyph
|
||||
unsigned int * spacing;
|
||||
|
||||
|
||||
public:
|
||||
ImageRasterizer(love::image::ImageData * imageData, unsigned short * glyphs, int length);
|
||||
virtual ~ImageRasterizer();
|
||||
@@ -60,9 +60,9 @@ namespace font
|
||||
virtual int getLineHeight() const;
|
||||
virtual GlyphData * getGlyphData(unsigned short glyph) const;
|
||||
virtual int getNumGlyphs() const;
|
||||
|
||||
|
||||
static const unsigned int MAX_CHARS = 256;
|
||||
|
||||
|
||||
}; // ImageRasterizer
|
||||
|
||||
} // font
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 LOVE Development Team
|
||||
*
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 LOVE Development Team
|
||||
*
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
@@ -47,7 +47,7 @@ namespace font
|
||||
{
|
||||
protected:
|
||||
FontMetrics metrics;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
virtual ~Rasterizer();
|
||||
@@ -82,7 +82,7 @@ namespace font
|
||||
* @param glyph The (UNICODE) glyph to get data for
|
||||
**/
|
||||
virtual GlyphData * getGlyphData(unsigned short glyph) const = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Gets the number of glyphs the rasterizer has data for.
|
||||
**/
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 LOVE Development Team
|
||||
*
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
@@ -31,7 +31,7 @@ namespace freetype
|
||||
{
|
||||
Font::Font()
|
||||
{
|
||||
if(FT_Init_FreeType(&library))
|
||||
if (FT_Init_FreeType(&library))
|
||||
throw love::Exception("TrueTypeFont Loading error: FT_Init_FreeType failed\n");
|
||||
}
|
||||
|
||||
@@ -44,12 +44,13 @@ namespace freetype
|
||||
{
|
||||
return new TrueTypeRasterizer(library, data, size);
|
||||
}
|
||||
|
||||
|
||||
Rasterizer * Font::newRasterizer(love::image::ImageData * data, std::string glyphs)
|
||||
{
|
||||
int length = glyphs.size();
|
||||
unsigned short * g = new unsigned short[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
g[i] = (unsigned char)glyphs[i];
|
||||
}
|
||||
Rasterizer * r = newRasterizer(data, g, length);
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 LOVE Development Team
|
||||
*
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
@@ -52,18 +52,18 @@ namespace freetype
|
||||
public:
|
||||
|
||||
Font();
|
||||
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
**/
|
||||
virtual ~Font();
|
||||
|
||||
|
||||
// Implements Font
|
||||
Rasterizer * newRasterizer(Data * data, int size);
|
||||
Rasterizer * newRasterizer(love::image::ImageData * data, std::string glyphs);
|
||||
Rasterizer * newRasterizer(love::image::ImageData * data, unsigned short * glyphs, int length);
|
||||
GlyphData * newGlyphData(Rasterizer * r, unsigned short glyph);
|
||||
|
||||
|
||||
// Implement Module
|
||||
const char * getName() const;
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 LOVE Development Team
|
||||
*
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
@@ -36,13 +36,13 @@ namespace freetype
|
||||
{
|
||||
data->retain();
|
||||
|
||||
if(FT_New_Memory_Face( library,
|
||||
if (FT_New_Memory_Face( library,
|
||||
(const FT_Byte *)data->getData(), /* first byte in memory */
|
||||
data->getSize(), /* size in bytes */
|
||||
0, /* face_index */
|
||||
&face))
|
||||
throw love::Exception("TrueTypeFont Loading error: FT_New_Face failed (there is probably a problem with your font file)\n");
|
||||
|
||||
|
||||
FT_Set_Pixel_Sizes(face, size, size);
|
||||
|
||||
// Set global metrics
|
||||
@@ -70,12 +70,12 @@ namespace freetype
|
||||
FT_Glyph ftglyph;
|
||||
|
||||
// Initialize
|
||||
if(FT_Load_Glyph(face, FT_Get_Char_Index(face, glyph), FT_LOAD_DEFAULT))
|
||||
if (FT_Load_Glyph(face, FT_Get_Char_Index(face, glyph), FT_LOAD_DEFAULT))
|
||||
throw love::Exception("TrueTypeFont Loading vm->error: FT_Load_Glyph failed\n");
|
||||
|
||||
if( FT_Get_Glyph(face->glyph, &ftglyph) )
|
||||
|
||||
if ( FT_Get_Glyph(face->glyph, &ftglyph) )
|
||||
throw love::Exception("TrueTypeFont Loading vm->error: FT_Get_Glyph failed\n");
|
||||
|
||||
|
||||
FT_Glyph_To_Bitmap(&ftglyph, FT_RENDER_MODE_NORMAL, 0, 1);
|
||||
FT_BitmapGlyph bitmap_glyph = (FT_BitmapGlyph)ftglyph;
|
||||
FT_Bitmap& bitmap = bitmap_glyph->bitmap; //just to make things easier
|
||||
@@ -93,22 +93,22 @@ namespace freetype
|
||||
int size = bitmap.rows*bitmap.width;
|
||||
unsigned char * dst = (unsigned char *)glyphData->getData();
|
||||
|
||||
// Note that bitmap.buffer contains only luminosity. We copy that single value to
|
||||
// our luminosity-alpha format.
|
||||
for(int i = 0; i<size; i++)
|
||||
// Note that bitmap.buffer contains only luminosity. We copy that single value to
|
||||
// our luminosity-alpha format.
|
||||
for (int i = 0; i<size; i++)
|
||||
{
|
||||
dst[2*i] = 255;
|
||||
dst[2*i+1] = bitmap.buffer[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Having copied the data over, we can destroy the glyph
|
||||
FT_Done_Glyph(ftglyph);
|
||||
|
||||
// Return data
|
||||
return glyphData;
|
||||
}
|
||||
|
||||
|
||||
int TrueTypeRasterizer::getNumGlyphs() const
|
||||
{
|
||||
return 256;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 LOVE Development Team
|
||||
*
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
@@ -51,7 +51,7 @@ namespace freetype
|
||||
|
||||
// File data
|
||||
Data * data;
|
||||
|
||||
|
||||
public:
|
||||
TrueTypeRasterizer(FT_Library library, Data * data, int size);
|
||||
virtual ~TrueTypeRasterizer();
|
||||
|
||||
@@ -1,108 +1,110 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#include "wrap_Font.h"
|
||||
|
||||
#include "Font.h"
|
||||
|
||||
#include <font/wrap_GlyphData.h>
|
||||
#include <font/wrap_Rasterizer.h>
|
||||
|
||||
#include "TrueTypeRasterizer.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace font
|
||||
{
|
||||
namespace freetype
|
||||
{
|
||||
static Font * instance = 0;
|
||||
|
||||
int w_newRasterizer(lua_State * L)
|
||||
{
|
||||
Rasterizer * t = NULL;
|
||||
if (luax_istype(L, 1, IMAGE_IMAGE_DATA_T)) {
|
||||
love::image::ImageData * d = luax_checktype<love::image::ImageData>(L, 1, "ImageData", IMAGE_IMAGE_DATA_T);
|
||||
const char * g = luaL_checkstring(L, 2);
|
||||
std::string glyphs(g);
|
||||
t = instance->newRasterizer(d, glyphs);
|
||||
}
|
||||
else if (luax_istype(L, 1, DATA_T)) {
|
||||
Data * d = luax_checkdata(L, 1);
|
||||
int size = luaL_checkint(L, 2);
|
||||
t = instance->newRasterizer(d, size);
|
||||
}
|
||||
|
||||
luax_newtype(L, "Rasterizer", FONT_RASTERIZER_T, t);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_newGlyphData(lua_State * L)
|
||||
{
|
||||
Rasterizer * r = luax_checkrasterizer(L, 1);
|
||||
unsigned short g = (unsigned short)luaL_checkint(L, 2);
|
||||
|
||||
GlyphData * t = instance->newGlyphData(r, g);
|
||||
luax_newtype(L, "GlyphData", FONT_GLYPH_DATA_T, t);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// List of functions to wrap.
|
||||
static const luaL_Reg functions[] = {
|
||||
{ "newRasterizer", w_newRasterizer },
|
||||
{ "newGlyphData", w_newGlyphData },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
static const lua_CFunction types[] = {
|
||||
luaopen_glyphdata,
|
||||
luaopen_rasterizer,
|
||||
0
|
||||
};
|
||||
|
||||
int luaopen_love_font(lua_State * L)
|
||||
{
|
||||
if(instance == 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
instance = new Font();
|
||||
}
|
||||
catch(Exception & e)
|
||||
{
|
||||
return luaL_error(L, e.what());
|
||||
}
|
||||
}
|
||||
else
|
||||
instance->retain();
|
||||
|
||||
WrappedModule w;
|
||||
w.module = instance;
|
||||
w.name = "font";
|
||||
w.flags = MODULE_T;
|
||||
w.functions = functions;
|
||||
w.types = types;
|
||||
|
||||
return luax_register_module(L, w);
|
||||
}
|
||||
|
||||
} // freetype
|
||||
} // font
|
||||
} // love
|
||||
/**
|
||||
* Copyright (c) 2006-2011 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#include "wrap_Font.h"
|
||||
|
||||
#include "Font.h"
|
||||
|
||||
#include <font/wrap_GlyphData.h>
|
||||
#include <font/wrap_Rasterizer.h>
|
||||
|
||||
#include "TrueTypeRasterizer.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace font
|
||||
{
|
||||
namespace freetype
|
||||
{
|
||||
static Font * instance = 0;
|
||||
|
||||
int w_newRasterizer(lua_State * L)
|
||||
{
|
||||
Rasterizer * t = NULL;
|
||||
if (luax_istype(L, 1, IMAGE_IMAGE_DATA_T))
|
||||
{
|
||||
love::image::ImageData * d = luax_checktype<love::image::ImageData>(L, 1, "ImageData", IMAGE_IMAGE_DATA_T);
|
||||
const char * g = luaL_checkstring(L, 2);
|
||||
std::string glyphs(g);
|
||||
t = instance->newRasterizer(d, glyphs);
|
||||
}
|
||||
else if (luax_istype(L, 1, DATA_T))
|
||||
{
|
||||
Data * d = luax_checkdata(L, 1);
|
||||
int size = luaL_checkint(L, 2);
|
||||
t = instance->newRasterizer(d, size);
|
||||
}
|
||||
|
||||
luax_newtype(L, "Rasterizer", FONT_RASTERIZER_T, t);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_newGlyphData(lua_State * L)
|
||||
{
|
||||
Rasterizer * r = luax_checkrasterizer(L, 1);
|
||||
unsigned short g = (unsigned short)luaL_checkint(L, 2);
|
||||
|
||||
GlyphData * t = instance->newGlyphData(r, g);
|
||||
luax_newtype(L, "GlyphData", FONT_GLYPH_DATA_T, t);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// List of functions to wrap.
|
||||
static const luaL_Reg functions[] = {
|
||||
{ "newRasterizer", w_newRasterizer },
|
||||
{ "newGlyphData", w_newGlyphData },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
static const lua_CFunction types[] = {
|
||||
luaopen_glyphdata,
|
||||
luaopen_rasterizer,
|
||||
0
|
||||
};
|
||||
|
||||
int luaopen_love_font(lua_State * L)
|
||||
{
|
||||
if (instance == 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
instance = new Font();
|
||||
}
|
||||
catch (Exception & e)
|
||||
{
|
||||
return luaL_error(L, e.what());
|
||||
}
|
||||
}
|
||||
else
|
||||
instance->retain();
|
||||
|
||||
WrappedModule w;
|
||||
w.module = instance;
|
||||
w.name = "font";
|
||||
w.flags = MODULE_T;
|
||||
w.functions = functions;
|
||||
w.types = types;
|
||||
|
||||
return luax_register_module(L, w);
|
||||
}
|
||||
|
||||
} // freetype
|
||||
} // font
|
||||
} // love
|
||||
|
||||
@@ -1,42 +1,42 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#ifndef LOVE_FONT_FREETYPE_WRAP_FONT_H
|
||||
#define LOVE_FONT_FREETYPE_WRAP_FONT_H
|
||||
|
||||
// LOVE
|
||||
#include <common/config.h>
|
||||
#include <common/runtime.h>
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace font
|
||||
{
|
||||
namespace freetype
|
||||
{
|
||||
int w_newRasterizer(lua_State * L);
|
||||
int w_newGlyphData(lua_State * L);
|
||||
extern "C" LOVE_EXPORT int luaopen_love_font(lua_State * L);
|
||||
|
||||
} // freetype
|
||||
} // font
|
||||
} // love
|
||||
|
||||
#endif // LOVE_FONT_FREETYPE_WRAP_FONT_H
|
||||
/**
|
||||
* Copyright (c) 2006-2011 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#ifndef LOVE_FONT_FREETYPE_WRAP_FONT_H
|
||||
#define LOVE_FONT_FREETYPE_WRAP_FONT_H
|
||||
|
||||
// LOVE
|
||||
#include <common/config.h>
|
||||
#include <common/runtime.h>
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace font
|
||||
{
|
||||
namespace freetype
|
||||
{
|
||||
int w_newRasterizer(lua_State * L);
|
||||
int w_newGlyphData(lua_State * L);
|
||||
extern "C" LOVE_EXPORT int luaopen_love_font(lua_State * L);
|
||||
|
||||
} // freetype
|
||||
} // font
|
||||
} // love
|
||||
|
||||
#endif // LOVE_FONT_FREETYPE_WRAP_FONT_H
|
||||
|
||||
@@ -1,44 +1,44 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#include "wrap_GlyphData.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace font
|
||||
{
|
||||
GlyphData * luax_checkglyphdata(lua_State * L, int idx)
|
||||
{
|
||||
return luax_checktype<GlyphData>(L, idx, "GlyphData", FONT_GLYPH_DATA_T);
|
||||
}
|
||||
|
||||
static const luaL_Reg functions[] = {
|
||||
{ "getPointer", w_Data_getPointer },
|
||||
{ "getSize", w_Data_getSize },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
int luaopen_glyphdata(lua_State * L)
|
||||
{
|
||||
return luax_register_type(L, "GlyphData", functions);
|
||||
}
|
||||
|
||||
} // font
|
||||
} // love
|
||||
/**
|
||||
* Copyright (c) 2006-2011 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#include "wrap_GlyphData.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace font
|
||||
{
|
||||
GlyphData * luax_checkglyphdata(lua_State * L, int idx)
|
||||
{
|
||||
return luax_checktype<GlyphData>(L, idx, "GlyphData", FONT_GLYPH_DATA_T);
|
||||
}
|
||||
|
||||
static const luaL_Reg functions[] = {
|
||||
{ "getPointer", w_Data_getPointer },
|
||||
{ "getSize", w_Data_getSize },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
int luaopen_glyphdata(lua_State * L)
|
||||
{
|
||||
return luax_register_type(L, "GlyphData", functions);
|
||||
}
|
||||
|
||||
} // font
|
||||
} // love
|
||||
|
||||
@@ -1,40 +1,40 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#ifndef LOVE_FONT_WRAP_GLYPH_DATA_H
|
||||
#define LOVE_FONT_WRAP_GLYPH_DATA_H
|
||||
|
||||
// LOVE
|
||||
#include <common/runtime.h>
|
||||
#include <common/wrap_Data.h>
|
||||
|
||||
#include "GlyphData.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace font
|
||||
{
|
||||
GlyphData * luax_checkglyphdata(lua_State * L, int idx);
|
||||
int luaopen_glyphdata(lua_State * L);
|
||||
|
||||
} // font
|
||||
} // love
|
||||
|
||||
#endif // LOVE_FONT_WRAP_GLYPH_DATA_H
|
||||
/**
|
||||
* Copyright (c) 2006-2011 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#ifndef LOVE_FONT_WRAP_GLYPH_DATA_H
|
||||
#define LOVE_FONT_WRAP_GLYPH_DATA_H
|
||||
|
||||
// LOVE
|
||||
#include <common/runtime.h>
|
||||
#include <common/wrap_Data.h>
|
||||
|
||||
#include "GlyphData.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace font
|
||||
{
|
||||
GlyphData * luax_checkglyphdata(lua_State * L, int idx);
|
||||
int luaopen_glyphdata(lua_State * L);
|
||||
|
||||
} // font
|
||||
} // love
|
||||
|
||||
#endif // LOVE_FONT_WRAP_GLYPH_DATA_H
|
||||
|
||||
@@ -1,44 +1,44 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#include "wrap_Rasterizer.h"
|
||||
|
||||
#include <common/wrap_Data.h>
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace font
|
||||
{
|
||||
Rasterizer * luax_checkrasterizer(lua_State * L, int idx)
|
||||
{
|
||||
return luax_checktype<Rasterizer>(L, idx, "Rasterizer", FONT_RASTERIZER_T);
|
||||
}
|
||||
|
||||
static const luaL_Reg functions[] = {
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
int luaopen_rasterizer(lua_State * L)
|
||||
{
|
||||
return luax_register_type(L, "Rasterizer", functions);
|
||||
}
|
||||
|
||||
} // font
|
||||
} // love
|
||||
/**
|
||||
* Copyright (c) 2006-2011 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#include "wrap_Rasterizer.h"
|
||||
|
||||
#include <common/wrap_Data.h>
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace font
|
||||
{
|
||||
Rasterizer * luax_checkrasterizer(lua_State * L, int idx)
|
||||
{
|
||||
return luax_checktype<Rasterizer>(L, idx, "Rasterizer", FONT_RASTERIZER_T);
|
||||
}
|
||||
|
||||
static const luaL_Reg functions[] = {
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
int luaopen_rasterizer(lua_State * L)
|
||||
{
|
||||
return luax_register_type(L, "Rasterizer", functions);
|
||||
}
|
||||
|
||||
} // font
|
||||
} // love
|
||||
|
||||
@@ -1,38 +1,38 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#ifndef LOVE_FONT_WRAP_RASTERIZER_H
|
||||
#define LOVE_FONT_WRAP_RASTERIZER_H
|
||||
|
||||
// LOVE
|
||||
#include <common/runtime.h>
|
||||
#include "Rasterizer.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace font
|
||||
{
|
||||
Rasterizer * luax_checkrasterizer(lua_State * L, int idx);
|
||||
int luaopen_rasterizer(lua_State * L);
|
||||
|
||||
} // font
|
||||
} // love
|
||||
|
||||
#endif // LOVE_FONT_WRAP_RASTERIZER_H
|
||||
/**
|
||||
* Copyright (c) 2006-2011 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#ifndef LOVE_FONT_WRAP_RASTERIZER_H
|
||||
#define LOVE_FONT_WRAP_RASTERIZER_H
|
||||
|
||||
// LOVE
|
||||
#include <common/runtime.h>
|
||||
#include "Rasterizer.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace font
|
||||
{
|
||||
Rasterizer * luax_checkrasterizer(lua_State * L, int idx);
|
||||
int luaopen_rasterizer(lua_State * L);
|
||||
|
||||
} // font
|
||||
} // love
|
||||
|
||||
#endif // LOVE_FONT_WRAP_RASTERIZER_H
|
||||
|
||||
Reference in New Issue
Block a user