#ifndef _DEVICE_FONT_H_ #define _DEVICE_FONT_H_ #include "gui_eng/stddefs.h" #include "gui_eng/device_gdi.h" #include "gui_eng/windef.h" #ifndef min #ifdef gcc static inline int min(int x, int y) {return (x)>(y) ? (y) : (x);} #else #define min(x,y) ((x)>(y) ? (y) : (x)) #endif #endif #ifndef max #ifdef gcc static inline int max(int x, int y) {return (x)>(y) ? (x) : (y);} #else #define max(x,y) ((x)>(y) ? (x) : (y)) #endif #endif #ifndef swap #define swap(x,y) do{x = x ^ y; y = x ^ y; x = x ^ y;}while(0); #endif //Check system configuration #ifdef CONFIG_FLASH_STORE_TTF #if !defined CONFIG_CHIP_512L || !defined CONFIG_SPI_FLASH_SIZE_8M || !defined CONFIG_FONT_ENGINE_HARFBUZZ #error "To support CONFIG_FLASH_STORE_TTF should config CONFIG_CHIP_512L, CONFIG_SPI_FLASH_SIZE_8M and CONFIG_FONT_ENGINE_HARFBUZZ" #endif #endif #define FONT_ALIGN_LEFT (0x00) // Text align: left in horizontal #define FONT_ALIGN_CENTER (0x01) // Text align: center in horizontal #define FONT_ALIGN_RIGHT (0x02) // Text align: right in horizontal #define FONT_ALIGN_CP_DIR (0x04) // Text align: codepage display direction #define FONT_ALIGN_MASK (0x0F) #define FONT_V_ALIGN_TOP (0x00) #define FONT_V_ALIGN_CENTER (0x10) #define FONT_V_ALIGN_BOTTOM (0x20) #define FONT_V_ALIGN_MASK (0xF0) #define CHARCELL_EFFECT_UNDERLINE (0x01) #define CHARCELL_EFFECT_RECT (0x02) #define NOT_DISPLAY_UNKOWN_CHAR (0xffff) #define INVALID_CHAR_SPACE (~0) enum { LINE_SEEK_SET, LINE_SEEK_CUR, LINE_SEEK_END, }; /* OSD Language for middleware*/ typedef enum { MID_OSDLANG_COMM = 0, MID_OSDLANG_KURDISH, MID_OSDLANG_BURMESE, MID_OSDLANG_KHMER } MID_OSDLanguage_t; typedef struct { UINT8 *pArray; INT8 style; INT8 sizeIdx; INT8 bmpSize; } FONTInfo_t; typedef struct { UINT8 ucBaseFontSize; UINT8 ucNumFontSize; UINT8 ucCharSpacing; UINT8 ucTotalLang; UINT16 usStrIDNum; UINT8*** pLangStrArray; FONTInfo_t *pFontInfo; } FontInitInfo_t; typedef struct { UINT8 bFgColor; /* The index value of text filling color. */ UINT8 bBgColor; /* The index value of text bg color. */ } TxtColor_t; typedef enum { FIXWIDTH_NONE, FIXWIDTH_NUMERRIC, FIXWIDTH_ALLCHARS, } FixWidth_t; /* external structure define for text attributes description */ typedef struct { UINT8 ucTextAlign; // The text alignment style UINT8 ucLineSpacing; // line spacing if multi line UINT8 ucFontSize; // Font style, an enumeration value. UINT8 ucShowEllipsis; UINT8 ucPrivateCharSpace; // has high priority if set ~0 UINT16 usStrWidth; TxtColor_t stColour; FixWidth_t eFixCharWidth; // Fix char width. RECT stRect; } TextInfo_t; typedef struct { /* Notice: Effect char must be ASCII character */ UINT16 usCellIdx; /* the idx of specified char cell(one char cell maybe constructed by multi unicode) */ UINT16 usCellEffect; /* use an underline character or one rectangle to replace the upper char cell */ TxtColor_t stColour; /* the colour of the effect char cell */ } CharEffect_t, *PCharEffect_t; INT32 Font_init(FontInitInfo_t *pstFontInfo); INT32 Font_unInitial(void); void Font_setUnknownChar(UINT16 usUnknownChar); UINT16 Font_getUnknownChar(void); INT32 Font_setEmColour(TxtColor_t *pstEmColour); INT32 Font_setCurLang(UINT8 ucLang); UINT8 Font_getCurLang(void); BOOL Font_isAPHChar(UINT16 utf16Code); UINT8* Font_SetUTF8Position(UINT8 *pStr, INT32 *pLen, UINT32 *pPosition); UINT8* Font_getStrByID(HDC hdc, UINT32 uiStrID); INT32 Font_getStrWH(UINT8 *pUTF8Str, UINT8 ucFontSize, FixWidth_t eFixCharWidth, UINT16 *pWidth, UINT16 *pHeight); INT32 Font_drawStr(HDC hdc, UINT8 *pUTF8Str, TextInfo_t *pstTxtInfo, PCharEffect_t pEffectChar, INT32 *pBlockID); INT32 Font_drawStrID(HDC hdc, UINT32 uiStrID, TextInfo_t *pstTxtInfo, INT32 *pBlockId); INT32 Font_getStrBmp(UINT8 *pUTF8Str, TextInfo_t *pstTxtInfo, BOOL *bDrawL2R, PRECT pDrawRect, IMAGEHDR *pImgInfo); INT32 Font_getPgrhInfo(UINT8 *str, TextInfo_t *pstTxtInfo, PPgrhInfo_t pPgrhInfo); INT32 Font_getLineStartOfPgrh(PPgrhInfo_t pPgrhInfo, UINT16 usLine, UINT16 *pLineStart); INT32 Font_drawPgrh(HDC hdc, PPgrhInfo_t pPgrhInfo, TextInfo_t *pstTxtInfo, INT32 iOffset, UINT8 ucMode, INT32 *pBlockID); INT32 Font_freePgrhInfo(PPgrhInfo_t pPgrhInfo); UINT8 Font_getStringHeight(UINT8 ucFontSize); #endif