// Necklace of the Eye v3.0
// roguelike frontend
// Copyright (C) 2010-2011 Zeno Rogue, see 'noteye.h' for details

Font *newFont(Image *base, int inx, int iny, int trans) {
  Font *F = new Font;
  int sx = base->s ? base->s->w : 0;
  int sy = base->s ? base->s->h : 0;
  int dx = sx / inx;
  int dy = sy / iny;
  for(int i=0; i<256; i++) {
    F->ti[i] = 
      addTile(base, dx * (i % inx), dy * (i / inx), dx, dy, trans);
    (byId<TileImage> (F->ti[i]))->chid = i;
    }
  return F;
  }

#ifdef USELUA
int lh_newfont(lua_State *L) {
  checkArg(L, 4, "newfont");
  return retObject(L, newFont(luaO(1, Image), luaInt(2), luaInt(3), luaInt(4)));
  }

int lh_getchar(lua_State *L) {
  checkArg(L, 2, "getchar");
  return retInt(L, luaO(1, Font)->ti[(unsigned char) (luaStr(2)[0])]);
  }
#endif
