Merge branch 'use-fcft'
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Daniel Eklöf · committed by Daniel Eklöf · parents 0d802e7, 92a5072 · Browse files · 16 files·+34 added−1323 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
16 files+34 added−1323 removed
- other:+34 added−1323 removed
Provenance
- Commit
e0b1de3- Tree
e04b8e5- Author
Daniel Eklöf <daniel@ekloef.se>- Committer
Daniel Eklöf <daniel@ekloef.se>- Parent 1
0d802e7- Parent 2
92a5072
16 files changed+34 added−1323 removed
deleted:external/tllistnot shown
Its text is not shown, deleted.
added:subprojects/fcftnot shown
Its text is not shown, added.
added:subprojects/tllistnot shown
Its text is not shown, added.
deleted:subprojects/tllist/LICENSE-21 removed
1-MIT License2-3-Copyright (c) 2018 Daniel Eklöf4-5-Permission is hereby granted, free of charge, to any person obtaining a copy6-of this software and associated documentation files (the "Software"), to deal7-in the Software without restriction, including without limitation the rights8-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell9-copies of the Software, and to permit persons to whom the Software is10-furnished to do so, subject to the following conditions:11-12-The above copyright notice and this permission notice shall be included in all13-copies or substantial portions of the Software.14-15-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR16-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,17-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE18-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER19-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 THE21-SOFTWARE.deleted:subprojects/tllist/meson.build-5 removed
1-project('tllist', 'c', version: '1.0.0', license: 'MIT', meson_version: '>=0.50.0')2-tllist = declare_dependency(include_directories: '.')3-4-unittest = executable('unittest', 'test.c', dependencies: [tllist])5-test('unittest', unittest)deleted:subprojects/tllist/README.md-301 removed
1-# tllist2-3-**tllist** is a *T*yped *L*inked *L*ist C header file only4-library implemented using pre-processor macros.5-6-7-1. [Description](#description)8-1. [Usage](#usage)9- 1. [Declaring a variable](#declaring-a-variable)10- 1. [Adding items - basic](#adding-items-basic)11- 1. [List length](#list-length)12- 1. [Accessing items](#accessing-items)13- 1. [Iterating](#iterating)14- 1. [Removing items - basic](#removing-items-basic)15- 1. [Adding items - advanced](#adding-items-advanced)16- 1. [Removing items - advanced](#removing-items-advanced)17- 1. [Freeing](#freeing)18-1. [Integrating](#integrating)19- 1. [Meson](#meson)20-1. [API](#api)21- 1. [Cheat sheet](#cheat-sheet)22-23-24-## Description25-26-Most C implementations of linked list are untyped. That is, their data27-carriers are typically `void *`. This is error prone since your28-compiler will not be able to help you correct your mistakes (_oh, was29-it pointer-to-a-pointer... I though it was just a pointer..._).30-31-**tllist** addresses this by using pre-processor macros to implement32-dynamic types, where the data carrier is typed to whatever you want;33-both **primitive** data types are supported as well as aggregated ones34-such as **structs**, **enums** and **unions**.35-36-Being a double-linked list, most operations are constant in time37-(including pushing and popping both to/from front and back).38-39-The memory overhead is fairly small; each item carries, besides its40-data, a _prev_ and _next_ pointer (i.e. a constant 16 byte overhead41-per item on 64-bit architectures).42-43-The list itself has two _head_ and _tail_ pointers, plus a _length_44-variable (typically 8 bytes on 64-bit architectures) to make list45-length lookup constant in time.46-47-Thus, assuming 64-bit pointers (and a 64-bit `size_t` type), the total48-overhead is `3*8 + n*2*8` bytes.49-50-51-## Usage52-53-### Declaring a variable54-55-1. **Declare a variable**56-57- ```c58- /* Declare a variable using an anonymous type */59- tll(int) an_integer_list = tll_init();60- ```61-62-63-2. **Typedef**64-65- ```c66- /* First typedef the list type */67- typedef tll(int) an_integer_list_t;68-69- /* Then declare a variable using that typedef */70- an_integer_list_t an_integer_list = tll_init();71- ```72-73-3. **Named struct**74-75- ```c76- /* First declare named struct */77- tll(int, an_integer_list);78-79- /* Then declare a variable using that named struct */80- struct an_integer_list an_integer_list = tll_init();81- ```82-83-### Adding items - basic84-85-Use `tll_push_back()` or `tll_push_front()` to add elements to the86-back or front of the list.87-88-```c89-tll_push_back(an_integer_list, 4711);90-tll_push_front(an_integer_list, 1234);91-```92-93-94-### List length95-96-`tll_length()` returns the length (number of items) in a list.97-98-```c99-tll_push_back(an_integer_list, 1234);100-tll_push_back(an_integer_list, 5678);101-printf("length: %zu\n", tll_length(an_integer_list));102-```103-104-Outputs:105-106- length: 2107-108-109-### Accessing items110-111-For the front and back items, you can use `tll_front()` and112-`tll_back()` respectively. For any other item in the list, you need to113-iterate the list and find the item yourself.114-115-```c116-tll_push_back(an_integer_list, 1234);117-tll_push_back(an_integer_list, 5555);118-tll_push_back(an_integer_list, 6789);119-120-printf("front: %d\n", tll_front(an_integer_list));121-printf("back: %d\n", tll_back(an_integer_list));122-```123-124-Outputs:125-126- front: 1234127- back: 6789128-129-130-### Iterating131-132-You can iterate the list either forward or backwards, using133-`tll_foreach()` and `tll_rforeach()` respectively.134-135-The `it` variable should be treated as an opaque iterator type, where136-`it->item` is the item.137-138-In reality, it is simply a pointer to the linked list entry, and since139-tllist is a header-only implementation, you do have access to e.g. the140-next/prev pointers. There should not be any need to access anything141-except `item` however.142-143-Note that `it` can be named anything.144-145-```c146-tll_push_back(an_integer_list, 1);147-tll_push_back(an_integer_list, 2);148-149-tll_foreach(an_integer_list, it) {150- printf("forward: %d\n", it->item);151-}152-153-tll_rforeach(an_integer_list, it) {154- printf("reverse: %d\n", it->item);155-}156-```157-158-Outputs:159-160- forward: 1161- forward: 2162- reverse: 2163- reverse: 1164-165-166-### Removing items - basic167-168-`tll_pop_front()` and `tll_pop_back()` removes the front/back item and169-returns it.170-171-```c172-tll_push_back(an_integer_list, 1234);173-tll_push_back(an_integer_list, 5678);174-175-printf("front: %d\n", tll_pop_front(an_integer_list));176-printf("back: %d\n", tll_pop_back(an_integer_list));177-printf("length: %zu\n", tll_length(an_integer_list));178-```179-180-Outputs:181-182- front: 1234183- back: 5678184- length: 0185-186-187-### Adding items - advanced188-189-Given an iterator, you can insert new items before or after that190-iterator, using `tll_insert_before()` and `tll_insert_after()`.191-192-```c193-tll_foreach(an_integer_list, it) {194- if (it->item == 1234) {195- tll_insert_before(an_integer_list, it, 7777);196- break;197- }198-}199-```200-201-Q: Why do I have to pass **both** the _list_ and the _iterator_ to202- `tll_insert_before()`?203-204-A: If not, **each** element in the list would have to contain a205- pointer to the owning list, which would significantly increase the206- overhead.207-208-209-### Removing items - advanced210-211-Similar to how you can add items while iterating a list, you can also212-remove them.213-214-Note that the `*foreach()` functions are **safe** in this regard - it215-is perfectly OK to remove the "current" item.216-217-```c218-tll_foreach(an_integer_list, it) {219- if (it->item.delete_me)220- tll_remove(an_integer_list, it);221-}222-```223-224-To make it slightly easier to handle cases where the item _itself_225-must be free:d as well, there is also `tll_remove_and_free()`. It226-works just like `tll_remove()`, but takes an additional argument; a227-callback that will be called for each item.228-229-```c230-tll(int *) int_p_list = tll_init();231-232-int *a = malloc(sizeof(*a));233-int *b = malloc(sizeof(*b));234-235-*a = 1234;236-*b = 5678;237-238-tll_push_back(int_p_list, a);239-tll_push_back(int_p_list, b);240-241-tll_foreach(int_p_list, it) {242- tll_remove_and_free(int_p_list, it, free);243-}244-```245-246-247-### Freeing248-249-To remove **all** items, use `tll_free()`, or250-`tll_free_and_free()`. These are just convenience functions and251-calling these are equivalent to:252-253-```c254-tll_foreach(an_integer_list, it) {255- tll_remove(an_integer_list, it);256-}257-```258-259-Note that there is no need to call `tll_free()` on an empty260-(`tll_length(list) == 0`) list.261-262-263-## Integrating264-265-The easiest way may be to simply copy `tllist.h` into your266-project. But see sections below for other ways.267-268-269-### Meson270-271-You can use tllist as a subproject. In your main project's272-`meson.build`, to something like:273-274-```meson275-tllist = subproject('tllist').get_variable('tllist')276-executable('you-executable', ..., dependencies: [tllist])277-```278-279-280-## API281-282-### Cheat sheet283-284-| Function | Description | Context | Complexity |285-|-------------------------------------|-------------------------------------------------------|--------------------|-----------:|286-| `list = tll_init()` | initialize a new tllist variable to an empty list | Variable init | O(1) |287-| `tll_length(list)` | returns the length (number of items) of a list | | O(1) |288-| `tll_push_front(list, item)` | inserts _item_ at the beginning of the list | | O(1) |289-| `tll_push_back(list, item)` | inserts _item_ at the end of the list | | O(1) |290-| `tll_front(list)` | returns the first item in the list | | O(1) |291-| `tll_back(list)` | returns the last item in the list | | O(1) |292-| `tll_pop_front(list)` | removes and returns the first item in the list | | O(1) |293-| `tll_pop_back(list)` | removes and returns the last item in the list | | O(1) |294-| `tll_foreach(list, it)` | iterates the list from the beginning to the end | | O(n) |295-| `tll_rforeach(list, it)` | iterates the list from the end to the beginning | | O(n) |296-| `tll_insert_before(list, it, item)` | inserts _item_ before _it_. | `tll_(r)foreach()` | O(1) |297-| `tll_insert_after(list, it, item)` | inserts _item_ after _it_. | `tll_(r)foreach()` | O(1) |298-| `tll_remove(list, it)` | removes _it_ from the list. | `tll_(r)foreach()` | O(1) |299-| `tll_remove_and_free(list, it, cb)` | removes _it_ from the list, and calls `cb(it->item)`. | `tll_(r)foreach()` | O(1) |300-| `tll_free(list)` | removes **all** items from the list | | O(n) |301-| `tll_free_and_free(list, cb)` | removes **all** items from the list, and calls `cb(it->item)` for each item. | | O(n) |deleted:subprojects/tllist/test.c-96 removed
1-#undef NDEBUG2-#include <stdlib.h>3-#include <string.h>4-#include <stdbool.h>5-#include <assert.h>6-7-#include <tllist.h>8-9-int10-main(int argc, const char *const *argv)11-{12- tll(int) l = tll_init();13- assert(tll_length(l) == 0);14-15- /* push back */16- tll_push_back(l, 123); assert(tll_length(l) == 1);17- tll_push_back(l, 456); assert(tll_length(l) == 2);18- tll_push_back(l, 789); assert(tll_length(l) == 3);19-20- assert(tll_front(l) == 123);21- assert(tll_back(l) == 789);22-23- /* push front */24- tll_push_front(l, 0xabc); assert(tll_length(l) == 4);25-26- assert(tll_front(l) == 0xabc);27- assert(tll_back(l) == 789);28-29- /* Pop back */30- assert(tll_pop_back(l) == 789);31- assert(tll_back(l) == 456);32-33- /* Pop front */34- assert(tll_pop_front(l) == 0xabc);35- assert(tll_front(l) == 123);36-37- /* foreach */38- assert(tll_length(l) == 2);39-40- int seen[tll_length(l)];41- memset(seen, 0, tll_length(l) * sizeof(seen[0]));42-43- size_t count = 0;44- tll_foreach(l, it)45- seen[count++] = it->item;46-47- assert(count == tll_length(l));48- assert(seen[0] == 123);49- assert(seen[1] == 456);50-51- /* rforeach */52- memset(seen, 0, tll_length(l) * sizeof(seen[0]));53- count = 0;54- tll_rforeach(l, it)55- seen[count++] = it->item;56-57- assert(count == tll_length(l));58- assert(seen[0] == 456);59- assert(seen[1] == 123);60-61- /* remove */62- tll_push_back(l, 789);63- tll_foreach(l, it) {64- if (it->item > 123 && it->item < 789)65- tll_remove(l, it);66- }67- assert(tll_length(l) == 2);68- assert(tll_front(l) == 123);69- assert(tll_back(l) == 789);70-71- /* insert before */72- tll_foreach(l, it) {73- if (it->item == 123)74- tll_insert_before(l, it, 0xabc);75- }76- assert(tll_length(l) == 3);77- assert(tll_front(l) == 0xabc);78- assert(tll_back(l) == 789);79-80- /* insert after */81- tll_foreach(l, it) {82- if (it->item == 789)83- tll_insert_after(l, it, 999);84- }85- assert(tll_length(l) == 4);86- assert(tll_front(l) == 0xabc);87- assert(tll_back(l) == 999);88-89- /* free */90- tll_free(l);91- assert(tll_length(l) == 0);92- assert(l.head == NULL);93- assert(l.tail == NULL);94-95- return EXIT_SUCCESS;96-}deleted:subprojects/tllist/tllist.h-180 removed
1-#pragma once2-3-#include <stdlib.h>4-#include <stddef.h>5-#include <assert.h>6-7-#define TLL_PASTE2( a, b) a##b8-#define TLL_PASTE( a, b) TLL_PASTE2( a, b)9-10-/* Utility macro to generate a list element struct with a unique struct tag */11-#define TLL_UNIQUE_INNER_STRUCT(TYPE, ID) \12- struct TLL_PASTE(__tllist_ , ID) { \13- TYPE item; \14- struct TLL_PASTE(__tllist_, ID) *prev; \15- struct TLL_PASTE(__tllist_, ID) *next; \16- } *head, *tail;17-18-/*19- * Defines a new typed-list type, or directly instantiate a typed-list variable20- *21- * Example a, declare a variable (list of integers):22- * tll(int) my_list;23- *24- * Example b, declare a type, and then use the type:25- * tll(int, my_list_type);26- * struct my_list_type my_list;27- */28-#define tll(TYPE, ...) \29- struct __VA_ARGS__ { \30- TLL_UNIQUE_INNER_STRUCT(TYPE, __COUNTER__) \31- size_t length; \32- }33-34-/* Initializer: tll(int) my_list = tll_init(); */35-#define tll_init() {.head = NULL, .tail = NULL, .length = 0}36-37-/* Length/size of list: printf("size: %zu\n", tll_length(my_list)); */38-#define tll_length(list) (list).length39-40-/* Adds a new item to the back of the list */41-#define tll_push_back(list, new_item) \42- do { \43- tll_insert_after(list, (list).tail, new_item); \44- if ((list).head == NULL) \45- (list).head = (list).tail; \46- } while (0)47-48-/* Adds a new item to the front of the list */49-#define tll_push_front(list, new_item) \50- do { \51- tll_insert_before(list, (list).head, new_item); \52- if ((list).tail == NULL) \53- (list).tail = (list).head; \54- } while (0)55-56-/*57- * Iterates the list. <it> is an iterator pointer. You can access the58- * list item with ->item:59- *60- * tll(int) my_list = vinit();61- * tll_push_back(my_list, 5);62- *63- * tll_foreach(my_list i) {64- * printf("%d\n", i->item);65- * }66-*/67-#define tll_foreach(list, it) \68- for (__typeof__(*(list).head) *it = (list).head, \69- *it_next = it != NULL ? it->next : NULL; \70- it != NULL; \71- it = it_next, \72- it_next = it_next != NULL ? it_next->next : NULL)73-74-/* Same as tll_foreach(), but iterates backwards */75-#define tll_rforeach(list, it) \76- for (__typeof__(*(list).tail) *it = (list).tail, \77- *it_prev = it != NULL ? it->prev : NULL; \78- it != NULL; \79- it = it_prev, \80- it_prev = it_prev != NULL ? it_prev->prev : NULL)81-82-/*83- * Inserts a new item after <it>, which is an iterator. I.e. you can84- * only call this from inside a tll_foreach() or tll_rforeach() loop.85- */86-#define tll_insert_after(list, it, new_item) \87- do { \88- __typeof__((list).head) __e = malloc(sizeof(*__e)); \89- __e->item = (new_item); \90- __e->prev = (it); \91- __e->next = (it) != NULL ? (it)->next : NULL; \92- if ((it) != NULL) { \93- if ((it)->next != NULL) \94- (it)->next->prev = __e; \95- (it)->next = __e; \96- } \97- if ((it) == (list).tail) \98- (list).tail = __e; \99- (list).length++; \100- } while (0)101-102-/*103- * Inserts a new item before <it>, which is an iterator. I.e. you can104- * only call this from inside a tll_foreach() or tll_rforeach() loop.105- */106-#define tll_insert_before(list, it, new_item) \107- do { \108- __typeof__((list).head) __e = malloc(sizeof(*__e)); \109- __e->item = (new_item); \110- __e->prev = (it) != NULL ? (it)->prev : NULL; \111- __e->next = (it); \112- if ((it) != NULL) { \113- if ((it)->prev != NULL) \114- (it)->prev->next = __e; \115- (it)->prev = __e; \116- } \117- if ((it) == (list).head) \118- (list).head = __e; \119- (list).length++; \120- } while (0)121-122-/*123- * Removes an entry from the list. <it> is an iterator. I.e. you can124- * only call this from inside a tll_foreach() or tll_rforeach() loop.125- */126-#define tll_remove(list, it) \127- do { \128- assert((list).length > 0); \129- __typeof__((list).head) __prev = it->prev; \130- __typeof__((list).head) __next = it->next; \131- if (__prev != NULL) \132- __prev->next = __next; \133- else \134- (list).head = __next; \135- if (__next != NULL) \136- __next->prev = __prev; \137- else \138- (list).tail = __prev; \139- free(it); \140- (list).length--; \141- } while (0)142-143-/* Same as tll_remove(), but calls free_callback(it->item) */144-#define tll_remove_and_free(list, it, free_callback) \145- do { \146- free_callback((it)->item); \147- tll_remove((list), (it)); \148- } while (0)149-150-#define tll_front(list) (list).head->item151-#define tll_back(list) (list).tail->item152-153-/*154- * Removes the first element from the list, and returns it (note:155- * returns the *actual* item, not an iterator.156- */157-#define tll_pop_front(list) \158- ({__typeof__((list).head) it = (list).head; \159- __typeof__((list).head->item) __ret = it->item; \160- tll_remove((list), it); \161- __ret; \162- })163-164-/* Same as tll_pop_front(), but returns/removes the *last* element */165-#define tll_pop_back(list) \166- ({__typeof__((list).tail) it = (list).tail; \167- __typeof__((list).tail->item) __ret = it->item; \168- tll_remove((list), it); \169- __ret; \170- })171-172-/* Frees the list. This call is *not* needed if the list is already empty. */173-#define tll_free(list) \174- tll_foreach(list, __it) \175- tll_remove(list, __it)176-177-/* Same as tll_free(), but also calls free_callback(item) for every item */178-#define tll_free_and_free(list, free_callback) \179- tll_foreach(list, __it) \180- tll_remove_and_free(list, __it, free_callback)modified:.gitmodules+5 added-3 removed
1 [submodule "external/wlr-protocols"]2 path = external/wlr-protocols3 url = https://github.com/swaywm/wlr-protocols.git4 branch = master5-[submodule "external/tllist"]6- path = external/tllist5+[submodule "subprojects/tllist"]6+ path = subprojects/tllist7 url = https://codeberg.org/dnkl/tllist.git8- branch = master8+[submodule "subprojects/fcft"]9+ path = subprojects/fcft10+ url = https://codeberg.org/dnkl/fcft.gitdeleted:font.c-628 removed
1-#include "font.h"2-3-#include <stdlib.h>4-#include <stdint.h>5-#include <stdbool.h>6-#include <math.h>7-#include <wchar.h>8-#include <assert.h>9-#include <threads.h>10-11-#include <freetype/tttables.h>12-13-#define LOG_MODULE "font"14-#define LOG_ENABLE_DBG 015-#include "log.h"16-#include "stride.h"17-18-#define min(x, y) ((x) < (y) ? (x) : (y))19-20-static FT_Library ft_lib;21-22-static tll(const struct font *) font_cache = tll_init();23-24-static const size_t glyph_cache_size = 512;25-26-static void __attribute__((constructor))27-init(void)28-{29- FcInit();30- FT_Init_FreeType(&ft_lib);31-32-#if defined(LOG_ENABLE_DBG) && LOG_ENABLE_DBG33- int raw_version = FcGetVersion();34-35- /* See FC_VERSION in <fontconfig/fontconfig.h> */36- const int major = raw_version / 10000; raw_version %= 10000;37- const int minor = raw_version / 100; raw_version %= 100;38- const int patch = raw_version;39-#endif40-41- LOG_DBG("fontconfig: %d.%d.%d", major, minor, patch);42-}43-44-static void __attribute__((destructor))45-fini(void)46-{47- assert(tll_length(font_cache) == 0);48-49- FT_Done_FreeType(ft_lib);50- FcFini();51-}52-53-static bool54-font_destroy_no_free(struct font *font)55-{56- assert(font->ref_counter > 0);57- if (--font->ref_counter > 0)58- return false;59-60- if (font->face != NULL)61- FT_Done_Face(font->face);62-63- if (font->fc_pattern != NULL)64- FcPatternDestroy(font->fc_pattern);65- if (font->fc_fonts != NULL)66- FcFontSetDestroy(font->fc_fonts);67-68- free(font->name);69-70- if (font->cache == NULL)71- return true;72-73- for (size_t i = 0; i < glyph_cache_size; i++) {74- if (font->cache[i] == NULL)75- continue;76-77- tll_foreach(*font->cache[i], it) {78- if (!it->item.valid)79- continue;80-81- void *image = pixman_image_get_data(it->item.pix);82- pixman_image_unref(it->item.pix);83- free(image);84- }85-86- tll_free(*font->cache[i]);87- free(font->cache[i]);88- }89- free(font->cache);90-91- tll_foreach(font_cache, it) {92- if (it->item == font) {93- tll_remove(font_cache, it);94- break;95- }96- }97-98- return true;99-}100-101-static void102-underline_strikeout_metrics(struct font *font)103-{104- FT_Face ft_face = font->face;105- double y_scale = ft_face->size->metrics.y_scale / 65536.;106- double height = ft_face->size->metrics.height / 64.;107- double descent = ft_face->size->metrics.descender / 64.;108-109- LOG_DBG("ft: y-scale: %f, height: %f, descent: %f",110- y_scale, height, descent);111-112- font->underline.position = ft_face->underline_position * y_scale / 64.;113- font->underline.thickness = ft_face->underline_thickness * y_scale / 64.;114-115- if (font->underline.position == 0.) {116- font->underline.position = descent / 2.;117- font->underline.thickness = fabs(descent / 5.);118- }119-120- LOG_DBG("underline: pos=%f, thick=%f",121- font->underline.position, font->underline.thickness);122-123- TT_OS2 *os2 = FT_Get_Sfnt_Table(ft_face, ft_sfnt_os2);124- if (os2 != NULL) {125- font->strikeout.position = os2->yStrikeoutPosition * y_scale / 64.;126- font->strikeout.thickness = os2->yStrikeoutSize * y_scale / 64.;127- }128-129- if (font->strikeout.position == 0.) {130- font->strikeout.position = height / 2. + descent;131- font->strikeout.thickness = font->underline.thickness;132- }133-134- LOG_DBG("strikeout: pos=%f, thick=%f",135- font->strikeout.position, font->strikeout.thickness);136-}137-138-static bool139-from_font_set(FcPattern *pattern, FcFontSet *fonts, int start_idx,140- struct font *font, bool is_fallback)141-{142- memset(font, 0, sizeof(*font));143-144- FcChar8 *face_file = NULL;145- FcPattern *final_pattern = NULL;146- int font_idx = -1;147-148- for (int i = start_idx; i < fonts->nfont; i++) {149- FcPattern *pat = FcFontRenderPrepare(NULL, pattern, fonts->fonts[i]);150- assert(pat != NULL);151-152- if (FcPatternGetString(pat, FC_FT_FACE, 0, &face_file) != FcResultMatch) {153- if (FcPatternGetString(pat, FC_FILE, 0, &face_file) != FcResultMatch) {154- FcPatternDestroy(pat);155- continue;156- }157- }158-159- final_pattern = pat;160- font_idx = i;161- break;162- }163-164- assert(font_idx != -1);165- assert(final_pattern != NULL);166-167- double dpi;168- if (FcPatternGetDouble(final_pattern, FC_DPI, 0, &dpi) != FcResultMatch)169- dpi = 96;170-171- double size;172- double pixel_size;173- if (FcPatternGetDouble(final_pattern, FC_SIZE, 0, &size) != FcResultMatch ||174- FcPatternGetDouble(final_pattern, FC_PIXEL_SIZE, 0, &pixel_size) != FcResultMatch)175- {176- LOG_ERR("%s: failed to get size", face_file);177- FcPatternDestroy(final_pattern);178- return false;179- }180-181- FcBool scalable;182- if (FcPatternGetBool(final_pattern, FC_SCALABLE, 0, &scalable) != FcResultMatch)183- scalable = FcTrue;184-185- FcBool outline;186- if (FcPatternGetBool(final_pattern, FC_OUTLINE, 0, &outline) != FcResultMatch)187- outline = FcTrue;188-189- double pixel_fixup;190- if (FcPatternGetDouble(final_pattern, "pixelsizefixupfactor", 0, &pixel_fixup) != FcResultMatch) {191- /*192- * Force a fixup factor on scalable bitmap fonts (typically193- * emoji fonts). The fixup factor is194- * requested-pixel-size / actual-pixels-size195- */196- if (scalable && !outline) {197- double original_pixel_size;198- if (FcPatternGetDouble(pattern, FC_PIXEL_SIZE, 0, &original_pixel_size) != FcResultMatch) {199- double original_size;200- if (FcPatternGetDouble(pattern, FC_SIZE, 0, &original_size) != FcResultMatch)201- original_size = size;202- original_pixel_size = original_size * dpi / 72;203- }204- pixel_fixup = original_pixel_size / pixel_size;205-206- LOG_DBG("estimated fixup factor to %f (requested pixel size: %f, actual: %f)",207- pixel_fixup, original_pixel_size, pixel_size);208- } else209- pixel_fixup = 1.;210- }211-212- LOG_DBG("loading: %s", face_file);213-214- FT_Face ft_face;215- FT_Error ft_err = FT_New_Face(ft_lib, (const char *)face_file, 0, &ft_face);216- if (ft_err != 0)217- LOG_ERR("%s: failed to create FreeType face", face_file);218-219- if ((ft_err = FT_Set_Pixel_Sizes(ft_face, 0, pixel_size)) != 0) {220- LOG_WARN("failed to set pixel size");221- FT_Done_Face(ft_face);222- FcPatternDestroy(final_pattern);223- return false;224- }225-226- FcBool fc_hinting;227- if (FcPatternGetBool(final_pattern, FC_HINTING,0, &fc_hinting) != FcResultMatch)228- fc_hinting = FcTrue;229-230- FcBool fc_antialias;231- if (FcPatternGetBool(final_pattern, FC_ANTIALIAS, 0, &fc_antialias) != FcResultMatch)232- fc_antialias = FcTrue;233-234- int fc_hintstyle;235- if (FcPatternGetInteger(final_pattern, FC_HINT_STYLE, 0, &fc_hintstyle) != FcResultMatch)236- fc_hintstyle = FC_HINT_SLIGHT;237-238- int fc_rgba;239- if (FcPatternGetInteger(final_pattern, FC_RGBA, 0, &fc_rgba) != FcResultMatch)240- fc_rgba = FC_RGBA_UNKNOWN;241-242- int load_flags = 0;243- if (!fc_antialias) {244- if (!fc_hinting || fc_hintstyle == FC_HINT_NONE)245- load_flags |= FT_LOAD_MONOCHROME | FT_LOAD_NO_HINTING | FT_LOAD_TARGET_NORMAL;246- else247- load_flags |= FT_LOAD_MONOCHROME | FT_LOAD_TARGET_MONO;248- } else {249- if (!fc_hinting || fc_hintstyle == FC_HINT_NONE)250- load_flags |= FT_LOAD_DEFAULT | FT_LOAD_NO_HINTING | FT_LOAD_TARGET_NORMAL;251- else if (fc_hinting && fc_hintstyle == FC_HINT_SLIGHT)252- load_flags |= FT_LOAD_DEFAULT | FT_LOAD_TARGET_LIGHT;253- else if (fc_rgba == FC_RGBA_RGB || fc_rgba == FC_RGBA_BGR)254- load_flags |= FT_LOAD_DEFAULT | FT_LOAD_TARGET_LCD;255- else if (fc_rgba == FC_RGBA_VRGB || fc_rgba == FC_RGBA_VBGR)256- load_flags |= FT_LOAD_DEFAULT | FT_LOAD_TARGET_LCD_V;257- else258- load_flags |= FT_LOAD_DEFAULT | FT_LOAD_TARGET_NORMAL;259- }260-261- FcBool fc_embeddedbitmap;262- if (FcPatternGetBool(final_pattern, FC_EMBEDDED_BITMAP, 0, &fc_embeddedbitmap) != FcResultMatch)263- fc_embeddedbitmap = FcTrue;264-265- if (!fc_embeddedbitmap)266- load_flags |= FT_LOAD_NO_BITMAP;267-268- int render_flags = 0;269- if (!fc_antialias)270- render_flags |= FT_RENDER_MODE_MONO;271- else {272- if (fc_rgba == FC_RGBA_RGB || fc_rgba == FC_RGBA_BGR)273- render_flags |= FT_RENDER_MODE_LCD;274- else if (fc_rgba == FC_RGBA_VRGB || fc_rgba == FC_RGBA_VBGR)275- render_flags |= FT_RENDER_MODE_LCD_V;276- else277- render_flags |= FT_RENDER_MODE_NORMAL;278- }279-280- int fc_lcdfilter;281- if (FcPatternGetInteger(final_pattern, FC_LCD_FILTER, 0, &fc_lcdfilter) != FcResultMatch)282- fc_lcdfilter = FC_LCD_DEFAULT;283-284- switch (fc_lcdfilter) {285- case FC_LCD_NONE: font->lcd_filter = FT_LCD_FILTER_NONE; break;286- case FC_LCD_DEFAULT: font->lcd_filter = FT_LCD_FILTER_DEFAULT; break;287- case FC_LCD_LIGHT: font->lcd_filter = FT_LCD_FILTER_LIGHT; break;288- case FC_LCD_LEGACY: font->lcd_filter = FT_LCD_FILTER_LEGACY; break;289- }290-291- FcPatternDestroy(final_pattern);292-293- font->face = ft_face;294- font->load_flags = load_flags | FT_LOAD_COLOR;295- font->render_flags = render_flags;296- font->pixel_size_fixup = pixel_fixup;297- font->bgr = fc_rgba == FC_RGBA_BGR || fc_rgba == FC_RGBA_VBGR;298- font->fc_idx = font_idx;299- font->is_fallback = is_fallback;300- font->ref_counter = 1;301-302- double max_x_advance = ft_face->size->metrics.max_advance / 64.;303- double height = ft_face->size->metrics.height / 64.;304- double descent = ft_face->size->metrics.descender / 64.;305- double ascent = ft_face->size->metrics.ascender / 64.;306-307- font->height = height * font->pixel_size_fixup;308- font->descent = -descent * font->pixel_size_fixup;309- font->ascent = ascent * font->pixel_size_fixup;310- font->max_x_advance = max_x_advance * font->pixel_size_fixup;311-312- LOG_DBG("metrics: height: %d, descent: %d, ascent: %d, x-advance: %d",313- font->height, font->descent, font->ascent, font->max_x_advance);314-315- if (!is_fallback) {316- font->fc_pattern = pattern;317- font->fc_fonts = fonts;318- font->cache = calloc(glyph_cache_size, sizeof(font->cache[0]));319- }320-321- underline_strikeout_metrics(font);322- return true;323-}324-325-struct font *326-font_from_name(const char *name)327-{328- LOG_DBG("instantiating %s", name);329-330- tll_foreach(font_cache, it) {331- if (strcmp(it->item->name, name) == 0)332- return font_clone(it->item);333- }334-335- FcPattern *pattern = FcNameParse((const unsigned char *)name);336- if (pattern == NULL) {337- LOG_ERR("%s: failed to lookup font", name);338- return NULL;339- }340-341- if (!FcConfigSubstitute(NULL, pattern, FcMatchPattern)) {342- LOG_ERR("%s: failed to do config substitution", name);343- FcPatternDestroy(pattern);344- return NULL;345- }346-347- FcDefaultSubstitute(pattern);348-349- FcResult result;350- FcFontSet *fonts = FcFontSort(NULL, pattern, FcTrue, NULL, &result);351- if (result != FcResultMatch) {352- LOG_ERR("%s: failed to match font", name);353- FcPatternDestroy(pattern);354- return NULL;355- }356-357- struct font *font = malloc(sizeof(*font));358- if (!from_font_set(pattern, fonts, 0, font, false)) {359- free(font);360- FcFontSetDestroy(fonts);361- FcPatternDestroy(pattern);362- return NULL;363- }364-365- font->name = strdup(name);366- tll_push_back(font_cache, font);367- return font;368-}369-370-static size_t371-hash_index(wchar_t wc)372-{373- return wc % glyph_cache_size;374-}375-376-static bool377-glyph_for_wchar(const struct font *font, wchar_t wc, struct glyph *glyph)378-{379- /*380- * LCD filter is per library instance. Thus we need to re-set it381- * every time...382- *383- * Also note that many freetype builds lack this feature384- * (FT_CONFIG_OPTION_SUBPIXEL_RENDERING must be defined, and isn't385- * by default) */386- FT_Error err = FT_Library_SetLcdFilter(ft_lib, font->lcd_filter);387- if (err != 0 && err != FT_Err_Unimplemented_Feature)388- goto err;389-390- FT_UInt idx = FT_Get_Char_Index(font->face, wc);391- if (idx == 0) {392- if (font->is_fallback)393- return false;394-395- /* No glyph in this font, try fontconfig fallback fonts */396-397- /* Try fontconfig fallback fonts */398- assert(font->fc_pattern != NULL);399- assert(font->fc_fonts != NULL);400- assert(font->fc_idx != -1);401-402- for (int i = font->fc_idx + 1; i < font->fc_fonts->nfont; i++) {403- struct font fallback;404- if (!from_font_set(font->fc_pattern, font->fc_fonts, i, &fallback, true))405- continue;406-407- if (glyph_for_wchar(&fallback, wc, glyph)) {408- LOG_DBG("%C: used fontconfig fallback", wc);409- font_destroy_no_free(&fallback);410- return true;411- }412-413- font_destroy_no_free(&fallback);414- }415-416- LOG_WARN("%C: no glyph found (in neither the main font, "417- "nor any fallback fonts)", wc);418- }419-420- err = FT_Load_Glyph(font->face, idx, font->load_flags);421- if (err != 0) {422- LOG_ERR("load failed");423- goto err;424- }425-426- err = FT_Render_Glyph(font->face->glyph, font->render_flags);427- if (err != 0)428- goto err;429-430- assert(font->face->glyph->format == FT_GLYPH_FORMAT_BITMAP);431-432- FT_Bitmap *bitmap = &font->face->glyph->bitmap;433- if (bitmap->width == 0)434- goto err;435-436- pixman_format_code_t pix_format;437- int width;438- int rows;439-440- switch (bitmap->pixel_mode) {441- case FT_PIXEL_MODE_MONO:442- pix_format = PIXMAN_a1;443- width = bitmap->width;444- rows = bitmap->rows;445- break;446-447- case FT_PIXEL_MODE_GRAY:448- pix_format = PIXMAN_a8;449- width = bitmap->width;450- rows = bitmap->rows;451- break;452-453- case FT_PIXEL_MODE_LCD:454- pix_format = PIXMAN_x8r8g8b8;455- width = bitmap->width / 3;456- rows = bitmap->rows;457- break;458-459- case FT_PIXEL_MODE_LCD_V:460- pix_format = PIXMAN_x8r8g8b8;461- width = bitmap->width;462- rows = bitmap->rows / 3;463- break;464-465- case FT_PIXEL_MODE_BGRA:466- pix_format = PIXMAN_a8r8g8b8;467- width = bitmap->width;468- rows = bitmap->rows;469- break;470-471- default:472- LOG_ERR("unimplemented: FT pixel mode: %d", bitmap->pixel_mode);473- goto err;474- break;475- }476-477- int stride = stride_for_format_and_width(pix_format, width);478- assert(stride >= bitmap->pitch);479-480- uint8_t *data = malloc(rows * stride);481-482- /* Convert FT bitmap to pixman image */483- switch (bitmap->pixel_mode) {484- case FT_PIXEL_MODE_MONO:485- for (size_t r = 0; r < bitmap->rows; r++) {486- for (size_t c = 0; c < (bitmap->width + 7) / 8; c++) {487- uint8_t v = bitmap->buffer[r * bitmap->pitch + c];488- uint8_t reversed = 0;489- for (size_t i = 0; i < min(8, bitmap->width - c * 8); i++)490- reversed |= ((v >> (7 - i)) & 1) << i;491-492- data[r * stride + c] = reversed;493- }494- }495- break;496-497- case FT_PIXEL_MODE_GRAY:498- for (size_t r = 0; r < bitmap->rows; r++) {499- for (size_t c = 0; c < bitmap->width; c++)500- data[r * stride + c] = bitmap->buffer[r * bitmap->pitch + c];501- }502- break;503-504- case FT_PIXEL_MODE_BGRA:505- assert(stride == bitmap->pitch);506- memcpy(data, bitmap->buffer, bitmap->rows * bitmap->pitch);507- break;508-509- case FT_PIXEL_MODE_LCD:510- for (size_t r = 0; r < bitmap->rows; r++) {511- for (size_t c = 0; c < bitmap->width; c += 3) {512- unsigned char _r = bitmap->buffer[r * bitmap->pitch + c + (font->bgr ? 2 : 0)];513- unsigned char _g = bitmap->buffer[r * bitmap->pitch + c + 1];514- unsigned char _b = bitmap->buffer[r * bitmap->pitch + c + (font->bgr ? 0 : 2)];515-516- uint32_t *p = (uint32_t *)&data[r * stride + 4 * (c / 3)];517- *p = _r << 16 | _g << 8 | _b;518- }519- }520- break;521-522- case FT_PIXEL_MODE_LCD_V:523- /* Unverified */524- for (size_t r = 0; r < bitmap->rows; r += 3) {525- for (size_t c = 0; c < bitmap->width; c++) {526- unsigned char _r = bitmap->buffer[(r + (font->bgr ? 2 : 0)) * bitmap->pitch + c];527- unsigned char _g = bitmap->buffer[(r + 1) * bitmap->pitch + c];528- unsigned char _b = bitmap->buffer[(r + (font->bgr ? 0 : 2)) * bitmap->pitch + c];529-530- uint32_t *p = (uint32_t *)&data[r / 3 * stride + 4 * c];531- *p = _r << 16 | _g << 8 | _b;532- }533- }534- break;535-536- default:537- abort();538- break;539- }540-541- pixman_image_t *pix = pixman_image_create_bits_no_clear(542- pix_format, width, rows, (uint32_t *)data, stride);543-544- if (pix == NULL) {545- free(data);546- goto err;547- }548-549- pixman_image_set_component_alpha(550- pix,551- bitmap->pixel_mode == FT_PIXEL_MODE_LCD ||552- bitmap->pixel_mode == FT_PIXEL_MODE_LCD_V);553-554- if (font->pixel_size_fixup != 1.) {555- struct pixman_transform scale;556- pixman_transform_init_scale(557- &scale,558- pixman_double_to_fixed(1. / font->pixel_size_fixup),559- pixman_double_to_fixed(1. / font->pixel_size_fixup));560- pixman_image_set_transform(pix, &scale);561- pixman_image_set_filter(pix, PIXMAN_FILTER_BEST, NULL, 0);562- }563-564- *glyph = (struct glyph){565- .wc = wc,566- .cols = wcwidth(wc),567- .pix = pix,568- .x = font->face->glyph->bitmap_left * font->pixel_size_fixup,569- .y = ceil(font->face->glyph->bitmap_top * font->pixel_size_fixup),570- .x_advance = ceil(font->face->glyph->advance.x / 64. * font->pixel_size_fixup),571- .width = width,572- .height = rows,573- .valid = true,574- };575-576- return true;577-578-err:579- *glyph = (struct glyph){580- .wc = wc,581- .valid = false,582- };583- return false;584-}585-586-const struct glyph *587-font_glyph_for_wc(struct font *font, wchar_t wc)588-{589- assert(font->cache != NULL);590- size_t hash_idx = hash_index(wc);591- hash_entry_t *hash_entry = font->cache[hash_idx];592-593- if (hash_entry != NULL) {594- tll_foreach(*hash_entry, it) {595- if (it->item.wc == wc)596- return it->item.valid ? &it->item : NULL;597- }598- }599-600- struct glyph glyph;601- bool got_glyph = glyph_for_wchar(font, wc, &glyph);602-603- if (hash_entry == NULL) {604- hash_entry = calloc(1, sizeof(*hash_entry));605-606- assert(font->cache[hash_idx] == NULL);607- font->cache[hash_idx] = hash_entry;608- }609-610- assert(hash_entry != NULL);611- tll_push_back(*hash_entry, glyph);612- return got_glyph ? &tll_back(*hash_entry) : NULL;613-}614-615-struct font *616-font_clone(const struct font *_font)617-{618- struct font *font = (struct font *)_font;619- font->ref_counter++;620- return font;621-}622-623-void624-font_destroy(struct font *font)625-{626- if (font_destroy_no_free(font))627- free(font);628-}deleted:font.h-68 removed
1-#pragma once2-3-#include <stdbool.h>4-#include <threads.h>5-6-#include <ft2build.h>7-#include FT_FREETYPE_H8-#include FT_LCD_FILTER_H9-#include <fontconfig/fontconfig.h>10-#include <pixman.h>11-12-#include "tllist.h"13-14-struct glyph {15- wchar_t wc;16- int cols;17-18- pixman_image_t *pix;19- int x;20- int y;21- int x_advance;22- int width;23- int height;24-25- bool valid;26-};27-28-typedef tll(struct glyph) hash_entry_t;29-30-struct font {31- char *name;32-33- FcPattern *fc_pattern;34- FcFontSet *fc_fonts;35- int fc_idx;36-37- FT_Face face;38- int load_flags;39- int render_flags;40- FT_LcdFilter lcd_filter;41- double pixel_size_fixup; /* Scale factor - should only be used with ARGB32 glyphs */42- bool bgr; /* True for FC_RGBA_BGR and FC_RGBA_VBGR */43-44- int height;45- int descent;46- int ascent;47- int max_x_advance;48-49- struct {50- double position;51- double thickness;52- } underline;53-54- struct {55- double position;56- double thickness;57- } strikeout;58-59- hash_entry_t **cache;60-61- bool is_fallback;62- int ref_counter;63-};64-65-struct font *font_from_name(const char *name);66-struct font *font_clone(const struct font *font);67-const struct glyph *font_glyph_for_wc(struct font *font, wchar_t wc);68-void font_destroy(struct font *font);modified:main.c+9 added-4 removed
9 unmodified lines10 #include <sys/stat.h>11 #include <fcntl.h>12 13 #include <tllist.h>14+#include <fcft/fcft.h>15 16 #define LOG_MODULE "fuzzel"17 #define LOG_ENABLE_DBG 018 #include "log.h"19 #include "application.h"20 #include "dmenu.h"21 #include "fdm.h"21-#include "font.h"22 #include "match.h"23 #include "render.h"24 #include "shm.h"25 #include "version.h"321 unmodified lines347 struct render *render = NULL;348 struct wayland *wayl = NULL;349 struct font *font = NULL;350 351+ font_list_t font_list = tll_init();352+ tll_push_back(font_list, font_name);351- if ((font = font_from_name(font_name)) == NULL)353+ if ((font = font_from_name(font_list, NULL)) == NULL) {354+ tll_free(font_list);355 goto out;356+ }357+ tll_free(font_list);358 359 LOG_DBG(360 "font: height: %d, ascent: %d, descent: %d",356- font->fextents.height, font->fextents.ascent, font->fextents.descent);361+ font->height, font->ascent, font->descent);362 363 /* Calculate number of entries we can show, based on the total364 * height and the fonts line height */365 const double line_height1 unmodified line367 const size_t max_matches =368 (render_options.height - 2 * render_options.border_size - line_height)369 / line_height;370 366- LOG_DBG("max matches: %d", max_matches);371+ LOG_DBG("max matches: %zu", max_matches);372 373 /* Load applications */374 if ((apps = applications_init()) == NULL)375 goto out;49 unmodified linesmodified:meson.build+15 added-7 removed
14 unmodified lines15 language: 'c',16 )17 18 pixman = dependency('pixman-1')19-freetype = dependency('freetype2')20-fontconfig = dependency('fontconfig')19 cairo = dependency('cairo')20 cairo_ft = dependency('cairo-ft')21 librsvg = dependency('librsvg-2.0')22 wayland_protocols = dependency('wayland-protocols')34 unmodified lines57 build_always_stale: true,58 output: 'version.h',59 command: [generate_version_sh, meson.project_version(), '@SOURCE_DIR@', '@OUTPUT@'])60 63-tllist = subproject('tllist').get_variable('tllist')61+tllist_proj = subproject('tllist', required: false)62+if tllist_proj.found()63+ tllist = tllist_proj.get_variable('tllist')64+else65+ tllist = dependency('tllist')66+endif67 68+fcft_proj = subproject('fcft', required: false)69+if fcft_proj.found()70+ fcft = fcft_proj.get_variable('fcft')71+else72+ fcft = dependency('fcft')73+endif74+75 executable(76 'fuzzel',77 'application.c', 'application.h',78 'dmenu.c', 'dmenu.h',79 'fdm.c', 'fdm.h',70- 'font.c', 'font.h',80 'icon.c', 'icon.h',81 'log.c', 'log.h',82 'main.c',83 'match.c', 'match.h',4 unmodified lines88 'wayland.c', 'wayland.h',89 'xdg.c', 'xdg.h',90 wl_proto_src + wl_proto_headers, version,91 dependencies: [pixman,83- freetype,84- fontconfig,92 cairo,93 cairo_ft,94 librsvg,95 wayland_client,96 wayland_cursor,97 wlroots,98 xkb,92- tllist],99+ tllist,100+ fcft],101 install: true)102 103 subdir('completions')104 subdir('doc')modified:PKGBUILD+1 added-4 removed
4 unmodified lines5 arch=('x86_64')6 url=https://codeberg.org/dnkl/fuzzel7 license=(mit)8 makedepends=('meson' 'ninja' 'scdoc')9-depends=(10- 'libxkbcommon'11- 'wayland' 'wlroots'12- 'freetype2' 'fontconfig' 'cairo' 'librsvg')9+depends=('libxkbcommon' 'wayland' 'wlroots' 'cairo' 'librsvg' 'tllist' 'fcft')10 source=()11 12 pkgver() {13 cd ../.git &> /dev/null && git describe --tags --long | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g' ||11 unmodified linesmodified:render.c+2 added-5 removed
2 unmodified lines3 #include <stdlib.h>4 #include <stdio.h>5 #include <string.h>6 7+#include <fcft/fcft.h>8+9 #define LOG_MODULE "render"10 #include "log.h"9-#include "font.h"11 12 struct render {13 struct render_options options;14 struct font *regular_font;158 unmodified lines173 const double row_height = 2 * y_margin + font->height;174 const double first_row = 1 * border_size + row_height;175 const double sel_margin = x_margin / 3;176 176- /*177- * LOG_DBG("height=%f, ascent=%f, descent=%f", fextents.height, fextents.ascent,178- * fextents.descent);179- */177 double y = first_row + (row_height + font->height) / 2 - font->descent;178 179 for (size_t i = 0; i < match_count; i++) {180 const struct match *match = matches_get(matches, i);//&matches[i];112 unmodified linesmodified:render.h+2 added-1 removed
1 unmodified line2 3 #include <pixman.h>4 #include <cairo.h>5 6-#include "font.h"6+#include <fcft/fcft.h>7+8 #include "shm.h"9 #include "match.h"10 #include "tllist.h"11 37 unmodified lines