text-hb.h - ltkx - GUI toolkit for X11 (old)
HTML git clone git://lumidify.org/ltkx.git (fast, but not encrypted)
HTML git clone https://lumidify.org/ltkx.git (encrypted, but very slow)
HTML git clone git://4kcetb7mo7hj6grozzybxtotsub5bempzo4lirzc3437amof2c2impyd.onion/ltkx.git (over tor)
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
text-hb.h (2740B)
---
1 /*
2 * This file is part of the Lumidify ToolKit (LTK)
3 * Copyright (c) 2017, 2018, 2020 lumidify <nobody@lumidify.org>
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in all
13 * copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 */
23
24 #ifndef _TEXT_HB_H_
25 #define _TEXT_HB_H_
26
27 /*
28 Requires the following includes:
29 <X11/Xlib.h>, <X11/Xutil.h>, "stb_truetype.h",
30 "khash.h", <harfbuzz/hb.h>, <fribidi.h>,
31 <fontconfig/fontconfig.h>, "text-common.h"
32 */
33
34 /* Single segment of text with same font */
35 typedef struct LtkTextSegment {
36 uint16_t font_id;
37 uint16_t font_size;
38 unsigned int w;
39 unsigned int h;
40 int start_x;
41 int start_y;
42 int x_min;
43 int y_min;
44 int x_max;
45 int y_max;
46 hb_direction_t dir;
47 uint32_t *str;
48 LtkGlyph *start_glyph;
49 struct LtkTextSegment *next;
50 } LtkTextSegment;
51
52 /* Single line of text */
53 typedef struct {
54 unsigned int w;
55 unsigned int h;
56 int x_max;
57 int x_min;
58 int y_max;
59 int y_min;
60 FriBidiParType dir;
61 LtkTextSegment *start_segment;
62 } LtkTextLine;
63
64 /* TODO: different sizes, colors, styles, etc. */
65 LtkTextLine *ltk_create_text_line(LtkTextManager *tm, char *text, uint16_t fontid, uint16_t size);
66
67 /* FIXME: could use unsigned int for fontid and size as long as there is code to check neither of them become too large
68 -> in case I want to get rid of uint_16_t, etc. */
69 LtkTextSegment *ltk_create_text_segment(LtkTextManager *tm, uint32_t *text, unsigned int text_len, uint16_t fontid, uint16_t size, hb_script_t script);
70
71 void ltk_destroy_text_segment(LtkTextSegment *ts);
72
73 XImage *ltk_render_text_line(LtkTextLine *tl, Display *dpy, Window window, GC gc, Colormap colormap, XColor fg, XColor bg);
74
75 void ltk_render_text_segment(LtkTextSegment *ts, unsigned int start_x, unsigned int start_y, XImage *img, XColor fg);
76
77
78 #endif /* _TEXT_HB_H_ */