]>
git.ipfire.org Git - thirdparty/cups.git/blob - cups/page.c
2 * "$Id: page.c 5238 2006-03-07 04:41:42Z mike $"
4 * Page size functions for the Common UNIX Printing System (CUPS).
6 * Copyright 1997-2005 by Easy Software Products, all rights reserved.
8 * These coded instructions, statements, and computer programs are the
9 * property of Easy Software Products and are protected by Federal
10 * copyright law. Distribution and use rights are outlined in the file
11 * "LICENSE.txt" which should have been included with this file. If this
12 * file is missing or damaged please contact Easy Software Products
15 * Attn: CUPS Licensing Information
16 * Easy Software Products
17 * 44141 Airport View Drive, Suite 204
18 * Hollywood, Maryland 20636 USA
20 * Voice: (301) 373-9600
21 * EMail: cups-info@cups.org
22 * WWW: http://www.cups.org
24 * PostScript is a trademark of Adobe Systems, Inc.
26 * This file is subject to the Apple OS-Developed Software exception.
30 * ppdPageSize() - Get the page size record for the given size.
31 * ppdPageWidth() - Get the page width for the given size.
32 * ppdPageLength() - Get the page length for the given size.
36 * Include necessary headers...
45 * 'ppdPageSize()' - Get the page size record for the given size.
48 ppd_size_t
* /* O - Size record for page or NULL */
49 ppdPageSize(ppd_file_t
*ppd
, /* I - PPD file record */
50 const char *name
) /* I - Size name */
52 int i
; /* Looping var */
53 float w
, l
; /* Width and length of page */
54 char *nameptr
; /* Pointer into name */
55 struct lconv
*loc
; /* Locale data */
63 if (!strncmp(name
, "Custom.", 7) && ppd
->variable_sizes
)
66 * Find the custom page size...
69 for (i
= 0; i
< ppd
->num_sizes
; i
++)
70 if (!strcmp("Custom", ppd
->sizes
[i
].name
))
73 if (i
== ppd
->num_sizes
)
77 * Variable size; size name can be one of the following:
79 * Custom.WIDTHxLENGTHin - Size in inches
80 * Custom.WIDTHxLENGTHcm - Size in centimeters
81 * Custom.WIDTHxLENGTHmm - Size in millimeters
82 * Custom.WIDTHxLENGTH[pt] - Size in points
86 w
= _cupsStrScand(name
+ 7, &nameptr
, loc
);
87 if (!nameptr
|| *nameptr
!= 'x')
90 l
= _cupsStrScand(nameptr
, &nameptr
, loc
);
94 if (!strcasecmp(nameptr
, "in"))
96 ppd
->sizes
[i
].width
= w
* 72.0f
;
97 ppd
->sizes
[i
].length
= l
* 72.0f
;
98 ppd
->sizes
[i
].left
= ppd
->custom_margins
[0];
99 ppd
->sizes
[i
].bottom
= ppd
->custom_margins
[1];
100 ppd
->sizes
[i
].right
= w
* 72.0f
- ppd
->custom_margins
[2];
101 ppd
->sizes
[i
].top
= l
* 72.0f
- ppd
->custom_margins
[3];
103 else if (!strcasecmp(nameptr
, "cm"))
105 ppd
->sizes
[i
].width
= w
/ 2.54f
* 72.0f
;
106 ppd
->sizes
[i
].length
= l
/ 2.54f
* 72.0f
;
107 ppd
->sizes
[i
].left
= ppd
->custom_margins
[0];
108 ppd
->sizes
[i
].bottom
= ppd
->custom_margins
[1];
109 ppd
->sizes
[i
].right
= w
/ 2.54f
* 72.0f
- ppd
->custom_margins
[2];
110 ppd
->sizes
[i
].top
= l
/ 2.54f
* 72.0f
- ppd
->custom_margins
[3];
112 else if (!strcasecmp(nameptr
, "mm"))
114 ppd
->sizes
[i
].width
= w
/ 25.4f
* 72.0f
;
115 ppd
->sizes
[i
].length
= l
/ 25.4f
* 72.0f
;
116 ppd
->sizes
[i
].left
= ppd
->custom_margins
[0];
117 ppd
->sizes
[i
].bottom
= ppd
->custom_margins
[1];
118 ppd
->sizes
[i
].right
= w
/ 25.4f
* 72.0f
- ppd
->custom_margins
[2];
119 ppd
->sizes
[i
].top
= l
/ 25.4f
* 72.0f
- ppd
->custom_margins
[3];
123 ppd
->sizes
[i
].width
= w
;
124 ppd
->sizes
[i
].length
= l
;
125 ppd
->sizes
[i
].left
= ppd
->custom_margins
[0];
126 ppd
->sizes
[i
].bottom
= ppd
->custom_margins
[1];
127 ppd
->sizes
[i
].right
= w
- ppd
->custom_margins
[2];
128 ppd
->sizes
[i
].top
= l
- ppd
->custom_margins
[3];
131 return (ppd
->sizes
+ i
);
139 for (i
= 0; i
< ppd
->num_sizes
; i
++)
140 if (!strcasecmp(name
, ppd
->sizes
[i
].name
))
141 return (ppd
->sizes
+ i
);
150 for (i
= 0; i
< ppd
->num_sizes
; i
++)
151 if (ppd
->sizes
[i
].marked
)
152 return (ppd
->sizes
+ i
);
160 * 'ppdPageWidth()' - Get the page width for the given size.
163 float /* O - Width of page in points or 0.0 */
164 ppdPageWidth(ppd_file_t
*ppd
, /* I - PPD file record */
165 const char *name
) /* I - Size name */
167 ppd_size_t
*size
; /* Page size */
170 if ((size
= ppdPageSize(ppd
, name
)) == NULL
)
173 return (size
->width
);
178 * 'ppdPageLength()' - Get the page length for the given size.
181 float /* O - Length of page in points or 0.0 */
182 ppdPageLength(ppd_file_t
*ppd
, /* I - PPD file */
183 const char *name
) /* I - Size name */
185 ppd_size_t
*size
; /* Page size */
188 if ((size
= ppdPageSize(ppd
, name
)) == NULL
)
191 return (size
->length
);
196 * End of "$Id: page.c 5238 2006-03-07 04:41:42Z mike $".