summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--html/en/drv/printer.html6
-rw-r--r--html/en/history.html2
-rw-r--r--src/win32/cdwin.c9
-rw-r--r--src/win32/cdwprn.c41
4 files changed, 48 insertions, 10 deletions
diff --git a/html/en/drv/printer.html b/html/en/drv/printer.html
index 25da760..3ef31d4 100644
--- a/html/en/drv/printer.html
+++ b/html/en/drv/printer.html
@@ -78,6 +78,12 @@ before creating the canvas.</p>
driver (GDI).</li>
</ul>
+<h4>Exclusive Attributes</h4>
+<ul>
+ <li><strong><font face="Courier">&quot;PRINTERNAME&quot;</font></strong>: Returns
+ the name of the selected printer.</li>
+</ul>
+
</body>
</html>
diff --git a/html/en/history.html b/html/en/history.html
index 1a1b8e8..083ef88 100644
--- a/html/en/history.html
+++ b/html/en/history.html
@@ -35,6 +35,8 @@
driver.</li>
<li><span style="color: #0000FF">New:</span>
&quot;FREETYPEVERSION&quot; attribute for the Simulation base driver.</li>
+ <li><span style="color: #0000FF">New:</span>
+ &quot;PRINTERNAME&quot; attribute for the CD_PRINTER base driver. </li>
<li><span class="style1">Changed</span><span class="hist_changed">:</span>
Freetype updated to version 2.3.11.</li>
<li><span class="style1">Changed</span><span class="hist_changed">:</span>
diff --git a/src/win32/cdwin.c b/src/win32/cdwin.c
index 3b04497..4b38187 100644
--- a/src/win32/cdwin.c
+++ b/src/win32/cdwin.c
@@ -575,6 +575,12 @@ static void cdstipple(cdCtxCanvas* ctxcanvas, int w, int h, const unsigned char
DeleteObject(hBitmap);
}
+static void set_dib_res(cdwDIB* dib, cdCtxCanvas* ctxcanvas)
+{
+ dib->bmih->biXPelsPerMeter = (LONG)(ctxcanvas->canvas->xres*1000);
+ dib->bmih->biYPelsPerMeter = (LONG)(ctxcanvas->canvas->yres*1000);
+}
+
static void cdpattern(cdCtxCanvas* ctxcanvas, int w, int h, const long int *colors)
{
cdwDIB dib;
@@ -589,6 +595,9 @@ static void cdpattern(cdCtxCanvas* ctxcanvas, int w, int h, const long int *colo
if (!cdwCreateDIB(&dib))
return;
+ /* important to preserve pattern size during printing */
+ set_dib_res(&dib, ctxcanvas);
+
cdwDIBEncodePattern(&dib, colors);
hBrush = CreateDIBPatternBrushPt(dib.dib, DIB_RGB_COLORS);
cdwKillDIB(&dib);
diff --git a/src/win32/cdwprn.c b/src/win32/cdwprn.c
index 95e4aca..1b3e1e0 100644
--- a/src/win32/cdwprn.c
+++ b/src/win32/cdwprn.c
@@ -28,6 +28,9 @@ static void cdkillcanvas (cdCtxCanvas *ctxcanvas)
cdwKillCanvas(ctxcanvas);
DeleteDC(ctxcanvas->hDC);
+
+ if (ctxcanvas->filename)
+ free(ctxcanvas->filename);
memset(ctxcanvas, 0, sizeof(cdCtxCanvas));
free(ctxcanvas);
@@ -46,6 +49,18 @@ static void cdflush(cdCtxCanvas *ctxcanvas)
cdwRestoreDC(ctxcanvas);
}
+static char* get_printername_attrib(cdCtxCanvas* ctxcanvas)
+{
+ return ctxcanvas->filename;
+}
+
+static cdAttribute printername_attrib =
+{
+ "PRINTERNAME",
+ NULL,
+ get_printername_attrib
+};
+
/*
%F cdCreateCanvas para Impresora.
Usa a impressora default.
@@ -123,24 +138,30 @@ static void cdcreatecanvas(cdCanvas* canvas, void *data)
canvas->w = GetDeviceCaps(hDC, HORZRES);
canvas->h = GetDeviceCaps(hDC, VERTRES);
- canvas->w_mm = (double) GetDeviceCaps(hDC, HORZSIZE);
- canvas->h_mm = (double) GetDeviceCaps(hDC, VERTSIZE);
+ canvas->w_mm = (double)GetDeviceCaps(hDC, HORZSIZE);
+ canvas->h_mm = (double)GetDeviceCaps(hDC, VERTSIZE);
canvas->bpp = GetDeviceCaps(hDC, BITSPIXEL);
- canvas->xres = canvas->w / canvas->w_mm;
- canvas->yres = canvas->h / canvas->h_mm;
+ canvas->xres = (double)canvas->w / canvas->w_mm;
+ canvas->yres = (double)canvas->h / canvas->h_mm;
ctxcanvas->clip_pnt[2].x = ctxcanvas->clip_pnt[1].x = canvas->w - 1;
ctxcanvas->clip_pnt[3].y = ctxcanvas->clip_pnt[2].y = canvas->h - 1;
- /* PDF Writer returns bpp=1, so we check if color is supported and overwrite this value */
- if (canvas->bpp==1 && pd.hDevNames)
+ if (pd.hDevNames)
{
unsigned char* devnames = (unsigned char*)GlobalLock(pd.hDevNames);
DEVNAMES* dn = (DEVNAMES*)devnames;
- char* name = (char*)(devnames + dn->wDeviceOffset);
- char* port = (char*)(devnames + dn->wOutputOffset);
+ char* device = (char*)(devnames + dn->wDeviceOffset);
+
+ ctxcanvas->filename = cdStrDup(device);
+ cdRegisterAttribute(canvas, &printername_attrib);
- if (DeviceCapabilities(name, port, DC_COLORDEVICE, NULL, NULL))
- canvas->bpp = 24;
+ /* PDF Writer returns bpp=1, so we check if color is supported and overwrite this value */
+ if (canvas->bpp==1)
+ {
+ char* port = (char*)(devnames + dn->wOutputOffset);
+ if (DeviceCapabilities(device, port, DC_COLORDEVICE, NULL, NULL))
+ canvas->bpp = 24;
+ }
GlobalUnlock(pd.hDevNames);
}