/usr/share/xml/xgridfit/utils/ff-functions.xgf is in xgridfit 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 | <?xml version="1.0" encoding="UTF-8"?>
<xgridfit xmlns="http://xgridfit.sourceforge.net/Xgridfit2">
<!--
The explanations of the FontForge functions are copied (with
minimal editing for clarity in the present context) from the
FontForge source file nowakowskittfinstr.c. That file contains
the following notice:
Copyright (C) 2000-2009 by
George Williams, Michal Nowakowski & Alexey Kryukov
Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the following
conditions are met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
The name of the author may not be used to endorse or promote
products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
-->
<macro name="ff-position-point-in-blue-zone">
<!--
Position a point within a blue zone (given via cvt). Note: in
case of successful init of 'cvt' and 'prep' this function
could be much simpler.
-->
<param name="pt"/>
<param name="cv-of-blue"/>
<push>pt cv-of-blue 0</push>
<command name="CALL"/>
</macro>
<macro name="ff-position-point-relative">
<!--
Place given point relatively to previous, maintaining the
minimum distance. Then call FPGM 12 to check if the point's
gridfitted position is too far from its original position, and
correct it, if necessary.
-->
<param name="pt"/>
<push>pt 1</push>
<command name="CALL"/>
</macro>
<macro name="ff-adjust-cv-at-low-res">
<!--
Below given ppem, substitute the width with cvt entry. Leave
the resulting width on the stack. Used as the first step in
normalizing cvt stems, see normalize_stem().
-->
<param name="width"/>
<param name="cv"/>
<param name="ppem"/>
<push>width cv ppem 2</push>
<command name="CALL"/>
</macro>
<macro name="ff-round-no-less-than-one-pixel">
<!--
Round a stack element as a black distance, respecting minimum
distance of 1px. This is used for rounding stems after width
normalization. Often preceeded with SROUND, so finally sets
RTG. Leaves the rounded width on the stack.
-->
<param name="val"/>
<push>val 3</push>
<command name="CALL"/>
</macro>
<macro name="ff-position-stem-second-edge">
<!--
Position the second edge of a stem that is not normally
regularized via cvt (but we snap it to cvt width below given
ppem). Vertical stems need special round state when not
snapped to cvt (basically, they are shortened by 0.25px before
being rounded).
-->
<param name="pt"/>
<param name="cv"/>
<param name="chg-rp0"/>
<param name="ppem"/>
<push>pt cv chg-rp0 ppem 4</push>
<command name="CALL"/>
</macro>
<macro name="ff-is-vertical">
<!--
Determine if we are hinting vertically. The function is crude
and it's use is limited to conditions set by SVTCA[]. Syntax:
PUSHB_1 5 CALL; leaves boolean on the stack.
-->
<push>5</push>
<command name="CALL"/>
</macro>
<macro name="ff-is-grayscale">
<!--
Check if we are hinting in grayscale. CAUTION! Older FreeType
versions lie if asked.
-->
<push>6</push>
<command name="CALL"/>
</macro>
<macro name="ff-is-cleartype">
<!--
Check if we are hinting in cleartype. CAUTION! FreeType
doesn't support that, as subpixel filtering is usually done by
higher level library.
-->
<push>7</push>
<command name="CALL"/>
</macro>
<macro name="ff-interpolate-and-snap">
<!--
Interpolate a point between two other points and snap it to
the grid.
-->
<param name="pt"/>
<param name="ref-pt-a"/>
<param name="ref-pt-b"/>
<push>pt ref-pt-a ref-pt-b 8</push>
<command name="CALL"/>
</macro>
<macro name="ff-link-serif-point">
<!--
Link a serif-like element edge to the opposite edge of the
base stem when rounding down to grid, but ensure that its
distance from the reference point is larger than the base stem
width at least to a specified amount of pixels.
-->
<param name="min-dist"/>
<param name="inner-pt"/>
<param name="outer-pt"/>
<push>min-dist inner-pt outer-pt 9</push>
<command name="CALL"/>
</macro>
<macro name="ff-link-serif-point-conditional">
<!--
Depending from the hinting mode (grayscale or mono) set rp0
either to pt1 or to pt2. This is used to link serif-like
elements either to the opposite side of the base stem or to
the same side (i. e. left-to-left and right-to-right).
-->
<param name="pt2"/>
<param name="pt1"/>
<push>pt2 pt1 10</push>
<command name="CALL"/>
</macro>
<macro name="ff-position-point-relative-no-min">
<!--
Similar to FPGM 1 (ff-position-point-relative), but places a
point without maintaining the minimum distance.
-->
<param name="pt"/>
<push>pt 11</push>
<command name="CALL"/>
</macro>
<macro name="ff-shift-from-too-far">
<!--
Check if the gridfitted position of the point is too far from
its original position, and shift it, if necessary. The
function is used to place vertical stems, it assures almost
linear advance width to PPEM scaling. Shift amount is capped
to at most 1 px to prevent some weird artifacts at very small
ppems. In cleartype mode, no shift is made at all.
-->
<param name="pt"/>
<push>pt 12</push>
<command name="CALL"/>
</macro>
<macro name="ff-interpolate-hstem-and-snap">
<!--
Interpolate a HStem edge's reference point between two other
points and snap it to the grid. Then compare its new position
with the ungridfitted position of the second edge. If the
gridfitted point belongs to the bottom edge and now it is
positioned above the top edge's original coordinate, then
shift it one pixel down; similarly, if the interpolation
resulted in positioning the top edge below the original
coordinate of the bottom edge, shift it one pixel up.
-->
<param name="other-edge-ref-pt"/>
<param name="pt"/>
<param name="ref-pt-a"/>
<param name="ref-pt-b"/>
<push> other-edge-ref-pt pt ref-pt-a ref-pt-b 13</push>
<command name="CALL"/>
</macro>
<macro name="ff-link-points-no-min">
<!--
Link two points using MDRP without maintaining the minimum
distance. In antialiased mode use rounding to double grid for
this operation, otherwise ensure there is no distance between
those two points below the given PPEM (i. e. points are
aligned). The function is used for linking nested stems to
each other, and guarantees their relative positioning is
preserved in the gridfitted outline.
-->
<param name="ppem"/>
<param name="ref-pt"/>
<param name="base-pt"/>
<push>ppem ref-pt base-pt 14</push>
<command name="CALL"/>
</macro>
<macro name="ff-position-point-relative-preserve-counter">
<!--
Similar to FPGM 1 (ff-position-point-relative), but used to
position a stem relatively to the previous stem preserving the
counter width equal to the distance between another pair of
previously positioned stems. Thus it serves nearly the same
purpose as PS counter hints.
-->
<param name="master-counter-start-pt"/>
<param name="master-counter-end-pt"/>
<param name="current-counter-start-pt"/>
<param name="current-counter-end-pt"/>
<param name="ppem"/>
<push>
master-counter-start-pt
master-counter-end-pt
current-counter-start-pt
current-counter-end-pt
ppem
15
</push>
<command name="CALL"/>
</macro>
<macro name="ff-position-point-relative-alt">
<!--
Same as FPGM 1 (ff-position-point-relative), but calls FPGM 18
rather than FPGM 12 and thus takes 3 arguments.
-->
<param name="ref-pt"/>
<param name="pt"/>
<push>ref-pt pt 16</push>
<command name="CALL"/>
</macro>
<macro name="ff-position-point-relative-no-min-alt">
<!--
Same as FPGM 11 (ff-position-point-relative-no-min), but calls
FPGM 18 rather than FPGM 12 and thus takes 3 arguments.
-->
<param name="ref-pt"/>
<param name="pt"/>
<push>ref-pt pt 17</push>
<command name="CALL"/>
</macro>
<macro name="ff-shift-from-too-far-alt">
<!--
This is a special version of FPGM 12 (ff-shift-from-too-far),
used when the counter control is enabled but doesn't directly
affect the stem which is going to be positioned. Unlike FPGM
12, it doesn't just attempt to position a point closely enough
to its original coordinate, but also checks if the previous
stem has already been shifted relatively to its "ideal"
position FPGM 12 would determine. If so, then the desired
point position is corrected relatively to the current
placement of the previous stem.
-->
<param name="ref-pt"/>
<param name="pt"/>
<push>ref-pt pt 18</push>
<command name="CALL"/>
</macro>
<macro name="ff-position-point-on-diagonal">
<!--
Used to align a point relatively to a diagonal line, specified
by two other points. First we check if the point going to be
positioned doesn't deviate too far from the line in the
original outline. If the deviation is small enough to neglect
it, we use ALIGNRP to position the point, otherwise MDRP is
used instead. We can't just always use MDRP, because this
command may produce wrong results at small PPEMs, if the
original and gridfitted coordinates of the line end points
specify slightly different unit vectors.
-->
<param name="pt"/>
<param name="diag-start-pt"/>
<param name="diag-end-pt"/>
<push>pt diag-start-pt diag-end-pt 19</push>
<command name="CALL"/>
</macro>
<macro name="ff-compute-projection-vector-adjustments">
<!--
Compute adjustments for X and Y components of projection
vector, for aspect ratios different than 1:1, and store them
in storage[0] and storage[1] respectively.
-->
<push>20</push>
<command name="CALL"/>
</macro>
<macro name="ff-adjust-aspect-ratio-before-setting-vector">
<!--
Compute adjustments for X and Y components of projection
vector, for aspect ratios different than 1:1, and store them
in storage[0] and storage[1] respectively.
-->
<param name="x"/>
<param name="y"/>
<push>x y 21</push>
<command name="CALL"/>
</macro>
</xgridfit>
|