]>
git.ipfire.org Git - thirdparty/cups.git/blob - cups/page.c
2 * "$Id: page.c,v 1.11 2000/01/04 13:45:36 mike Exp $"
4 * Page size functions for the Common UNIX Printing System (CUPS).
6 * Copyright 1997-2000 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-3111 USA
20 * Voice: (301) 373-9603
21 * EMail: cups-info@cups.org
22 * WWW: http://www.cups.org
24 * PostScript is a trademark of Adobe Systems, Inc.
28 * ppdPageSize() - Get the page size record for the given size.
29 * ppdPageWidth() - Get the page width for the given size.
30 * ppdPageLength() - Get the page length for the given size.
34 * Include necessary headers...
43 * 'ppdPageSize()' - Get the page size record for the given size.
46 ppd_size_t
* /* O - Size record for page or NULL */
47 ppdPageSize(ppd_file_t
*ppd
, /* I - PPD file record */
48 const char *name
) /* I - Size name */
50 int i
; /* Looping var */
51 float w
, l
; /* Width and length of page */
52 char units
[255]; /* Page size units... */
60 if (strncmp(name
, "Custom.", 7) == 0 && ppd
->variable_sizes
)
63 * Find the custom page size...
66 for (i
= 0; i
< ppd
->num_sizes
; i
++)
67 if (strcmp("Custom", ppd
->sizes
[i
].name
) == 0)
70 if (i
== ppd
->num_sizes
)
74 * Variable size; size name can be one of the following:
76 * Custom.WIDTHxLENGTHin - Size in inches
77 * Custom.WIDTHxLENGTHcm - Size in centimeters
78 * Custom.WIDTHxLENGTHmm - Size in millimeters
79 * Custom.WIDTHxLENGTH[pt] - Size in points
83 if (sscanf(name
+ 7, "%fx%f%254s", &w
, &l
, units
) < 2)
86 if (strcasecmp(units
, "in") == 0)
88 ppd
->sizes
[i
].width
= w
* 72.0f
;
89 ppd
->sizes
[i
].length
= l
* 72.0f
;
90 ppd
->sizes
[i
].left
= ppd
->custom_margins
[0];
91 ppd
->sizes
[i
].bottom
= ppd
->custom_margins
[1];
92 ppd
->sizes
[i
].right
= w
* 72.0f
- ppd
->custom_margins
[2];
93 ppd
->sizes
[i
].top
= l
* 72.0f
- ppd
->custom_margins
[3];
95 else if (strcasecmp(units
, "cm") == 0)
97 ppd
->sizes
[i
].width
= w
/ 2.54f
* 72.0f
;
98 ppd
->sizes
[i
].length
= l
/ 2.54f
* 72.0f
;
99 ppd
->sizes
[i
].left
= ppd
->custom_margins
[0];
100 ppd
->sizes
[i
].bottom
= ppd
->custom_margins
[1];
101 ppd
->sizes
[i
].right
= w
/ 2.54f
* 72.0f
- ppd
->custom_margins
[2];
102 ppd
->sizes
[i
].top
= l
/ 2.54f
* 72.0f
- ppd
->custom_margins
[3];
104 else if (strcasecmp(units
, "mm") == 0)
106 ppd
->sizes
[i
].width
= w
/ 25.4f
* 72.0f
;
107 ppd
->sizes
[i
].length
= l
/ 25.4f
* 72.0f
;
108 ppd
->sizes
[i
].left
= ppd
->custom_margins
[0];
109 ppd
->sizes
[i
].bottom
= ppd
->custom_margins
[1];
110 ppd
->sizes
[i
].right
= w
/ 25.4f
* 72.0f
- ppd
->custom_margins
[2];
111 ppd
->sizes
[i
].top
= l
/ 25.4f
* 72.0f
- ppd
->custom_margins
[3];
115 ppd
->sizes
[i
].width
= w
;
116 ppd
->sizes
[i
].length
= l
;
117 ppd
->sizes
[i
].left
= ppd
->custom_margins
[0];
118 ppd
->sizes
[i
].bottom
= ppd
->custom_margins
[1];
119 ppd
->sizes
[i
].right
= w
- ppd
->custom_margins
[2];
120 ppd
->sizes
[i
].top
= l
- ppd
->custom_margins
[3];
123 return (ppd
->sizes
+ i
);
131 for (i
= 0; i
< ppd
->num_sizes
; i
++)
132 if (strcmp(name
, ppd
->sizes
[i
].name
) == 0)
133 return (ppd
->sizes
+ i
);
142 for (i
= 0; i
< ppd
->num_sizes
; i
++)
143 if (ppd
->sizes
[i
].marked
)
144 return (ppd
->sizes
+ i
);
152 * 'ppdPageWidth()' - Get the page width for the given size.
155 float /* O - Width of page in points or 0.0 */
156 ppdPageWidth(ppd_file_t
*ppd
, /* I - PPD file record */
157 const char *name
) /* I - Size name */
159 ppd_size_t
*size
; /* Page size */
162 if ((size
= ppdPageSize(ppd
, name
)) == NULL
)
165 return (size
->width
);
170 * 'ppdPageLength()' - Get the page length for the given size.
173 float /* O - Length of page in points or 0.0 */
174 ppdPageLength(ppd_file_t
*ppd
, /* I - PPD file */
175 const char *name
) /* I - Size name */
177 ppd_size_t
*size
; /* Page size */
180 if ((size
= ppdPageSize(ppd
, name
)) == NULL
)
183 return (size
->length
);
188 * End of "$Id: page.c,v 1.11 2000/01/04 13:45:36 mike Exp $".