⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 devfont.h

📁 嵌入式图形处理系统,emgui嵌入式图形处理系统,
💻 H
字号:
/*
 *  Font Device
 *
 *
 *  COPYRIGHT (c) 2001 - 2010.
 *  emTech System Corporation.
 *
 *  The license and distribution terms for this file may be
 *  found in found in the file LICENSE.
 */

/*	Huangf emcore@263.net
 */

#ifndef __DEVFONT_h
#define __DEVFONT_h

typedef unsigned short	MWIMAGEBITS;	/* bitmap image unit size*/

/* 	MWIMAGEBITS macros*/
/*  #define	MWIMAGE_SIZE(width, height)  	((height) * (((width) + MWIMAGE_BITSPERIMAGE - 1) / MWIMAGE_BITSPERIMAGE))
 */
#define MWIMAGE_WORDS(x)				(((x)+15)/16)
#define MWIMAGE_BYTES(x)				(((x)+7)/8)
#define	MWIMAGE_BITSPERIMAGE			(sizeof(MWIMAGEBITS) * 8)
#define	MWIMAGE_FIRSTBIT				((MWIMAGEBITS) 0x8000)
#define	MWIMAGE_NEXTBIT(m)				((MWIMAGEBITS) ((m) >> 1))
#define	MWIMAGE_TESTBIT(m)				((m) & MWIMAGE_FIRSTBIT)
#define	MWIMAGE_SHIFTBIT(m)				((MWIMAGEBITS) ((m) << 1))

/* GetFontInfo structure*/
typedef struct {
	int 			maxwidth;		/* maximum width of any char */
	int 			height;			/* height of font in pixels*/
	int 			baseline;		/* baseline (ascent) of font */
	int				firstchar;		/* first character in font*/
	int				lastchar;		/* last character in font*/
	int				fixed;			/* TRUE if font is fixed width */
	unsigned char 	widths[256];	/* table of character widths */
} MWFONTINFO, *PMWFONTINFO;

/* logical font descriptor*/

/* font classes - used internally*/
#define MWLF_CLASS_BUILTIN	1	/* Builtin fonts (bitmaps) */
#define MWLF_CLASS_FREETYPE	2	/* FreeType fonts in TT format */
#define MWLF_CLASS_T1LIB	3	/* T1LIB outlined Adobe Type 1 fonts */
#define MWLF_CLASS_ANY		4	/* Any font*/

#define MWLF_FACESIZE		64	/* max facename size*/

/* font type selection - lfOutPrecision*/
#define MWLF_TYPE_DEFAULT	0	/* any font*/
#define MWLF_TYPE_SCALED	4	/* outlined font (tt or adobe)*/
#define MWLF_TYPE_RASTER	5	/* raster only*/
#define MWLF_TYPE_TRUETYPE	7	/* truetype only*/
#define MWLF_TYPE_ADOBE		10	/* adobe type 1 only*/

/* font weights - lfWeight*/
#define MWLF_WEIGHT_DEFAULT	0	/* any weight*/
#define MWLF_WEIGHT_THIN	100	/* thin*/
#define MWLF_WEIGHT_EXTRALIGHT	200
#define MWLF_WEIGHT_LIGHT	300	/* light */
#define MWLF_WEIGHT_NORMAL	400	/* regular*/
#define MWLF_WEIGHT_REGULAR	400
#define MWLF_WEIGHT_MEDIUM	500	/* medium */
#define MWLF_WEIGHT_DEMIBOLD	600
#define MWLF_WEIGHT_BOLD	700	/* bold*/
#define MWLF_WEIGTH_EXTRABOLD	800
#define MWLF_WEIGHT_BLACK	900	/* black */

/* font charset - lfCharSet*/
#define MWLF_CHARSET_ANSI	0	/* win32 ansi*/
#define MWLF_CHARSET_DEFAULT	1	/* any charset*/
#define MWLF_CHARSET_UNICODE	254	/* unicode*/
#define MWLF_CHARSET_OEM	255	/* local hw*/

/* font pitch - lfPitch */
#define MWLF_PITCH_DEFAULT		0	/* any pitch */
#define MWLF_PITCH_ULTRACONDENSED	10
#define MWLF_PITCH_EXTRACONDENSED	20
#define MWLF_PITCH_CONDENSED		30
#define MWLF_PITCH_SEMICONDENSED	40
#define MWLF_PITCH_NORMAL		50
#define MWLF_PITCH_SEMIEXPANDED		60
#define MWLF_PITCH_EXPANDED		70
#define MWLF_PITCH_EXTRAEXPANDED	80
#define MWLF_PITCH_ULTRAEXPANDED	90


