device_font.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #ifndef _DEVICE_FONT_H_
  2. #define _DEVICE_FONT_H_
  3. #include "gui_eng/stddefs.h"
  4. #include "gui_eng/device_gdi.h"
  5. #include "gui_eng/windef.h"
  6. #ifndef min
  7. #ifdef gcc
  8. static inline int min(int x, int y) {return (x)>(y) ? (y) : (x);}
  9. #else
  10. #define min(x,y) ((x)>(y) ? (y) : (x))
  11. #endif
  12. #endif
  13. #ifndef max
  14. #ifdef gcc
  15. static inline int max(int x, int y) {return (x)>(y) ? (x) : (y);}
  16. #else
  17. #define max(x,y) ((x)>(y) ? (x) : (y))
  18. #endif
  19. #endif
  20. #ifndef swap
  21. #define swap(x,y) do{x = x ^ y; y = x ^ y; x = x ^ y;}while(0);
  22. #endif
  23. //Check system configuration
  24. #ifdef CONFIG_FLASH_STORE_TTF
  25. #if !defined CONFIG_CHIP_512L || !defined CONFIG_SPI_FLASH_SIZE_8M || !defined CONFIG_FONT_ENGINE_HARFBUZZ
  26. #error "To support CONFIG_FLASH_STORE_TTF should config CONFIG_CHIP_512L, CONFIG_SPI_FLASH_SIZE_8M and CONFIG_FONT_ENGINE_HARFBUZZ"
  27. #endif
  28. #endif
  29. #define FONT_ALIGN_LEFT (0x00) // Text align: left in horizontal
  30. #define FONT_ALIGN_CENTER (0x01) // Text align: center in horizontal
  31. #define FONT_ALIGN_RIGHT (0x02) // Text align: right in horizontal
  32. #define FONT_ALIGN_CP_DIR (0x04) // Text align: codepage display direction
  33. #define FONT_ALIGN_MASK (0x0F)
  34. #define FONT_V_ALIGN_TOP (0x00)
  35. #define FONT_V_ALIGN_CENTER (0x10)
  36. #define FONT_V_ALIGN_BOTTOM (0x20)
  37. #define FONT_V_ALIGN_MASK (0xF0)
  38. #define CHARCELL_EFFECT_UNDERLINE (0x01)
  39. #define CHARCELL_EFFECT_RECT (0x02)
  40. #define NOT_DISPLAY_UNKOWN_CHAR (0xffff)
  41. #define INVALID_CHAR_SPACE (~0)
  42. enum
  43. {
  44. LINE_SEEK_SET,
  45. LINE_SEEK_CUR,
  46. LINE_SEEK_END,
  47. };
  48. /* OSD Language for middleware*/
  49. typedef enum {
  50. MID_OSDLANG_COMM = 0,
  51. MID_OSDLANG_KURDISH,
  52. MID_OSDLANG_BURMESE,
  53. MID_OSDLANG_KHMER
  54. } MID_OSDLanguage_t;
  55. typedef struct {
  56. UINT8 *pArray;
  57. INT8 style;
  58. INT8 sizeIdx;
  59. INT8 bmpSize;
  60. } FONTInfo_t;
  61. typedef struct
  62. {
  63. UINT8 ucBaseFontSize;
  64. UINT8 ucNumFontSize;
  65. UINT8 ucCharSpacing;
  66. UINT8 ucTotalLang;
  67. UINT16 usStrIDNum;
  68. UINT8*** pLangStrArray;
  69. FONTInfo_t *pFontInfo;
  70. } FontInitInfo_t;
  71. typedef struct
  72. {
  73. UINT8 bFgColor; /* The index value of text filling color. */
  74. UINT8 bBgColor; /* The index value of text bg color. */
  75. } TxtColor_t;
  76. typedef enum
  77. {
  78. FIXWIDTH_NONE,
  79. FIXWIDTH_NUMERRIC,
  80. FIXWIDTH_ALLCHARS,
  81. } FixWidth_t;
  82. /* external structure define for text attributes description */
  83. typedef struct
  84. {
  85. UINT8 ucTextAlign; // The text alignment style
  86. UINT8 ucLineSpacing; // line spacing if multi line
  87. UINT8 ucFontSize; // Font style, an enumeration value.
  88. UINT8 ucShowEllipsis;
  89. UINT8 ucPrivateCharSpace; // has high priority if set ~0
  90. UINT16 usStrWidth;
  91. TxtColor_t stColour;
  92. FixWidth_t eFixCharWidth; // Fix char width.
  93. RECT stRect;
  94. } TextInfo_t;
  95. typedef struct
  96. {
  97. /* Notice: Effect char must be ASCII character */
  98. UINT16 usCellIdx; /* the idx of specified char cell(one char cell maybe constructed by multi unicode) */
  99. UINT16 usCellEffect; /* use an underline character or one rectangle to replace the upper char cell */
  100. TxtColor_t stColour; /* the colour of the effect char cell */
  101. } CharEffect_t, *PCharEffect_t;
  102. INT32 Font_init(FontInitInfo_t *pstFontInfo);
  103. INT32 Font_unInitial(void);
  104. void Font_setUnknownChar(UINT16 usUnknownChar);
  105. UINT16 Font_getUnknownChar(void);
  106. INT32 Font_setEmColour(TxtColor_t *pstEmColour);
  107. INT32 Font_setCurLang(UINT8 ucLang);
  108. UINT8 Font_getCurLang(void);
  109. BOOL Font_isAPHChar(UINT16 utf16Code);
  110. UINT8* Font_SetUTF8Position(UINT8 *pStr, INT32 *pLen, UINT32 *pPosition);
  111. UINT8* Font_getStrByID(HDC hdc, UINT32 uiStrID);
  112. INT32 Font_getStrWH(UINT8 *pUTF8Str, UINT8 ucFontSize, FixWidth_t eFixCharWidth, UINT16 *pWidth, UINT16 *pHeight);
  113. INT32 Font_drawStr(HDC hdc, UINT8 *pUTF8Str, TextInfo_t *pstTxtInfo, PCharEffect_t pEffectChar, INT32 *pBlockID);
  114. INT32 Font_drawStrID(HDC hdc, UINT32 uiStrID, TextInfo_t *pstTxtInfo, INT32 *pBlockId);
  115. INT32 Font_getStrBmp(UINT8 *pUTF8Str, TextInfo_t *pstTxtInfo, BOOL *bDrawL2R, PRECT pDrawRect, IMAGEHDR *pImgInfo);
  116. INT32 Font_getPgrhInfo(UINT8 *str, TextInfo_t *pstTxtInfo, PPgrhInfo_t pPgrhInfo);
  117. INT32 Font_getLineStartOfPgrh(PPgrhInfo_t pPgrhInfo, UINT16 usLine, UINT16 *pLineStart);
  118. INT32 Font_drawPgrh(HDC hdc, PPgrhInfo_t pPgrhInfo, TextInfo_t *pstTxtInfo, INT32 iOffset, UINT8 ucMode, INT32 *pBlockID);
  119. INT32 Font_freePgrhInfo(PPgrhInfo_t pPgrhInfo);
  120. UINT8 Font_getStringHeight(UINT8 ucFontSize);
  121. #endif