/usr/share/doc/xgridfit/html/graphics.html is in xgridfit-doc 2.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>xgridfit</title>
<link rel="stylesheet" href="oeg.css" media="screen" type="text/css" />
<link rel="stylesheet" href="parchment.css" media="screen"
type="text/css" title="parchment" />
<link rel="alternate stylesheet" href="legible.css" media="screen"
type="text/css" title="legible" />
<style type="text/css" media="print"> @import "oeg.print.css"; </style>
<meta name="AUTHOR" content="Peter S. Baker" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<div id="jumplist">
<a href="http://sourceforge.net"><img
src=""
width="125" height="37" border="0" alt="SourceForge.net Logo" /></a>
<a href="http://xgridfit.sourceforge.net/">Home Page</a>
<a href="http://sourceforge.net/projects/xgridfit">Project Page</a>
<a href="http://sourceforge.net/project/showfiles.php?group_id=159705">Download</a>
<a href="http://xgridfit.cvs.sourceforge.net/xgridfit/xgridfit/">CVS repository</a>
<hr/>
<a href="#read-write">Reading and Writing</a>
<a href="#set-default">Setting Defaults</a>
<a href="#engine">Engine and Glyph Info</a>
<a href="#storage">Graphics and Storage Area</a>
<a href="#other-defaults">Other Defaults</a>
</div>
<div id="content">
<h1>The Graphics State and Xgridfit Defaults</h1>
<p>
The graphics state is a collection of variables that control the
behavior of TrueType instructions. These include the <a
href="round.html">round state</a>, <a
href="vectors.html">vectors</a>, <a
href="cvt.html#cvt-cut-in">control-value cut-in</a>, <a
href="reference.html#set-minimum-distance">minimum distance</a>,
<a href="reference.html#set-single-width">single width</a>, <a
href="reference.html#set-auto-flip">auto flip</a>, <a
href="reference.html#set-dropout-control">dropout control</a>, <a
href="deltas.html#set-delta-shift">delta shift</a>, <a
href="deltas.html#set-delta-base">delta base</a>, and <a
href="reference.html#enable-instructions">enable</a>/<a
href="reference.html#disable-instructions">disable
instructions</a>. The graphics state also includes the <a
href="reference.html#srp">reference pointers</a> and <a
href="reference.html#szp">zone pointers</a>, but it is not
recommended that you set these directly in Xgridfit. The uses of
the graphics variables are described elsewhere in this
documentation: this section describes how the graphics variables
are controlled in Xgridfit.
</p>
<h2 id="read-write">Reading and Writing the Graphics State</h2>
<p>
The most important graphics variables can be accessed in any of
three ways: they can be set via a "set" instruction or a "with"
block, and they can be read or set via a special variable.
</p>
<p>
A "set" instruction simply sets the graphics variable, which
remains as set until the end of the glyph program, or until set by
another instruction. These are the "set"
instructions in Xgridfit:
</p>
<ul>
<li><a href="reference.html#set-auto-flip"><set-auto-flip></a></li>
<li><a href="reference.html#set-control-value-cut-in"><set-control-value-cut-in></a></li>
<li><a href="reference.html#set-delta-base"><set-delta-base></a></li>
<li><a href="reference.html#set-delta-shift"><set-delta-shift></a></li>
<li><a href="reference.html#set-dropout-control"><set-dropout-control></a></li>
<li><a href="reference.html#set-dropout-type"><set-dropout-type></a></li>
<li><a href="reference.html#set-dual-projection-vector"><set-dual-projection-vector></a></li>
<li><a href="reference.html#set-freedom-vector"><set-freedom-vector></a></li>
<li><a href="reference.html#set-minimum-distance"><set-minimum-distance></a></li>
<li><a href="reference.html#set-projection-vector"><set-projection-vector></a></li>
<li><a href="reference.html#set-round-state"><set-round-state></a></li>
<li><a href="reference.html#set-single-width"><set-single-width></a></li>
<li><a href="reference.html#set-single-width-cut-in"><set-single-width-cut-in></a></li>
<li><a href="reference.html#set-vectors"><set-vectors></a></li>
</ul>
<p>
A "with" block is a block of code enclosed by an element whose
name begins "with-": a graphics variable is set before the code in
the "with" block is executed, and afterwards is restored to its
former state. Example:
</p>
<pre>
<with-minimum-distance value="0.55">
<diagonal-stem round="no">
<line ref="line1"/>
<line ref="line2"/>
</diagonal-stem>
</with-minimum-distance>
</pre>
<p>
These are the "with" elements in Xgridfit (note that a few "set"
elements do not have corresponding "with" elements):
</p>
<ul>
<li><a href="reference.html#set-control-value-cut-in"><with-control-value-cut-in></a></li>
<li><a href="reference.html#set-delta-base"><with-delta-base></a></li>
<li><a href="reference.html#set-delta-shift"><with-delta-shift></a></li>
<li><a href="reference.html#set-freedom-vector"><with-freedom-vector></a></li>
<li><a href="reference.html#set-minimum-distance"><with-minimum-distance></a></li>
<li><a href="reference.html#with-param"><with-param></a></li>
<li><a href="reference.html#set-projection-vector"><with-projection-vector></a></li>
<li><a href="reference.html#set-round-state"><with-round-state></a></li>
<li><a href="reference.html#set-single-width"><with-single-width></a></li>
<li><a href="reference.html#set-single-width-cut-in"><with-single-width-cut-in></a></li>
<li><a href="reference.html#set-vectors"><with-vectors></a></li>
</ul>
<p>
A graphics variable can be read by any instruction that can read
variables, and most of them can be written by any instruction that
can write to variables. Here is an example of how a graphics
variable might be read:
</p>
<pre>
<with-minimum-distance value="minimum-distance * 0.66">
<diagonal-stem round="no">
<line ref="line1"/>
<line ref="line2"/>
</diagonal-stem>
</with-minimum-distance>
</pre>
<p>
And here is an example of how a graphics variable might be written
to:
</p>
<pre>
<set-equal target="minimum-distance" source="minimum-distance * 0.66"/>
</pre>
<p>
The code above has the same effect as this:
</p>
<pre>
<set-minimum-distance value="minimum-distance * 0.66"/>
</pre>
<p>
These graphics variables can be both read and written to:
</p>
<ul>
<li>minimum-distance</li>
<li>control-value-cut-in</li>
<li>single-width</li>
<li>single-width-cut-in</li>
<li>delta-base</li>
<li>delta-shift</li>
</ul>
<p>
Each of these variables has a "default" variant,
e.g. <tt>minimum-distance-default</tt>, which records the default
value, that is, the value the variable has at the beginning of
each glyph program. These may be written to only in the
<pre-program> (where writing to them sets the default
value); but they may be used elsewhere to restore a default value:
</p>
<pre>
<set-minimum-distance value="minimum-distance-default"/>
</pre>
<p>
There are two graphics variables that relate to the round state:
<tt>round-state</tt> and <tt>custom-round-state</tt>. These are
both read-only: the round state can be set only via
<set-round-state> and <with-round-state>. The
value of <tt>round-state</tt> can be tested against these
constants:
</p>
<ul>
<li>to-grid</li>
<li>to-half-grid</li>
<li>to-double-grid</li>
<li>down-to-grid</li>
<li>up-to-grid</li>
<li>no</li>
<li>custom</li>
</ul>
<p>
When <tt>round-state = custom</tt>, the value of the period, phase
and threshold is stored in <tt>custom-round-state</tt>. The three
values are not separated here, as they are in the
<round-state> element; rather, the three values are ANDed
into a single number, which is more suitable for storage and
retrieval than for analysis.
</p>
<p>
There are two other read-only values in the graphics state:
<tt>pixels-per-em</tt> and <tt>point-size</tt>. Of these,
<tt>pixels-per-em</tt> tends to be the more useful, and it is
often used to decide when to alter the outline at low resolution:
</p>
<pre>
<if test="pixels-per-em &lt; 20">
. . .
</if>
</pre>
<h2 id="set-default">Setting Defaults</h2>
<p>
A default value for a graphics variable is the value it has at the
beginning of each glyph program. There are two ways to set
defaults in Xgridfit: one is simply to place a "set" element
anywhere in the <pre-program>. The second, and recommended,
method is to include a <default> element in the top level of
your program file, thus:
</p>
<pre>
<default type="minimum-distance" value="0.9">
</pre>
<p>
That is, in the <default> element, the <tt>type</tt>
attribute identifies the graphics default to set, and the
<tt>value</tt> attribute is the value. These types are available
for use in <default> elements:
</p>
<ul>
<li>minimum-distance</li>
<li>control-value-cut-in</li>
<li>single-width</li>
<li>single-width-cut-in</li>
<li>delta-base</li>
<li>delta-shift</li>
<li>round-state</li>
</ul>
<p>
To reset any of these to the default value you have set (or to the
TrueType default if you have not set one yourself), pass one of
these types to <restore-default>, thus:
</p>
<pre>
<restore-default name="delta-shift"/>
</pre>
<p>
If you want the TrueType engine to reject all attempts to set
defaults (that is, if you want to use only the defaults that are
standard for TrueType), include this:
</p>
<pre>
<default type="use-truetype-defaults" value="yes"/>
</pre>
<p>
The result will be that "set" instructions encountered in the
<pre-program> will not set defaults, and <default>
elements that set the graphics state will be ignored.
</p>
<h2 id="engine">Getting Information about the Engine and Glyph</h2>
<p>
You can get a limited amount of information about the TrueType
engine. These read-only values are available for use in such
contexts as <if> elements and expressions:
</p>
<ul>
<li>
<tt>engine-version</tt>: returns a number that corresponds to a
specific version of the TrueType engine (or "scaler"). (This is
different from a version number such as "Xgridfit version
1.6."). The result can be tested against any of these constants:
<ul>
<li>engine-mac-6-init (1)</li>
<li>engine-mac-7 (2)</li>
<li>engine-windows-3-1 (3)</li>
<li>engine-freetype-1 (3)</li>
<li>engine-kanjitalk-6-1 (4)</li>
<li>engine-ms-1-5 (33)</li>
<li>engine-ms-1-6 (34)</li>
<li>engine-ms-1-6-plus (36)</li>
<li>engine-ms-1-7 (35)</li>
<li>engine-freetype-2 (35)</li>
<li>engine-ms-1-8 (37)</li>
<li>engine-ms-1-9 (38)</li>
</ul>
Here's a snippet of code to illustrate:
<pre>
<if test="engine-version = engine-freetype-2">
<!-- code here -->
</if></pre>
</li>
<li>
<tt>is-cleartype-enabled</tt>. This value will be true
(non-zero) if Microsoft's ClearType system is enabled.
</li>
<li>
<tt>is-compatible-width-enabled</tt>. This value will be true if
"compatible-width" ClearType is enabled. In this system, the
engine makes sure that use of ClearType does not change the text
layout.
</li>
<li>
<tt>is-symmetrical-smoothing-enabled</tt>. True if "symmetrical
smoothing" ClearType is enabled. If you have a use for this, you
presumably know what "symmetrical smoothing" is.
</li>
<li>
<tt>is-BGR-order</tt>. According to the Microsoft specification,
this is true if "ClearType is processing the LCD stripes in BGR
(Blue, Green, Red) order."
</li>
</ul>
<p>
You can also get information about the current glyph, which may
influence whether or how to write instructions:
</p>
<ul>
<li>
<tt>is-glyph-rotated</tt>. True (non-zero) if the current glyph
has been rotated.
</li>
<li>
<tt>is-glyph-stretched</tt>. True if the current glyph has been
stretched.
</li>
<li>
<tt>is-glyph-grayscale</tt>. True if the current glyph has been
rasterized for grayscale.
</li>
<li>
<tt>is-glyph-transformed</tt>. True if one or more of the above
three transformations has been performed.
</li>
</ul>
<h2 id="storage">The Graphics State and the Storage Area</h2>
<p>
Most TrueType graphics variables are write-only; that is, the
TrueType engine provides no instructions for determining their
current values. Xgridfit tracks the values of graphics variables
by using several reserved locations in the TrueType storage
area--the same area that is used to store variables. In order to
make sure that this system functions correctly, you should take
the following precautions:
</p>
<ul>
<li>
If your program file contains legacy code, set <default
type="legacy-storage"/> so that Xgridfit and the legacy code
will not be writing to the same storage locations. The easiest
way to determine the correct value for <tt>legacy-storage</tt>
is to copy the maxStorage value from the maxp table. Xgridfit's
conversion utility <tt>ttx2xgf</tt> does this for you
automatically. (<b>N.B. Merge-mode manages the storage area for
you automatically.</b>)
</li>
<li>
Avoid using low-level <command> elements to set graphics
variables, except in legacy code. This instruction:
<pre>
<command name="SMD" value="54"/></pre>
will set the minimum distance, but subsequent attempts to read
the <tt>minimum-distance</tt> graphics variable will yield
mistaken results, and the <with-minimum-distance> element
will restore the wrong value at the end of the block.
</li>
</ul>
<h2 id="other-defaults">Other Defaults</h2>
<p>
Several important defaults other than those relating to the
graphics state are also controlled with <default> elements
in the top level of your program file. These set values in the
TrueType maxp table or control aspects of the Xgridfit compiler's
behavior:
</p>
<ul>
<li>
<tt>max-twilight-points</tt>. Sets the number of points
available in the twilight zone.
</li>
<li>
<tt>max-storage</tt>. Sets the number of locations available in
the TrueType storage area. The default value is 64, which allows
for 24 reserved locations used by Xgridfit and 40 variables
defined by your programming. Increase or decrease this value
depending on the number of variables that are likely to be in
use at one time in your programs.
</li>
<li>
<tt>max-stack</tt>. Sets the size of the run-time stack. The
default is 256, which is usually large enough for Xgridfit's
purposes; but if your font includes legacy programming it may
have to be bigger.
</li>
<li>
<tt>legacy-storage</tt>. As explained above, the amount of
storage to be reserved for the use of legacy programming. This
is determined automatically when an older font is converted for
use with Xgridfit.
</li>
<li>
<tt>function-base</tt> tells Xgridfit where to start numbering
functions. Use this if you have declared some functions with the
<tt>num</tt> attribute (to support legacy code) and you are not
satisfied with Xgridfit's standard way of handling that
situation (starting the numbering after the highest numbered
function).
</li>
<li>
<tt>init-graphics</tt> tells Xgridfit whether or not to
initialize variables that will help it to track the graphics
state. Usually this is necessary, so the default is "yes"; but
if this value is "no," it is not done. This setting may be
overridden by including the <tt>init-graphics</tt> attribute on
any <glyph> element.
</li>
<li>
<tt>color</tt> is the "color" used for those elements
that can perform rounding (chiefly <move>, but also
<mirp>, <mdrp>, <round> and <no-round>;
also the round() operator) when no other color is
specified. Possible values are "black," "white" and "gray"; the
default is "gray."
</li>
<li>
<tt>auto-instr</tt> tells the compiler (running in merge-mode)
to generate code that makes FontForge auto-instruct a font.
</li>
<li>
<tt>auto-hint</tt> tells the compiler (running in merge-mode) to
generate code that makes FontForge auto-hint a font before
auto-instructing it. This has no effect except when
<tt>auto-instr</tt> is "yes," and then its default value is
"yes."
</li>
<li>
<tt>combine-prep</tt> tells the compiler (running in merge-mode)
to append the <pre-program> generated by Xgridfit to the
one that is already in the font or that is generated by the
FontForge auto-instructor. The default value is "yes."
</li>
<li>
<tt>delete-all</tt> tells the compiler to delete all TrueType
programming and data before installing Xgridfit code in a
font. It is always "yes" if <tt>auto-instr</tt> is "yes."
</li>
<li>
<tt>cv-num-in-compile-if</tt> tells the Xgridfit compiler
(running in merge-mode) to resolve any control-value index as a
number rather than as a symbol for use in the <tt>test</tt>
attribute of the <compile-if> element and in the
<tt>compile-if</tt> attribute on various elements. The default
value is "no."
</li>
</ul>
</div>
</body>
</html>
|