refactor font api
Some checks failed
pyrite-dev/milsko/pipeline/head There was a failure building this commit

This commit is contained in:
Nishi 2026-04-06 17:29:09 +09:00
commit 0de09207a4
Signed by: nishi
GPG key ID: 27EF69B208EB9343
31 changed files with 12209 additions and 6149 deletions

View file

@ -176,29 +176,31 @@ MWDECL void MwDrawDiamond(MwWidget handle, MwRect* rect, MwLLColor color, int in
/*!
* @brief Draws a text
* @param handle Widget
* @param ttf TTF, NULLable
* @param point Center point of the text
* @param text Text
* @param bold Bold
* @param align Align
* @param color Color
*/
MWDECL void MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, int align, MwLLColor color);
MWDECL void MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text, int align, MwLLColor color);
/*!
* @brief Calculates a text width
* @param handle Widget
* @param text Text
* @param font Font, NULLable
* @return Text width
*/
MWDECL int MwTextWidth(MwWidget handle, const char* text);
MWDECL int MwTextWidth(MwWidget handle, MwFLFont font, const char* text);
/*!
* @brief Calculates a text height
* @param handle Widget
* @param text Text
* @param font Font, NULLable
* @return Text height
*/
MWDECL int MwTextHeight(MwWidget handle, const char* text);
MWDECL int MwTextHeight(MwWidget handle, MwFLFont font, const char* text);
/* color.c */

View file

@ -177,6 +177,10 @@ struct _MwLLTextDispatchTable {
void (*fontFree)(void* handle);
};
#define MwFLFlagMonospace (1 << 0)
#define MwFLFlagBold (1 << 1)
#define MwFLBuildFont(x) ((MwFLFont)(void*)(size_t)(x))
#ifdef __cplusplus
extern "C" {
#endif
@ -246,9 +250,9 @@ MWDECL int MWFL_FT2Setup(void);
MWDECL int MwFL_STBTTSetup(void);
#endif
MWDECL int (*MwFLDrawText)(MwWidget handle, MwPoint* point, const char* text, int bold, int align, MwLLColor color);
MWDECL int (*MwFLTextWidth)(MwWidget handle, const char* text);
MWDECL int (*MwFLTextHeight)(MwWidget handle, int count);
MWDECL int (*MwFLDrawText)(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text, MwLLColor color);
MWDECL int (*MwFLTextWidth)(MwFLFont ttf, const char* text);
MWDECL int (*MwFLTextHeight)(MwFLFont ttf, int count);
MWDECL void* (*MwFLFontLoad)(unsigned char* data, unsigned int size);
MWDECL void (*MwFLFontFree)(void* handle);

View file

@ -42,6 +42,26 @@ MWDECL unsigned char MwBoldTTFData[];
*/
MWDECL unsigned int MwBoldTTFDataSize;
/*!
* @brief Default monospace TTF font data
*/
MWDECL unsigned char MwMonospaceTTFData[];
/*!
* @brief Default monospace TTF font size
*/
MWDECL unsigned int MwMonospaceTTFDataSize;
/*!
* @brief Default bold monospace TTF font data
*/
MWDECL unsigned char MwBoldMonospaceTTFData[];
/*!
* @brief Default bold monospace TTF font size
*/
MWDECL unsigned int MwBoldMonospaceTTFDataSize;
#ifdef __cplusplus
}
#endif

View file

@ -42,6 +42,7 @@
#define MwNroundness "Iroundness"
#define MwNisRounded "IisRounded"
#define MwNdarkTheme "IdarkTheme"
#define MwNuseMonospace "IuseMonospace"
#define MwNtitle "Stitle"
#define MwNtext "Stext"
@ -56,6 +57,8 @@
#define MwNfont "Vfont"
#define MwNboldFont "VboldFont"
#define MwNbackgroundPixmap "VbackgroundPixmap"
#define MwNmonospaceFont "VmonospaceFont"
#define MwNboldMonospaceFont "VboldMonospaceFont"
#define MwNactivateHandler "Cactivate" /* NULL/int* (MwListBox)/void* (MwTreeView) */
#define MwNresizeHandler "Cresize" /* NULL */

View file

@ -104,6 +104,8 @@ struct _MwWidget {
void* root_font;
void* root_boldfont;
void* root_monofont;
void* root_boldmonofont;
int berserk;
};