📄 lua_font.c
字号:
/****************************************************************************
** **
** LuAllegro library - Lua port of Allegro **
** Copyright (C) 2005 Peter Jamroz **
** e-mail: peterjam at poczta dot onet dot pl **
** **
** Permission to use, copy, modify, publish this software **
** is hereby granted to any person obtaining a copy of this software, **
** FREE OF CHARGE, **
** under the following conditions: **
** **
** 1: The above copyright notice and this permission notice shall be **
** included in all copies or substantial portions of the Software. **
** **
** 2: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, **
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF **
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.**
** IN NO EVENT SHALL THE AUTHOR OR COPYRIGHT HOLDER BE LIABLE FOR ANY **
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, **
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE **
** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **
** **
****************************************************************************/
#include <allegro.h>
#include <string.h>
#include "lua_aleg.h"
#include "lua_font.h"
//------------------------------------------------------------------------------------------
#define set_field_i(L,key,intvalue){\
lua_pushstring(L,key);\
lua_pushnumber(L,intvalue);\
lua_settable(L,-3);}
//------------------------------------------------------------------------------------------
#define set_field_n(L,indx,intvalue){\
lua_pushnumber(L,indx);\
lua_pushnumber(L,intvalue);\
lua_settable(L,-3);}
//------------------------------------------------------------------------------------------
//--- Font functions -----------------------------------------------------------------------
//------------------------------------------------------------------------------------------
//FONT *load_font(const char *filename, RGB *pal, void *param);
//fnt,pal = load_font(filename);
static int l_load_font(lua_State* L)
{
int x;
AUD* ad;
FONT* fnt;
PALETTE pal;
char* filename;
filename= (char*) lua_tostring(L,1);
if (!filename) return 0;
memset(pal,0,sizeof(pal));
fnt= load_font(filename,pal,NULL);
if (fnt==NULL)
return 0;
else
{
ad= (AUD*) lua_newuserdata (L, sizeof(AUD));
if (!ad)
{ destroy_font(fnt); return 0; }
luaL_getmetatable(L, "allegro_meta");
lua_setmetatable(L, -2);
ad->DataType = AL_FONT;
ad->DataPtr = fnt;
//czy paleta istnieje?
for (x=0; x<PAL_SIZE;x++)
if (pal[x].r || pal[x].g || pal[x].b)
break;
//je渓i informacja o palecie nie istnieje to zwr箧 tylko 1 parametr.
if (x>=PAL_SIZE) return 1;
//ustaw palet
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -