aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2020-04-28 22:03:11 +0200
committerMattias Andrée <maandree@kth.se>2020-04-28 22:03:11 +0200
commitf531476aed448926b6ac0c746b93e6c6c587d16f (patch)
tree9f36488fddb59d3860846b7aa153f955d9516e2b
parentDocument alpha blending algorithm (diff)
downloadlibskrift-f531476aed448926b6ac0c746b93e6c6c587d16f.tar.gz
libskrift-f531476aed448926b6ac0c746b93e6c6c587d16f.tar.bz2
libskrift-f531476aed448926b6ac0c746b93e6c6c587d16f.tar.xz
Thread-safety
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rw-r--r--demo.c4
-rw-r--r--libskrift_get_grapheme_glyph.c10
2 files changed, 8 insertions, 6 deletions
diff --git a/demo.c b/demo.c
index 55bfe40..60ba4bb 100644
--- a/demo.c
+++ b/demo.c
@@ -11,7 +11,7 @@ main(void)
LIBSKRIFT_CONTEXT *ctx;
struct libskrift_image image = {LIBSKRIFT_R8G8B8A8, LIBSKRIFT_HOST_SUBPIXEL, 0, 800, 600, NULL, NULL, NULL};
struct libskrift_rendering rendering = LIBSKRIFT_DEFAULT_RENDERING;
- struct libskrift_colour colour = LIBSKRIFT_PREMULTIPLY(1, 1, .80f, .50f, .20f);
+ struct libskrift_colour colour = LIBSKRIFT_PREMULTIPLY(0.8f, 0.25f, .80f, .50f, .20f);
double height;
size_t size, i;
@@ -42,7 +42,7 @@ main(void)
((uint8_t *)image.image)[i + 0] = 32U;
((uint8_t *)image.image)[i + 1] = 48U;
((uint8_t *)image.image)[i + 2] = 64U;
- ((uint8_t *)image.image)[i + 3] = 192U;
+ ((uint8_t *)image.image)[i + 3] = 250U;
}
if (libskrift_draw_text(ctx, "hello world", &colour, 0, 300, &image) < 0) {
diff --git a/libskrift_get_grapheme_glyph.c b/libskrift_get_grapheme_glyph.c
index 14f9a1b..fa7a8c5 100644
--- a/libskrift_get_grapheme_glyph.c
+++ b/libskrift_get_grapheme_glyph.c
@@ -6,18 +6,20 @@ libskrift_get_grapheme_glyph(LIBSKRIFT_CONTEXT *ctx, libskrift_codepoint_t codep
double cursor_x, double cursor_y, struct libskrift_glyph **glyphp)
{
struct SFT_Char sft_chr;
+ struct SFT sft_ctx;
size_t size = 1, width1, width2, width3, osize, off, r, c, i;
int top = 0, left = 0, right = 0, bottom = 0;
uint16_t width, height, vmul = 1, hmul = 1;
uint8_t *image, *in_image;
memset(&sft_chr, 0, sizeof(sft_chr));
+ sft_ctx = ctx->schrift_ctx;
- ctx->schrift_ctx.x = cursor_x * (ctx->subpixel_horizontally ? 3 : 1);
- ctx->schrift_ctx.y = cursor_y * (ctx->subpixel_vertically ? 3 : 1);
- ctx->schrift_ctx.flags = SFT_DOWNWARD_Y | SFT_CHAR_IMAGE;
+ 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;
- if (sft_char(&ctx->schrift_ctx, codepoint, &sft_chr))
+ if (sft_char(&sft_ctx, codepoint, &sft_chr))
return -1;
if (ctx->subpixel_horizontally) {