From 980f5a74196cdfe0f1fb70799b95201207779d1d Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 10 Jan 2016 21:02:40 -0500 Subject: [PATCH] Some more text API changes. --- ui.h | 50 ++++++++++++++------------------------------------ 1 file changed, 14 insertions(+), 36 deletions(-) diff --git a/ui.h b/ui.h index e82c537a..b2fef779 100644 --- a/ui.h +++ b/ui.h @@ -442,15 +442,20 @@ _UI_EXTERN void uiDrawClip(uiDrawContext *c, uiDrawPath *path); _UI_EXTERN void uiDrawSave(uiDrawContext *c); _UI_EXTERN void uiDrawRestore(uiDrawContext *c); +// TODO manage the use of Text, Font, and TextFont, and of the uiDrawText prefix in general + +///// TODO typedef struct uiDrawFontFamilies uiDrawFontFamilies; _UI_EXTERN uiDrawFontFamilies *uiDrawListFontFamilies(void); _UI_EXTERN uintmax_t uiDrawFontFamiliesNumFamilies(uiDrawFontFamilies *ff); _UI_EXTERN char *uiDrawFontFamiliesFamily(uiDrawFontFamilies *ff, uintmax_t n); _UI_EXTERN void uiDrawFreeFontFamilies(uiDrawFontFamilies *ff); +///// END TODO typedef struct uiDrawTextLayout uiDrawTextLayout; -typedef struct uiDrawInitialTextStyle uiDrawInitialTextStyle; +typedef struct uiDrawTextFont uiDrawTextFont; +typedef struct uiDrawTextFontDescriptor uiDrawTextFontDescriptor; typedef enum uiDrawTextWeight { uiDrawTextWeightThin, @@ -493,8 +498,7 @@ typedef enum uiDrawTextGravity { uiDrawTextGravityAuto, } uiDrawTextGravity; -// TODO should this be renamed to uiDrawTextFontDescription? and should a pre-matched uiDrawTextFont be used for the initialStyle instead? -struct uiDrawInitialTextStyle { +struct uiDrawTextFontDescriptor { const char *Family; double Size; uiDrawTextWeight Weight; @@ -504,43 +508,17 @@ struct uiDrawInitialTextStyle { uiDrawTextGravity Gravity; }; -/*TODO -struct uiDrawTextStyle { - const char *Family; - double Size; - uiDrawTextWeight Weight; - uiDrawTextItalic Italic; - int SmallCaps; - uiDrawTextStretch Stretch; - double TextR; - double TextG; - double TextB; - double TextA; - int HasBackground; - double BackgroundR; - double BackgroundG; - double BackgroundB; - double BackgroundA; // TODO Pango - int HasStrikethrough; - double StrikethroughR; - double StrikethroughG; - double StrikethroughB; - double StrikethroughA; // TODO Pango - int HasUnderline; - double UnderlineR; - double UnderlineG; - double UnderlineB; - double UnderlineA; // TODO Pango - const char *Language; // RFC 3066; NULL for default - // TODO other Pango attributes -}; -*/ - // TODO wait why do I have these functions? I don't think they provide a correct line height... _UI_EXTERN double uiDrawTextSizeToPoints(double textSize); _UI_EXTERN double uiDrawPointsToTextSize(double points); -_UI_EXTERN uiDrawTextLayout *uiDrawNewTextLayout(const char *text, const uiDrawInitialTextStyle *initialTextStyle); +_UI_EXTERN uiDrawTextFont *uiDrawLoadClosestFont(const uiDrawTextFontDescriptor *desc); +_UI_EXTERN void uiDrawFreeTextFont(uiDrawTextFont *font); +_UI_EXTERN uintptr_t uiDrawTextFontHandle(uiDrawTextFont *font); +_UI_EXTERN void uiDrawTextFontDescribe(uiDrawTextFont *font, uiDrawTextFontDescriptor *desc); +// TODO make copy with given attributes methods? + +_UI_EXTERN uiDrawTextLayout *uiDrawNewTextLayout(const char *text, uiDrawTextFont *defaultFont); _UI_EXTERN void uiDrawFreeTextLayout(uiDrawTextLayout *layout); _UI_EXTERN void uiDrawText(uiDrawContext *c, double x, double y, uiDrawTextLayout *layout);