/usr/share/doc/xgridfit/html/xinclude.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 | <!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>
</div>
<div id="content">
<h1>Managing large projects</h1>
<h2>XInclude</h2>
<p>
Instructions for large fonts and font families may be split into
parts so as to speed compilation for testing purposes, distribute
work among members of a team, or create libraries of shared
functions. Xgridfit's mechanism for splitting projects is <a
href="http://www.w3.org/TR/xinclude/">XInclude</a>, the W3C "XML
Inclusions" specification. XInclude is extremely flexible and
simple to use: it allows you to structure a complex project in a
number of ways.
</p>
<p>
To use XInclude in an Xgridfit file requires just two
steps. First, include the XInclude namespace declaration in the
<xgridfit> element:
</p>
<pre>
<xgridfit xmlns="http://xgridfit.sourceforge.net/Xgridfit2"
xmlns:xi="http://www.w3.org/2001/XInclude"></pre>
<p>
Next, to merge part of another file into the file you're
editing, add an <xi:include> element:
</p>
<pre>
<xi:include href="Junicode-Regular-Basic.xgf"
xpointer="xmlns(x=http://xgridfit.sourceforge.net/Xgridfit2)
xpointer(/x:xgridfit/x:glyph)"/></pre>
<p>
Here the <tt>href</tt> attribute (a URI) points to a file. The
<tt>xpointer</tt> attribute points to the element or elements that
we want to import into the current file; it is an <a
href="http://www.w3.org/TR/WD-xptr">XPointer</a> (usually a simple
<a href="http://www.w3.org/TR/xpath">XPath</a> expression). In the
present example, the XPointer expression pulls in all the
<glyph> elements from the file
<tt>Junicode-Regular-Basic.xgf</tt>.
</p>
<p>
It is necessary to specify the Xgridfit namespace for each
<xi:include> element, and this makes the <xi:include>
tag rather verbose; but much of this is boilerplate which can be
copied from tag to tag. Indeed, the only variable part of the
<tt>xpointer</tt> attribute is inside the final set of
parentheses.
</p>
<p>
Several Xgridfit elements can take an <tt>xml:id</tt>
attribute, and can be included by referencing that id:
<xgridfit>, <pre-program>, <function>,
<macro>, <glyph>. To fetch this <function>
element
</p>
<pre>
<function name="myfunc" xml:id="jun-reg-myfunc">
. . .
</function></pre>
<p>
use one of these <xi:include> elements:
</p>
<pre>
<xi:include href="Junicode-Regular-common.xgf" xpointer="jun-reg-myfunc"/>
<xi:include href="Junicode-Regular-common.xgf#jun-reg-myfunc"/></pre>
<p>
Notice that you do not need to worry about namespaces when you use
the <tt>xml:id</tt> method.
</p>
<p>
Some XSLT engines can handle XInclude and others cannot. The
XInclude capability in xsltproc (the engine invoked by the
xgridfit shell script) is turned on by simply
including the parameter <tt>--xinclude</tt> on the command line
(this is done for you in the shell script). For some other
engines, turning on XInclude capability is an arcane and difficult
matter: you must check the documentation for your preferred
engine. The <tt>xgridfit</tt> shell script uses <tt>xmllint</tt>
when necessary to work around difficulties with XSLT engines and
XML validators.
</p>
<h2>Example of a large project</h2>
<p>
XInclude is flexible enough to permit you to structure your
project in many different ways (you must just remember to avoid
recursive includes). Here is a simple example involving the <a
href="http://junicode.sf.net">Junicode</a> font (complete source
code available at the download site).
</p>
<p>
Instructions for Junicode-Regular are compiled by running xgridfit
against a master file, <tt>Junicode-Regular.xgf</tt>, which contains
little besides <xi:include> elements:
</p>
<pre>
<?xml version="1.0"?>
<xgridfit xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="Junicode-Regular-common.xgf"
xpointer="xmlns(x=http://xgridfit.sourceforge.net/Xgridfit2)
xpointer(/x:xgridfit/x:infile)"/>
<xi:include href="Junicode-Regular-common.xgf"
xpointer="xmlns(x=http://xgridfit.sourceforge.net/Xgridfit2)
xpointer(/x:xgridfit/x:outfile)"/>
<xi:include href="Junicode-Regular-common.xgf"
xpointer="xmlns(x=http://xgridfit.sourceforge.net/Xgridfit2)
xpointer(/x:xgridfit/x:constant)"/>
<xi:include href="Junicode-Regular-common.xgf"
xpointer="xmlns(x=http://xgridfit.sourceforge.net/Xgridfit2)
xpointer(//x:control-value)"/>
<xi:include href="Junicode-Regular-common.xgf"
xpointer="xmlns(x=http://xgridfit.sourceforge.net/Xgridfit2)
xpointer(//x:function)"/>
<xi:include href="Junicode-Regular-common.xgf"
xpointer="xmlns(x=http://xgridfit.sourceforge.net/Xgridfit2)
xpointer(//x:macro)"/>
<xi:include href="Junicode-Regular-common.xgf" xpointer="jun-reg-prep"/>
<xi:include href="Junicode-Regular-Basic.xgf"
xpointer="xmlns(x=http://xgridfit.sourceforge.net/Xgridfit2)
xpointer(/x:xgridfit/x:glyph)"/>
<xi:include href="Junicode-Regular-Latin1.xgf"
xpointer="xmlns(x=http://xgridfit.sourceforge.net/Xgridfit2)
xpointer(/x:xgridfit/x:glyph)"/>
<xi:include href="Junicode-Regular-LatExtA.xgf"
xpointer="xmlns(x=http://xgridfit.sourceforge.net/Xgridfit2)
xpointer(/x:xgridfit/x:glyph)"/>
<xi:include href="Junicode-Regular-LatExtA-dotlessi.xgf"
xpointer="xmlns(x=http://xgridfit.sourceforge.net/Xgridfit2)
xpointer(/x:xgridfit/x:glyph)"/>
<xi:include href="Junicode-Regular-LatExtB.xgf"
xpointer="xmlns(x=http://xgridfit.sourceforge.net/Xgridfit2)
xpointer(/x:xgridfit/x:glyph)"/>
<xi:include href="Junicode-Regular-IPA.xgf"
xpointer="xmlns(x=http://xgridfit.sourceforge.net/Xgridfit2)
xpointer(/x:xgridfit/x:glyph)"/>
<xi:include href="Junicode-Regular-SpacMod.xgf"
xpointer="xmlns(x=http://xgridfit.sourceforge.net/Xgridfit2)
xpointer(/x:xgridfit/x:glyph)"/>
<xi:include href="Junicode-Regular-CombDiac.xgf"
xpointer="xmlns(x=http://xgridfit.sourceforge.net/Xgridfit2)
xpointer(/x:xgridfit/x:glyph)"/>
<xi:include href="Junicode-Regular-LatExtAdd.xgf"
xpointer="xmlns(x=http://xgridfit.sourceforge.net/Xgridfit2)
xpointer(/x:xgridfit/x:glyph)"/>
<xi:include href="Junicode-Regular-GenPunct.xgf"
xpointer="xmlns(x=http://xgridfit.sourceforge.net/Xgridfit2)
xpointer(/x:xgridfit/x:glyph)"/>
<xi:include href="Junicode-Regular-Greek.xgf"
xpointer="xmlns(x=http://xgridfit.sourceforge.net/Xgridfit2)
xpointer(/x:xgridfit/x:glyph)"/>
<xi:include href="Junicode-Regular-PUA.xgf"
xpointer="xmlns(x=http://xgridfit.sourceforge.net/Xgridfit2)
xpointer(/x:xgridfit/x:glyph)"/>
<xi:include href="Junicode-Regular-NoEncode.xgf"
xpointer="xmlns(x=http://xgridfit.sourceforge.net/Xgridfit2)
xpointer(/x:xgridfit/x:glyph)"/>
</xgridfit></pre>
<p>
The file <tt>Junicode-Regular-common.xgf</tt> contains no
<glyph> elements, but only global elements: <infile>,
<outfile>, <constant>, <control-value>,
<function>, <macro>, <pre-program>. These are
included with the first seven xi:include elements (the
<pre-program> is included by <tt>xml:id</tt>, just by way of
illustration). The other files contain only <glyph> elements
organized by Unicode range. These are included with a specific
XPointer, <tt>/x:gridfit/x:glyph</tt>, rather than
<tt>//x:glyph</tt>, to avoid pulling in <glyph> elements
inside of <no-compile> elements. Each file validates against
the Relax NG schema xgridfit.rnc.
</p>
<p>
When working with any particular Unicode range, most or all of the
other <xi:include> elements can be commented out in the
master file, speeding compilation. If more than one developer were
working on this font, the file
<tt>Junicode-Regular-common.xgf</tt> might be controlled by the
lead developer so as to avoid conflicts introduced by individual
contributors, who when necessary would submit patches on that file
for approval.
</p>
<h2>Shared functions and libraries</h2>
<p>
You very likely have some favorite functions that you insert in
all your fonts. In addition, similar members of a font family are
likely to share functions. For a library of shared functions,
simply create an Xgridfit program file in which the only children
of the <xgridfit> element are <function> elements. An
Xgridfit program file can very easily merge the functions from
this library anywhere in the sequence of your own functions:
</p>
<pre>
<function name="local-function">
. . .
</function>
<xi:include href="My-Library.xgf#xpointer(//function)"/>
<function name="another-local-function">
. . .
</function></pre>
<p>
Alternatively, you can merge a single function from the library if
you have supplied that function with an <tt>xml:id</tt> attribute:
</p>
<pre>
<function name="local-function">
. . .
</function>
<xi:include href="My-Library.xgf#set-left-sidebearing"/>
<function name="another-local-function">
. . .
</function></pre>
<p>
Note that the included function must be called by its required
<tt>name</tt> attribute and not by the <tt>xml:id</tt> attribute,
which is needed only when a function is merged, before it gets
compiled. The <tt>name</tt> and <tt>xml:id</tt> attributes should
probably be the same when both are present.
</p>
<h2>Separate compilation of source files</h2>
<p>
Though an Xgridfit file is destined to be included in a master
file, it can also be compiled separately. This may be convenient
when writing instructions for a specific range of glyphs. To
prepare a file for separate compilation, simply use XInclude to
pull in global elements from the common file. For example, one of
the Junicode source files containing only glyphs has these
XIncludes:
</p>
<pre>
<xi:include href="Junicode-Regular-common.xgf"
xpointer="xmlns(x=http://xgridfit.sourceforge.net/Xgridfit2)
xpointer(/x:xgridfit/x:constant)"/>
<xi:include href="Junicode-Regular-common.xgf"
xpointer="xmlns(x=http://xgridfit.sourceforge.net/Xgridfit2)
xpointer(//x:control-value)"/>
<xi:include href="Junicode-Regular-common.xgf"
xpointer="xmlns(x=http://xgridfit.sourceforge.net/Xgridfit2)
xpointer(//x:function)"/>
<xi:include href="Junicode-Regular-common.xgf"
xpointer="xmlns(x=http://xgridfit.sourceforge.net/Xgridfit2)
xpointer(//x:pre-program)"/>
<xi:include href="Junicode-Regular-common.xgf"
xpointer="xmlns(x=http://xgridfit.sourceforge.net/Xgridfit2)
xpointer(//x:macro)"/></pre>
<p>
If any glyph program in the file needs to refer to a glyph program
in another file, this can also be pulled in via
XInclude. <xi:include> elements for this purpose should be
placed in a <no-compile> element, which makes them visible
to all the programming in the file but prevents their being
compiled. This is from <tt>Junicode-Regular-Latin1.xgf</tt>:
</p>
<pre>
<no-compile>
<xi:include href="Junicode-Regular-Basic.xgf"
xpointer="xmlns(x=http://xgridfit.sourceforge.net/Xgridfit2)
xpointer(/x:xgridfit/x:glyph)"/>
<xi:include href="Junicode-Regular-NoEncode.xgf" xpointer="CapAcute"/>
<xi:include href="Junicode-Regular-NoEncode.xgf" xpointer="CapCircumflex"/>
<xi:include href="Junicode-Regular-NoEncode.xgf" xpointer="CapDieresis"/>
<xi:include href="Junicode-Regular-NoEncode.xgf" xpointer="CapGrave"/>
<xi:include href="Junicode-Regular-NoEncode.xgf" xpointer="CapTilde"/>
<xi:include href="Junicode-Regular-SpacMod.xgf" xpointer="circumflex"/>
<xi:include href="Junicode-Regular-SpacMod.xgf" xpointer="tilde"/>
<xi:include href="Junicode-Regular-LatExtA-dotlessi.xgf" xpointer="dotlessi"/>
</no-compile></pre>
<p>
Note that any of these included glyphs <em>will</em> be compiled
if specified in a <glyph-select> element or with the
<tt>-g</tt> command-line option.
</p>
<p>
Remember that you must either take care to avoid recursive
XIncludes or comment out the XIncludes in a file before including
elements from it it in another file.
</p>
<p>
Another strategy for speeding development is to create a
quick-and-dirty Makefile for compiling and displaying a single
file of glyph programs. The following example uses merge-mode, in
which it is necessary first to compile the file containing the
font's common elements (functions, control-values, etc.) and run
that script. The Makefile compiles the common file only when it
has changed.
</p>
<pre>
FONTNAME = MyFont
RANGE = IPA
COMMON = $(FONTNAME)-common
COMMONSCRIPT = $(COMMON).py
COMMONXGF = $(COMMON).xgf
GLYPH = $(FONTNAME)-$(RANGE)
GLYPHSCRIPT = $(GLYPH).py
GLYPHXGF = $(GLYPH).xgf
SOURCEFONT = $(FONTNAME).sfd
OUTPUTFONT = $(FONTNAME).ttf
INTERMEDIATEFONT = temporary.sfd
$(COMMONSCRIPT) : $(COMMONXGF)
xgridfit -m -D -c yes -O $(COMMONSCRIPT) -o $(INTERMEDIATEFONT) \
-i $(SOURCEFONT) $(COMMONXGF)
$(GLYPHSCRIPT) : $(GLYPHXGF)
xgridfit -m -c no -O $(GLYPHSCRIPT) -o $(OUTPUTFONT) \
-i $(INTERMEDIATEFONT) $(GLYPHXGF)
$(INTERMEDIATEFONT) : $(COMMONSCRIPT) $(SOURCEFONT)
fontforge -script $(COMMONSCRIPT)
$(OUTPUTFONT) : $(COMMONSCRIPT) $(GLYPHSCRIPT) $(INTERMEDIATEFONT)
fontforge -script $(GLYPHSCRIPT)</pre>
<p>
When you type <tt>make MyFont.ttf</tt>, this Makefile does the
following:
</p>
<ul>
<li>
Compiles MyFont-common.xgf to make MyFont-common.py
</li>
<li>
Compiles MyFont-IPA.xgf to make MyFont-IPA.py
</li>
<li>
Runs the script MyFont-common.py against MyFont.sfd to create
temporary.sfd
</li>
<li>
Runs the script MyFont-IPA.py against temporary.sfd to make
MyFont.ttf
</li>
</ul>
<p>
This font contains all the glyphs in MyFont.sfd, but TrueType
instructions only for the glyphs in the IPA range. To do the same
with a file containing glyphs for another range, you need only
change the <tt>RANGE</tt> variable near the top of the file.
</p>
</div>
</body>
</html>
|