From 3f663a0e6f266bcb250df03a3e23e4809ca3914b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 1 Dec 2019 15:50:45 +0100 Subject: [PATCH 1/4] tllist: remove git submodule and local copy under subprojects --- .gitmodules | 3 - external/tllist | 1 - subprojects/tllist/LICENSE | 21 --- subprojects/tllist/README.md | 301 --------------------------------- subprojects/tllist/meson.build | 5 - subprojects/tllist/test.c | 96 ----------- subprojects/tllist/tllist.h | 180 -------------------- 7 files changed, 607 deletions(-) delete mode 160000 external/tllist delete mode 100644 subprojects/tllist/LICENSE delete mode 100644 subprojects/tllist/README.md delete mode 100644 subprojects/tllist/meson.build delete mode 100644 subprojects/tllist/test.c delete mode 100644 subprojects/tllist/tllist.h diff --git a/.gitmodules b/.gitmodules index ca00cd8..0235ef9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,6 +2,3 @@ path = external/wlr-protocols url = https://github.com/swaywm/wlr-protocols.git branch = master -[submodule "external/tllist"] - path = external/tllist - url = https://codeberg.org/dnkl/tllist.git diff --git a/external/tllist b/external/tllist deleted file mode 160000 index d61be2b..0000000 --- a/external/tllist +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d61be2b6238617d9bfd80aeb1ba0cef13d3a6aba diff --git a/subprojects/tllist/LICENSE b/subprojects/tllist/LICENSE deleted file mode 100644 index 6d93abc..0000000 --- a/subprojects/tllist/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 Daniel Eklöf - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/subprojects/tllist/README.md b/subprojects/tllist/README.md deleted file mode 100644 index 0fc3fa4..0000000 --- a/subprojects/tllist/README.md +++ /dev/null @@ -1,301 +0,0 @@ -# tllist - -**tllist** is a *T*yped *L*inked *L*ist C header file only -library implemented using pre-processor macros. - - -1. [Description](#description) -1. [Usage](#usage) - 1. [Declaring a variable](#declaring-a-variable) - 1. [Adding items - basic](#adding-items-basic) - 1. [List length](#list-length) - 1. [Accessing items](#accessing-items) - 1. [Iterating](#iterating) - 1. [Removing items - basic](#removing-items-basic) - 1. [Adding items - advanced](#adding-items-advanced) - 1. [Removing items - advanced](#removing-items-advanced) - 1. [Freeing](#freeing) -1. [Integrating](#integrating) - 1. [Meson](#meson) -1. [API](#api) - 1. [Cheat sheet](#cheat-sheet) - - -## Description - -Most C implementations of linked list are untyped. That is, their data -carriers are typically `void *`. This is error prone since your -compiler will not be able to help you correct your mistakes (_oh, was -it pointer-to-a-pointer... I though it was just a pointer..._). - -**tllist** addresses this by using pre-processor macros to implement -dynamic types, where the data carrier is typed to whatever you want; -both **primitive** data types are supported as well as aggregated ones -such as **structs**, **enums** and **unions**. - -Being a double-linked list, most operations are constant in time -(including pushing and popping both to/from front and back). - -The memory overhead is fairly small; each item carries, besides its -data, a _prev_ and _next_ pointer (i.e. a constant 16 byte overhead -per item on 64-bit architectures). - -The list itself has two _head_ and _tail_ pointers, plus a _length_ -variable (typically 8 bytes on 64-bit architectures) to make list -length lookup constant in time. - -Thus, assuming 64-bit pointers (and a 64-bit `size_t` type), the total -overhead is `3*8 + n*2*8` bytes. - - -## Usage - -### Declaring a variable - -1. **Declare a variable** - - ```c - /* Declare a variable using an anonymous type */ - tll(int) an_integer_list = tll_init(); - ``` - - -2. **Typedef** - - ```c - /* First typedef the list type */ - typedef tll(int) an_integer_list_t; - - /* Then declare a variable using that typedef */ - an_integer_list_t an_integer_list = tll_init(); - ``` - -3. **Named struct** - - ```c - /* First declare named struct */ - tll(int, an_integer_list); - - /* Then declare a variable using that named struct */ - struct an_integer_list an_integer_list = tll_init(); - ``` - -### Adding items - basic - -Use `tll_push_back()` or `tll_push_front()` to add elements to the -back or front of the list. - -```c -tll_push_back(an_integer_list, 4711); -tll_push_front(an_integer_list, 1234); -``` - - -### List length - -`tll_length()` returns the length (number of items) in a list. - -```c -tll_push_back(an_integer_list, 1234); -tll_push_back(an_integer_list, 5678); -printf("length: %zu\n", tll_length(an_integer_list)); -``` - -Outputs: - - length: 2 - - -### Accessing items - -For the front and back items, you can use `tll_front()` and -`tll_back()` respectively. For any other item in the list, you need to -iterate the list and find the item yourself. - -```c -tll_push_back(an_integer_list, 1234); -tll_push_back(an_integer_list, 5555); -tll_push_back(an_integer_list, 6789); - -printf("front: %d\n", tll_front(an_integer_list)); -printf("back: %d\n", tll_back(an_integer_list)); -``` - -Outputs: - - front: 1234 - back: 6789 - - -### Iterating - -You can iterate the list either forward or backwards, using -`tll_foreach()` and `tll_rforeach()` respectively. - -The `it` variable should be treated as an opaque iterator type, where -`it->item` is the item. - -In reality, it is simply a pointer to the linked list entry, and since -tllist is a header-only implementation, you do have access to e.g. the -next/prev pointers. There should not be any need to access anything -except `item` however. - -Note that `it` can be named anything. - -```c -tll_push_back(an_integer_list, 1); -tll_push_back(an_integer_list, 2); - -tll_foreach(an_integer_list, it) { - printf("forward: %d\n", it->item); -} - -tll_rforeach(an_integer_list, it) { - printf("reverse: %d\n", it->item); -} -``` - -Outputs: - - forward: 1 - forward: 2 - reverse: 2 - reverse: 1 - - -### Removing items - basic - -`tll_pop_front()` and `tll_pop_back()` removes the front/back item and -returns it. - -```c -tll_push_back(an_integer_list, 1234); -tll_push_back(an_integer_list, 5678); - -printf("front: %d\n", tll_pop_front(an_integer_list)); -printf("back: %d\n", tll_pop_back(an_integer_list)); -printf("length: %zu\n", tll_length(an_integer_list)); -``` - -Outputs: - - front: 1234 - back: 5678 - length: 0 - - -### Adding items - advanced - -Given an iterator, you can insert new items before or after that -iterator, using `tll_insert_before()` and `tll_insert_after()`. - -```c -tll_foreach(an_integer_list, it) { - if (it->item == 1234) { - tll_insert_before(an_integer_list, it, 7777); - break; - } -} -``` - -Q: Why do I have to pass **both** the _list_ and the _iterator_ to - `tll_insert_before()`? - -A: If not, **each** element in the list would have to contain a - pointer to the owning list, which would significantly increase the - overhead. - - -### Removing items - advanced - -Similar to how you can add items while iterating a list, you can also -remove them. - -Note that the `*foreach()` functions are **safe** in this regard - it -is perfectly OK to remove the "current" item. - -```c -tll_foreach(an_integer_list, it) { - if (it->item.delete_me) - tll_remove(an_integer_list, it); -} -``` - -To make it slightly easier to handle cases where the item _itself_ -must be free:d as well, there is also `tll_remove_and_free()`. It -works just like `tll_remove()`, but takes an additional argument; a -callback that will be called for each item. - -```c -tll(int *) int_p_list = tll_init(); - -int *a = malloc(sizeof(*a)); -int *b = malloc(sizeof(*b)); - -*a = 1234; -*b = 5678; - -tll_push_back(int_p_list, a); -tll_push_back(int_p_list, b); - -tll_foreach(int_p_list, it) { - tll_remove_and_free(int_p_list, it, free); -} -``` - - -### Freeing - -To remove **all** items, use `tll_free()`, or -`tll_free_and_free()`. These are just convenience functions and -calling these are equivalent to: - -```c -tll_foreach(an_integer_list, it) { - tll_remove(an_integer_list, it); -} -``` - -Note that there is no need to call `tll_free()` on an empty -(`tll_length(list) == 0`) list. - - -## Integrating - -The easiest way may be to simply copy `tllist.h` into your -project. But see sections below for other ways. - - -### Meson - -You can use tllist as a subproject. In your main project's -`meson.build`, to something like: - -```meson -tllist = subproject('tllist').get_variable('tllist') -executable('you-executable', ..., dependencies: [tllist]) -``` - - -## API - -### Cheat sheet - -| Function | Description | Context | Complexity | -|-------------------------------------|-------------------------------------------------------|--------------------|-----------:| -| `list = tll_init()` | initialize a new tllist variable to an empty list | Variable init | O(1) | -| `tll_length(list)` | returns the length (number of items) of a list | | O(1) | -| `tll_push_front(list, item)` | inserts _item_ at the beginning of the list | | O(1) | -| `tll_push_back(list, item)` | inserts _item_ at the end of the list | | O(1) | -| `tll_front(list)` | returns the first item in the list | | O(1) | -| `tll_back(list)` | returns the last item in the list | | O(1) | -| `tll_pop_front(list)` | removes and returns the first item in the list | | O(1) | -| `tll_pop_back(list)` | removes and returns the last item in the list | | O(1) | -| `tll_foreach(list, it)` | iterates the list from the beginning to the end | | O(n) | -| `tll_rforeach(list, it)` | iterates the list from the end to the beginning | | O(n) | -| `tll_insert_before(list, it, item)` | inserts _item_ before _it_. | `tll_(r)foreach()` | O(1) | -| `tll_insert_after(list, it, item)` | inserts _item_ after _it_. | `tll_(r)foreach()` | O(1) | -| `tll_remove(list, it)` | removes _it_ from the list. | `tll_(r)foreach()` | O(1) | -| `tll_remove_and_free(list, it, cb)` | removes _it_ from the list, and calls `cb(it->item)`. | `tll_(r)foreach()` | O(1) | -| `tll_free(list)` | removes **all** items from the list | | O(n) | -| `tll_free_and_free(list, cb)` | removes **all** items from the list, and calls `cb(it->item)` for each item. | | O(n) | diff --git a/subprojects/tllist/meson.build b/subprojects/tllist/meson.build deleted file mode 100644 index 2f6123f..0000000 --- a/subprojects/tllist/meson.build +++ /dev/null @@ -1,5 +0,0 @@ -project('tllist', 'c', version: '1.0.0', license: 'MIT', meson_version: '>=0.50.0') -tllist = declare_dependency(include_directories: '.') - -unittest = executable('unittest', 'test.c', dependencies: [tllist]) -test('unittest', unittest) diff --git a/subprojects/tllist/test.c b/subprojects/tllist/test.c deleted file mode 100644 index 515b5ad..0000000 --- a/subprojects/tllist/test.c +++ /dev/null @@ -1,96 +0,0 @@ -#undef NDEBUG -#include -#include -#include -#include - -#include - -int -main(int argc, const char *const *argv) -{ - tll(int) l = tll_init(); - assert(tll_length(l) == 0); - - /* push back */ - tll_push_back(l, 123); assert(tll_length(l) == 1); - tll_push_back(l, 456); assert(tll_length(l) == 2); - tll_push_back(l, 789); assert(tll_length(l) == 3); - - assert(tll_front(l) == 123); - assert(tll_back(l) == 789); - - /* push front */ - tll_push_front(l, 0xabc); assert(tll_length(l) == 4); - - assert(tll_front(l) == 0xabc); - assert(tll_back(l) == 789); - - /* Pop back */ - assert(tll_pop_back(l) == 789); - assert(tll_back(l) == 456); - - /* Pop front */ - assert(tll_pop_front(l) == 0xabc); - assert(tll_front(l) == 123); - - /* foreach */ - assert(tll_length(l) == 2); - - int seen[tll_length(l)]; - memset(seen, 0, tll_length(l) * sizeof(seen[0])); - - size_t count = 0; - tll_foreach(l, it) - seen[count++] = it->item; - - assert(count == tll_length(l)); - assert(seen[0] == 123); - assert(seen[1] == 456); - - /* rforeach */ - memset(seen, 0, tll_length(l) * sizeof(seen[0])); - count = 0; - tll_rforeach(l, it) - seen[count++] = it->item; - - assert(count == tll_length(l)); - assert(seen[0] == 456); - assert(seen[1] == 123); - - /* remove */ - tll_push_back(l, 789); - tll_foreach(l, it) { - if (it->item > 123 && it->item < 789) - tll_remove(l, it); - } - assert(tll_length(l) == 2); - assert(tll_front(l) == 123); - assert(tll_back(l) == 789); - - /* insert before */ - tll_foreach(l, it) { - if (it->item == 123) - tll_insert_before(l, it, 0xabc); - } - assert(tll_length(l) == 3); - assert(tll_front(l) == 0xabc); - assert(tll_back(l) == 789); - - /* insert after */ - tll_foreach(l, it) { - if (it->item == 789) - tll_insert_after(l, it, 999); - } - assert(tll_length(l) == 4); - assert(tll_front(l) == 0xabc); - assert(tll_back(l) == 999); - - /* free */ - tll_free(l); - assert(tll_length(l) == 0); - assert(l.head == NULL); - assert(l.tail == NULL); - - return EXIT_SUCCESS; -} diff --git a/subprojects/tllist/tllist.h b/subprojects/tllist/tllist.h deleted file mode 100644 index ec2fd41..0000000 --- a/subprojects/tllist/tllist.h +++ /dev/null @@ -1,180 +0,0 @@ -#pragma once - -#include -#include -#include - -#define TLL_PASTE2( a, b) a##b -#define TLL_PASTE( a, b) TLL_PASTE2( a, b) - -/* Utility macro to generate a list element struct with a unique struct tag */ -#define TLL_UNIQUE_INNER_STRUCT(TYPE, ID) \ - struct TLL_PASTE(__tllist_ , ID) { \ - TYPE item; \ - struct TLL_PASTE(__tllist_, ID) *prev; \ - struct TLL_PASTE(__tllist_, ID) *next; \ - } *head, *tail; - -/* - * Defines a new typed-list type, or directly instantiate a typed-list variable - * - * Example a, declare a variable (list of integers): - * tll(int) my_list; - * - * Example b, declare a type, and then use the type: - * tll(int, my_list_type); - * struct my_list_type my_list; - */ -#define tll(TYPE, ...) \ - struct __VA_ARGS__ { \ - TLL_UNIQUE_INNER_STRUCT(TYPE, __COUNTER__) \ - size_t length; \ - } - -/* Initializer: tll(int) my_list = tll_init(); */ -#define tll_init() {.head = NULL, .tail = NULL, .length = 0} - -/* Length/size of list: printf("size: %zu\n", tll_length(my_list)); */ -#define tll_length(list) (list).length - -/* Adds a new item to the back of the list */ -#define tll_push_back(list, new_item) \ - do { \ - tll_insert_after(list, (list).tail, new_item); \ - if ((list).head == NULL) \ - (list).head = (list).tail; \ - } while (0) - -/* Adds a new item to the front of the list */ -#define tll_push_front(list, new_item) \ - do { \ - tll_insert_before(list, (list).head, new_item); \ - if ((list).tail == NULL) \ - (list).tail = (list).head; \ - } while (0) - -/* - * Iterates the list. is an iterator pointer. You can access the - * list item with ->item: - * - * tll(int) my_list = vinit(); - * tll_push_back(my_list, 5); - * - * tll_foreach(my_list i) { - * printf("%d\n", i->item); - * } -*/ -#define tll_foreach(list, it) \ - for (__typeof__(*(list).head) *it = (list).head, \ - *it_next = it != NULL ? it->next : NULL; \ - it != NULL; \ - it = it_next, \ - it_next = it_next != NULL ? it_next->next : NULL) - -/* Same as tll_foreach(), but iterates backwards */ -#define tll_rforeach(list, it) \ - for (__typeof__(*(list).tail) *it = (list).tail, \ - *it_prev = it != NULL ? it->prev : NULL; \ - it != NULL; \ - it = it_prev, \ - it_prev = it_prev != NULL ? it_prev->prev : NULL) - -/* - * Inserts a new item after , which is an iterator. I.e. you can - * only call this from inside a tll_foreach() or tll_rforeach() loop. - */ -#define tll_insert_after(list, it, new_item) \ - do { \ - __typeof__((list).head) __e = malloc(sizeof(*__e)); \ - __e->item = (new_item); \ - __e->prev = (it); \ - __e->next = (it) != NULL ? (it)->next : NULL; \ - if ((it) != NULL) { \ - if ((it)->next != NULL) \ - (it)->next->prev = __e; \ - (it)->next = __e; \ - } \ - if ((it) == (list).tail) \ - (list).tail = __e; \ - (list).length++; \ - } while (0) - -/* - * Inserts a new item before , which is an iterator. I.e. you can - * only call this from inside a tll_foreach() or tll_rforeach() loop. - */ -#define tll_insert_before(list, it, new_item) \ - do { \ - __typeof__((list).head) __e = malloc(sizeof(*__e)); \ - __e->item = (new_item); \ - __e->prev = (it) != NULL ? (it)->prev : NULL; \ - __e->next = (it); \ - if ((it) != NULL) { \ - if ((it)->prev != NULL) \ - (it)->prev->next = __e; \ - (it)->prev = __e; \ - } \ - if ((it) == (list).head) \ - (list).head = __e; \ - (list).length++; \ - } while (0) - -/* - * Removes an entry from the list. is an iterator. I.e. you can - * only call this from inside a tll_foreach() or tll_rforeach() loop. - */ -#define tll_remove(list, it) \ - do { \ - assert((list).length > 0); \ - __typeof__((list).head) __prev = it->prev; \ - __typeof__((list).head) __next = it->next; \ - if (__prev != NULL) \ - __prev->next = __next; \ - else \ - (list).head = __next; \ - if (__next != NULL) \ - __next->prev = __prev; \ - else \ - (list).tail = __prev; \ - free(it); \ - (list).length--; \ - } while (0) - -/* Same as tll_remove(), but calls free_callback(it->item) */ -#define tll_remove_and_free(list, it, free_callback) \ - do { \ - free_callback((it)->item); \ - tll_remove((list), (it)); \ - } while (0) - -#define tll_front(list) (list).head->item -#define tll_back(list) (list).tail->item - -/* - * Removes the first element from the list, and returns it (note: - * returns the *actual* item, not an iterator. - */ -#define tll_pop_front(list) \ - ({__typeof__((list).head) it = (list).head; \ - __typeof__((list).head->item) __ret = it->item; \ - tll_remove((list), it); \ - __ret; \ - }) - -/* Same as tll_pop_front(), but returns/removes the *last* element */ -#define tll_pop_back(list) \ - ({__typeof__((list).tail) it = (list).tail; \ - __typeof__((list).tail->item) __ret = it->item; \ - tll_remove((list), it); \ - __ret; \ - }) - -/* Frees the list. This call is *not* needed if the list is already empty. */ -#define tll_free(list) \ - tll_foreach(list, __it) \ - tll_remove(list, __it) - -/* Same as tll_free(), but also calls free_callback(item) for every item */ -#define tll_free_and_free(list, free_callback) \ - tll_foreach(list, __it) \ - tll_remove_and_free(list, __it, free_callback) From 75d9c9a12d54e0875975158dec8ee84628141fe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 1 Dec 2019 15:51:57 +0100 Subject: [PATCH 2/4] tllist: add git submodule directly under subprojects Meson now falls back to a system dependency if the subproject isn't available. --- .gitmodules | 3 +++ meson.build | 7 ++++++- subprojects/tllist | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) create mode 160000 subprojects/tllist diff --git a/.gitmodules b/.gitmodules index 0235ef9..1dbfd77 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,3 +2,6 @@ path = external/wlr-protocols url = https://github.com/swaywm/wlr-protocols.git branch = master +[submodule "subprojects/tllist"] + path = subprojects/tllist + url = https://codeberg.org/dnkl/tllist.git diff --git a/meson.build b/meson.build index 0a59f09..2d17375 100644 --- a/meson.build +++ b/meson.build @@ -57,7 +57,12 @@ if backend_x11 install_headers('xcb.h', subdir: 'yambar') endif -tllist = subproject('tllist').get_variable('tllist') +tllist_proj = subproject('tllist', required: false) +if tllist_proj.found() + tllist = tllist_proj.get_variable('tllist') +else + tllist = dependency('tllist') +endif subdir('completions') subdir('doc') diff --git a/subprojects/tllist b/subprojects/tllist new file mode 160000 index 0000000..5054d3d --- /dev/null +++ b/subprojects/tllist @@ -0,0 +1 @@ +Subproject commit 5054d3dbbbd7d76e35f9d0d875e3c7f500fde52b From 51a6631c19c23f1f592337586de4c2e818cbba5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 1 Dec 2019 16:00:15 +0100 Subject: [PATCH 3/4] fcft: use fcft instead of local copy of font.{c,h} --- .gitmodules | 3 + config.c | 14 +- config.h | 2 +- decorations/meson.build | 2 +- font.c | 642 ---------------------------------------- font.h | 68 ----- meson.build | 13 +- modules/meson.build | 2 +- particle.h | 3 +- particles/meson.build | 2 +- subprojects/fcft | 1 + 11 files changed, 30 insertions(+), 722 deletions(-) delete mode 100644 font.c delete mode 100644 font.h create mode 160000 subprojects/fcft diff --git a/.gitmodules b/.gitmodules index 1dbfd77..3cf404e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -5,3 +5,6 @@ [submodule "subprojects/tllist"] path = subprojects/tllist url = https://codeberg.org/dnkl/tllist.git +[submodule "subprojects/fcft"] + path = subprojects/fcft + url = https://codeberg.org/dnkl/fcft.git diff --git a/config.c b/config.c index 7a885dc..23cc39c 100644 --- a/config.c +++ b/config.c @@ -67,7 +67,13 @@ conf_to_color(const struct yml_node *node) struct font * conf_to_font(const struct yml_node *node) { - return font_from_name(yml_value_as_string(node)); + font_list_t font_list = tll_init(); + tll_push_back(font_list, yml_value_as_string(node)); + + struct font *font = font_from_name(font_list, NULL); + + tll_free(font_list); + return font; } struct deco * @@ -263,7 +269,11 @@ conf_to_bar(const struct yml_node *bar, enum bar_backend backend) * and particles. This allows us to specify a default font and * foreground color at top-level. */ - struct font *font = font_from_name("sans"); + font_list_t font_list = tll_init(); + tll_push_back(font_list, "sans"); + struct font *font = font_from_name(font_list, NULL); + tll_free(font_list); + pixman_color_t foreground = {0xffff, 0xffff, 0xffff, 0xffff}; /* White */ const struct yml_node *font_node = yml_get_value(bar, "font"); diff --git a/config.h b/config.h index 28e3f5a..3610c1f 100644 --- a/config.h +++ b/config.h @@ -1,6 +1,6 @@ #pragma once -#include "font.h" +#include #include "yml.h" #include "bar/bar.h" diff --git a/decorations/meson.build b/decorations/meson.build index b9cf372..4d388db 100644 --- a/decorations/meson.build +++ b/decorations/meson.build @@ -1,4 +1,4 @@ -deco_sdk = declare_dependency(dependencies: [freetype, pixman, tllist]) +deco_sdk = declare_dependency(dependencies: [pixman, tllist]) decorations = [] foreach deco : ['background', 'stack', 'underline'] diff --git a/font.c b/font.c deleted file mode 100644 index 72227e1..0000000 --- a/font.c +++ /dev/null @@ -1,642 +0,0 @@ -#include "font.h" - -#include -#include -#include -#include -#include -#include -#include - -//#include - -#define LOG_MODULE "font" -#define LOG_ENABLE_DBG 0 -#include "log.h" -#include "stride.h" - -#define min(x, y) ((x) < (y) ? (x) : (y)) - -static FT_Library ft_lib; -static mtx_t ft_lock; - -static tll(const struct font *) font_cache = tll_init(); - -static const size_t glyph_cache_size = 512; - -static void __attribute__((constructor)) -init(void) -{ - FcInit(); - FT_Init_FreeType(&ft_lib); - mtx_init(&ft_lock, mtx_plain); - -#if defined(LOG_ENABLE_DBG) && LOG_ENABLE_DBG - int raw_version = FcGetVersion(); - - /* See FC_VERSION in */ - const int major = raw_version / 10000; raw_version %= 10000; - const int minor = raw_version / 100; raw_version %= 100; - const int patch = raw_version; -#endif - - LOG_DBG("fontconfig: %d.%d.%d", major, minor, patch); -} - -static void __attribute__((destructor)) -fini(void) -{ - assert(tll_length(font_cache) == 0); - - mtx_destroy(&ft_lock); - FT_Done_FreeType(ft_lib); - FcFini(); -} - -static bool -font_destroy_no_free(struct font *font) -{ - assert(font->ref_counter > 0); - if (--font->ref_counter > 0) - return false; - - if (font->face != NULL) { - mtx_lock(&ft_lock); - FT_Done_Face(font->face); - mtx_unlock(&ft_lock); - } - - if (font->fc_pattern != NULL) - FcPatternDestroy(font->fc_pattern); - if (font->fc_fonts != NULL) - FcFontSetDestroy(font->fc_fonts); - - free(font->name); - - if (font->cache == NULL) - return true; - - for (size_t i = 0; i < glyph_cache_size; i++) { - if (font->cache[i] == NULL) - continue; - - tll_foreach(*font->cache[i], it) { - if (!it->item.valid) - continue; - - void *image = pixman_image_get_data(it->item.pix); - pixman_image_unref(it->item.pix); - free(image); - } - - tll_free(*font->cache[i]); - free(font->cache[i]); - } - free(font->cache); - - tll_foreach(font_cache, it) { - if (it->item == font) { - tll_remove(font_cache, it); - break; - } - } - - return true; -} - -/* Not used in yambar */ -#if 0 -static void -underline_strikeout_metrics(struct font *font) -{ - FT_Face ft_face = font->face; - double y_scale = ft_face->size->metrics.y_scale / 65536.; - double height = ft_face->size->metrics.height / 64.; - double descent = ft_face->size->metrics.descender / 64.; - - LOG_DBG("ft: y-scale: %f, height: %f, descent: %f", - y_scale, height, descent); - - font->underline.position = ft_face->underline_position * y_scale / 64.; - font->underline.thickness = ft_face->underline_thickness * y_scale / 64.; - - if (font->underline.position == 0.) { - font->underline.position = descent / 2.; - font->underline.thickness = fabs(descent / 5.); - } - - LOG_DBG("underline: pos=%f, thick=%f", - font->underline.position, font->underline.thickness); - - TT_OS2 *os2 = FT_Get_Sfnt_Table(ft_face, ft_sfnt_os2); - if (os2 != NULL) { - font->strikeout.position = os2->yStrikeoutPosition * y_scale / 64.; - font->strikeout.thickness = os2->yStrikeoutSize * y_scale / 64.; - } - - if (font->strikeout.position == 0.) { - font->strikeout.position = height / 2. + descent; - font->strikeout.thickness = font->underline.thickness; - } - - LOG_DBG("strikeout: pos=%f, thick=%f", - font->strikeout.position, font->strikeout.thickness); -} -#endif - -static bool -from_font_set(FcPattern *pattern, FcFontSet *fonts, int start_idx, - struct font *font, bool is_fallback) -{ - memset(font, 0, sizeof(*font)); - - FcChar8 *face_file = NULL; - FcPattern *final_pattern = NULL; - int font_idx = -1; - - for (int i = start_idx; i < fonts->nfont; i++) { - FcPattern *pat = FcFontRenderPrepare(NULL, pattern, fonts->fonts[i]); - assert(pat != NULL); - - if (FcPatternGetString(pat, FC_FT_FACE, 0, &face_file) != FcResultMatch) { - if (FcPatternGetString(pat, FC_FILE, 0, &face_file) != FcResultMatch) { - FcPatternDestroy(pat); - continue; - } - } - - final_pattern = pat; - font_idx = i; - break; - } - - assert(font_idx != -1); - assert(final_pattern != NULL); - - double dpi; - if (FcPatternGetDouble(final_pattern, FC_DPI, 0, &dpi) != FcResultMatch) - dpi = 96; - - double size; - double pixel_size; - if (FcPatternGetDouble(final_pattern, FC_SIZE, 0, &size) != FcResultMatch || - FcPatternGetDouble(final_pattern, FC_PIXEL_SIZE, 0, &pixel_size) != FcResultMatch) - { - LOG_ERR("%s: failed to get size", face_file); - FcPatternDestroy(final_pattern); - return false; - } - - FcBool scalable; - if (FcPatternGetBool(final_pattern, FC_SCALABLE, 0, &scalable) != FcResultMatch) - scalable = FcTrue; - - FcBool outline; - if (FcPatternGetBool(final_pattern, FC_OUTLINE, 0, &outline) != FcResultMatch) - outline = FcTrue; - - double pixel_fixup; - if (FcPatternGetDouble(final_pattern, "pixelsizefixupfactor", 0, &pixel_fixup) != FcResultMatch) { - /* - * Force a fixup factor on scalable bitmap fonts (typically - * emoji fonts). The fixup factor is - * requested-pixel-size / actual-pixels-size - */ - if (scalable && !outline) { - double requested_pixel_size; - if (FcPatternGetDouble(pattern, FC_PIXEL_SIZE, 0, &requested_pixel_size) != FcResultMatch) { - double requested_size; - if (FcPatternGetDouble(pattern, FC_SIZE, 0, &requested_size) != FcResultMatch) - requested_size = size; - requested_pixel_size = requested_size * dpi / 72; - } - pixel_fixup = requested_pixel_size / pixel_size; - - LOG_DBG("estimated fixup factor to %f (requested pixel size: %f, actual: %f)", - pixel_fixup, requested_pixel_size, pixel_size); - } else - pixel_fixup = 1.; - } - - LOG_DBG("loading: %s", face_file); - - mtx_lock(&ft_lock); - FT_Face ft_face; - FT_Error ft_err = FT_New_Face(ft_lib, (const char *)face_file, 0, &ft_face); - mtx_unlock(&ft_lock); - if (ft_err != 0) - LOG_ERR("%s: failed to create FreeType face", face_file); - - if ((ft_err = FT_Set_Pixel_Sizes(ft_face, 0, pixel_size)) != 0) { - LOG_WARN("failed to set pixel size"); - mtx_lock(&ft_lock); - FT_Done_Face(ft_face); - mtx_unlock(&ft_lock); - FcPatternDestroy(final_pattern); - return false; - } - - FcBool fc_hinting; - if (FcPatternGetBool(final_pattern, FC_HINTING,0, &fc_hinting) != FcResultMatch) - fc_hinting = FcTrue; - - FcBool fc_antialias; - if (FcPatternGetBool(final_pattern, FC_ANTIALIAS, 0, &fc_antialias) != FcResultMatch) - fc_antialias = FcTrue; - - int fc_hintstyle; - if (FcPatternGetInteger(final_pattern, FC_HINT_STYLE, 0, &fc_hintstyle) != FcResultMatch) - fc_hintstyle = FC_HINT_SLIGHT; - - int fc_rgba; - if (FcPatternGetInteger(final_pattern, FC_RGBA, 0, &fc_rgba) != FcResultMatch) - fc_rgba = FC_RGBA_UNKNOWN; - - int load_flags = 0; - if (!fc_antialias) { - if (!fc_hinting || fc_hintstyle == FC_HINT_NONE) - load_flags |= FT_LOAD_MONOCHROME | FT_LOAD_NO_HINTING | FT_LOAD_TARGET_NORMAL; - else - load_flags |= FT_LOAD_MONOCHROME | FT_LOAD_TARGET_MONO; - } else { - if (!fc_hinting || fc_hintstyle == FC_HINT_NONE) - load_flags |= FT_LOAD_DEFAULT | FT_LOAD_NO_HINTING | FT_LOAD_TARGET_NORMAL; - else if (fc_hinting && fc_hintstyle == FC_HINT_SLIGHT) - load_flags |= FT_LOAD_DEFAULT | FT_LOAD_TARGET_LIGHT; - else if (fc_rgba == FC_RGBA_RGB || fc_rgba == FC_RGBA_BGR) - load_flags |= FT_LOAD_DEFAULT | FT_LOAD_TARGET_LCD; - else if (fc_rgba == FC_RGBA_VRGB || fc_rgba == FC_RGBA_VBGR) - load_flags |= FT_LOAD_DEFAULT | FT_LOAD_TARGET_LCD_V; - else - load_flags |= FT_LOAD_DEFAULT | FT_LOAD_TARGET_NORMAL; - } - - FcBool fc_embeddedbitmap; - if (FcPatternGetBool(final_pattern, FC_EMBEDDED_BITMAP, 0, &fc_embeddedbitmap) != FcResultMatch) - fc_embeddedbitmap = FcTrue; - - if (!fc_embeddedbitmap) - load_flags |= FT_LOAD_NO_BITMAP; - - int render_flags = 0; - if (!fc_antialias) - render_flags |= FT_RENDER_MODE_MONO; - else { - if (fc_rgba == FC_RGBA_RGB || fc_rgba == FC_RGBA_BGR) - render_flags |= FT_RENDER_MODE_LCD; - else if (fc_rgba == FC_RGBA_VRGB || fc_rgba == FC_RGBA_VBGR) - render_flags |= FT_RENDER_MODE_LCD_V; - else - render_flags |= FT_RENDER_MODE_NORMAL; - } - - int fc_lcdfilter; - if (FcPatternGetInteger(final_pattern, FC_LCD_FILTER, 0, &fc_lcdfilter) != FcResultMatch) - fc_lcdfilter = FC_LCD_DEFAULT; - - switch (fc_lcdfilter) { - case FC_LCD_NONE: font->lcd_filter = FT_LCD_FILTER_NONE; break; - case FC_LCD_DEFAULT: font->lcd_filter = FT_LCD_FILTER_DEFAULT; break; - case FC_LCD_LIGHT: font->lcd_filter = FT_LCD_FILTER_LIGHT; break; - case FC_LCD_LEGACY: font->lcd_filter = FT_LCD_FILTER_LEGACY; break; - } - - FcPatternDestroy(final_pattern); - - font->face = ft_face; - font->load_flags = load_flags | FT_LOAD_COLOR; - font->render_flags = render_flags; - font->pixel_size_fixup = pixel_fixup; - font->bgr = fc_rgba == FC_RGBA_BGR || fc_rgba == FC_RGBA_VBGR; - font->fc_idx = font_idx; - font->is_fallback = is_fallback; - font->ref_counter = 1; - - double max_x_advance = ft_face->size->metrics.max_advance / 64.; - double height = ft_face->size->metrics.height / 64.; - double descent = ft_face->size->metrics.descender / 64.; - double ascent = ft_face->size->metrics.ascender / 64.; - - font->height = height * font->pixel_size_fixup; - font->descent = -descent * font->pixel_size_fixup; - font->ascent = ascent * font->pixel_size_fixup; - font->max_x_advance = max_x_advance * font->pixel_size_fixup; - - LOG_DBG("metrics: height: %d, descent: %d, ascent: %d, x-advance: %d", - font->height, font->descent, font->ascent, font->max_x_advance); - - if (!is_fallback) { - font->fc_pattern = pattern; - font->fc_fonts = fonts; - font->cache = calloc(glyph_cache_size, sizeof(font->cache[0])); - } - - /* Not used in yambar */ - /* underline_strikeout_metrics(font); */ - return true; -} - -struct font * -font_from_name(const char *name) -{ - LOG_DBG("instantiating %s", name); - - tll_foreach(font_cache, it) { - if (strcmp(it->item->name, name) == 0) - return font_clone(it->item); - } - - FcPattern *pattern = FcNameParse((const unsigned char *)name); - if (pattern == NULL) { - LOG_ERR("%s: failed to lookup font", name); - return NULL; - } - - if (!FcConfigSubstitute(NULL, pattern, FcMatchPattern)) { - LOG_ERR("%s: failed to do config substitution", name); - FcPatternDestroy(pattern); - return NULL; - } - - FcDefaultSubstitute(pattern); - - FcResult result; - FcFontSet *fonts = FcFontSort(NULL, pattern, FcTrue, NULL, &result); - if (result != FcResultMatch) { - LOG_ERR("%s: failed to match font", name); - FcPatternDestroy(pattern); - return NULL; - } - - struct font *font = malloc(sizeof(*font)); - if (!from_font_set(pattern, fonts, 0, font, false)) { - free(font); - FcFontSetDestroy(fonts); - FcPatternDestroy(pattern); - return NULL; - } - - font->name = strdup(name); - tll_push_back(font_cache, font); - return font; -} - -static size_t -hash_index(wchar_t wc) -{ - return wc % glyph_cache_size; -} - -static bool -glyph_for_wchar(const struct font *font, wchar_t wc, struct glyph *glyph) -{ - /* - * LCD filter is per library instance. Thus we need to re-set it - * every time... - * - * Also note that many freetype builds lack this feature - * (FT_CONFIG_OPTION_SUBPIXEL_RENDERING must be defined, and isn't - * by default) */ - FT_Error err = FT_Library_SetLcdFilter(ft_lib, font->lcd_filter); - if (err != 0 && err != FT_Err_Unimplemented_Feature) - goto err; - - FT_UInt idx = FT_Get_Char_Index(font->face, wc); - if (idx == 0) { - if (font->is_fallback) - return false; - - /* No glyph in this font, try fontconfig fallback fonts */ - - /* Try fontconfig fallback fonts */ - assert(font->fc_pattern != NULL); - assert(font->fc_fonts != NULL); - assert(font->fc_idx != -1); - - for (int i = font->fc_idx + 1; i < font->fc_fonts->nfont; i++) { - struct font fallback; - if (!from_font_set(font->fc_pattern, font->fc_fonts, i, &fallback, true)) - continue; - - if (glyph_for_wchar(&fallback, wc, glyph)) { - LOG_DBG("%C: used fontconfig fallback", wc); - font_destroy_no_free(&fallback); - return true; - } - - font_destroy_no_free(&fallback); - } - - LOG_WARN("%C: no glyph found (in neither the main font, " - "nor any fallback fonts)", wc); - } - - err = FT_Load_Glyph(font->face, idx, font->load_flags); - if (err != 0) { - LOG_ERR("load failed"); - goto err; - } - - err = FT_Render_Glyph(font->face->glyph, font->render_flags); - if (err != 0) - goto err; - - assert(font->face->glyph->format == FT_GLYPH_FORMAT_BITMAP); - - FT_Bitmap *bitmap = &font->face->glyph->bitmap; - if (bitmap->width == 0) - goto err; - - pixman_format_code_t pix_format; - int width; - int rows; - - switch (bitmap->pixel_mode) { - case FT_PIXEL_MODE_MONO: - pix_format = PIXMAN_a1; - width = bitmap->width; - rows = bitmap->rows; - break; - - case FT_PIXEL_MODE_GRAY: - pix_format = PIXMAN_a8; - width = bitmap->width; - rows = bitmap->rows; - break; - - case FT_PIXEL_MODE_LCD: - pix_format = PIXMAN_x8r8g8b8; - width = bitmap->width / 3; - rows = bitmap->rows; - break; - - case FT_PIXEL_MODE_LCD_V: - pix_format = PIXMAN_x8r8g8b8; - width = bitmap->width; - rows = bitmap->rows / 3; - break; - - case FT_PIXEL_MODE_BGRA: - pix_format = PIXMAN_a8r8g8b8; - width = bitmap->width; - rows = bitmap->rows; - break; - - default: - LOG_ERR("unimplemented: FT pixel mode: %d", bitmap->pixel_mode); - goto err; - break; - } - - int stride = stride_for_format_and_width(pix_format, width); - assert(stride >= bitmap->pitch); - - uint8_t *data = malloc(rows * stride); - - /* Convert FT bitmap to pixman image */ - switch (bitmap->pixel_mode) { - case FT_PIXEL_MODE_MONO: - for (size_t r = 0; r < bitmap->rows; r++) { - for (size_t c = 0; c < (bitmap->width + 7) / 8; c++) { - uint8_t v = bitmap->buffer[r * bitmap->pitch + c]; - uint8_t reversed = 0; - for (size_t i = 0; i < min(8, bitmap->width - c * 8); i++) - reversed |= ((v >> (7 - i)) & 1) << i; - - data[r * stride + c] = reversed; - } - } - break; - - case FT_PIXEL_MODE_GRAY: - for (size_t r = 0; r < bitmap->rows; r++) { - for (size_t c = 0; c < bitmap->width; c++) - data[r * stride + c] = bitmap->buffer[r * bitmap->pitch + c]; - } - break; - - case FT_PIXEL_MODE_BGRA: - assert(stride == bitmap->pitch); - memcpy(data, bitmap->buffer, bitmap->rows * bitmap->pitch); - break; - - case FT_PIXEL_MODE_LCD: - for (size_t r = 0; r < bitmap->rows; r++) { - for (size_t c = 0; c < bitmap->width; c += 3) { - unsigned char _r = bitmap->buffer[r * bitmap->pitch + c + (font->bgr ? 2 : 0)]; - unsigned char _g = bitmap->buffer[r * bitmap->pitch + c + 1]; - unsigned char _b = bitmap->buffer[r * bitmap->pitch + c + (font->bgr ? 0 : 2)]; - - uint32_t *p = (uint32_t *)&data[r * stride + 4 * (c / 3)]; - *p = _r << 16 | _g << 8 | _b; - } - } - break; - - case FT_PIXEL_MODE_LCD_V: - /* Unverified */ - for (size_t r = 0; r < bitmap->rows; r += 3) { - for (size_t c = 0; c < bitmap->width; c++) { - unsigned char _r = bitmap->buffer[(r + (font->bgr ? 2 : 0)) * bitmap->pitch + c]; - unsigned char _g = bitmap->buffer[(r + 1) * bitmap->pitch + c]; - unsigned char _b = bitmap->buffer[(r + (font->bgr ? 0 : 2)) * bitmap->pitch + c]; - - uint32_t *p = (uint32_t *)&data[r / 3 * stride + 4 * c]; - *p = _r << 16 | _g << 8 | _b; - } - } - break; - - default: - abort(); - break; - } - - pixman_image_t *pix = pixman_image_create_bits_no_clear( - pix_format, width, rows, (uint32_t *)data, stride); - - if (pix == NULL) { - free(data); - goto err; - } - - pixman_image_set_component_alpha( - pix, - bitmap->pixel_mode == FT_PIXEL_MODE_LCD || - bitmap->pixel_mode == FT_PIXEL_MODE_LCD_V); - - if (font->pixel_size_fixup != 1.) { - struct pixman_transform scale; - pixman_transform_init_scale( - &scale, - pixman_double_to_fixed(1. / font->pixel_size_fixup), - pixman_double_to_fixed(1. / font->pixel_size_fixup)); - pixman_image_set_transform(pix, &scale); - pixman_image_set_filter(pix, PIXMAN_FILTER_BEST, NULL, 0); - } - - *glyph = (struct glyph){ - .wc = wc, - .cols = wcwidth(wc), - .pix = pix, - .x = font->face->glyph->bitmap_left * font->pixel_size_fixup, - .y = ceil(font->face->glyph->bitmap_top * font->pixel_size_fixup), - .x_advance = ceil(font->face->glyph->advance.x / 64) * font->pixel_size_fixup, - .width = width, - .height = rows, - .valid = true, - }; - - return true; - -err: - *glyph = (struct glyph){ - .wc = wc, - .valid = false, - }; - return false; -} - -const struct glyph * -font_glyph_for_wc(struct font *font, wchar_t wc) -{ - assert(font->cache != NULL); - size_t hash_idx = hash_index(wc); - hash_entry_t *hash_entry = font->cache[hash_idx]; - - if (hash_entry != NULL) { - tll_foreach(*hash_entry, it) { - if (it->item.wc == wc) - return it->item.valid ? &it->item : NULL; - } - } - - struct glyph glyph; - bool got_glyph = glyph_for_wchar(font, wc, &glyph); - - if (hash_entry == NULL) { - hash_entry = calloc(1, sizeof(*hash_entry)); - - assert(font->cache[hash_idx] == NULL); - font->cache[hash_idx] = hash_entry; - } - - assert(hash_entry != NULL); - tll_push_back(*hash_entry, glyph); - return got_glyph ? &tll_back(*hash_entry) : NULL; -} - -struct font * -font_clone(const struct font *_font) -{ - struct font *font = (struct font *)_font; - font->ref_counter++; - return font; -} - -void -font_destroy(struct font *font) -{ - if (font_destroy_no_free(font)) - free(font); -} diff --git a/font.h b/font.h deleted file mode 100644 index 395db18..0000000 --- a/font.h +++ /dev/null @@ -1,68 +0,0 @@ -#pragma once - -#include -#include - -#include -#include FT_FREETYPE_H -#include FT_LCD_FILTER_H -#include -#include - -#include "tllist.h" - -struct glyph { - wchar_t wc; - int cols; - - pixman_image_t *pix; - int x; - int y; - int x_advance; - int width; - int height; - - bool valid; -}; - -typedef tll(struct glyph) hash_entry_t; - -struct font { - char *name; - - FcPattern *fc_pattern; - FcFontSet *fc_fonts; - int fc_idx; - - FT_Face face; - int load_flags; - int render_flags; - FT_LcdFilter lcd_filter; - double pixel_size_fixup; /* Scale factor - should only be used with ARGB32 glyphs */ - bool bgr; /* True for FC_RGBA_BGR and FC_RGBA_VBGR */ - - int height; - int descent; - int ascent; - int max_x_advance; - - struct { - double position; - double thickness; - } underline; - - struct { - double position; - double thickness; - } strikeout; - - hash_entry_t **cache; - - bool is_fallback; - int ref_counter; -}; - -struct font *font_from_name(const char *name); -struct font *font_clone(const struct font *font); -const struct glyph *font_glyph_for_wc(struct font *font, wchar_t wc); -void font_destroy(struct font *font); diff --git a/meson.build b/meson.build index 2d17375..a46497b 100644 --- a/meson.build +++ b/meson.build @@ -14,8 +14,6 @@ plugs_as_libs = get_option('core-plugins-as-shared-libraries') cc = meson.get_compiler('c') dl = cc.find_library('dl') threads = dependency('threads') -freetype = dependency('freetype2') -fontconfig = dependency('fontconfig') pixman = dependency('pixman-1') yaml = dependency('yaml-0.1') @@ -64,6 +62,13 @@ else tllist = dependency('tllist') endif +fcft_proj = subproject('fcft', required: false) +if fcft_proj.found() + fcft = fcft_proj.get_variable('fcft') +else + fcft = dependency('fcft') +endif + subdir('completions') subdir('doc') subdir('bar') @@ -84,7 +89,6 @@ yambar = executable( 'config-verify.c', 'config-verify.h', 'config.c', 'config.h', 'decoration.h', - 'font.c', 'font.h', 'log.c', 'log.h', 'main.c', 'module.c', 'module.h', @@ -93,7 +97,7 @@ yambar = executable( 'tag.c', 'tag.h', 'yml.c', 'yml.h', version, - dependencies: [bar, freetype, fontconfig, pixman, yaml, threads, dl, tllist] + + dependencies: [bar, pixman, yaml, threads, dl, tllist, fcft] + decorations + particles + modules, build_rpath: '$ORIGIN/modules:$ORIGIN/decorations:$ORIGIN/particles', export_dynamic: true, @@ -109,7 +113,6 @@ install_headers( 'config.h', 'config-verify.h', 'decoration.h', - 'font.h', 'log.h', 'module.h', 'particle.h', diff --git a/modules/meson.build b/modules/meson.build index 2f22c9d..ccafb8a 100644 --- a/modules/meson.build +++ b/modules/meson.build @@ -1,4 +1,4 @@ -module_sdk = declare_dependency(dependencies: [freetype, pixman, threads, tllist]) +module_sdk = declare_dependency(dependencies: [pixman, threads, tllist]) modules = [] diff --git a/particle.h b/particle.h index 789fd87..9bd417e 100644 --- a/particle.h +++ b/particle.h @@ -1,9 +1,10 @@ #pragma once #include +#include + #include "color.h" #include "decoration.h" -#include "font.h" #include "tag.h" struct bar; diff --git a/particles/meson.build b/particles/meson.build index 484ecfd..f571f12 100644 --- a/particles/meson.build +++ b/particles/meson.build @@ -1,4 +1,4 @@ -particle_sdk = declare_dependency(dependencies: [freetype, fontconfig, pixman, tllist]) +particle_sdk = declare_dependency(dependencies: [pixman, tllist, fcft]) particles = [] foreach particle : ['empty', 'list', 'map', 'progress-bar', 'ramp', 'string'] diff --git a/subprojects/fcft b/subprojects/fcft new file mode 160000 index 0000000..6976022 --- /dev/null +++ b/subprojects/fcft @@ -0,0 +1 @@ +Subproject commit 69760222af15611216d2e6b38f004d5ad2377651 From efd27c41adf24f800ab8b004cd53b514e7796f87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 1 Dec 2019 16:01:39 +0100 Subject: [PATCH 4/4] PKGBUILD: we depend on tllist and fcft instead of fontconfig/freetype --- PKGBUILD | 5 +++-- PKGBUILD.wayland-only | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/PKGBUILD b/PKGBUILD index 2c15630..b0de147 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -9,12 +9,13 @@ makedepends=('meson' 'ninja' 'scdoc') depends=( 'libxcb' 'xcb-util' 'xcb-util-cursor' 'xcb-util-wm' 'wayland' 'wlroots' - 'freetype2' 'fontconfig' 'pixman' + 'pixman' 'libyaml' 'alsa-lib' 'libudev.so' 'json-c' - 'libmpdclient') + 'libmpdclient' + 'tllist' 'fcft') optdepends=('xcb-util-errors: better X error messages') source=() diff --git a/PKGBUILD.wayland-only b/PKGBUILD.wayland-only index 5abc202..48ebeae 100644 --- a/PKGBUILD.wayland-only +++ b/PKGBUILD.wayland-only @@ -10,12 +10,13 @@ provides=('yambar') makedepends=('meson' 'ninja' 'scdoc') depends=( 'wayland' 'wlroots' - 'freetype2' 'fontconfig' 'pixman' + 'pixman' 'libyaml' 'alsa-lib' 'libudev.so' 'json-c' - 'libmpdclient') + 'libmpdclient' + 'tllist' 'fcft') source=() pkgver() {