/*  builtin font std names*/
#define MWFONT_SYSTEM_VAR	"System"	/* winSystem 14x16 (ansi)*/
#define MWFONT_GUI_VAR		"Helvetica"	/* winMSSansSerif 11x13 (ansi)*/
#define MWFONT_OEM_FIXED	"Terminal"	/* rom8x16 (oem)*/
#define MWFONT_SYSTEM_FIXED	"SystemFixed"	/* X6x13 (should be ansi)*/

/* Text/GetTextSize encoding flags*/
#define MWTF_ASCII			0x0000	/* 8 bit packing, ascii*/
#define MWTF_UTF8			0x0001	/* 8 bit packing, utf8*/
#define MWTF_UC16			0x0002	/* 16 bit packing, unicode 16*/
#define MWTF_UC32			0x0004	/* 32 bit packing, unicode 32*/
#define MWTF_PACKMASK		0x0007	/* packing mask*/

/* Text alignment flags*/
#define MWTF_TOP			0x0010	/* align on top*/
#define MWTF_BASELINE		0x0020	/* align on baseline*/
#define MWTF_BOTTOM			0x0040	/* align on bottom*/

/* SetFontAttr flags*/
#define MWTF_KERNING		0x1000	/* font kerning*/
#define MWTF_ANTIALIAS		0x2000	/* antialiased output*/
#define MWTF_UNDERLINE		0x4000	/* draw underline*/

/* builtin C-based proportional/fixed font structure*/
typedef struct {
	char 			*name;		/* font name*/
	int				maxwidth;	/* max width in pixels*/
	int				height;		/* height in pixels*/
	int				ascent;		/* ascent (baseline) height*/
	int				firstchar;	/* first character in bitmap*/
	int				size;		/* font size in characters*/
	MWIMAGEBITS 	*bits;		/* 16-bit right-padded bitmap data*/
	unsigned short 	*offset;	/* 256 offsets into bitmap data*/
	unsigned char 	*width;		/* 256 character widths or 0 if fixed*/
} MWCFONT;

typedef MWCFONT *PMWCFONT;

/* draw procs associated with fonts.  Strings are [re]packed using defencoding*/
typedef struct {
	int		encoding;	/* routines expect this encoding*/
	boolean	(*GetFontInfo)(PMWFONT pfont, PMWFONTINFO pfontinfo);
	void 	(*GetTextSize)(PMWFONT pfont, const void *text, int cc,	int *pwidth, int *pheight, int *pbase);
	void	(*GetTextBits)(PMWFONT pfont, int ch, MWIMAGEBITS *retmap, int *pwidth, int *pheight, int *pbase);
	void	(*DestroyFont)(PMWFONT pfont);
	void	(*DrawText)(void *win, void *gc, int x, int y, const void *str, int count, int flags);
	void    (*SetFontSize)(PMWFONT pfont, int fontsize);
	void    (*SetFontRotation)(PMWFONT pfont, int tenthdegrees);
	void    (*SetFontAttr)(PMWFONT pfont, int setflags, int clrflags);
} MWFONTPROCS, *PMWFONTPROCS;

/* new multi-renderer font struct*/
typedef struct _mwfont {		/* common hdr for all font structures*/
	PMWFONTPROCS	fontprocs;	/* font-specific rendering routines*/
	int				fontsize;	/* font height in pixels*/
	int				fontrotation;	/* font rotation*/
	int				fontattr;	/* font attributes: kerning/antialias*/
	/* font-specific rendering data here*/
} MWFONT;

/* builtin core font struct*/
typedef struct {
	PMWFONTPROCS	fontprocs;	/* common hdr*/
	int				fontsize;
	int				fontrotation;
	int				fontattr;

	char 			*name;		/* Microwindows font name*/
	PMWCFONT		cfont;		/* builtin font data*/
} MWCOREFONT, *PMWCOREFONT;

#define NUMBER_FONTS	4	/* number of compiled-in fonts*/

/* entry points*/
boolean	gen_getfontinfo(PMWFONT pfont, PMWFONTINFO pfontinfo);
void	gen_gettextsize(PMWFONT pfont, const void *text, int cc, int *pwidth, int *pheight, int *pbase);
void	gen_gettextbits(PMWFONT pfont, int ch, MWIMAGEBITS *retmap, int *pwidth, int *pheight, int *pbase);
void	gen_unloadfont(PMWFONT pfont);

void	corefont_drawtext(struct Window *win, struct GC *gc, int x, int y,	const void *text, int cc, int flags);

void GrBitmap(
	WndID	win, 
	struct GC *gc,
	int	 	x, 
	int 	y, 
	int 	width, 
	int 	height,
	MWIMAGEBITS *imagebits
);

/* local data*/
extern MWCOREFONT gen_fonts[NUMBER_FONTS];
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -