First import
[xorg_rtime.git] / xorg-server-1.4 / hw / xprint / mediaSizes.c
blob7acc70679bcac6425e5eda24b0c72db1eda9d1dd
1 /*
2 (c) Copyright 1996 Hewlett-Packard Company
3 (c) Copyright 1996 International Business Machines Corp.
4 (c) Copyright 1996 Sun Microsystems, Inc.
5 (c) Copyright 1996 Novell, Inc.
6 (c) Copyright 1996 Digital Equipment Corp.
7 (c) Copyright 1996 Fujitsu Limited
8 (c) Copyright 1996 Hitachi, Ltd.
10 Permission is hereby granted, free of charge, to any person obtaining a copy
11 of this software and associated documentation files (the "Software"), to deal
12 in the Software without restriction, including without limitation the rights
13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
24 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 Except as contained in this notice, the names of the copyright holders shall
28 not be used in advertising or otherwise to promote the sale, use or other
29 dealings in this Software without prior written authorization from said
30 copyright holders.
32 /*******************************************************************
34 ** *********************************************************
35 ** *
36 ** * File: mediaSizes.c
37 ** *
38 ** * Contents:
39 ** * Routines to return the sizes associated
40 ** * with particular media and particular printers.
41 ** *
42 ** * Created: 2/19/96
43 ** *
44 ** * Copyright: Copyright 1993,1995 Hewlett-Packard Company
45 ** *
46 ** *********************************************************
47 **
48 ********************************************************************/
50 #ifdef HAVE_DIX_CONFIG_H
51 #include <dix-config.h>
52 #endif
54 #include <unistd.h>
55 #include <stdlib.h>
56 #include <stdio.h>
57 #include <ctype.h>
58 #include <string.h>
59 #include <locale.h>
61 #include <X11/X.h>
62 #include "dixstruct.h"
63 #include "screenint.h"
64 #include "misc.h"
65 #include "scrnintstr.h"
66 #include <X11/fonts/fontstruct.h>
68 #include "DiPrint.h"
69 #include "attributes.h"
71 typedef struct {
72 XpOid page_size;
73 float width;
74 float height;
75 } PageDimensionsRec;
77 static PageDimensionsRec PageDimensions[] =
79 {xpoid_val_medium_size_na_letter, 215.9, 279.4},
80 {xpoid_val_medium_size_na_legal, 215.9, 355.6},
81 {xpoid_val_medium_size_executive, 184.15, 266.7},
82 {xpoid_val_medium_size_folio, 210.82, 330.2},
83 {xpoid_val_medium_size_invoice, 139.7, 215.9},
84 {xpoid_val_medium_size_ledger, 279.4, 431.8},
85 {xpoid_val_medium_size_quarto, 215.9, 275.082},
86 {xpoid_val_medium_size_a, 215.9, 279.4},
87 {xpoid_val_medium_size_b, 279.4, 431.8},
88 {xpoid_val_medium_size_c, 431.8, 558.8},
89 {xpoid_val_medium_size_d, 558.8, 863.6},
90 {xpoid_val_medium_size_e, 863.6, 1117.6},
91 {xpoid_val_medium_size_na_6x9_envelope, 152.4, 228.6},
92 {xpoid_val_medium_size_na_10x15_envelope, 254, 381},
93 {xpoid_val_medium_size_monarch_envelope, 98.298, 190.5},
94 {xpoid_val_medium_size_na_10x13_envelope, 254, 330.2},
95 {xpoid_val_medium_size_na_9x12_envelope, 228.6, 304.8},
96 {xpoid_val_medium_size_na_number_10_envelope, 104.775, 241.3},
97 {xpoid_val_medium_size_na_7x9_envelope, 177.8, 228.6},
98 {xpoid_val_medium_size_na_9x11_envelope, 228.6, 279.4},
99 {xpoid_val_medium_size_na_10x14_envelope, 254, 355.6},
100 {xpoid_val_medium_size_na_number_9_envelope, 98.425, 225.425},
101 {xpoid_val_medium_size_iso_a0, 841, 1189},
102 {xpoid_val_medium_size_iso_a1, 594, 841},
103 {xpoid_val_medium_size_iso_a2, 420, 594},
104 {xpoid_val_medium_size_iso_a3, 297, 420},
105 {xpoid_val_medium_size_iso_a4, 210, 297},
106 {xpoid_val_medium_size_iso_a5, 148, 210},
107 {xpoid_val_medium_size_iso_a6, 105, 148},
108 {xpoid_val_medium_size_iso_a7, 74, 105},
109 {xpoid_val_medium_size_iso_a8, 52, 74},
110 {xpoid_val_medium_size_iso_a9, 37, 52},
111 {xpoid_val_medium_size_iso_a10, 26, 37},
112 {xpoid_val_medium_size_iso_b0, 1000, 1414},
113 {xpoid_val_medium_size_iso_b1, 707, 1000},
114 {xpoid_val_medium_size_iso_b2, 500, 707},
115 {xpoid_val_medium_size_iso_b3, 353, 500},
116 {xpoid_val_medium_size_iso_b4, 250, 353},
117 {xpoid_val_medium_size_iso_b5, 176, 250},
118 {xpoid_val_medium_size_iso_b6, 125, 176},
119 {xpoid_val_medium_size_iso_b7, 88, 125},
120 {xpoid_val_medium_size_iso_b8, 62, 88},
121 {xpoid_val_medium_size_iso_b9, 44, 62},
122 {xpoid_val_medium_size_iso_b10, 31, 44},
123 {xpoid_val_medium_size_jis_b0, 1030, 1456},
124 {xpoid_val_medium_size_jis_b1, 728, 1030},
125 {xpoid_val_medium_size_jis_b2, 515, 728},
126 {xpoid_val_medium_size_jis_b3, 364, 515},
127 {xpoid_val_medium_size_jis_b4, 257, 364},
128 {xpoid_val_medium_size_jis_b5, 182, 257},
129 {xpoid_val_medium_size_jis_b6, 128, 182},
130 {xpoid_val_medium_size_jis_b7, 91, 128},
131 {xpoid_val_medium_size_jis_b8, 64, 91},
132 {xpoid_val_medium_size_jis_b9, 45, 64},
133 {xpoid_val_medium_size_jis_b10, 32, 45},
134 {xpoid_val_medium_size_hp_2x_postcard, 148, 200},
135 {xpoid_val_medium_size_hp_european_edp, 304.8, 355.6},
136 {xpoid_val_medium_size_hp_mini, 139.7, 215.9},
137 {xpoid_val_medium_size_hp_postcard, 100, 148},
138 {xpoid_val_medium_size_hp_tabloid, 279.4, 431.8},
139 {xpoid_val_medium_size_hp_us_edp, 279.4, 355.6},
140 {xpoid_val_medium_size_hp_us_government_legal, 203.2, 330.2},
141 {xpoid_val_medium_size_hp_us_government_letter, 203.2, 254},
142 {xpoid_val_medium_size_iso_c3, 324, 458},
143 {xpoid_val_medium_size_iso_c4, 229, 324},
144 {xpoid_val_medium_size_iso_c5, 162, 229},
145 {xpoid_val_medium_size_iso_c6, 114, 162},
146 {xpoid_val_medium_size_iso_designated_long, 110, 220}
150 * XpGetResolution returns an integer representing the printer resolution
151 * in dots-per-inch for the specified print context.
153 * Note: This routine assumes the values found in the passed context's
154 * attributes pools have been validated.
157 XpGetResolution(
158 XpContextPtr pContext)
160 unsigned long resolution;
162 resolution = XpGetCardAttr(pContext, XPPageAttr,
163 xpoid_att_default_printer_resolution,
164 (XpOidCardList*)NULL);
165 if(0 == resolution)
166 resolution = XpGetCardAttr(pContext, XPDocAttr,
167 xpoid_att_default_printer_resolution,
168 (XpOidCardList*)NULL);
169 if(0 == resolution)
171 XpOidCardList* resolutions_supported;
173 * default-printer-resolution not specified; default to 1st entry
174 * in printer-resolutions-supported.
176 resolutions_supported =
177 XpGetCardListAttr(pContext, XPPrinterAttr,
178 xpoid_att_printer_resolutions_supported,
179 (XpOidCardList*)NULL);
180 resolution = XpOidCardListGetCard(resolutions_supported, 0);
181 XpOidCardListDelete(resolutions_supported);
183 return (int)resolution;
187 * XpGetContentOrientation determines the content-orientation as
188 * determined by the passed context. The page and document pools are
189 * queried in turn for a specified content-orientation attribute. If none
190 * is found the first content-orientation in the
191 * content-orientations-supported printer attribute is taken as the
192 * default.
194 * Note: This routine assumes the values found in the passed context's
195 * attributes pools have been validated.
197 XpOid
198 XpGetContentOrientation(
199 XpContextPtr pContext)
201 XpOid orientation;
203 orientation = XpGetOidAttr(pContext, XPPageAttr,
204 xpoid_att_content_orientation,
205 (XpOidList*)NULL);
206 if(xpoid_none == orientation)
207 orientation = XpGetOidAttr(pContext, XPDocAttr,
208 xpoid_att_content_orientation,
209 (XpOidList*)NULL);
210 if(xpoid_none == orientation)
212 XpOidList* content_orientations_supported;
214 content_orientations_supported =
215 XpGetListAttr(pContext, XPPrinterAttr,
216 xpoid_att_content_orientations_supported,
217 (XpOidList*)NULL);
218 orientation = XpOidListGetOid(content_orientations_supported, 0);
219 XpOidListDelete(content_orientations_supported);
221 return orientation;
225 * XpGetAvailableCompression determines the available-compression as
226 * determined by the passed context. The page and document pools are
227 * queried in turn for a specified content-orientation attribute. If none
228 * is found the first available-compression in the
229 * avaiable-compressions-supported printer attribute is taken as the
230 * default.
232 * Note: This routine assumes the values found in the passed context's
233 * attributes pools have been validated.
235 XpOid
236 XpGetAvailableCompression(
237 XpContextPtr pContext)
239 XpOid compression;
241 compression = XpGetOidAttr(pContext, XPPageAttr,
242 xpoid_att_available_compression,
243 (XpOidList*)NULL);
244 if(xpoid_none == compression)
245 compression = XpGetOidAttr(pContext, XPDocAttr,
246 xpoid_att_available_compression,
247 (XpOidList*)NULL);
248 if(xpoid_none == compression)
250 XpOidList* available_compressions_supported;
252 available_compressions_supported =
253 XpGetListAttr(pContext, XPPrinterAttr,
254 xpoid_att_available_compressions_supported,
255 (XpOidList*)NULL);
256 compression = XpOidListGetOid(available_compressions_supported, 0);
257 XpOidListDelete(available_compressions_supported);
259 return compression;
263 * XpGetPlex determines the plex as determined by the passed context. The page
264 * and document pools are queried in turn for a specified plex attribute. If
265 * none is found the first plex in the plexes-supported printer attribute is
266 * taken as the default.
268 * Note: This routine assumes the values found in the passed context's
269 * attributes pools have been validated.
271 XpOid
272 XpGetPlex(
273 XpContextPtr pContext)
275 XpOid plex;
277 plex = XpGetOidAttr(pContext, XPPageAttr, xpoid_att_plex,
278 (XpOidList*)NULL);
279 if(xpoid_none == plex)
280 plex = XpGetOidAttr(pContext, XPDocAttr, xpoid_att_plex,
281 (XpOidList*)NULL);
282 if(xpoid_none == plex)
284 XpOidList* plexes_supported;
286 plexes_supported =
287 XpGetListAttr(pContext, XPPrinterAttr,
288 xpoid_att_plexes_supported,
289 (XpOidList*)NULL);
290 plex = XpOidListGetOid(plexes_supported, 0);
291 XpOidListDelete(plexes_supported);
293 return plex;
297 * XpGetPageSize returns the XpOid of the current page size (medium names
298 * are page sizes in this implementation) as indicated by the passed
299 * context.
301 * The relevant input-tray is returned in pTray. This parm must not be
302 * NULL. If the input-tray is not indicated or irrelevant, xpoid_none
303 * will be returned.
305 * This function optionally takes a XpOidMediumSS representation of the
306 * medium-source-sizes-supported attribute in order to avoid parsing the
307 * string value twice for calling functions that need to parse m-s-s-s
308 * anyway (e.g. XpGetReproductionArea). If the caller has no other reason
309 * to parse medium-source-sizes-supported, it is recommended that NULL be
310 * passed. This function will obtain medium-source-sizes-supported if it
311 * needs to.
313 * Note: This routine assumes the values found in the passed context's
314 * attributes pools have been validated.
316 XpOid
317 XpGetPageSize(XpContextPtr pContext,
318 XpOid* pTray,
319 const XpOidMediumSS* msss)
321 XpOid medium;
323 * check to see if default-medium is specified
325 medium = XpGetOidAttr(pContext, XPPageAttr, xpoid_att_default_medium,
326 (const XpOidList*)NULL);
327 if(medium == xpoid_none)
330 * default-medium not in page pool; try the document pool
332 medium = XpGetOidAttr(pContext, XPDocAttr, xpoid_att_default_medium,
333 (const XpOidList*)NULL);
335 if(medium == xpoid_none)
338 * default-medium not specified; try default-input-tray
340 *pTray = XpGetOidAttr(pContext, XPPageAttr,
341 xpoid_att_default_input_tray,
342 (const XpOidList*)NULL);
343 if(*pTray == xpoid_none)
346 * default-input-tray not in page pool; try the document pool
348 *pTray = XpGetOidAttr(pContext, XPDocAttr,
349 xpoid_att_default_input_tray,
350 (const XpOidList*)NULL);
352 if(*pTray != xpoid_none)
355 * default-input-tray found; get corresponding medium from
356 * input-trays-medium
358 XpOidTrayMediumList* input_trays_medium;
359 int i;
361 input_trays_medium =
362 XpGetTrayMediumListAttr(pContext, XPPrinterAttr,
363 xpoid_att_input_trays_medium,
364 (const XpOidList*)NULL,
365 (const XpOidMediumSS*)NULL);
366 for(i = 0; i < XpOidTrayMediumListCount(input_trays_medium); i++)
368 if(*pTray == XpOidTrayMediumListTray(input_trays_medium, i))
370 medium = XpOidTrayMediumListMedium(input_trays_medium, i);
371 break;
374 XpOidTrayMediumListDelete(input_trays_medium);
377 else
378 *pTray = xpoid_none;
380 if(medium == xpoid_none)
382 XpOidMediumSS* local_msss = (XpOidMediumSS*)NULL;
383 int i_mss, i_ds;
384 XpOidMediumDiscreteSizeList* ds_list;
386 * no medium specified; use 1st page size found in
387 * medium-source-sizes-supported
389 if((XpOidMediumSS*)NULL == msss)
390 msss = local_msss =
391 XpGetMediumSSAttr(pContext, XPPrinterAttr,
392 xpoid_att_medium_source_sizes_supported,
393 (const XpOidList*)NULL,
394 (const XpOidList*)NULL);
395 for(i_mss = 0;
396 i_mss < XpOidMediumSSCount(msss) && xpoid_none == medium;
397 i_mss++)
399 if(XpOidMediumSS_DISCRETE == (msss->mss)[i_mss].mstag
401 xpoid_none != (msss->mss)[i_mss].input_tray)
403 ds_list = (msss->mss)[i_mss].ms.discrete;
404 for(i_ds = 0; i_ds < ds_list->count; i_ds++)
406 if(xpoid_none != (ds_list->list)[i_ds].page_size)
408 medium = (ds_list->list)[i_ds].page_size;
409 break;
414 XpOidMediumSSDelete(local_msss);
416 return medium;
420 * XpGetMediumMillimeters returns into the supplied float pointers the
421 * width and height in millimeters of the passed page size identifier.
423 void
424 XpGetMediumMillimeters(
425 XpOid page_size,
426 float *width, /* return */
427 float *height) /* return */
429 int i;
431 *width = *height = 0;
432 for(i = 0; i < XpNumber(PageDimensions); i++)
434 if(page_size == PageDimensions[i].page_size)
436 *width = PageDimensions[i].width;
437 *height = PageDimensions[i].height;
438 return;
444 * Converts a millimeter specification into pixels given a resolution in
445 * DPI.
447 static float
448 MmToPixels(float mm, int resolution)
450 float f;
452 f = mm * resolution;
453 f /= 25.4;
454 return f;
458 * XpGetMediumDimensions returns into the supplied short pointers the
459 * width and height in pixels of the medium associated with the specified
460 * print context. It obtains the page size associated with the current
461 * medium by calling XpGetPageSize. It passes XpGetMediumMillimeters the
462 * page size, and converts the returned millimeter dimensions into pixels
463 * using the resolution returned by XpGetResolution.
465 * Note: This routine assumes the values found in the passed context's
466 * attributes pools have been validated.
468 void
469 XpGetMediumDimensions(
470 XpContextPtr pContext,
471 unsigned short *width, /* return */
472 unsigned short *height) /* return */
474 XpOid page_size;
475 XpOid tray;
476 XpOid orientation;
478 int resolution;
479 float w_mm, h_mm;
481 page_size = XpGetPageSize(pContext, &tray, (XpOidMediumSS*)NULL);
482 if(page_size == xpoid_none)
485 * fail-safe: if the pools have been validated, this defaulting logic
486 * isn't needed.
488 page_size = xpoid_val_medium_size_na_letter;
490 XpGetMediumMillimeters(page_size, &w_mm, &h_mm);
491 resolution = XpGetResolution(pContext);
492 orientation = XpGetContentOrientation(pContext);
493 switch(orientation)
495 case xpoid_val_content_orientation_landscape:
496 case xpoid_val_content_orientation_reverse_landscape:
498 * transpose width and height
500 *height = MmToPixels(w_mm, resolution);
501 *width = MmToPixels(h_mm, resolution);
502 break;
504 default:
505 *width = MmToPixels(w_mm, resolution);
506 *height = MmToPixels(h_mm, resolution);
507 break;
512 * XRectangleFromXpOidArea converts an XpOidArea area specification
513 * into an XRectangle. The passed resolution is used to convert from
514 * millimeters (XpOidArea) into pixels (XRectangle).
516 static void
517 XRectangleFromXpOidArea(
518 xRectangle *pRect,
519 const XpOidArea* repro,
520 int resolution,
521 XpOid orientation)
523 switch(orientation)
525 case xpoid_val_content_orientation_landscape:
526 case xpoid_val_content_orientation_reverse_landscape:
528 * transpose x and y, width and height
530 pRect->y = MmToPixels(repro->minimum_x, resolution);
531 pRect->x = MmToPixels(repro->minimum_y, resolution);
532 pRect->height =
533 MmToPixels(repro->maximum_x - repro->minimum_x, resolution);
534 pRect->width =
535 MmToPixels(repro->maximum_y - repro->minimum_y, resolution);
536 break;
538 default:
539 pRect->x = MmToPixels(repro->minimum_x, resolution);
540 pRect->y = MmToPixels(repro->minimum_y, resolution);
541 pRect->width =
542 MmToPixels(repro->maximum_x - repro->minimum_x, resolution);
543 pRect->height =
544 MmToPixels(repro->maximum_y - repro->minimum_y, resolution);
545 break;
550 * XpGetReproductionArea queries the current pool attribute values in
551 * order to determine the reproduction area for the currently selected
552 * medium.
554 * First the current page size (equivalent to current medium) and tray
555 * (if specified) is retrieved via XpGetPageSize. The value of the
556 * medium-source-sizes-supported attribute is interrogated until a matching
557 * entry for the current page size and tray is found. The reproduction
558 * area defined for the current entry is converted into an XRectangle
559 * using XRectangleFromXpOidArea and returned to the caller.
561 * Note: This routine assumes the values found in the passed context's
562 * attributes pools have been validated.
564 void
565 XpGetReproductionArea(XpContextPtr pContext,
566 xRectangle *pRect)
568 XpOid page_size;
569 XpOid tray;
570 XpOidMediumSS* msss;
571 int i_mss, i_ds;
572 XpOidMediumDiscreteSizeList* ds_list;
573 XpOidArea* repro;
574 BOOL done;
575 int resolution;
576 XpOid orientation;
578 * find the appropriate assured reproduction area for the current
579 * tray and page size in the medium-source-sizes-supported attribute.
581 msss = XpGetMediumSSAttr(pContext, XPPrinterAttr,
582 xpoid_att_medium_source_sizes_supported,
583 (const XpOidList*)NULL,
584 (const XpOidList*)NULL);
585 page_size = XpGetPageSize(pContext, &tray, msss);
586 resolution = XpGetResolution(pContext);
587 orientation = XpGetContentOrientation(pContext);
589 memset(pRect, 0, sizeof(xRectangle));
591 if(xpoid_none == tray)
594 * no tray specified; use 1st matching page size
596 for(i_mss = 0, done = xFalse;
597 i_mss < XpOidMediumSSCount(msss) && !done;
598 i_mss++)
600 if(XpOidMediumSS_DISCRETE == (msss->mss)[i_mss].mstag
602 xpoid_none != (msss->mss)[i_mss].input_tray)
604 ds_list = (msss->mss)[i_mss].ms.discrete;
605 for(i_ds = 0; i_ds < ds_list->count; i_ds++)
607 if(page_size == (ds_list->list)[i_ds].page_size)
609 repro =
610 &(ds_list->list)[i_ds].assured_reproduction_area;
611 XRectangleFromXpOidArea(pRect, repro,
612 resolution, orientation);
613 done = xTrue;
614 break;
620 else
623 * tray && page size specified; find matching entry
625 for(i_mss = 0, done = xFalse;
626 i_mss < XpOidMediumSSCount(msss) && !done;
627 i_mss++)
629 if(XpOidMediumSS_DISCRETE == (msss->mss)[i_mss].mstag
631 xpoid_none != (msss->mss)[i_mss].input_tray
633 (tray == (msss->mss)[i_mss].input_tray
635 xpoid_unspecified == (msss->mss)[i_mss].input_tray)
638 ds_list = (msss->mss)[i_mss].ms.discrete;
639 for(i_ds = 0; i_ds < ds_list->count; i_ds++)
641 if(page_size == (ds_list->list)[i_ds].page_size)
643 repro =
644 &(ds_list->list)[i_ds].assured_reproduction_area;
645 XRectangleFromXpOidArea(pRect, repro,
646 resolution, orientation);
647 if(xpoid_unspecified != (msss->mss)[i_mss].input_tray)
650 * exact match on tray takes precendence over
651 * unspecified tray entry in m-s-s-s
653 done = xTrue;
655 break;
661 XpOidMediumSSDelete(msss);
665 * XpGetMaxWidthHeightRes returns into the supplied width and height
666 * unsigned short pointers the dimensions in millimeters of the largest
667 * supported media for a specific printer. It looks at the
668 * medium-source-sizes-supported attribute (if it exists) to determine
669 * the list of possible media, and calls XpGetMediumMillimeters to get the
670 * dimensions for each medium. If the m-s-s-s attribute is not defined,
671 * then the dimensions for the na-letter medium is returned.
673 * This function also returns the largest resolution in DPI defined in
674 * printer-resolutions-supported. If printer-resolutions-supported is not
675 * specified, the default is obtained from the passed XpValidatePoolsRec.
677 * The passed XpValidatePoolsRec is also used to determine valid values
678 * when parsing attribute values.
680 void
681 XpGetMaxWidthHeightRes(
682 const char *printer_name,
683 const XpValidatePoolsRec* vpr,
684 float *width,
685 float *height,
686 int* resolution)
688 const char* value;
689 const char* attr_str;
690 XpOidMediumSS* pool_msss;
691 const XpOidMediumSS* msss;
692 int i_mss, i_ds;
693 XpOidMediumDiscreteSizeList* ds_list;
694 float w, h;
695 XpOidCardList* pool_resolutions_supported;
696 const XpOidCardList* resolutions_supported;
697 int i;
698 int res;
700 * get the max medium width and height
702 attr_str = XpOidString(xpoid_att_medium_source_sizes_supported);
703 value = XpGetPrinterAttribute(printer_name, attr_str);
704 pool_msss = XpOidMediumSSNew(value,
705 vpr->valid_input_trays,
706 vpr->valid_medium_sizes);
707 if(0 == XpOidMediumSSCount(pool_msss))
708 msss = XpGetDefaultMediumSS();
709 else
710 msss = pool_msss;
711 *width = *height = 0;
712 for(i_mss = 0; i_mss < XpOidMediumSSCount(msss); i_mss++)
714 if(XpOidMediumSS_DISCRETE == (msss->mss)[i_mss].mstag
716 xpoid_none != (msss->mss)[i_mss].input_tray)
718 ds_list = (msss->mss)[i_mss].ms.discrete;
719 for(i_ds = 0; i_ds < ds_list->count; i_ds++)
721 if(xpoid_none != (ds_list->list)[i_ds].page_size)
723 XpGetMediumMillimeters((ds_list->list)[i_ds].page_size,
724 &w, &h);
725 if(w > *width) *width = w;
726 if(h > *height) *height = h;
731 XpOidMediumSSDelete(pool_msss);
733 * get the maximum resolution
735 attr_str = XpOidString(xpoid_att_printer_resolutions_supported);
736 value = XpGetPrinterAttribute(printer_name, attr_str);
737 pool_resolutions_supported =
738 XpOidCardListNew(value, vpr->valid_printer_resolutions_supported);
739 if(0 == XpOidCardListCount(pool_resolutions_supported))
740 resolutions_supported = vpr->default_printer_resolutions_supported;
741 else
742 resolutions_supported = pool_resolutions_supported;
743 *resolution = 0;
744 for(i = 0; i < XpOidCardListCount(resolutions_supported); i++)
746 res = XpOidCardListGetCard(resolutions_supported, i);
747 if(res > *resolution) *resolution = res;
749 XpOidCardListDelete(pool_resolutions_supported);
752 FontResolutionPtr
753 XpGetClientResolutions(client, num)
754 ClientPtr client;
755 int *num;
757 static struct _FontResolution res;
758 int resolution = XpGetResolution(XpContextOfClient(client));
760 res.x_resolution = resolution;
761 res.y_resolution = resolution;
763 res.point_size = 120;
765 *num = 1;
767 return &res;
771 void XpSetFontResFunc(client)
772 ClientPtr client;
774 client->fontResFunc = XpGetClientResolutions;
778 void XpUnsetFontResFunc(client)
779 ClientPtr client;
781 client->fontResFunc = NULL;