]>
git.ipfire.org Git - thirdparty/cups.git/blob - cups/page.c
2 * "$Id: page.c 6188 2007-01-10 16:23:06Z mike $"
4 * Page size functions for the Common UNIX Printing System (CUPS).
6 * Copyright 1997-2007 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 ppd_size_t
*size
; /* Current page size */
54 float w
, l
; /* Width and length of page */
55 char *nameptr
; /* Pointer into name */
56 struct lconv
*loc
; /* Locale data */
57 ppd_coption_t
*coption
; /* Custom option for page size */
58 ppd_cparam_t
*cparam
; /* Custom option parameter */
66 if (!strncmp(name
, "Custom.", 7) && ppd
->variable_sizes
)
69 * Find the custom page size...
72 for (i
= ppd
->num_sizes
, size
= ppd
->sizes
; i
> 0; i
--, size
++)
73 if (!strcmp("Custom", size
->name
))
80 * Variable size; size name can be one of the following:
82 * Custom.WIDTHxLENGTHin - Size in inches
83 * Custom.WIDTHxLENGTHcm - Size in centimeters
84 * Custom.WIDTHxLENGTHmm - Size in millimeters
85 * Custom.WIDTHxLENGTH[pt] - Size in points
89 w
= (float)_cupsStrScand(name
+ 7, &nameptr
, loc
);
90 if (!nameptr
|| *nameptr
!= 'x')
93 l
= (float)_cupsStrScand(nameptr
+ 1, &nameptr
, loc
);
97 if (!strcasecmp(nameptr
, "in"))
102 else if (!strcasecmp(nameptr
, "ft"))
107 else if (!strcasecmp(nameptr
, "mm"))
112 else if (!strcasecmp(nameptr
, "cm"))
117 else if (!strcasecmp(nameptr
, "m"))
119 w
*= 72.0f
/ 0.0254f
;
120 l
*= 72.0f
/ 0.0254f
;
125 size
->left
= ppd
->custom_margins
[0];
126 size
->bottom
= ppd
->custom_margins
[1];
127 size
->right
= w
- ppd
->custom_margins
[2];
128 size
->top
= l
- ppd
->custom_margins
[3];
131 * Update the custom option records for the page size, too...
134 if ((coption
= ppdFindCustomOption(ppd
, "PageSize")) != NULL
)
136 if ((cparam
= ppdFindCustomParam(coption
, "Width")) != NULL
)
137 cparam
->current
.custom_points
= w
;
139 if ((cparam
= ppdFindCustomParam(coption
, "Height")) != NULL
)
140 cparam
->current
.custom_points
= l
;
144 * Return the page size...
155 for (i
= ppd
->num_sizes
, size
= ppd
->sizes
; i
> 0; i
--, size
++)
156 if (!strcmp(name
, size
->name
))
166 for (i
= ppd
->num_sizes
, size
= ppd
->sizes
; i
> 0; i
--, size
++)
176 * 'ppdPageWidth()' - Get the page width for the given size.
179 float /* O - Width of page in points or 0.0 */
180 ppdPageWidth(ppd_file_t
*ppd
, /* I - PPD file record */
181 const char *name
) /* I - Size name */
183 ppd_size_t
*size
; /* Page size */
186 if ((size
= ppdPageSize(ppd
, name
)) == NULL
)
189 return (size
->width
);
194 * 'ppdPageLength()' - Get the page length for the given size.
197 float /* O - Length of page in points or 0.0 */
198 ppdPageLength(ppd_file_t
*ppd
, /* I - PPD file */
199 const char *name
) /* I - Size name */
201 ppd_size_t
*size
; /* Page size */
204 if ((size
= ppdPageSize(ppd
, name
)) == NULL
)
207 return (size
->length
);
212 * End of "$Id: page.c 6188 2007-01-10 16:23:06Z mike $".