Aborted implementing text rendering for now.

This commit is contained in:
Pietro Gagliardi 2015-09-15 09:25:59 -04:00
parent 601bced3ac
commit 640598f417
4 changed files with 72 additions and 207 deletions

72
areatext/ui.h Normal file
View File

@ -0,0 +1,72 @@
// 15 september 2015
// TODO uiDrawBeginTextRGB(/RGBA?)
// might need something more flexible for attributed text
typedef struct uiDrawFont uiDrawFont;
typedef struct uiDrawFontSpec uiDrawFontSpec;
typedef struct uiDrawTextBlockParams uiDrawTextBlockParams;
typedef struct uiDrawFontMetrics uiDrawFontMetrics;
typedef enum uiDrawTextWeight uiDrawTextWeight;
typedef enum uiDrawTextAlign uiDrawTextAlign;
enum uiDrawTextWeight {
uiDrawTextWeightThin,
uiDrawTextWeightExtraLight,
uiDrawTextWeightLight,
uiDrawTextWeightNormal,
uiDrawTextWeightMedium,
uiDrawTextWeightSemiBold,
uiDrawTextWeightBold,
uiDrawTextWeightExtraBold,
uiDrawTextWeightHeavy,
};
struct uiDrawFontSpec {
const char *Family;
uintmax_t PointSize;
uiDrawTextWeight Weight;
int Italic; // always prefers true italics over obliques whenever possible
int Vertical;
};
enum uiDrawTextAlign {
uiDrawTextAlignLeft,
uiDrawTextAlignCenter,
uiDrawTextAlignRight,
};
struct uiDrawTextBlockParams {
intmax_t Width;
intmax_t FirstLineIndent;
intmax_t LineSpacing;
uiDrawTextAlign Align;
int Justify;
};
struct uiDrawFontMetrics {
// TODO
// metrics on Windows are per-device; other platforms not?
};
#define uiDrawTextPixelSizeToPointSize(pix, dpiY) \
((uintmax_t) ((((double) (pix)) * 72.0) / ((double) (dpiY))))
#define uiDrawTextPointSizeToPixelSize(pt, dpiY) \
((uintmax_t) (((double) (pt)) * (((double) (dpiY)) / 72.0)))
uiDrawFont *uiDrawPrepareFont(uiDrawFontSpec *);
void uiDrawFreeFont(uiDrawFont *);
void uiDrawText(uiDrawContext *, const char *, uiDrawFont *, intmax_t, intmax_t);
void uiDrawTextBlock(uiDrawContext *, const char *, uiDrawFont *, intmax_t, intmax_t, uiDrawTextBlockParams *);
void uiDrawTextExtents(uiDrawContext *, const char *, uiDrawFont *, intmax_t *, intmax_t *);
intmax_t uiDrawTextExtentsBlockHeight(uiDrawContext *, const char *, uiDrawFont *, uiDrawTextBlockParams *);
// TODO width for number of lines
//TODOvoid uiDrawContextFontMetrics(uiDrawContext *, uiDrawFont *, uiDrawFontMetrics *);
// TODO draw text, single line, control font
// TODO draw text, wrapped to width, control font
// TODO get text extents, single line, control font
// TODO get text height for width, control font
// TODO width for number of lines, control font
// TODO get font metrics, control font

View File

