Module: wine Branch: master Commit: 19eab9c0e59201277f359d55ee5747383e014e87 URL: https://gitlab.winehq.org/wine/wine/-/commit/19eab9c0e59201277f359d55ee57473...
Author: Piotr Caban piotr@codeweavers.com Date: Tue May 9 17:47:06 2023 +0200
wineps: Store font substitution table in DEVMODE.
---
dlls/wineps.drv/init.c | 23 ++++++++++++++++++----- dlls/wineps.drv/psdrv.h | 1 + dlls/wineps.drv/unixlib.c | 37 +++++++++++++++++++------------------ dlls/wineps.drv/unixlib.h | 6 ++++++ 4 files changed, 44 insertions(+), 23 deletions(-)
diff --git a/dlls/wineps.drv/init.c b/dlls/wineps.drv/init.c index c5f97c85073..0da75ac60c9 100644 --- a/dlls/wineps.drv/init.c +++ b/dlls/wineps.drv/init.c @@ -503,10 +503,11 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCWSTR name) WCHAR *ppd_filename = NULL; char *nameA = NULL; BOOL using_default_devmode = FALSE; - int len, input_slots, resolutions, page_sizes, size; + int i, len, input_slots, resolutions, page_sizes, font_subs, size; struct input_slot *dm_slot; struct resolution *dm_res; struct page_size *dm_page; + struct font_sub *dm_sub; INPUTSLOT *slot; RESOLUTION *res; PAGESIZE *page; @@ -544,11 +545,17 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCWSTR name) goto fail; }
+ pi->FontSubTable = load_font_sub_table( hPrinter, &pi->FontSubTableSize ); + input_slots = list_count( &pi->ppd->InputSlots ); resolutions = list_count( &pi->ppd->Resolutions ); page_sizes = list_count( &pi->ppd->PageSizes ); - size = FIELD_OFFSET(PSDRV_DEVMODE, data[input_slots * sizeof(struct input_slot) + - resolutions * sizeof(struct resolution) + page_sizes * sizeof(struct page_size)]); + font_subs = pi->FontSubTableSize; + size = FIELD_OFFSET(PSDRV_DEVMODE, data[ + input_slots * sizeof(struct input_slot) + + resolutions * sizeof(struct resolution) + + page_sizes * sizeof(struct page_size) + + font_subs * sizeof(struct font_sub)]);
pi->Devmode = get_devmode( hPrinter, name, &using_default_devmode, size ); if (!pi->Devmode) goto fail; @@ -622,6 +629,14 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCWSTR name) dm_page->win_page = page->WinPage; dm_page++; } + + dm_sub = (struct font_sub *)dm_page; + for (i = 0; i < font_subs; i++) + { + lstrcpynW(dm_sub->name, pi->FontSubTable[i].pValueName, ARRAY_SIZE(dm_sub->name)); + lstrcpynW(dm_sub->sub, (WCHAR *)pi->FontSubTable[i].pData, ARRAY_SIZE(dm_sub->sub)); + dm_sub++; + } }
/* Duplex is indicated by the setting of the DM_DUPLEX bit in dmFields. @@ -640,8 +655,6 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCWSTR name)
set_devmode( hPrinter, pi->Devmode );
- pi->FontSubTable = load_font_sub_table( hPrinter, &pi->FontSubTableSize ); - LIST_FOR_EACH_ENTRY( font, &pi->ppd->InstalledFonts, FONTNAME, entry ) { afm = PSDRV_FindAFMinList(PSDRV_AFMFontList, font->Name); diff --git a/dlls/wineps.drv/psdrv.h b/dlls/wineps.drv/psdrv.h index 30ca6755cc6..29ce1e80d9d 100644 --- a/dlls/wineps.drv/psdrv.h +++ b/dlls/wineps.drv/psdrv.h @@ -227,6 +227,7 @@ typedef struct { int input_slots; int resolutions; int page_sizes; + int font_subs; BYTE data[1]; } PSDRV_DEVMODE;
diff --git a/dlls/wineps.drv/unixlib.c b/dlls/wineps.drv/unixlib.c index 1ca87461d17..792a2ad69d3 100644 --- a/dlls/wineps.drv/unixlib.c +++ b/dlls/wineps.drv/unixlib.c @@ -1050,9 +1050,11 @@ static HFONT CDECL select_font(PHYSDEV dev, HFONT hfont, UINT *aa_flags) { PSDRV_PDEVICE *pdev = get_psdrv_dev(dev); PHYSDEV next = GET_NEXT_PHYSDEV(dev, pSelectFont); + const struct font_sub *font_sub; HFONT ret; LOGFONTW lf; BOOL subst = FALSE; + int i;
if (!NtGdiExtGetObjectW(hfont, sizeof(lf), &lf)) return 0;
@@ -1097,28 +1099,27 @@ static HFONT CDECL select_font(PHYSDEV dev, HFONT hfont, UINT *aa_flags) } }
- if (pdev->pi->pi->FontSubTableSize != 0) + font_sub = (const struct font_sub *)(pdev->devmode->data + + pdev->devmode->input_slots * sizeof(struct input_slot) + + pdev->devmode->resolutions * sizeof(struct resolution) + + pdev->devmode->page_sizes * sizeof(struct page_size)); + for (i = 0; i < pdev->devmode->font_subs; i++) { - DWORD i; - - for (i = 0; i < pdev->pi->pi->FontSubTableSize; ++i) + if (!wcsicmp(lf.lfFaceName, font_sub[i].name)) { - if (!wcsicmp(lf.lfFaceName, pdev->pi->pi->FontSubTable[i].pValueName)) + TRACE("substituting facename %s for %s\n", + debugstr_w(font_sub[i].sub), debugstr_w(lf.lfFaceName)); + if (wcslen(font_sub[i].sub) < LF_FACESIZE) { - TRACE("substituting facename %s for %s\n", - debugstr_w((WCHAR *)pdev->pi->pi->FontSubTable[i].pData), debugstr_w(lf.lfFaceName)); - if (wcslen((WCHAR *)pdev->pi->pi->FontSubTable[i].pData) < LF_FACESIZE) - { - wcscpy(lf.lfFaceName, (WCHAR *)pdev->pi->pi->FontSubTable[i].pData); - subst = TRUE; - } - else - { - WARN("Facename %s is too long; ignoring substitution\n", - debugstr_w((WCHAR *)pdev->pi->pi->FontSubTable[i].pData)); - } - break; + wcscpy(lf.lfFaceName, font_sub[i].sub); + subst = TRUE; } + else + { + WARN("Facename %s is too long; ignoring substitution\n", + debugstr_w(font_sub[i].sub)); + } + break; } }
diff --git a/dlls/wineps.drv/unixlib.h b/dlls/wineps.drv/unixlib.h index 1c71d758a91..931bc14c152 100644 --- a/dlls/wineps.drv/unixlib.h +++ b/dlls/wineps.drv/unixlib.h @@ -60,6 +60,12 @@ struct page_size short win_page; };
+struct font_sub +{ + WCHAR name[LF_FACESIZE]; + WCHAR sub[LF_FACESIZE]; +}; + /* Unix calls */ enum wineps_funcs {