The R Project SVN R

Rev

Rev 6458 | Rev 6648 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6458 Rev 6625
Line 70... Line 70...
70
 
70
 
71
typedef struct {
71
typedef struct {
72
    /* R Graphics Parameters */
72
    /* R Graphics Parameters */
73
    /* local device copy so that we can detect */
73
    /* local device copy so that we can detect */
74
    /* when parameter changes */
74
    /* when parameter changes */
75
    int   col;			/* Color */
75
    int   col;			   /* Color */
76
    int   fg;			/* Foreground */
76
    int   fg;			   /* Foreground */
77
    int   bg;			/* Background */
77
    int   bg;			   /* Background */
78
    int   fontface;		/* Typeface */
78
    int   fontface;		   /* Typeface */
79
    int   fontsize;		/* Size in points */
79
    int   fontsize, basefontsize;  /* Size in points */
80
    double fontangle;
80
    double fontangle;
81
 
81
 
82
    /* X11 Driver Specific */
82
    /* X11 Driver Specific */
83
    /* parameters with copy per x11 device */
83
    /* parameters with copy per x11 device */
84
 
84
 
Line 370... Line 370...
370
 
370
 
371
 
371
 
372
static int SetBaseFont(x11Desc *xd)
372
static int SetBaseFont(x11Desc *xd)
373
{
373
{
374
    xd->fontface = 1;
374
    xd->fontface = 1;
375
    xd->fontsize = 12;
375
    xd->fontsize = xd->basefontsize;
376
    xd->fontangle = 0.0;
376
    xd->fontangle = 0.0;
377
    xd->usefixed = 0;
377
    xd->usefixed = 0;
378
    xd->font = gnewfont(xd->gawin, fontname[0], fontstyle[0], 
378
    xd->font = gnewfont(xd->gawin, fontname[0], fontstyle[0], 
379
			MulDiv(12,xd->wanteddpi,xd->truedpi), 0.0);
379
			MulDiv(xd->fontsize,xd->wanteddpi,xd->truedpi), 0.0);
380
    if (!xd->font) {
380
    if (!xd->font) {
381
	xd->usefixed = 1;
381
	xd->usefixed = 1;
382
	xd->font = xd->fixedfont = FixedFont;
382
	xd->font = xd->fixedfont = FixedFont;
383
	if (!xd->fixedfont)
383
	if (!xd->fixedfont)
384
	    return 0;
384
	    return 0;
Line 386... Line 386...
386
    return 1;
386
    return 1;
387
}
387
}
388
 
388
 
389
 
389
 
390
 
390
 
391
 /* Set the font size and face */
391
/* Set the font size and face */
392
/* If the font of this size and at that the specified */
392
/* If the font of this size and at that the specified */
393
/* rotation is not present it is loaded. */
393
/* rotation is not present it is loaded. */
394
/* 0 = plain text, 1 = bold */
394
/* 0 = plain text, 1 = bold */
395
/* 2 = oblique, 3 = bold-oblique */
395
/* 2 = oblique, 3 = bold-oblique */
396
 
396
 
Line 1249... Line 1249...
1249
				rect(0, 0, MM_PER_INCH * w, MM_PER_INCH * h));
1249
				rect(0, 0, MM_PER_INCH * w, MM_PER_INCH * h));
1250
	xd->kind = METAFILE;
1250
	xd->kind = METAFILE;
1251
	if (!xd->gawin)
1251
	if (!xd->gawin)
1252
	    return 0;
1252
	    return 0;
1253
    }
1253
    }
-
 
1254
    xd->truedpi = devicepixelsy(xd->gawin);
-
 
1255
    if ((xd->kind==PNG) || (xd->kind==JPEG) || (xd->kind==BMP)) 
-
 
1256
      xd->wanteddpi = 72 ;
-
 
1257
    else
-
 
1258
      xd->wanteddpi = xd->truedpi;
1254
    if (!SetBaseFont(xd)) {
1259
    if (!SetBaseFont(xd)) {
1255
	Rprintf("can't find any fonts\n");
1260
	Rprintf("can't find any fonts\n");
1256
	del(xd->gawin);
1261
	del(xd->gawin);
1257
	if (xd->kind==SCREEN) del(xd->bm);
1262
	if (xd->kind==SCREEN) del(xd->bm);
1258
	return 0;
1263
	return 0;
1259
    }
1264
    }
1260
    rr = getrect(xd->gawin);
1265
    rr = getrect(xd->gawin);
1261
    xd->windowWidth = rr.width;
1266
    xd->windowWidth = rr.width;
1262
    xd->windowHeight = rr.height;
1267
    xd->windowHeight = rr.height;
1263
    xd->clip = rr;
