[2/3] wineps.drv: Allow text copy paste from print to pdf
Daniel Horn
danielrh at dropbox.com
Mon Sep 8 23:19:54 CDT 2014
additional -Werror fix
-------------- next part --------------
From ae1d1098ec178e371dbdb000b255c1bcb55aaa03 Mon Sep 17 00:00:00 2001
From: Daniel Reiter Horn <danielrh at dropbox.com>
Date: Fri, 5 Sep 2014 03:08:36 +0000
Subject: [PATCH 2/3] Allow text copy/paste from print-to-pdf
Fixes http://bugs.winehq.org/show_bug.cgi?id=6416 by using unicode
encodings for fonts.
This patch has been tested on hundreds of print jobs under linux ubuntu 12.04
with a wide array of applications
---
dlls/wineps.drv/download.c | 17 ++++++++++-------
dlls/wineps.drv/psdrv.h | 4 ++--
dlls/wineps.drv/text.c | 16 ++++++++--------
dlls/wineps.drv/type42.c | 2 +-
4 files changed, 21 insertions(+), 18 deletions(-)
diff --git a/dlls/wineps.drv/download.c b/dlls/wineps.drv/download.c
index d3e818e..7f8ddb9 100644
--- a/dlls/wineps.drv/download.c
+++ b/dlls/wineps.drv/download.c
@@ -342,7 +342,7 @@ BOOL PSDRV_WriteSetDownloadFont(PHYSDEV dev, BOOL vertical)
if(pdl->type == Type42) {
char g_name[MAX_G_NAME + 1];
- get_glyph_name(dev->hdc, 0, g_name);
+ get_glyph_name(dev->hdc, FALSE, 0, g_name);
T42_download_glyph(dev, pdl, 0, g_name, TRUE);
}
}
@@ -359,10 +359,12 @@ BOOL PSDRV_WriteSetDownloadFont(PHYSDEV dev, BOOL vertical)
return TRUE;
}
-void get_glyph_name(HDC hdc, WORD index, char *name)
+void get_glyph_name(HDC hdc, BOOL unicode, WORD index, char *name)
{
- /* FIXME */
- sprintf(name, "g%04x", index);
+ if(unicode)
+ sprintf(name, "uni%04X", index);
+ else
+ sprintf(name, "g%04x", index);
return;
}
@@ -372,7 +374,8 @@ void get_glyph_name(HDC hdc, WORD index, char *name)
* Download and write out a number of glyphs
*
*/
-BOOL PSDRV_WriteDownloadGlyphShow(PHYSDEV dev, const WORD *glyphs,
+BOOL PSDRV_WriteDownloadGlyphShow(PHYSDEV dev, UINT flags, const WORD *glyphs,
+ const LPCWSTR str,
UINT count)
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
@@ -383,7 +386,7 @@ BOOL PSDRV_WriteDownloadGlyphShow(PHYSDEV dev, const WORD *glyphs,
switch(physDev->font.fontinfo.Download->type) {
case Type42:
for(i = 0; i < count; i++) {
- get_glyph_name(dev->hdc, glyphs[i], g_name);
+ get_glyph_name(dev->hdc, (flags & ETO_GLYPH_INDEX) == 0, str[i], g_name);
T42_download_glyph(dev, physDev->font.fontinfo.Download, glyphs[i], g_name, TRUE);
PSDRV_WriteGlyphShow(dev, g_name);
}
@@ -391,7 +394,7 @@ BOOL PSDRV_WriteDownloadGlyphShow(PHYSDEV dev, const WORD *glyphs,
case Type1:
for(i = 0; i < count; i++) {
- get_glyph_name(dev->hdc, glyphs[i], g_name);
+ get_glyph_name(dev->hdc, (flags & ETO_GLYPH_INDEX) == 0, str[i], g_name);
T1_download_glyph(dev, physDev->font.fontinfo.Download, glyphs[i], g_name);
PSDRV_WriteGlyphShow(dev, g_name);
}
diff --git a/dlls/wineps.drv/psdrv.h b/dlls/wineps.drv/psdrv.h
index 4198716..2cabf9f 100644
--- a/dlls/wineps.drv/psdrv.h
+++ b/dlls/wineps.drv/psdrv.h
@@ -549,13 +549,13 @@ extern BOOL PSDRV_WriteBuiltinGlyphShow(PHYSDEV dev, LPCWSTR str, INT count) DEC
extern BOOL PSDRV_SelectDownloadFont(PHYSDEV dev) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteSetDownloadFont(PHYSDEV dev, BOOL vertical) DECLSPEC_HIDDEN;
-extern BOOL PSDRV_WriteDownloadGlyphShow(PHYSDEV dev, const WORD *glpyhs, UINT count) DECLSPEC_HIDDEN;
+extern BOOL PSDRV_WriteDownloadGlyphShow(PHYSDEV dev, UINT flags, const WORD *glpyhs, const LPCWSTR str, UINT count) DECLSPEC_HIDDEN;
extern BOOL PSDRV_EmptyDownloadList(PHYSDEV dev, BOOL write_undef) DECLSPEC_HIDDEN;
extern DWORD write_spool( PHYSDEV dev, const void *data, DWORD num ) DECLSPEC_HIDDEN;
#define MAX_G_NAME 31 /* max length of PS glyph name */
-extern void get_glyph_name(HDC hdc, WORD index, char *name) DECLSPEC_HIDDEN;
+extern void get_glyph_name(HDC hdc, BOOL unicode, WORD index, char *name) DECLSPEC_HIDDEN;
extern TYPE1 *T1_download_header(PHYSDEV dev, char *ps_name,
RECT *bbox, UINT emsize) DECLSPEC_HIDDEN;
diff --git a/dlls/wineps.drv/text.c b/dlls/wineps.drv/text.c
index 96728ca..b85784d 100644
--- a/dlls/wineps.drv/text.c
+++ b/dlls/wineps.drv/text.c
@@ -205,12 +205,12 @@ BOOL PSDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT *lprect
/***********************************************************************
* PSDRV_Text
*/
+#define DEFAULT_PARAGRAPH_SIZE 16384
static BOOL PSDRV_Text(PHYSDEV dev, INT x, INT y, UINT flags, LPCWSTR str,
UINT count, BOOL bDrawBackground, const INT *lpDx)
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
- WORD *glyphs = NULL;
-
+ LPCWSTR glyphs = str;
if (!count)
return TRUE;
@@ -218,14 +218,13 @@ static BOOL PSDRV_Text(PHYSDEV dev, INT x, INT y, UINT flags, LPCWSTR str,
{
glyphs = HeapAlloc( GetProcessHeap(), 0, count * sizeof(WORD) );
GetGlyphIndicesW( dev->hdc, str, count, glyphs, 0 );
- str = glyphs;
}
PSDRV_WriteMoveTo(dev, x, y);
if(!lpDx) {
if(physDev->font.fontloc == Download)
- PSDRV_WriteDownloadGlyphShow(dev, str, count);
+ PSDRV_WriteDownloadGlyphShow(dev, flags, glyphs, str, count);
else
PSDRV_WriteBuiltinGlyphShow(dev, str, count);
}
@@ -235,7 +234,7 @@ static BOOL PSDRV_Text(PHYSDEV dev, INT x, INT y, UINT flags, LPCWSTR str,
for(i = 0; i < count-1; i++) {
if(physDev->font.fontloc == Download)
- PSDRV_WriteDownloadGlyphShow(dev, str + i, 1);
+ PSDRV_WriteDownloadGlyphShow(dev, flags, glyphs + i, str + i, 1);
else
PSDRV_WriteBuiltinGlyphShow(dev, str + i, 1);
if(flags & ETO_PDY)
@@ -248,11 +247,12 @@ static BOOL PSDRV_Text(PHYSDEV dev, INT x, INT y, UINT flags, LPCWSTR str,
PSDRV_WriteMoveTo(dev, x + offset.x, y + offset.y);
}
if(physDev->font.fontloc == Download)
- PSDRV_WriteDownloadGlyphShow(dev, str + i, 1);
+ PSDRV_WriteDownloadGlyphShow(dev, flags, glyphs + i, str + i, 1);
else
PSDRV_WriteBuiltinGlyphShow(dev, str + i, 1);
}
-
- HeapFree( GetProcessHeap(), 0, glyphs );
+ if (glyphs != str) {
+ HeapFree( GetProcessHeap(), 0, glyphs );
+ }
return TRUE;
}
diff --git a/dlls/wineps.drv/type42.c b/dlls/wineps.drv/type42.c
index 8e23c43..6265f1c 100644
--- a/dlls/wineps.drv/type42.c
+++ b/dlls/wineps.drv/type42.c
@@ -326,7 +326,7 @@ BOOL T42_download_glyph(PHYSDEV dev, DOWNLOAD *pdl, DWORD index,
sg_index = GET_BE_WORD(sg_start + 2);
TRACE("Sending subglyph %04x for glyph %04x\n", sg_index, index);
- get_glyph_name(dev->hdc, sg_index, sg_name);
+ get_glyph_name(dev->hdc, FALSE, sg_index, sg_name);
T42_download_glyph(dev, pdl, sg_index, sg_name, FALSE);
sg_start += 4;
if(sg_flags & ARG_1_AND_2_ARE_WORDS)
--
1.8.4.2
More information about the wine-patches
mailing list