From 5bd71990de55e5c944559a3829a8d4e1fb96153f Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 21 Jan 2023 12:04:25 +0100 Subject: Add libfonts_get_subpixel_expansion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libfonts_get_subpixel_expansion.c | 52 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 libfonts_get_subpixel_expansion.c (limited to 'libfonts_get_subpixel_expansion.c') diff --git a/libfonts_get_subpixel_expansion.c b/libfonts_get_subpixel_expansion.c new file mode 100644 index 0000000..99f72ba --- /dev/null +++ b/libfonts_get_subpixel_expansion.c @@ -0,0 +1,52 @@ +/* See LICENSE file for copyright and license details. */ +#include "common.h" +#ifndef TEST + + +int +libfonts_get_subpixel_expansion(enum libfonts_subpixel_order_class layout, size_t *restrict widthmulp, size_t *restrict heightmulp) +{ + size_t w, h; + + if (layout == LIBFONTS_SUBPIXEL_ORDER_CLASS_123) { + w = 3; + h = 1; + } else if (layout == LIBFONTS_SUBPIXEL_ORDER_CLASS_1_2_3) { + w = 1; + h = 3; + } else if (layout >= LIBFONTS_SUBPIXEL_ORDER_CLASS_11_23 && + layout <= LIBFONTS_SUBPIXEL_ORDER_CLASS_13_12) { + w = 2; + h = 2; + } else if (layout == LIBFONTS_SUBPIXEL_ORDER_CLASS_BALANCED_11_23 || + layout == LIBFONTS_SUBPIXEL_ORDER_CLASS_BALANCED_32_11) { + w = 2; + h = 3; + } else if (layout == LIBFONTS_SUBPIXEL_ORDER_CLASS_BALANCED_21_31 || + layout == LIBFONTS_SUBPIXEL_ORDER_CLASS_BALANCED_13_12) { + w = 3; + h = 2; + } else { + errno = EINVAL; + return -1; + } + + if (widthmulp) + *widthmulp = w; + if (heightmulp) + *heightmulp = h; + return 0; +} + + +#else + + +int +main(void) +{ + return 0; +} + + +#endif -- cgit v1.2.3-70-g09d2