@ -76,7 +76,6 @@ struct uiDrawStrokeParams {
void uiDrawBeginPathRGB(uiDrawContext *, uint8_t, uint8_t, uint8_t);
// TODO verify these aren't alpha premultiplied anywhere
void uiDrawBeginPathRGBA(uiDrawContext *, uint8_t, uint8_t, uint8_t, uint8_t);
// TODO uiDrawBeginTextRGB(/RGBA?)
void uiDrawMoveTo(uiDrawContext *, intmax_t, intmax_t);
void uiDrawLineTo(uiDrawContext *, intmax_t, intmax_t);
@ -95,74 +94,6 @@ void uiDrawFill(uiDrawContext *, uiDrawFillMode);
// - elliptical arcs
// - quadratic bezier curves
typedef struct uiDrawFont uiDrawFont;
typedef struct uiDrawFontSpec uiDrawFontSpec;
typedef struct uiDrawTextBlockParams uiDrawTextBlockParams;
typedef struct uiDrawFontMetrics uiDrawFontMetrics;
typedef enum uiDrawTextWeight uiDrawTextWeight;
typedef enum uiDrawTextAlign uiDrawTextAlign;
enum uiDrawTextWeight {
uiDrawTextWeightThin,
uiDrawTextWeightExtraLight,
uiDrawTextWeightLight,
uiDrawTextWeightNormal,
uiDrawTextWeightMedium,
uiDrawTextWeightSemiBold,
uiDrawTextWeightBold,
uiDrawTextWeightExtraBold,
uiDrawTextWeightHeavy,
};
struct uiDrawFontSpec {
const char *Family;
uintmax_t PointSize;
uiDrawTextWeight Weight;
int Italic; // always prefers true italics over obliques whenever possible
int Vertical;
};
enum uiDrawTextAlign {
uiDrawTextAlignLeft,
uiDrawTextAlignCenter,
uiDrawTextAlignRight,
};
struct uiDrawTextBlockParams {
intmax_t Width;
intmax_t FirstLineIndent;
intmax_t LineSpacing;
uiDrawTextAlign Align;
int Justify;
};
struct uiDrawFontMetrics {
// TODO
// metrics on Windows are per-device; other platforms not?
};
#define uiDrawTextPixelSizeToPointSize(pix, dpiY) \
((uintmax_t) ((((double) (pix)) * 72.0) / ((double) (dpiY))))
#define uiDrawTextPointSizeToPixelSize(pt, dpiY) \
((uintmax_t) (((double) (pt)) * (((double) (dpiY)) / 72.0)))
uiDrawFont *uiDrawPrepareFont(uiDrawFontSpec *);
void uiDrawFreeFont(uiDrawFont *);
void uiDrawText(uiDrawContext *, const char *, uiDrawFont *, intmax_t, intmax_t);
void uiDrawTextBlock(uiDrawContext *, const char *, uiDrawFont *, intmax_t, intmax_t, uiDrawTextBlockParams *);
void uiDrawTextExtents(uiDrawContext *, const char *, uiDrawFont *, intmax_t *, intmax_t *);
intmax_t uiDrawTextExtentsBlockHeight(uiDrawContext *, const char *, uiDrawFont *, uiDrawTextBlockParams *);
// TODO width for number of lines
//TODOvoid uiDrawContextFontMetrics(uiDrawContext *, uiDrawFont *, uiDrawFontMetrics *);
// TODO draw text, single line, control font
// TODO draw text, wrapped to width, control font
// TODO get text extents, single line, control font
// TODO get text height for width, control font
// TODO width for number of lines, control font
// TODO get font metrics, control font
typedef enum uiModifiers uiModifiers;
enum uiModifiers {

View File

@ -76,7 +76,6 @@ struct uiDrawStrokeParams {
void uiDrawBeginPathRGB(uiDrawContext *, uint8_t, uint8_t, uint8_t);
// TODO verify these aren't alpha premultiplied anywhere
void uiDrawBeginPathRGBA(uiDrawContext *, uint8_t, uint8_t, uint8_t, uint8_t);
// TODO uiDrawBeginTextRGB(/RGBA?)
void uiDrawMoveTo(uiDrawContext *, intmax_t, intmax_t);
void uiDrawLineTo(uiDrawContext *, intmax_t, intmax_t);
@ -95,74 +94,6 @@ void uiDrawFill(uiDrawContext *, uiDrawFillMode);
// - elliptical arcs
// - quadratic bezier curves
typedef struct uiDrawFont uiDrawFont;
typedef struct uiDrawFontSpec uiDrawFontSpec;
typedef struct uiDrawTextBlockParams uiDrawTextBlockParams;
typedef struct uiDrawFontMetrics uiDrawFontMetrics;
typedef enum uiDrawTextWeight uiDrawTextWeight;
typedef enum uiDrawTextAlign uiDrawTextAlign;
enum uiDrawTextWeight {
uiDrawTextWeightThin,
uiDrawTextWeightExtraLight,
uiDrawTextWeightLight,
uiDrawTextWeightNormal,
uiDrawTextWeightMedium,
uiDrawTextWeightSemiBold,
uiDrawTextWeightBold,
uiDrawTextWeightExtraBold,
uiDrawTextWeightHeavy,
};
struct uiDrawFontSpec {
const char *Family;
uintmax_t PointSize;
uiDrawTextWeight Weight;
int Italic; // always prefers true italics over obliques whenever possible
int Vertical;
};
enum uiDrawTextAlign {
uiDrawTextAlignLeft,
uiDrawTextAlignCenter,
uiDrawTextAlignRight,
};
struct uiDrawTextBlockParams {
intmax_t Width;
intmax_t FirstLineIndent;
intmax_t LineSpacing;
uiDrawTextAlign Align;
int Justify;
};
struct uiDrawFontMetrics {
// TODO
// metrics on Windows are per-device; other platforms not?
};
#define uiDrawTextPixelSizeToPointSize(pix, dpiY) \
((uintmax_t) ((((double) (pix)) * 72.0) / ((double) (dpiY))))
#define uiDrawTextPointSizeToPixelSize(pt, dpiY) \
((uintmax_t) (((double) (pt)) * (((double) (dpiY)) / 72.0)))
uiDrawFont *uiDrawPrepareFont(uiDrawFontSpec *);
void uiDrawFreeFont(uiDrawFont *);
void uiDrawText(uiDrawContext *, const char *, uiDrawFont *, intmax_t, intmax_t);
void uiDrawTextBlock(uiDrawContext *, const char *, uiDrawFont *, intmax_t, intmax_t, uiDrawTextBlockParams *);
void uiDrawTextExtents(uiDrawContext *, const char *, uiDrawFont *, intmax_t *, intmax_t *);
intmax_t uiDrawTextExtentsBlockHeight(uiDrawContext *, const char *, uiDrawFont *, uiDrawTextBlockParams *);
// TODO width for number of lines
//TODOvoid uiDrawContextFontMetrics(uiDrawContext *, uiDrawFont *, uiDrawFontMetrics *);
// TODO draw text, single line, control font
// TODO draw text, wrapped to width, control font
// TODO get text extents, single line, control font
// TODO get text height for width, control font
// TODO width for number of lines, control font
// TODO get font metrics, control font
typedef enum uiModifiers uiModifiers;
enum uiModifiers {

View File

@ -76,7 +76,6 @@ struct uiDrawStrokeParams {
void uiDrawBeginPathRGB(uiDrawContext *, uint8_t, uint8_t, uint8_t);
// TODO verify these aren't alpha premultiplied anywhere
void uiDrawBeginPathRGBA(uiDrawContext *, uint8_t, uint8_t, uint8_t, uint8_t);
// TODO uiDrawBeginTextRGB(/RGBA?)
void uiDrawMoveTo(uiDrawContext *, intmax_t, intmax_t);
void uiDrawLineTo(uiDrawContext *, intmax_t, intmax_t);
@ -95,74 +94,6 @@ void uiDrawFill(uiDrawContext *, uiDrawFillMode);
// - elliptical arcs
// - quadratic bezier curves
typedef struct uiDrawFont uiDrawFont;
typedef struct uiDrawFontSpec uiDrawFontSpec;
typedef struct uiDrawTextBlockParams uiDrawTextBlockParams;
typedef struct uiDrawFontMetrics uiDrawFontMetrics;
typedef enum uiDrawTextWeight uiDrawTextWeight;
typedef enum uiDrawTextAlign uiDrawTextAlign;
enum uiDrawTextWeight {
uiDrawTextWeightThin,
uiDrawTextWeightExtraLight,
uiDrawTextWeightLight,
uiDrawTextWeightNormal,
uiDrawTextWeightMedium,
uiDrawTextWeightSemiBold,
uiDrawTextWeightBold,
uiDrawTextWeightExtraBold,
uiDrawTextWeightHeavy,
};
struct uiDrawFontSpec {
const char *Family;
uintmax_t PointSize;
uiDrawTextWeight Weight;
int Italic; // always prefers true italics over obliques whenever possible
int Vertical;
};
enum uiDrawTextAlign {
uiDrawTextAlignLeft,
uiDrawTextAlignCenter,
uiDrawTextAlignRight,
};
struct uiDrawTextBlockParams {
intmax_t Width;
intmax_t FirstLineIndent;
intmax_t LineSpacing;
uiDrawTextAlign Align;
int Justify;
};
struct uiDrawFontMetrics {
// TODO
// metrics on Windows are per-device; other platforms not?
};
#define uiDrawTextPixelSizeToPointSize(pix, dpiY) \
((uintmax_t) ((((double) (pix)) * 72.0) / ((double) (dpiY))))
#define uiDrawTextPointSizeToPixelSize(pt, dpiY) \
((uintmax_t) (((double) (pt)) * (((double) (dpiY)) / 72.0)))
uiDrawFont *uiDrawPrepareFont(uiDrawFontSpec *);
void uiDrawFreeFont(uiDrawFont *);
void uiDrawText(uiDrawContext *, const char *, uiDrawFont *, intmax_t, intmax_t);
void uiDrawTextBlock(uiDrawContext *, const char *, uiDrawFont *, intmax_t, intmax_t, uiDrawTextBlockParams *);
void uiDrawTextExtents(uiDrawContext *, const char *, uiDrawFont *, intmax_t *, intmax_t *);
intmax_t uiDrawTextExtentsBlockHeight(uiDrawContext *, const char *, uiDrawFont *, uiDrawTextBlockParams *);
// TODO width for number of lines
//TODOvoid uiDrawContextFontMetrics(uiDrawContext *, uiDrawFont *, uiDrawFontMetrics *);
// TODO draw text, single line, control font
// TODO draw text, wrapped to width, control font
// TODO get text extents, single line, control font
// TODO get text height for width, control font
// TODO width for number of lines, control font
// TODO get font metrics, control font
typedef enum uiModifiers uiModifiers;
enum uiModifiers {