]>
git.ipfire.org Git - thirdparty/cups.git/blob - cups/page.c
2 * "$Id: page.c 6649 2007-07-11 21:46:42Z mike $"
4 * Page size functions for the Common UNIX Printing System (CUPS).
6 * Copyright 2007 by Apple Inc.
7 * Copyright 1997-2007 by Easy Software Products, all rights reserved.
9 * These coded instructions, statements, and computer programs are the
10 * property of Apple Inc. and are protected by Federal copyright
11 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 * which should have been included with this file. If this file is
13 * file is missing or damaged, see the license at "http://www.cups.org/".
15 * PostScript is a trademark of Adobe Systems, Inc.
17 * This file is subject to the Apple OS-Developed Software exception.
21 * ppdPageSize() - Get the page size record for the given size.
22 * ppdPageWidth() - Get the page width for the given size.
23 * ppdPageLength() - Get the page length for the given size.
27 * Include necessary headers...
36 * 'ppdPageSize()' - Get the page size record for the given size.
39 ppd_size_t
* /* O - Size record for page or NULL */
40 ppdPageSize(ppd_file_t
*ppd
, /* I - PPD file record */
41 const char *name
) /* I - Size name */
43 int i
; /* Looping var */
44 ppd_size_t
*size
; /* Current page size */
45 float w
, l
; /* Width and length of page */
46 char *nameptr
; /* Pointer into name */
47 struct lconv
*loc
; /* Locale data */
48 ppd_coption_t
*coption
; /* Custom option for page size */
49 ppd_cparam_t
*cparam
; /* Custom option parameter */
57 if (!strncmp(name
, "Custom.", 7) && ppd
->variable_sizes
)
60 * Find the custom page size...
63 for (i
= ppd
->num_sizes
, size
= ppd
->sizes
; i
> 0; i
--, size
++)
64 if (!strcmp("Custom", size
->name
))
71 * Variable size; size name can be one of the following:
73 * Custom.WIDTHxLENGTHin - Size in inches
74 * Custom.WIDTHxLENGTHcm - Size in centimeters
75 * Custom.WIDTHxLENGTHmm - Size in millimeters
76 * Custom.WIDTHxLENGTH[pt] - Size in points
80 w
= (float)_cupsStrScand(name
+ 7, &nameptr
, loc
);
81 if (!nameptr
|| *nameptr
!= 'x')
84 l
= (float)_cupsStrScand(nameptr
+ 1, &nameptr
, loc
);
88 if (!strcasecmp(nameptr
, "in"))
93 else if (!strcasecmp(nameptr
, "ft"))
98 else if (!strcasecmp(nameptr
, "mm"))
103 else if (!strcasecmp(nameptr
, "cm"))
108 else if (!strcasecmp(nameptr
, "m"))
110 w
*= 72.0f
/ 0.0254f
;
111 l
*= 72.0f
/ 0.0254f
;
116 size
->left
= ppd
->custom_margins
[0];
117 size
->bottom
= ppd
->custom_margins
[1];
118 size
->right
= w
- ppd
->custom_margins
[2];
119 size
->top
= l
- ppd
->custom_margins
[3];
122 * Update the custom option records for the page size, too...
125 if ((coption
= ppdFindCustomOption(ppd
, "PageSize")) != NULL
)
127 if ((cparam
= ppdFindCustomParam(coption
, "Width")) != NULL
)
128 cparam
->current
.custom_points
= w
;
130 if ((cparam
= ppdFindCustomParam(coption
, "Height")) != NULL
)
131 cparam
->current
.custom_points
= l
;
135 * Return the page size...
146 for (i
= ppd
->num_sizes
, size
= ppd
->sizes
; i
> 0; i
--, size
++)
147 if (!strcmp(name
, size
->name
))
157 for (i
= ppd
->num_sizes
, size
= ppd
->sizes
; i
> 0; i
--, size
++)
167 * 'ppdPageWidth()' - Get the page width for the given size.
170 float /* O - Width of page in points or 0.0 */
171 ppdPageWidth(ppd_file_t
*ppd
, /* I - PPD file record */
172 const char *name
) /* I - Size name */
174 ppd_size_t
*size
; /* Page size */
177 if ((size
= ppdPageSize(ppd
, name
)) == NULL
)
180 return (size
->width
);
185 * 'ppdPageLength()' - Get the page length for the given size.
188 float /* O - Length of page in points or 0.0 */
189 ppdPageLength(ppd_file_t
*ppd
, /* I - PPD file */
190 const char *name
) /* I - Size name */
192 ppd_size_t
*size
; /* Page size */
195 if ((size
= ppdPageSize(ppd
, name
)) == NULL
)
198 return (size
->length
);
203 * End of "$Id: page.c 6649 2007-07-11 21:46:42Z mike $".