2022-09-04 11:56:38 +00:00
|
|
|
/*
|
2022-12-08 06:33:50 +00:00
|
|
|
text.h
|
2022-09-04 11:56:38 +00:00
|
|
|
|
2022-12-08 06:33:50 +00:00
|
|
|
Text management
|
2022-09-04 11:56:38 +00:00
|
|
|
|
|
|
|
Copyright (C) 2022 Bill Currie <bill@taniwha.org>
|
|
|
|
|
|
|
|
Author: Bill Currie <bill@taniwha.org>
|
|
|
|
Date: 2022/9/4
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2022-12-08 06:33:50 +00:00
|
|
|
#ifndef __QF_ui_text_h
|
|
|
|
#define __QF_ui_text_h
|
2022-09-04 11:56:38 +00:00
|
|
|
|
|
|
|
#include <hb.h>
|
|
|
|
#include <hb-ft.h>
|
|
|
|
|
|
|
|
#include "QF/darray.h"
|
|
|
|
|
2022-10-31 15:40:52 +00:00
|
|
|
#include "QF/ecs/component.h"
|
|
|
|
|
|
|
|
typedef struct script_component_s {
|
|
|
|
hb_language_t language;
|
|
|
|
hb_script_t script;
|
|
|
|
hb_direction_t direction;
|
|
|
|
} script_component_t;
|
|
|
|
|
2022-12-08 06:33:50 +00:00
|
|
|
typedef struct glyphobj_s {
|
|
|
|
int glyphid;
|
2022-12-07 06:11:08 +00:00
|
|
|
int x, y;
|
2022-12-08 06:33:50 +00:00
|
|
|
int fontid;
|
|
|
|
} glyphobj_t;
|
2022-12-07 06:11:08 +00:00
|
|
|
|
2022-12-08 06:33:50 +00:00
|
|
|
typedef struct glyphref_s {
|
|
|
|
uint32_t start;
|
|
|
|
uint32_t count;
|
|
|
|
} glyphref_t;
|
|
|
|
|
|
|
|
typedef struct glyphset_s {
|
|
|
|
glyphobj_t *glyphs;
|
|
|
|
uint32_t count;
|
|
|
|
} glyphset_t;
|
|
|
|
|
|
|
|
typedef struct text_s {
|
2022-09-04 11:56:38 +00:00
|
|
|
const char *text;
|
|
|
|
const char *language;
|
|
|
|
hb_script_t script;
|
|
|
|
hb_direction_t direction;
|
2022-12-08 06:33:50 +00:00
|
|
|
} text_t;
|
|
|
|
|
|
|
|
enum {
|
|
|
|
// covers both view and passage text object hierarcies
|
|
|
|
text_href,
|
|
|
|
// all the glyhphs in a passage
|
|
|
|
text_passage,
|
|
|
|
text_glyphs,
|
|
|
|
text_script,
|
|
|
|
text_font,
|
|
|
|
text_features,
|
2022-09-04 11:56:38 +00:00
|
|
|
|
2022-12-08 06:33:50 +00:00
|
|
|
text_type_count
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct featureset_s DARRAY_TYPE (hb_feature_t) featureset_t;
|
2022-09-04 11:56:38 +00:00
|
|
|
|
2022-12-07 06:11:08 +00:00
|
|
|
struct font_s;
|
2022-09-04 11:56:38 +00:00
|
|
|
struct rglyph_s;
|
2022-12-08 06:33:50 +00:00
|
|
|
typedef void text_render_t (uint32_t glyphid, int x, int y, void *data);
|
2022-09-04 11:56:38 +00:00
|
|
|
|
2022-12-08 06:33:50 +00:00
|
|
|
typedef struct shaper_s {
|
2022-12-07 06:11:08 +00:00
|
|
|
struct font_s *rfont;
|
2022-09-04 11:56:38 +00:00
|
|
|
hb_font_t *font;
|
|
|
|
hb_buffer_t *buffer;
|
2022-12-08 06:33:50 +00:00
|
|
|
featureset_t features;
|
|
|
|
} shaper_t;
|
2022-09-04 11:56:38 +00:00
|
|
|
|
2022-10-31 15:40:52 +00:00
|
|
|
extern hb_feature_t LigatureOff;
|
|
|
|
extern hb_feature_t LigatureOn;
|
2022-09-04 11:56:38 +00:00
|
|
|
extern hb_feature_t KerningOff;
|
|
|
|
extern hb_feature_t KerningOn;
|
|
|
|
extern hb_feature_t CligOff;
|
|
|
|
extern hb_feature_t CligOn;
|
|
|
|
|
2022-12-08 06:33:50 +00:00
|
|
|
struct font_s;
|
|
|
|
struct passage_s;
|
2022-12-09 06:18:47 +00:00
|
|
|
extern struct ecs_registry_s *text_reg;
|
2022-12-08 06:33:50 +00:00
|
|
|
|
|
|
|
shaper_t *Text_NewShaper (struct font_s *font);
|
|
|
|
void Text_DeleteShaper (shaper_t *shaper);
|
|
|
|
void Text_AddFeature (shaper_t *shaper, hb_feature_t feature);
|
|
|
|
void Text_ShapeText (shaper_t *shaper, text_t *text);
|
|
|
|
void Text_RenderText (shaper_t *shaper, text_t *text, int x, int y,
|
|
|
|
text_render_t *render, void *data);
|
|
|
|
void Text_Init (void);
|
|
|
|
struct view_s Text_View (struct font_s *font, struct passage_s *passage);
|
|
|
|
|
|
|
|
#endif//__QF_ui_text_h
|