1268
    xd->clip = rr;
1264
    xd->truedpi = devicepixelsy(xd->gawin);
-
 
1265
    if ((xd->kind==PNG) || (xd->kind==JPEG) || (xd->kind==BMP)) 
-
 
1266
      xd->wanteddpi = 72 ;
-
 
1267
    else
-
 
1268
      xd->wanteddpi = xd->truedpi;
-
 
1269
    setdata(xd->gawin, (void *) dd);
1269
    setdata(xd->gawin, (void *) dd);
1270
    xd->needsave = 0;
1270
    xd->needsave = 0;
1271
    return 1;
1271
    return 1;
1272
}
1272
}
1273
 
1273
 
Line 1324... Line 1324...
1324
static void X11_Clip(double x0, double x1, double y0, double y1, DevDesc *dd)
1324
static void X11_Clip(double x0, double x1, double y0, double y1, DevDesc *dd)
1325
{
1325
{
1326
    x11Desc *xd = (x11Desc *) dd->deviceSpecific;
1326
    x11Desc *xd = (x11Desc *) dd->deviceSpecific;
1327
 
1327
 
1328
    xd->clip = rcanon(rpt(pt(x0, y0), pt(x1, y1)));
1328
    xd->clip = rcanon(rpt(pt(x0, y0), pt(x1, y1)));
-
 
1329
    xd->clip.width  += 1;
-
 
1330
    xd->clip.height += 1;
1329
}
1331
}
1330
 
1332
 
1331
	/********************************************************/
1333
	/********************************************************/
1332
	/* device_Resize is called whenever the device is 	*/
1334
	/* device_Resize is called whenever the device is 	*/
1333
	/* resized.  the function must update the GPar 		*/
1335
	/* resized.  the function must update the GPar 		*/
Line 1849... Line 1851...
1849
    /* must free(dd) */
1851
    /* must free(dd) */
1850
 
1852
 
1851
    int   ps;
1853
    int   ps;
1852
    x11Desc *xd;
1854
    x11Desc *xd;
1853
    rect  rr;
1855
    rect  rr;
-
 
1856
    int a, d, w;
1854
 
1857
 
1855
    /* allocate new device description */
1858
    /* allocate new device description */
1856
    if (!(xd = (x11Desc *) malloc(sizeof(x11Desc))))
1859
    if (!(xd = (x11Desc *) malloc(sizeof(x11Desc))))
1857
	return 0;
1860
	return 0;
1858
 
1861
 
Line 1865... Line 1868...
1865
    if (ps < 6 || ps > 24)
1868
    if (ps < 6 || ps > 24)
1866
	ps = 12;
1869
	ps = 12;
1867
    ps = 2 * (ps / 2);
1870
    ps = 2 * (ps / 2);
1868
    xd->fontface = -1;
1871
    xd->fontface = -1;
1869
    xd->fontsize = -1;
1872
    xd->fontsize = -1;
-
 
1873
    xd->basefontsize = ps ;
1870
    dd->dp.font = 1;
1874
    dd->dp.font = 1;
1871
    dd->dp.ps = ps;
1875
    dd->dp.ps = ps;
1872
 
1876
 
1873
    /* Start the Device Driver and Hardcopy.  */
1877
    /* Start the Device Driver and Hardcopy.  */
1874
 
1878
 
Line 1905... Line 1909...
1905
    dd->dp.top = (xd->kind == PRINTER) ? rr.y : 0;	/* top */
1909
    dd->dp.top = (xd->kind == PRINTER) ? rr.y : 0;	/* top */
1906
    dd->dp.bottom = dd->dp.top + rr.height;	/* bottom */
1910
    dd->dp.bottom = dd->dp.top + rr.height;	/* bottom */
1907
 
1911
 
1908
 
1912
 
1909
    /* Nominal Character Sizes in Pixels */
1913
    /* Nominal Character Sizes in Pixels */
-
 
1914
    gcharmetric(xd->gawin, xd->font, 0, &a, &d, &w);
1910
    dd->dp.cra[0] = fontwidth(xd->font);
1915
    dd->dp.cra[0] = w;
1911
    dd->dp.cra[1] = fontascent(xd->font) + fontdescent(xd->font);
1916
    dd->dp.cra[1] = a + d;
1912
 
-
 
1913
    /* Character Addressing Offsets */
1917
    /* Character Addressing Offsets */
1914
    /* These are used to plot a single plotting character */
1918
    /* These are used to plot a single plotting character */
1915
    /* so that it is exactly over the plotting point */
1919
    /* so that it is exactly over the plotting point */
1916
 
1920
 
1917
    dd->dp.xCharOffset = 0.50;
1921
    dd->dp.xCharOffset = 0.50;