mirror of
https://github.com/love2d/love.git
synced 2026-08-20 20:49:54 +02:00
Added FontData class, preparing for overhauling love.graphics' Font class
This commit is contained in:
@@ -26,6 +26,8 @@
|
||||
A93E6E5510420B57007D418B /* Lua.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A93E6E5310420B57007D418B /* Lua.framework */; };
|
||||
A93E6EED10420BA8007D418B /* love.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A93E6A3410420AC0007D418B /* love.cpp */; };
|
||||
A946CE821172BCD7005E1462 /* wrap_EncodedImageData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A946CE811172BCD7005E1462 /* wrap_EncodedImageData.cpp */; };
|
||||
A946D3BB117681BD005E1462 /* FontData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A946D3BA117681BC005E1462 /* FontData.cpp */; };
|
||||
A946D3C611768D69005E1462 /* wrap_FontData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A946D3C511768D69005E1462 /* wrap_FontData.cpp */; };
|
||||
A946D67F104248DA002BF36C /* Reference.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A93E69EA10420ABF007D418B /* Reference.cpp */; };
|
||||
A946D680104248DA002BF36C /* Matrix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A93E69E310420ABF007D418B /* Matrix.cpp */; };
|
||||
A946D681104248DA002BF36C /* Object.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A93E69E810420ABF007D418B /* Object.cpp */; };
|
||||
@@ -576,6 +578,10 @@
|
||||
A93E6E5310420B57007D418B /* Lua.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Lua.framework; path = /Library/Frameworks/Lua.framework; sourceTree = "<absolute>"; };
|
||||
A946CE801172BCD6005E1462 /* wrap_EncodedImageData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_EncodedImageData.h; sourceTree = "<group>"; };
|
||||
A946CE811172BCD7005E1462 /* wrap_EncodedImageData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_EncodedImageData.cpp; sourceTree = "<group>"; };
|
||||
A946D3B9117681BC005E1462 /* FontData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontData.h; sourceTree = "<group>"; };
|
||||
A946D3BA117681BC005E1462 /* FontData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontData.cpp; sourceTree = "<group>"; };
|
||||
A946D3C411768D69005E1462 /* wrap_FontData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_FontData.h; sourceTree = "<group>"; };
|
||||
A946D3C511768D69005E1462 /* wrap_FontData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_FontData.cpp; sourceTree = "<group>"; };
|
||||
A968F0C61083A07B00A895AA /* EnumMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EnumMap.h; sourceTree = "<group>"; };
|
||||
A968F0C71083A07C00A895AA /* StringMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringMap.h; sourceTree = "<group>"; };
|
||||
A968F0CE1083A9A900A895AA /* Event.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Event.cpp; sourceTree = "<group>"; };
|
||||
@@ -928,6 +934,8 @@
|
||||
A93E6A6F10420AC1007D418B /* font */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A946D3BA117681BC005E1462 /* FontData.cpp */,
|
||||
A946D3B9117681BC005E1462 /* FontData.h */,
|
||||
A93E6A7010420AC1007D418B /* freetype */,
|
||||
A93E6A7710420AC2007D418B /* GlyphData.cpp */,
|
||||
A93E6A7810420AC2007D418B /* GlyphData.h */,
|
||||
@@ -935,6 +943,8 @@
|
||||
A93E6A7A10420AC2007D418B /* ImageRasterizer.h */,
|
||||
A93E6A7B10420AC2007D418B /* Rasterizer.cpp */,
|
||||
A93E6A7C10420AC2007D418B /* Rasterizer.h */,
|
||||
A946D3C511768D69005E1462 /* wrap_FontData.cpp */,
|
||||
A946D3C411768D69005E1462 /* wrap_FontData.h */,
|
||||
A93E6A7D10420AC2007D418B /* wrap_GlyphData.cpp */,
|
||||
A93E6A7E10420AC2007D418B /* wrap_GlyphData.h */,
|
||||
A93E6A7F10420AC2007D418B /* wrap_Rasterizer.cpp */,
|
||||
@@ -1656,6 +1666,8 @@
|
||||
A986DEB5113249A800810279 /* Thread.cpp in Sources */,
|
||||
A986DEB6113249A800810279 /* wrap_Thread.cpp in Sources */,
|
||||
A946CE821172BCD7005E1462 /* wrap_EncodedImageData.cpp in Sources */,
|
||||
A946D3BB117681BD005E1462 /* FontData.cpp in Sources */,
|
||||
A946D3C611768D69005E1462 /* wrap_FontData.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
@@ -39,6 +39,7 @@ namespace love
|
||||
FILESYSTEM_FILE_DATA_ID,
|
||||
|
||||
// Font
|
||||
FONT_FONT_DATA_ID,
|
||||
FONT_GLYPH_DATA_ID,
|
||||
FONT_RASTERIZER_ID,
|
||||
|
||||
@@ -102,6 +103,7 @@ namespace love
|
||||
const bits FILESYSTEM_FILE_T = (bits(1) << FILESYSTEM_FILE_ID) | OBJECT_T;
|
||||
const bits FILESYSTEM_FILE_DATA_T = (bits(1) << FILESYSTEM_FILE_DATA_ID) | DATA_T;
|
||||
|
||||
const bits FONT_FONT_DATA_T = (bits(1) << FONT_FONT_DATA_ID) | DATA_T;
|
||||
const bits FONT_GLYPH_DATA_T = (bits(1) << FONT_GLYPH_DATA_ID) | DATA_T;
|
||||
const bits FONT_RASTERIZER_T = (bits(1) << FONT_RASTERIZER_ID) | OBJECT_T;
|
||||
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2010 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 "FontData.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace font
|
||||
{
|
||||
|
||||
FontData::FontData(Rasterizer * raster)
|
||||
: height(0)
|
||||
{
|
||||
data = new GlyphData *[MAX_CHARS];
|
||||
for (unsigned int i = 0; i < MAX_CHARS; i++) {
|
||||
data[i] = raster->getGlyphData(i);
|
||||
int h = data[i]->getHeight();
|
||||
if (h > height) height = h;
|
||||
}
|
||||
}
|
||||
|
||||
FontData::~FontData()
|
||||
{
|
||||
delete[] data;
|
||||
}
|
||||
|
||||
void * FontData::getData() const
|
||||
{
|
||||
return (void *)data;
|
||||
}
|
||||
|
||||
int FontData::getSize() const
|
||||
{
|
||||
return MAX_CHARS;
|
||||
}
|
||||
|
||||
GlyphData * FontData::getGlyph(unsigned short glyph) const
|
||||
{
|
||||
return data[glyph];
|
||||
}
|
||||
|
||||
int FontData::getHeight() const
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
} // font
|
||||
} // love
|
||||
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2010 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_FONT_DATA_H
|
||||
#define LOVE_FONT_FONT_DATA_H
|
||||
|
||||
// LOVE
|
||||
#include <common/Data.h>
|
||||
|
||||
#include "GlyphData.h"
|
||||
#include "Rasterizer.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace font
|
||||
{
|
||||
class FontData : public Data
|
||||
{
|
||||
public:
|
||||
FontData(Rasterizer * raster);
|
||||
virtual ~FontData();
|
||||
|
||||
// Implements Data.
|
||||
void * getData() const;
|
||||
int getSize() const;
|
||||
|
||||
GlyphData * getGlyph(unsigned short glyph) const;
|
||||
int getHeight() const;
|
||||
|
||||
static const unsigned int MAX_CHARS = 256;
|
||||
|
||||
private:
|
||||
GlyphData ** data;
|
||||
int height;
|
||||
};
|
||||
} // font
|
||||
} // love
|
||||
|
||||
#endif // LOVE_FONT_FONT_DATA_H
|
||||
@@ -100,6 +100,9 @@ namespace freetype
|
||||
}
|
||||
}
|
||||
|
||||
// Having copied the data over, we can destroy the glyph
|
||||
FT_Done_Glyph(ftglyph);
|
||||
|
||||
// Return data
|
||||
return glyphData;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "wrap_Font.h"
|
||||
|
||||
#include <font/wrap_FontData.h>
|
||||
#include <font/wrap_GlyphData.h>
|
||||
#include <font/wrap_Rasterizer.h>
|
||||
|
||||
@@ -61,6 +62,7 @@ namespace freetype
|
||||
};
|
||||
|
||||
static const lua_CFunction types[] = {
|
||||
luaopen_fontdata,
|
||||
luaopen_glyphdata,
|
||||
luaopen_rasterizer,
|
||||
0
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2010 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_FontData.h"
|
||||
|
||||
#include <common/wrap_Data.h>
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace font
|
||||
{
|
||||
FontData * luax_checkfontdata(lua_State * L, int idx)
|
||||
{
|
||||
return luax_checktype<FontData>(L, idx, "FontData", FONT_FONT_DATA_T);
|
||||
}
|
||||
|
||||
static const luaL_Reg functions[] = {
|
||||
{ "getPointer", w_Data_getPointer },
|
||||
{ "getSize", w_Data_getSize },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
int luaopen_fontdata(lua_State * L)
|
||||
{
|
||||
return luax_register_type(L, "FontData", functions);
|
||||
}
|
||||
|
||||
} // font
|
||||
} // love
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2010 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_FONT_DATA_H
|
||||
#define LOVE_FONT_WRAP_FONT_DATA_H
|
||||
|
||||
// LOVE
|
||||
#include <common/runtime.h>
|
||||
|
||||
#include "FontData.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace font
|
||||
{
|
||||
FontData * luax_checkfontdata(lua_State * L, int idx);
|
||||
int luaopen_fontdata(lua_State * L);
|
||||
|
||||
} // font
|
||||
} // love
|
||||
|
||||
#endif // LOVE_FONT_WRAP_FONT_DATA_H
|
||||
@@ -40,5 +40,5 @@ namespace font
|
||||
return luax_register_type(L, "GlyphData", functions);
|
||||
}
|
||||
|
||||
} // sound
|
||||
} // font
|
||||
} // love
|
||||
|
||||
Reference in New Issue
Block a user