예제 #1
0
파일: auto_ai.c 프로젝트: shouya/bar
static void do_render(void) {
  clear_canvas(impl.cvs, 0x0);
  clear_canvas(impl.pnl, 0x0);

  draw_bm(impl.cvs, impl.bm, 0, 0, BOX_SZ, 0x7f7f7f7f, 0xff);
  draw_sb(impl.cvs, impl.sb, 0, 0, BOX_SZ, 0xff7f7f7f, 0xe0);

  draw_grid(impl.cvs, impl.bm, 0, 0, BOX_SZ, 0x10ffffff);

  draw_box(impl.pnl, 0, 0, 100, 100, 0x0, 0xff111111);

  draw_shape_center(impl.pnl, 0, 20, 50, 50, 12,
                    impl.queue->queue[0], 0x3f<<24, 0xf0);
  draw_shape_center(impl.pnl, 55, 20, 40, 40, 10,
                    impl.queue->queue[1], 0x2f<<24, 0xc0);
  draw_shape_center(impl.pnl, 55, 60, 40, 40, 10,
                    impl.queue->queue[2], 0x1f<<24, 0x80);
  draw_shape_center(impl.pnl, 55, 100, 40, 40, 10,
                    impl.queue->queue[3], 0x0f<<24, 0x50);

  blit_ui(impl.cvs, 0, 0);
  blit_ui(impl.pnl, BOX_SZ*XRES, 0);
}
예제 #2
0
static void *font_ttf_get_glyph(unsigned char *_msg) {
	FT_GlyphSlot   slot;
	FT_UShort      code;
	FT_Error       err;
	FT_Pixel_Mode  pixelmode;
	FT_Int         loadflag;
	int x = 0;
	unsigned char *msg = _msg;
	
	if (fontset == NULL) return &img_glyph;
	
	clear_canvas();
	
	while (*msg) {
		code = this->codeconv[fontset->type](&msg);
	
		if (this->antialiase_on) {
			loadflag = FT_LOAD_RENDER;
			// if( 埋め込みビットマップを使いたくない時)
			//	loadglag |= FT_LOAD_NO_BITMAP;
		} else {
			loadflag = (FT_LOAD_RENDER | FT_LOAD_MONOCHROME);
		}
#if 1
		err = FT_Load_Char(fontset->face, code, loadflag);
#else
		int glyphindex = FT_Get_Char_Index(fontset->face, code);
		err = FT_Load_Glyph(fontset->face, glyphindex, loadflag);
		err = FT_Render_Glyph(fontset->face->glyph, FT_RENDER_MODE_NORMAL);
#endif
		/* gray scaleでもモノクロでもない埋め込みビットマップは使わず、
		   アウトラインフォントを使用 */
		pixelmode = fontset->face->glyph->bitmap.pixel_mode ;
		if (!err &&
		    pixelmode != ft_pixel_mode_mono &&
		    pixelmode != ft_pixel_mode_grays){
			WARNING("Not supported type embeded bitmap font!!!");
			err = FT_Load_Char(fontset->face, code, loadflag | FT_LOAD_NO_BITMAP);
			pixelmode = fontset->face->glyph->bitmap.pixel_mode;
		}
		
		if (err) continue;
		
		slot = fontset->face->glyph;
		
		// lazy check, but needed
		if (x + fontset->size > GLYPH_PIXMAP_WIDTH) {
			break;
		}
		
		if (pixelmode == ft_pixel_mode_grays) {
			pixmap2comimg(slot->bitmap.buffer,
				      x + slot->bitmap_left,
				      max(0, fontset->size * 0.9 - slot->metrics.horiBearingY/64),
				      slot->bitmap.width,
				      slot->metrics.height/64,
				      slot->bitmap.pitch);
		} else if (pixelmode == ft_pixel_mode_mono) {
			pixmapmono2comimg(slot->bitmap.buffer,
					  x + slot->bitmap_left,
					  max(0, fontset->size * 0.9 - slot->metrics.horiBearingY/64),
					  slot->bitmap.width,
					  slot->metrics.height/64,
					  slot->bitmap.pitch);
		}
		x += slot->metrics.horiAdvance/64;
	}
	
	img_glyph.width  = x;
	img_glyph.height = fontset->size;
	
	return &img_glyph;
}