Commit 19eab9c0 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

wineps: Store font substitution table in DEVMODE.

parent aa3699dd
......@@ -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);
......
......@@ -227,6 +227,7 @@ typedef struct {
int input_slots;
int resolutions;
int page_sizes;
int font_subs;
BYTE data[1];
} PSDRV_DEVMODE;
......
......@@ -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;
}
}
......
......@@ -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
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment