sinc with TeXLive revision 41114. (trunk,fix prev. wrong message)
[luatex.git] / manual / luatex-graphics.tex
blob91feaaff8ec9e36b6b1cea6889c48fdc83081175
1 % language=uk
3 \environment luatex-style
4 \environment luatex-logos
6 \startcomponent luatex-graphics
8 \startchapter[reference=graphics,title={The graphic libraries}]
10 \section{The \type {img} library}
12 The \type {img} library can be used as an alternative to \type {\pdfximage} and
13 \type {\pdfrefximage}, and the associated \quote {satellite} commands like \type
14 {\pdfximagebbox}. Image objects can also be used within virtual fonts via the
15 \type {image} command listed in~\in {section} [virtualfonts].
17 \subsection{\type {new}}
19 \startfunctioncall
20 <image> var = img.new()
21 <image> var = img.new(<table> image_spec)
22 \stopfunctioncall
24 This function creates a userdata object of type \quote {image}. The \type
25 {image_spec} argument is optional. If it is given, it must be a table, and that
26 table must contain a \type {filename} key. A number of other keys can also be
27 useful, these are explained below.
29 You can either say
31 \starttyping
32 a = img.new()
33 \stoptyping
35 followed by
37 \starttyping
38 a.filename = "foo.png"
39 \stoptyping
41 or you can put the file name (and some or all of the other keys) into a table
42 directly, like so:
44 \starttyping
45 a = img.new({filename='foo.pdf', page=1})
46 \stoptyping
48 The generated \type {<image>} userdata object allows access to a set of
49 user|-|specified values as well as a set of values that are normally filled in
50 and updated automatically by \LUATEX\ itself. Some of those are derived from the
51 actual image file, others are updated to reflect the \PDF\ output status of the
52 object.
54 There is one required user-specified field: the file name (\type {filename}). It
55 can optionally be augmented by the requested image dimensions (\type {width},
56 \type {depth}, \type {height}), user|-|specified image attributes (\type {attr}),
57 the requested \PDF\ page identifier (\type {page}), the requested boundingbox
58 (\type {pagebox}) for \PDF\ inclusion, the requested color space object (\type
59 {colorspace}).
61 The function \type {img.new} does not access the actual image file, it just
62 creates the \type {<image>} userdata object and initializes some memory
63 structures. The \type {<image>} object and its internal structures are
64 automatically garbage collected.
66 Once the image is scanned, all the values in the \type {<image>} except \type
67 {width}, \type {height} and \type {depth}, become frozen, and you cannot change
68 them any more.
70 You can use \type {pdf.setignoreunknownimages(1)} (or at the \TEX\ end the \type
71 {\pdfvariable} \type {ignoreunknownimages}) to get around a quit when no known
72 image type is found (based on name or preamble). Beware: this will not catch
73 invalid images and we cannot guarantee side effects. A zero dimension image is
74 still included when requested. No special flags are set. A proper workflow will
75 not rely in such a catch but make sure that images are valid.
77 \subsection{\type {keys}}
79 \startfunctioncall
80 <table> keys = img.keys()
81 \stopfunctioncall
83 This function returns a list of all the possible \type {image_spec} keys, both
84 user-supplied and automatic ones.
86 % hahe: i need to add r/w ro column...
87 \starttabulate[|Tl|l|p|]
88 \NC \bf field name \NC \bf type \NC description \NC \NR
89 \NC attr \NC string \NC the image attributes for \LUATEX \NC \NR
90 \NC bbox \NC table \NC table with 4 boundingbox dimensions \type
91 {llx}, \type {lly}, \type {urx} and \type
92 {ury} overruling the \type {pagebox} entry \NC \NR
93 \NC colordepth \NC number \NC the number of bits used by the color space \NC \NR
94 \NC colorspace \NC number \NC the color space object number \NC \NR
95 \NC depth \NC number \NC the image depth for \LUATEX \NC \NR
96 \NC filename \NC string \NC the image file name \NC \NR
97 \NC filepath \NC string \NC the full (expanded) file name of the image\NC \NR
98 \NC height \NC number \NC the image height for \LUATEX \NC \NR
99 \NC imagetype \NC string \NC one of \type {pdf}, \type {png}, \type {jpg},
100 \type {jp2} or \type {jbig2} \NC \NR
101 \NC index \NC number \NC the \PDF\ image name suffix \NC \NR
102 \NC objnum \NC number \NC the \PDF\ image object number \NC \NR
103 \NC page \NC number \NC the identifier for the requested image page \NC \NR
104 \NC pagebox \NC string \NC the requested bounding box, one of
105 \type {none}, \type {media}, \type {crop},
106 \type {bleed}, \type {trim}, \type {art} \NC \NR
107 \NC pages \NC number \NC the total number of available pages \NC \NR
108 \NC rotation \NC number \NC the image rotation from included \PDF\ file,
109 in multiples of 90~deg. \NC \NR
110 \NC stream \NC string \NC the raw stream data for an \type {/Xobject}
111 \type {/Form} object\NC \NR
112 \NC transform \NC number \NC the image transform, integer number 0..7\NC \NR
113 \NC width \NC number \NC the image width for \LUATEX \NC \NR
114 \NC xres \NC number \NC the horizontal natural image resolution
115 (in \DPI) \NC \NR
116 \NC xsize \NC number \NC the natural image width \NC \NR
117 \NC yres \NC number \NC the vertical natural image resolution
118 (in \DPI) \NC \NR
119 \NC ysize \NC number \NC the natural image height \NC \NR
120 \NC visiblefileame \NC string \NC when set, this name will find its way in the
121 \PDF\ file as \type {PTEX} specification; when
122 an empty string is assigned nothing is written
123 to file; otherwise the natural filename is
124 taken \NC \NR
125 \stoptabulate
127 A running (undefined) dimension in \type {width}, \type {height}, or \type
128 {depth} is represented as \type {nil} in \LUA, so if you want to load an image at
129 its \quote {natural} size, you do not have to specify any of those three fields.
131 The \type {stream} parameter allows to fabricate an \type {/XObject} \type
132 {/Form} object from a string giving the stream contents, e.g., for a filled
133 rectangle:
135 \startfunctioncall
136 a.stream = "0 0 20 10 re f"
137 \stopfunctioncall
139 When writing the image, an \type {/Xobject} \type {/Form} object is created, like
140 with embedded \PDF\ file writing. The object is written out only once. The \type
141 {stream} key requires that also the \type {bbox} table is given. The \type
142 {stream} key conflicts with the \type {filename} key. The \type {transform} key
143 works as usual also with \type {stream}.
145 The \type {bbox} key needs a table with four boundingbox values, e.g.:
147 \startfunctioncall
148 a.bbox = { "30bp", 0, "225bp", "200bp" }
149 \stopfunctioncall
151 This replaces and overrules any given \type {pagebox} value; with given \type
152 {bbox} the box dimensions coming with an embedded \PDF\ file are ignored. The
153 \type {xsize} and \type {ysize} dimensions are set accordingly, when the image is
154 scaled. The \type {bbox} parameter is ignored for non-\PDF\ images.
156 The \type {transform} allows to mirror and rotate the image in steps of 90~deg.
157 The default value~$0$ gives an unmirrored, unrotated image. Values $1-3$ give
158 counterclockwise rotation by $90$, $180$, or $270$~degrees, whereas with values
159 $4-7$ the image is first mirrored and then rotated counterclockwise by $90$,
160 $180$, or $270$~degrees. The \type {transform} operation gives the same visual
161 result as if you would externally preprocess the image by a graphics tool and
162 then use it by \LUATEX. If a \PDF\ file to be embedded already contains a \type
163 {/Rotate} specification, the rotation result is the combination of the \type
164 {/Rotate} rotation followed by the \type {transform} operation.
166 \subsection{\type {scan}}
168 \startfunctioncall
169 <image> var = img.scan(<image> var)
170 <image> var = img.scan(<table> image_spec)
171 \stopfunctioncall
173 When you say \type {img.scan(a)} for a new image, the file is scanned, and
174 variables such as \type {xsize}, \type {ysize}, image \type {type}, number of
175 \type {pages}, and the resolution are extracted. Each of the \type {width}, \type
176 {height}, \type {depth} fields are set up according to the image dimensions, if
177 they were not given an explicit value already. An image file will never be
178 scanned more than once for a given image variable. With all subsequent \type
179 {img.scan(a)} calls only the dimensions are again set up (if they have been
180 changed by the user in the meantime).
182 For ease of use, you can do right-away a
184 \starttyping
185 <image> a = img.scan { filename = "foo.png" }
186 \stoptyping
188 without a prior \type {img.new}.
190 Nothing is written yet at this point, so you can do \type {a=img.scan}, retrieve
191 the available info like image width and height, and then throw away \type {a}
192 again by saying \type {a=nil}. In that case no image object will be reserved in
193 the PDF, and the used memory will be cleaned up automatically.
195 \subsection{\type {copy}}
197 \startfunctioncall
198 <image> var = img.copy(<image> var)
199 <image> var = img.copy(<table> image_spec)
200 \stopfunctioncall
202 If you say \type {a = b}, then both variables point to the same \type {<image>}
203 object. if you want to write out an image with different sizes, you can do a
204 \type {b = img.copy(a)}.
206 Afterwards, \type {a} and \type {b} still reference the same actual image
207 dictionary, but the dimensions for \type {b} can now be changed from their
208 initial values that were just copies from \type {a}.
210 \subsection{\type {write}}
212 \startfunctioncall
213 <image> var = img.write(<image> var)
214 <image> var = img.write(<table> image_spec)
215 \stopfunctioncall
217 By \type {img.write(a)} a \PDF\ object number is allocated, and a whatsit node of
218 subtype \type {pdf_refximage} is generated and put into the output list. By this
219 the image \type {a} is placed into the page stream, and the image file is written
220 out into an image stream object after the shipping of the current page is
221 finished.
223 Again you can do a terse call like
225 \starttyping
226 img.write { filename = "foo.png" }
227 \stoptyping
229 The \type {<image>} variable is returned in case you want it for later
230 processing.
232 \subsection{\type {immediatewrite}}
234 \startfunctioncall
235 <image> var = img.immediatewrite(<image> var)
236 <image> var = img.immediatewrite(<table> image_spec)
237 \stopfunctioncall
239 By \type {img.immediatewrite(a)} a \PDF\ object number is allocated, and the
240 image file for image \type {a} is written out immediately into the \PDF\ file as
241 an image stream object (like with \type {\immediate}\type {\pdfximage}). The object
242 number of the image stream dictionary is then available by the \type {objnum}
243 key. No \type {pdf_refximage} whatsit node is generated. You will need an
244 \type {img.write(a)} or \type {img.node(a)} call to let the image appear on the
245 page, or reference it by another trick; else you will have a dangling image
246 object in the \PDF\ file.
248 Also here you can do a terse call like
250 \starttyping
251 a = img.immediatewrite { filename = "foo.png" }
252 \stoptyping
254 The \type {<image>} variable is returned and you will most likely need it.
256 \subsection{\type {node}}
258 \startfunctioncall
259 <node> n = img.node(<image> var)
260 <node> n = img.node(<table> image_spec)
261 \stopfunctioncall
263 This function allocates a \PDF\ object number and returns a whatsit node of
264 subtype \type {pdf_refximage}, filled with the image parameters \type {width},
265 \type {height}, \type {depth}, and \type {objnum}. Also here you can do a terse
266 call like:
268 \starttyping
269 n = img.node ({ filename = "foo.png" })
270 \stoptyping
272 This example outputs an image:
274 \starttyping
275 node.write(img.node{filename="foo.png"})
276 \stoptyping
278 \subsection{\type {types}}
280 \startfunctioncall
281 <table> types = img.types()
282 \stopfunctioncall
284 This function returns a list with the supported image file type names, currently
285 these are \type {pdf}, \type {png}, \type {jpg}, \type {jp2} (JPEG~2000), and
286 \type {jbig2}.
288 \subsection{\type {boxes}}
290 \startfunctioncall
291 <table> boxes = img.boxes()
292 \stopfunctioncall
294 This function returns a list with the supported \PDF\ page box names, currently
295 these are \type {media}, \type {crop}, \type {bleed}, \type {trim}, and \type
296 {art}, all in lowercase letters.
298 \section{The \type {mplib} library}
300 The \MP\ library interface registers itself in the table \type {mplib}. It is
301 based on \MPLIB\ version \ctxlua {context(mplib.version())}.
303 \subsection{\type {new}}
305 To create a new \METAPOST\ instance, call
307 \startfunctioncall
308 <mpinstance> mp = mplib.new({...})
309 \stopfunctioncall
311 This creates the \type {mp} instance object. The argument hash can have a number
312 of different fields, as follows:
314 \starttabulate[|lT|l|p|p|]
315 \NC \rmbf name \NC \bf type \NC \bf description \NC \bf default \NC \NR
316 \NC error_line \NC number \NC error line width \NC 79 \NC \NR
317 \NC print_line \NC number \NC line length in ps output \NC 100 \NC \NR
318 \NC random_seed \NC number \NC the initial random seed \NC variable \NC \NR
319 \NC interaction \NC string \NC the interaction mode,
320 one of
321 \type {batch},
322 \type {nonstop},
323 \type {scroll},
324 \type {errorstop} \NC \type {errorstop} \NC \NR
325 \NC job_name \NC string \NC \type {--jobname} \NC \type {mpout} \NC \NR
326 \NC find_file \NC function \NC a function to find files \NC only local files \NC \NR
327 \stoptabulate
329 The \type {find_file} function should be of this form:
331 \starttyping
332 <string> found = finder (<string> name, <string> mode, <string> type)
333 \stoptyping
335 with:
337 \starttabulate[|lT|l|p|]
338 \NC \bf name \NC \bf the requested file \NC \NR
339 \NC mode \NC the file mode: \type {r} or \type {w} \NC \NR
340 \NC type \NC the kind of file, one of: \type {mp}, \type {tfm}, \type {map},
341 \type {pfb}, \type {enc} \NC \NR
342 \stoptabulate
344 Return either the full path name of the found file, or \type {nil} if the file
345 cannot be found.
347 Note that the new version of \MPLIB\ no longer uses binary mem files, so the way
348 to preload a set of macros is simply to start off with an \type {input} command
349 in the first \type {mp:execute()} call.
351 \subsection{\type {mp:statistics}}
353 You can request statistics with:
355 \startfunctioncall
356 <table> stats = mp:statistics()
357 \stopfunctioncall
359 This function returns the vital statistics for an \MPLIB\ instance. There are
360 four fields, giving the maximum number of used items in each of four allocated
361 object classes:
363 \starttabulate[|lT|l|p|]
364 \NC main_memory \NC number \NC memory size \NC \NR
365 \NC hash_size \NC number \NC hash size\NC \NR
366 \NC param_size \NC number \NC simultaneous macro parameters\NC \NR
367 \NC max_in_open \NC number \NC input file nesting levels\NC \NR
368 \stoptabulate
370 Note that in the new version of \MPLIB, this is informational only. The objects
371 are all allocated dynamically, so there is no chance of running out of space
372 unless the available system memory is exhausted.
374 \subsection{\type {mp:execute}}
376 You can ask the \METAPOST\ interpreter to run a chunk of code by calling
378 \startfunctioncall
379 <table> rettable = mp:execute('metapost language chunk')
380 \stopfunctioncall
382 for various bits of \METAPOST\ language input. Be sure to check the \type
383 {rettable.status} (see below) because when a fatal \METAPOST\ error occurs the
384 \MPLIB\ instance will become unusable thereafter.
386 Generally speaking, it is best to keep your chunks small, but beware that all
387 chunks have to obey proper syntax, like each of them is a small file. For
388 instance, you cannot split a single statement over multiple chunks.
390 In contrast with the normal stand alone \type {mpost} command, there is {\em no}
391 implied \quote{input} at the start of the first chunk.
393 \subsection{\type {mp:finish}}
395 \startfunctioncall
396 <table> rettable = mp:finish()
397 \stopfunctioncall
399 If for some reason you want to stop using an \MPLIB\ instance while processing is
400 not yet actually done, you can call \type {mp:finish}. Eventually, used memory
401 will be freed and open files will be closed by the \LUA\ garbage collector, but
402 an explicit \type {mp:finish} is the only way to capture the final part of the
403 output streams.
405 \subsection{Result table}
407 The return value of \type {mp:execute} and \type {mp:finish} is a table with a
408 few possible keys (only \type {status} is always guaranteed to be present).
410 \starttabulate[|Tl|l|p|]
411 \NC log \NC string \NC output to the \quote {log} stream \NC \NR
412 \NC term \NC string \NC output to the \quote {term} stream \NC \NR
413 \NC error \NC string \NC output to the \quote {error} stream
414 (only used for \quote {out of memory}) \NC \NR
415 \NC status \NC number \NC the return value:
416 \type {0} = good,
417 \type {1} = warning,
418 \type {2} = errors,
419 \type {3} = fatal error \NC \NR
420 \NC fig \NC table \NC an array of generated figures (if any) \NC \NR
421 \stoptabulate
423 When \type {status} equals~3, you should stop using this \MPLIB\ instance
424 immediately, it is no longer capable of processing input.
426 If it is present, each of the entries in the \type {fig} array is a userdata
427 representing a figure object, and each of those has a number of object methods
428 you can call:
430 \starttabulate[|Tl|l|p|]
431 \NC boundingbox \NC function \NC returns the bounding box, as an array of 4
432 values\NC \NR
433 \NC postscript \NC function \NC returns a string that is the ps output of the
434 \type {fig}. this function accepts two optional
435 integer arguments for specifying the values of
436 \type {prologues} (first argument) and \type
437 {procset} (second argument)\NC \NR
438 \NC svg \NC function \NC returns a string that is the svg output of the
439 \type {fig}. This function accepts an optional
440 integer argument for specifying the value of
441 \type {prologues}\NC \NR
442 \NC objects \NC function \NC returns the actual array of graphic objects in
443 this \type {fig} \NC \NR
444 \NC copy_objects \NC function \NC returns a deep copy of the array of graphic
445 objects in this \type {fig} \NC \NR
446 \NC filename \NC function \NC the filename this \type {fig}'s \POSTSCRIPT\
447 output would have written to in stand alone
448 mode \NC \NR
449 \NC width \NC function \NC the \type {fontcharwd} value \NC \NR
450 \NC height \NC function \NC the \type {fontcharht} value \NC \NR
451 \NC depth \NC function \NC the \type {fontchardp} value \NC \NR
452 \NC italcorr \NC function \NC the \type {fontcharit} value \NC \NR
453 \NC charcode \NC function \NC the (rounded) \type {charcode} value \NC \NR
454 \stoptabulate
456 Note: you can call \type {fig:objects()} only once for any one \type {fig}
457 object!
459 When the boundingbox represents a \quote {negated rectangle}, i.e.\ when the
460 first set of coordinates is larger than the second set, the picture is empty.
462 Graphical objects come in various types that each has a different list of
463 accessible values. The types are: \type {fill}, \type {outline}, \type {text},
464 \type {start_clip}, \type {stop_clip}, \type {start_bounds}, \type {stop_bounds},
465 \type {special}.
467 There is helper function (\type {mplib.fields(obj)}) to get the list of
468 accessible values for a particular object, but you can just as easily use the
469 tables given below.
471 All graphical objects have a field \type {type} that gives the object type as a
472 string value; it is not explicit mentioned in the following tables. In the
473 following, \type {number}s are \POSTSCRIPT\ points represented as a floating
474 point number, unless stated otherwise. Field values that are of type \type
475 {table} are explained in the next section.
477 \subsubsection{fill}
479 \starttabulate[|Tl|l|p|]
480 \NC path \NC table \NC the list of knots \NC \NR
481 \NC htap \NC table \NC the list of knots for the reversed trajectory \NC \NR
482 \NC pen \NC table \NC knots of the pen \NC \NR
483 \NC color \NC table \NC the object's color \NC \NR
484 \NC linejoin \NC number \NC line join style (bare number)\NC \NR
485 \NC miterlimit \NC number \NC miterlimit\NC \NR
486 \NC prescript \NC string \NC the prescript text \NC \NR
487 \NC postscript \NC string \NC the postscript text \NC \NR
488 \stoptabulate
490 The entries \type {htap} and \type {pen} are optional.
492 There is helper function (\type {mplib.pen_info(obj)}) that returns a table
493 containing a bunch of vital characteristics of the used pen (all values are
494 floats):
496 \starttabulate[|Tl|l|p|]
497 \NC width \NC number \NC width of the pen \NC \NR
498 \NC sx \NC number \NC $x$ scale \NC \NR
499 \NC rx \NC number \NC $xy$ multiplier \NC \NR
500 \NC ry \NC number \NC $yx$ multiplier \NC \NR
501 \NC sy \NC number \NC $y$ scale \NC \NR
502 \NC tx \NC number \NC $x$ offset \NC \NR
503 \NC ty \NC number \NC $y$ offset \NC \NR
504 \stoptabulate
506 \subsubsection{outline}
508 \starttabulate[|Tl|l|p|]
509 \NC path \NC table \NC the list of knots \NC \NR
510 \NC pen \NC table \NC knots of the pen \NC \NR
511 \NC color \NC table \NC the object's color \NC \NR
512 \NC linejoin \NC number \NC line join style (bare number) \NC \NR
513 \NC miterlimit \NC number \NC miterlimit \NC \NR
514 \NC linecap \NC number \NC line cap style (bare number) \NC \NR
515 \NC dash \NC table \NC representation of a dash list \NC \NR
516 \NC prescript \NC string \NC the prescript text \NC \NR
517 \NC postscript \NC string \NC the postscript text \NC \NR
518 \stoptabulate
520 The entry \type {dash} is optional.
522 \subsubsection{text}
524 \starttabulate[|Tl|l|p|]
525 \NC text \NC string \NC the text \NC \NR
526 \NC font \NC string \NC font tfm name \NC \NR
527 \NC dsize \NC number \NC font size \NC \NR
528 \NC color \NC table \NC the object's color \NC \NR
529 \NC width \NC number \NC \NC \NR
530 \NC height \NC number \NC \NC \NR
531 \NC depth \NC number \NC \NC \NR
532 \NC transform \NC table \NC a text transformation \NC \NR
533 \NC prescript \NC string \NC the prescript text \NC \NR
534 \NC postscript \NC string \NC the postscript text \NC \NR
535 \stoptabulate
537 \subsubsection{special}
539 \starttabulate[|Tl|l|p|]
540 \NC prescript \NC string \NC special text \NC \NR
541 \stoptabulate
543 \subsubsection{start_bounds, start_clip}
545 \starttabulate[|Tl|l|p|]
546 \NC path \NC table \NC the list of knots \NC \NR
547 \stoptabulate
549 \subsubsection{stop_bounds, stop_clip}
551 Here are no fields available.
553 \subsection{Subsidiary table formats}
555 \subsubsection{Paths and pens}
557 Paths and pens (that are really just a special type of paths as far as \MPLIB\ is
558 concerned) are represented by an array where each entry is a table that
559 represents a knot.
561 \starttabulate[|lT|l|p|]
562 \NC left_type \NC string \NC when present: endpoint, but usually absent \NC \NR
563 \NC right_type \NC string \NC like \type {left_type} \NC \NR
564 \NC x_coord \NC number \NC X coordinate of this knot \NC \NR
565 \NC y_coord \NC number \NC Y coordinate of this knot \NC \NR
566 \NC left_x \NC number \NC X coordinate of the precontrol point of this knot \NC \NR
567 \NC left_y \NC number \NC Y coordinate of the precontrol point of this knot \NC \NR
568 \NC right_x \NC number \NC X coordinate of the postcontrol point of this knot \NC \NR
569 \NC right_y \NC number \NC Y coordinate of the postcontrol point of this knot \NC \NR
570 \stoptabulate
572 There is one special case: pens that are (possibly transformed) ellipses have an
573 extra string-valued key \type {type} with value \type {elliptical} besides the
574 array part containing the knot list.
576 \subsubsection{Colors}
578 A color is an integer array with 0, 1, 3 or 4 values:
580 \starttabulate[|Tl|l|p|]
581 \NC 0 \NC marking only \NC no values \NC \NR
582 \NC 1 \NC greyscale \NC one value in the range $(0,1)$, \quote {black} is $0$ \NC \NR
583 \NC 3 \NC \RGB \NC three values in the range $(0,1)$, \quote {black} is $0,0,0$ \NC \NR
584 \NC 4 \NC \CMYK \NC four values in the range $(0,1)$, \quote {black} is $0,0,0,1$ \NC \NR
585 \stoptabulate
587 If the color model of the internal object was \type {uninitialized}, then it was
588 initialized to the values representing \quote {black} in the colorspace \type
589 {defaultcolormodel} that was in effect at the time of the \type {shipout}.
591 \subsubsection{Transforms}
593 Each transform is a six|-|item array.
595 \starttabulate[|Tl|l|p|]
596 \NC 1 \NC number \NC represents x \NC \NR
597 \NC 2 \NC number \NC represents y \NC \NR
598 \NC 3 \NC number \NC represents xx \NC \NR
599 \NC 4 \NC number \NC represents yx \NC \NR
600 \NC 5 \NC number \NC represents xy \NC \NR
601 \NC 6 \NC number \NC represents yy \NC \NR
602 \stoptabulate
604 Note that the translation (index 1 and 2) comes first. This differs from the
605 ordering in \POSTSCRIPT, where the translation comes last.
607 \subsubsection{Dashes}
609 Each \type {dash} is two-item hash, using the same model as \POSTSCRIPT\ for the
610 representation of the dashlist. \type {dashes} is an array of \quote {on} and
611 \quote {off}, values, and \type {offset} is the phase of the pattern.
613 \starttabulate[|Tl|l|p|]
614 \NC dashes \NC hash \NC an array of on-off numbers \NC \NR
615 \NC offset \NC number \NC the starting offset value \NC \NR
616 \stoptabulate
618 \subsection{Character size information}
620 These functions find the size of a glyph in a defined font. The \type {fontname}
621 is the same name as the argument to \type {infont}; the \type {char} is a glyph
622 id in the range 0 to 255; the returned \type {w} is in AFM units.
624 \subsubsection{\type {mp:char_width}}
626 \startfunctioncall
627 <number> w = mp:char_width(<string> fontname, <number> char)
628 \stopfunctioncall
630 \subsubsection{\type {mp:char_height}}
632 \startfunctioncall
633 <number> w = mp:char_height(<string> fontname, <number> char)
634 \stopfunctioncall
636 \subsubsection{\type {mp:char_depth}}
638 \startfunctioncall
639 <number> w = mp:char_depth(<string> fontname, <number> char)
640 \stopfunctioncall
642 \stopchapter