text.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.h (1993B)
---
1 /*
2 * This file is part of the Lumidify ToolKit (LTK)
3 * Copyright (c) 2016, 2017 Lumidify Productions <lumidify@openmailbox.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 _LTK_TEXT_
25 #define _LTK_TEXT_
26
27 /* These unicode routines are taken from
28 * https://github.com/JeffBezanson/cutef8 */
29
30 /* is c the start of a utf8 sequence? */
31 #define isutf(c) (((c)&0xC0)!=0x80)
32
33 static const uint32_t offsetsFromUTF8[6] = {
34 0x00000000UL, 0x00003080UL, 0x000E2080UL,
35 0x03C82080UL, 0xFA082080UL, 0x82082080UL
36 };
37
38 /* next character without NUL character terminator */
39 uint32_t u8_nextmemchar(const char *s, size_t *i);
40
41 #define STB_TRUETYPE_IMPLEMENTATION
42 #include "stb_truetype.h" /* http://nothings.org/stb/stb_truetype.h */
43
44 stbtt_fontinfo ltk_load_font(const char *path);
45
46 int ltk_text_width(uint8_t *text, stbtt_fontinfo fontinfo, int height);
47
48 unsigned char *ltk_render_text(uint8_t *text, stbtt_fontinfo fontinfo, int height, int width);
49
50 #endif