From 398b1aba2b9ce2d51027ff3aa26d6bf4ea6735df Mon Sep 17 00:00:00 2001 From: Robin Stuart Date: Tue, 4 Aug 2020 13:12:47 +0100 Subject: [PATCH] Correct EMF bug: text does not change colour --- backend/emf.c | 13 ++++++++++++- backend/emf.h | 6 ++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/backend/emf.c b/backend/emf.c index cabf5bd5..dece436c 100644 --- a/backend/emf.c +++ b/backend/emf.c @@ -207,6 +207,7 @@ INTERNAL int emf_plot(struct zint_symbol *symbol) { emr_selectobject_t emr_selectobject_pen; emr_rectangle_t background; emr_extcreatefontindirectw_t emr_extcreatefontindirectw; + emr_settextcolor_t emr_settextcolor; emr_selectobject_t emr_selectobject_font; //emr_extcreatefontindirectw_t emr_extcreatefontindirectw_big; //emr_selectobject_t emr_selectobject_font_big; @@ -493,12 +494,21 @@ INTERNAL int emf_plot(struct zint_symbol *symbol) { utfle_copy(emr_extcreatefontindirectw.elw.facename, (unsigned char*) "sans-serif", 10); bytecount += 104; recordcount++; - + emr_selectobject_font.type = 0x00000025; // EMR_SELECTOBJECT emr_selectobject_font.size = 12; emr_selectobject_font.ih_object = 4; bytecount += 12; recordcount++; + + emr_settextcolor.type = 0x0000018; // EMR_SETTEXTCOLOR + emr_settextcolor.size = 12; + emr_settextcolor.color.red = fgred; + emr_settextcolor.color.green = fggrn; + emr_settextcolor.color.blue = fgblu; + emr_settextcolor.color.reserved = 0; + bytecount += 12; + recordcount++; } //Text @@ -643,6 +653,7 @@ INTERNAL int emf_plot(struct zint_symbol *symbol) { // Text if (string_count > 0) { fwrite(&emr_selectobject_font, sizeof (emr_selectobject_t), 1, emf_file); + fwrite(&emr_settextcolor, sizeof (emr_settextcolor_t), 1, emf_file); } /* Suppresses clang-tidy clang-analyzer-core.UndefinedBinaryOperatorResult warning */ diff --git a/backend/emf.h b/backend/emf.h index 5ecb23dc..4182e187 100644 --- a/backend/emf.h +++ b/backend/emf.h @@ -187,6 +187,12 @@ extern "C" { log_font_t elw; } emr_extcreatefontindirectw_t; + typedef struct emr_settextcolor { + uint32_t type; + uint32_t size; + color_ref_t color; + } emr_settextcolor_t; + typedef struct emr_exttextoutw { uint32_t type; uint32_t size;