Example #1
0
int
CKLBLuaLibFONT::luaFontRelease(lua_State * L)
{
	CLuaState lua(L);
	int argc = lua.numArgs();
	for(int i = 1; i <= argc; i++) {
		FONTOBJ * fontobj = (FONTOBJ *)lua.getPointer(i);
		remove_font(fontobj);
		lua.retNil();
	}
	return argc;
}
Example #2
0
/* -------------- */
int load_font_in(char *font_path, int font_nr)
{
register int f_handle;
register long len;
register fontform *fnt_mem, *search;

f_handle = Fopen(font_path, 0);	
if (f_handle > 0)
	{
	len = Fseek(0L, f_handle, 2);
	Fseek(0L, f_handle, 0);

	pic_sub += len + 4;
	if (pic_sub & 1)
		{
		pic_sub--;
		*(long *)(mtext_mem + mtext_mlen - pic_sub) = len + 1;
		}
	else
		*(long *)(mtext_mem + mtext_mlen - pic_sub) = len;

	fnt_mem = (fontform *)(mtext_mem + mtext_mlen - pic_sub + 4);

	Fread(f_handle, len, fnt_mem);
	Fclose(f_handle);

	if ((long)fnt_point[akt_id] > 0)
		vst_unload_fonts(vdi_handle, 1);

	if ((long)fnt_point[akt_id] > 0)
		fnt_mem[0].next = fnt_point[akt_id];
	else
		fnt_mem[0].next = 0;

	fnt_point[akt_id] = fnt_mem;

	fnt_mem[0].id = 99;
	fnt_mem[0].ch_ofst = (int *)((long)fnt_mem[0].ch_ofst + (long)fnt_mem);
	fnt_mem[0].fnt_dta  = (int *)((long)fnt_mem[0].fnt_dta + (long)fnt_mem);

	remove_font(font_nr);

	fnt_mem = fnt_point[akt_id];
	fnt_mem[0].id = font_nr;

	inst_font();

	return(1);
	}

return(0);
}
Example #3
0
int
CKLBLuaLibFONT::remove_all_font()
{
	FONTOBJ * fontobj = ms_begin;
	int cnt = 0;
	while(fontobj) {
		FONTOBJ * next = fontobj->next;
		remove_font(fontobj);
		fontobj = next;
		cnt++;
	}
	return cnt;
}
Example #4
0
/* Get a glyph corresponding to the codepoint CODE.  Always fill glyph
   information with something, even if no glyph is found.  */
int
grub_font_get_glyph (grub_uint32_t code,
                     grub_font_glyph_t glyph)
{
    struct font *font;
    grub_uint8_t bitmap[32];

    /* FIXME: It is necessary to cache glyphs!  */

restart:
    for (font = font_list; font; font = font->next)
    {
        grub_uint32_t offset;

        offset = find_glyph (font, code);
        if (offset)
        {
            grub_uint32_t w;
            int len;

            /* Make sure we can find glyphs for error messages.  Push active
               error message to error stack and reset error message.  */
            grub_error_push ();

            grub_file_seek (font->file, offset);
            if ((len = grub_file_read (font->file, (char *) &w, sizeof (w)))
                    != sizeof (w))
            {
                remove_font (font);
                goto restart;
            }

            w = grub_le_to_cpu32 (w);
            if (w != 1 && w != 2)
            {
                /* grub_error (GRUB_ERR_BAD_FONT, "invalid width"); */
                remove_font (font);
                goto restart;
            }

            if (grub_file_read (font->file, (char *) bitmap, w * 16)
                    != (grub_ssize_t) w * 16)
            {
                remove_font (font);
                goto restart;
            }

            /* Fill glyph with information.  */
            grub_memcpy (glyph->bitmap, bitmap, w * 16);

            glyph->char_width = w;
            glyph->width = glyph->char_width * 8;
            glyph->height = 16;
            glyph->baseline = (16 * 3) / 4;

            /* Restore old error message.  */
            grub_error_pop ();

            return 1;
        }
    }

    /* Uggh...  No font was found.  */
    fill_with_default_glyph (glyph);
    return 0;
}
Example #5
0
/* Get a glyph for the Unicode character CODE in FONT.  The glyph is loaded
   from the font file if has not been loaded yet.
   Returns a pointer to the glyph if found, or 0 if it is not found.  */
static struct grub_font_glyph *
grub_font_get_glyph_internal (grub_font_t font, grub_uint32_t code)
{
  struct char_index_entry *index_entry;

  index_entry = find_glyph (font, code);
  if (index_entry)
    {
      struct grub_font_glyph *glyph = 0;
      grub_uint16_t width;
      grub_uint16_t height;
      grub_int16_t xoff;
      grub_int16_t yoff;
      grub_int16_t dwidth;
      int len;

      if (index_entry->glyph)
	/* Return cached glyph.  */
	return index_entry->glyph;

      if (!font->file)
	/* No open file, can't load any glyphs.  */
	return 0;

      /* Make sure we can find glyphs for error messages.  Push active
         error message to error stack and reset error message.  */
      grub_error_push ();

      grub_file_seek (font->file, index_entry->offset);

      /* Read the glyph width, height, and baseline.  */
      if (read_be_uint16 (font->file, &width) != 0
	  || read_be_uint16 (font->file, &height) != 0
	  || read_be_int16 (font->file, &xoff) != 0
	  || read_be_int16 (font->file, &yoff) != 0
	  || read_be_int16 (font->file, &dwidth) != 0)
	{
	  remove_font (font);
	  return 0;
	}

      len = (width * height + 7) / 8;
      glyph = grub_malloc (sizeof (struct grub_font_glyph) + len);
      if (!glyph)
	{
	  remove_font (font);
	  return 0;
	}

      glyph->font = font;
      glyph->width = width;
      glyph->height = height;
      glyph->offset_x = xoff;
      glyph->offset_y = yoff;
      glyph->device_width = dwidth;

      /* Don't try to read empty bitmaps (e.g., space characters).  */
      if (len != 0)
	{
	  if (grub_file_read (font->file, glyph->bitmap, len) != len)
	    {
	      remove_font (font);
	      return 0;
	    }
	}

      /* Restore old error message.  */
      grub_error_pop ();

      /* Cache the glyph.  */
      index_entry->glyph = glyph;

      return glyph;
    }

  return 0;
}
Example #6
0
/* ------------------- */
void remove_allf(int id)
{
register int i;

for (i = 2; i < 5; remove_font(i++));
}