mirror of
https://github.com/Relintai/sfw.git
synced 2025-04-21 01:11:16 +02:00
Initial font rework.
This commit is contained in:
parent
82853c99f2
commit
2c358a1466
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,12 @@
|
|||||||
|
#ifndef FONT_RENDERER_H
|
||||||
|
#define FONT_RENDERER_H
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// font framework
|
// font framework originally from FWK
|
||||||
// - rlyeh, public domain
|
// - rlyeh, public domain
|
||||||
|
|
||||||
|
#include "object/object.h"
|
||||||
|
|
||||||
// font size tags
|
// font size tags
|
||||||
#define FONT_H1 "\1" // largest
|
#define FONT_H1 "\1" // largest
|
||||||
#define FONT_H2 "\2"
|
#define FONT_H2 "\2"
|
||||||
@ -39,6 +44,10 @@
|
|||||||
#define FONT_BASELINE "\\_"
|
#define FONT_BASELINE "\\_"
|
||||||
#define FONT_BOTTOM "\\v"
|
#define FONT_BOTTOM "\\v"
|
||||||
|
|
||||||
|
class TextRenderer : public Object {
|
||||||
|
SFW_OBJECT(TextRenderer, Object);
|
||||||
|
|
||||||
|
public:
|
||||||
// font flags
|
// font flags
|
||||||
enum FONT_FLAGS {
|
enum FONT_FLAGS {
|
||||||
// font atlas size
|
// font atlas size
|
||||||
@ -78,23 +87,31 @@ typedef struct font_metrics_t {
|
|||||||
} font_metrics_t;
|
} font_metrics_t;
|
||||||
|
|
||||||
// configures
|
// configures
|
||||||
API void font_face(const char *face_tag, const char *filename_ttf, float font_size, unsigned flags);
|
void font_face(const char *face_tag, const char *filename_ttf, float font_size, unsigned flags);
|
||||||
API void font_face_from_mem(const char *tag, const void *ttf_buffer, unsigned ttf_len, float font_size, unsigned flags);
|
void font_face_from_mem(const char *tag, const void *ttf_buffer, unsigned ttf_len, float font_size, unsigned flags);
|
||||||
API void font_scales(const char *face_tag, float h1, float h2, float h3, float h4, float h5, float h6);
|
void font_scales(const char *face_tag, float h1, float h2, float h3, float h4, float h5, float h6);
|
||||||
API void font_color(const char *color_tag, uint32_t color);
|
void font_color(const char *color_tag, uint32_t color);
|
||||||
|
|
||||||
// commands
|
// commands
|
||||||
API vec2 font_xy();
|
vec2 font_xy();
|
||||||
API void font_goto(float x, float y);
|
void font_goto(float x, float y);
|
||||||
API vec2 font_print(const char *text);
|
vec2 font_print(const char *text);
|
||||||
API vec2 font_rect(const char *text);
|
vec2 font_rect(const char *text);
|
||||||
API font_metrics_t font_metrics(const char *text);
|
font_metrics_t font_metrics(const char *text);
|
||||||
// void font_clip(vec2 topleft, vec2 bottomright);
|
// void font_clip(vec2 topleft, vec2 bottomright);
|
||||||
// void font_wrap(vec2 topleft, vec2 bottomright);
|
// void font_wrap(vec2 topleft, vec2 bottomright);
|
||||||
|
|
||||||
// syntax highlighting
|
// syntax highlighting
|
||||||
API void* font_colorize(const char *text, const char *comma_types, const char *comma_keywords); // comma separated tokens. expensive, please cache result.
|
void *font_colorize(const char *text, const char *comma_types, const char *comma_keywords); // comma separated tokens. expensive, please cache result.
|
||||||
API vec2 font_highlight(const char *text, const void *colors);
|
vec2 font_highlight(const char *text, const void *colors);
|
||||||
|
|
||||||
// ui
|
// ui
|
||||||
API void ui_font();
|
void ui_font();
|
||||||
|
|
||||||
|
static TextRenderer *get_singleton();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static TextRenderer *_singleton;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user