Module: wine Branch: master Commit: 82ef9166a71155d89a1dda2916a41083c18fcd06 URL: https://gitlab.winehq.org/wine/wine/-/commit/82ef9166a71155d89a1dda2916a4108...
Author: Piotr Caban piotr@codeweavers.com Date: Sun May 14 14:28:33 2023 +0200
wineps: Convert WCHAR to Adobe Glyph name on PE side.
---
dlls/wineps.drv/builtin.c | 26 ++++++++++++++++++++++++-- dlls/wineps.drv/unixlib.c | 7 ++++--- dlls/wineps.drv/unixlib.h | 2 +- 3 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/dlls/wineps.drv/builtin.c b/dlls/wineps.drv/builtin.c index 2a2c9106f12..d62d4fc134f 100644 --- a/dlls/wineps.drv/builtin.c +++ b/dlls/wineps.drv/builtin.c @@ -50,14 +50,36 @@ BOOL PSDRV_WriteSetBuiltinFont(print_ctx *ctx) font_info.escapement, FALSE); }
+static int __cdecl agl_by_uv(const void *a, const void *b) +{ + return (int)(((const UNICODEGLYPH *)a)->UV - ((const UNICODEGLYPH *)b)->UV); +} + +static const char *find_ag_name(WCHAR wch) +{ + UNICODEGLYPH key = { .UV = wch }; + UNICODEGLYPH *needle; + + needle = bsearch(&key, PSDRV_AGLbyUV, PSDRV_AGLbyUVSize, sizeof(key), agl_by_uv); + return needle ? needle->name->sz : NULL; +} + BOOL PSDRV_WriteBuiltinGlyphShow(print_ctx *ctx, LPCWSTR str, INT count) { - char name[32]; + const char *name; + WCHAR wch; int i;
for (i = 0; i < count; ++i) { - ExtEscape(ctx->hdc, PSDRV_GET_GLYPH_NAME, sizeof(str[i]), (const char *)&str[i], sizeof(name), name); + ExtEscape(ctx->hdc, PSDRV_CHECK_WCHAR, sizeof(str[i]), + (const char *)&str[i], sizeof(wch), (char *)&wch); + name = find_ag_name(wch); + if (!name) + { + ERR("can't find glyph name for %x\n", wch); + continue; + } PSDRV_WriteGlyphShow(ctx, name); }
diff --git a/dlls/wineps.drv/unixlib.c b/dlls/wineps.drv/unixlib.c index 792a2ad69d3..b67a1848270 100644 --- a/dlls/wineps.drv/unixlib.c +++ b/dlls/wineps.drv/unixlib.c @@ -839,13 +839,14 @@ static int CDECL ext_escape(PHYSDEV dev, int escape, int input_size, const void case CLIP_TO_PATH: return 1;
- case PSDRV_GET_GLYPH_NAME: + case PSDRV_CHECK_WCHAR: { PSDRV_PDEVICE *pdev = get_psdrv_dev(dev); WCHAR *uv = (WCHAR *)input; - const char *name = uv_metrics(*uv, pdev->afm)->N->sz; + WCHAR out = uv_metrics(*uv, pdev->afm)->UV;
- lstrcpynA(output, name, output_size); + if ((out & 0xff00) == 0xf000) out &= ~0xf000; + *(WCHAR *)output = out; return 1; }
diff --git a/dlls/wineps.drv/unixlib.h b/dlls/wineps.drv/unixlib.h index 931bc14c152..a3b1a233a4e 100644 --- a/dlls/wineps.drv/unixlib.h +++ b/dlls/wineps.drv/unixlib.h @@ -20,7 +20,7 @@ #include "wine/unixlib.h"
/* escapes */ -#define PSDRV_GET_GLYPH_NAME 0x10000 +#define PSDRV_CHECK_WCHAR 0x10000 #define PSDRV_GET_BUILTIN_FONT_INFO 0x10001
struct font_info