Module: wine Branch: master Commit: d1b09fa24c1d5007af91a1a9d5ea8a617da37683 URL: https://gitlab.winehq.org/wine/wine/-/commit/d1b09fa24c1d5007af91a1a9d5ea8a6...
Author: Piotr Caban piotr@codeweavers.com Date: Sat May 6 12:24:01 2023 +0200
wineps: Introduce PSDRV_GET_GLYPH_NAME escape to obtain builtin glyph name from unixlib.
---
dlls/wineps.drv/builtin.c | 7 +++-- dlls/wineps.drv/unixlib.c | 67 +++++++++++++++++++++++++++-------------------- dlls/wineps.drv/unixlib.h | 2 ++ 3 files changed, 44 insertions(+), 32 deletions(-)
diff --git a/dlls/wineps.drv/builtin.c b/dlls/wineps.drv/builtin.c index 74ffda36f92..4fdbc58f099 100644 --- a/dlls/wineps.drv/builtin.c +++ b/dlls/wineps.drv/builtin.c @@ -31,6 +31,7 @@ #include "winternl.h"
#include "psdrv.h" +#include "unixlib.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(psdrv); @@ -244,14 +245,12 @@ BOOL PSDRV_WriteSetBuiltinFont(PHYSDEV dev)
BOOL PSDRV_WriteBuiltinGlyphShow(PHYSDEV dev, LPCWSTR str, INT count) { - PSDRV_PDEVICE *physDev = get_psdrv_dev( dev ); + char name[32]; int i; - LPCSTR name;
for (i = 0; i < count; ++i) { - name = PSDRV_UVMetrics(str[i], physDev->font.fontinfo.Builtin.afm)->N->sz; - + ExtEscape(dev->hdc, PSDRV_GET_GLYPH_NAME, sizeof(str[i]), (const char *)&str[i], sizeof(name), name); PSDRV_WriteGlyphShow(dev, name); }
diff --git a/dlls/wineps.drv/unixlib.c b/dlls/wineps.drv/unixlib.c index 72f63c81300..36971f65495 100644 --- a/dlls/wineps.drv/unixlib.c +++ b/dlls/wineps.drv/unixlib.c @@ -518,6 +518,34 @@ static BOOL CDECL reset_dc(PHYSDEV dev, const DEVMODEW *devmode) return TRUE; }
+static int metrics_by_uv(const void *a, const void *b) +{ + return (int)(((const AFMMETRICS *)a)->UV - ((const AFMMETRICS *)b)->UV); +} + +const AFMMETRICS *uv_metrics(LONG uv, const AFM *afm) +{ + const AFMMETRICS *needle; + AFMMETRICS key; + + /* + * Ugly work-around for symbol fonts. Wine is sending characters which + * belong in the Unicode private use range (U+F020 - U+F0FF) as ASCII + * characters (U+0020 - U+00FF). + */ + if ((afm->Metrics->UV & 0xff00) == 0xf000 && uv < 0x100) + uv |= 0xf000; + + key.UV = uv; + needle = bsearch(&key, afm->Metrics, afm->NumofMetrics, sizeof(AFMMETRICS), metrics_by_uv); + if (!needle) + { + WARN("No glyph for U+%.4X in '%s'\n", (int)uv, afm->FontName); + needle = afm->Metrics; + } + return needle; +} + static int CDECL ext_escape(PHYSDEV dev, int escape, int input_size, const void *input, int output_size, void *output) { @@ -770,6 +798,17 @@ 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: + { + PSDRV_PDEVICE *pdev = get_psdrv_dev(dev); + WCHAR *uv = (WCHAR *)input; + const char *name = uv_metrics(*uv, pdev->font.fontinfo.Builtin.afm)->N->sz; + + lstrcpynA(output, name, output_size); + return 1; + } + default: FIXME("Unimplemented code %d\n", escape); return 0; @@ -1135,34 +1174,6 @@ static BOOL CDECL enum_fonts(PHYSDEV dev, LPLOGFONTW plf, FONTENUMPROCW proc, LP return ret; }
-static int metrics_by_uv(const void *a, const void *b) -{ - return (int)(((const AFMMETRICS *)a)->UV - ((const AFMMETRICS *)b)->UV); -} - -const AFMMETRICS *uv_metrics(LONG uv, const AFM *afm) -{ - const AFMMETRICS *needle; - AFMMETRICS key; - - /* - * Ugly work-around for symbol fonts. Wine is sending characters which - * belong in the Unicode private use range (U+F020 - U+F0FF) as ASCII - * characters (U+0020 - U+00FF). - */ - if ((afm->Metrics->UV & 0xff00) == 0xf000 && uv < 0x100) - uv |= 0xf000; - - key.UV = uv; - needle = bsearch(&key, afm->Metrics, afm->NumofMetrics, sizeof(AFMMETRICS), metrics_by_uv); - if (!needle) - { - WARN("No glyph for U+%.4X in '%s'\n", (int)uv, afm->FontName); - needle = afm->Metrics; - } - return needle; -} - static BOOL CDECL get_char_width(PHYSDEV dev, UINT first, UINT count, const WCHAR *chars, INT *buffer) { PSDRV_PDEVICE *pdev = get_psdrv_dev(dev); diff --git a/dlls/wineps.drv/unixlib.h b/dlls/wineps.drv/unixlib.h index 95efdd4c310..eb82188807c 100644 --- a/dlls/wineps.drv/unixlib.h +++ b/dlls/wineps.drv/unixlib.h @@ -19,6 +19,8 @@ #include "ntuser.h" #include "wine/unixlib.h"
+#define PSDRV_GET_GLYPH_NAME 0x10000 + enum wineps_funcs { unix_init_dc,