aboutsummaryrefslogtreecommitdiffstats
path: root/libskrift_get_grapheme_glyph.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2021-08-18 00:17:42 +0200
committerMattias Andrée <maandree@kth.se>2021-08-18 00:17:42 +0200
commitbbec322f1c7079c0186ea3242085b4ff8267d825 (patch)
tree3f62487f71a88c74590409dc834062c58af37154 /libskrift_get_grapheme_glyph.c
parentAdd support for gzip compression and prepare for PSF support (diff)
downloadlibskrift-bbec322f1c7079c0186ea3242085b4ff8267d825.tar.gz
libskrift-bbec322f1c7079c0186ea3242085b4ff8267d825.tar.bz2
libskrift-bbec322f1c7079c0186ea3242085b4ff8267d825.tar.xz
Small fixes + other font types should be handled via conversion
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--libskrift_get_grapheme_glyph.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/libskrift_get_grapheme_glyph.c b/libskrift_get_grapheme_glyph.c
index 515e81d..e0b699d 100644
--- a/libskrift_get_grapheme_glyph.c
+++ b/libskrift_get_grapheme_glyph.c
@@ -1,9 +1,9 @@
/* See LICENSE file for copyright and license details. */
#include "common.h"
-int
-libskrift_get_grapheme_glyph(LIBSKRIFT_CONTEXT *ctx, libskrift_codepoint_t codepoint,
- double cursor_x, double cursor_y, struct libskrift_glyph **glyphp)
+static int
+get_grapheme_glyph_with_font(LIBSKRIFT_CONTEXT *ctx, libskrift_codepoint_t codepoint, double cursor_x,
+ double cursor_y, struct libskrift_glyph **glyphp, LIBSKRIFT_FONT *font)
{
struct SFT_Char sft_chr;
struct SFT sft_ctx;
@@ -15,12 +15,14 @@ libskrift_get_grapheme_glyph(LIBSKRIFT_CONTEXT *ctx, libskrift_codepoint_t codep
memset(&sft_chr, 0, sizeof(sft_chr));
sft_ctx = ctx->schrift_ctx;
+ sft_ctx.font = font->font;
sft_ctx.x = cursor_x * (ctx->subpixel_horizontally ? 3 : 1);
sft_ctx.y = cursor_y * (ctx->subpixel_vertically ? 3 : 1);
sft_ctx.flags = SFT_DOWNWARD_Y | SFT_CHAR_IMAGE;
+ errno = 0;
if (sft_char(&sft_ctx, codepoint, &sft_chr))
- return -1;
+ return errno ? -1 : 1;
if (ctx->subpixel_horizontally) {
hmul = 3;
@@ -99,3 +101,20 @@ libskrift_get_grapheme_glyph(LIBSKRIFT_CONTEXT *ctx, libskrift_codepoint_t codep
free(sft_chr.image);
return 0;
}
+
+int
+libskrift_get_grapheme_glyph(LIBSKRIFT_CONTEXT *ctx, libskrift_codepoint_t codepoint,
+ double cursor_x, double cursor_y, struct libskrift_glyph **glyphp)
+{
+ size_t i;
+ int r;
+
+ for (i = 0; i < ctx->nfonts; i++) {
+ r = get_grapheme_glyph_with_font(ctx, codepoint, cursor_x, cursor_y, glyphp, ctx->fonts[i]);
+ if (r <= 0)
+ return r;
+ }
+
+ /* TODO add callback for drawing fallback glyph, draw square by default. */
+ return -1;
+}