205 lines
6.1 KiB
HTML
205 lines
6.1 KiB
HTML
<!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">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<title>How to Understand Contours</title>
|
|
|
|
<link href="../default.css" type="text/css" rel="stylesheet" />
|
|
|
|
</head>
|
|
<body>
|
|
|
|
|
|
|
|
<div id="modellogo">
|
|
<img src="../img/drawmodel_header.jpg" width="595" height="112" />
|
|
</div>
|
|
<div class="leftcontent">
|
|
<h2 class="crb-seealso">
|
|
RoboFab
|
|
</h2>
|
|
<p class="menu">
|
|
<a href="../index.html">
|
|
Home
|
|
</a>
|
|
<br />
|
|
<a href="../download/license.html">
|
|
Download v1.1.1
|
|
</a>
|
|
<br />
|
|
<a href="../intro.html">
|
|
Intro
|
|
</a>
|
|
<br />
|
|
<a href="../install.html">
|
|
Install Notes
|
|
</a>
|
|
<br />
|
|
<a href="../history.html">
|
|
History
|
|
</a>
|
|
<br />
|
|
<a href="../executive.html">
|
|
Summary
|
|
</a>
|
|
</p>
|
|
<p class="menu">
|
|
<a href="index.html">
|
|
How to's
|
|
</a>
|
|
<br />
|
|
<a href="../objects/index.html">
|
|
Fab Objects
|
|
</a>
|
|
<br />
|
|
<a href="../objects/model.html">
|
|
Fab Map
|
|
</a>
|
|
<br />
|
|
<a href="../tools/index.html">
|
|
Fab Tools
|
|
</a>
|
|
<br />
|
|
<a href="../ufo/index.html">
|
|
UFO Overview
|
|
</a>
|
|
<br />
|
|
<a href="../limitations.html">
|
|
Fab Limitations
|
|
</a>
|
|
</p>
|
|
<p class="menu">
|
|
<a href="../links/index.html">
|
|
Links
|
|
</a>
|
|
<br />
|
|
<a href="../glossary/index.html">
|
|
Glossary
|
|
</a>
|
|
<br />
|
|
<a href="../credits.html">
|
|
Credits
|
|
</a>
|
|
</p>
|
|
<br />
|
|
<br />
|
|
<p class="crb-uplink"><a href="index.html">Back to How To</a></p>
|
|
|
|
<br />
|
|
<br />
|
|
<p class="menu">
|
|
<a href="../objects/anchor.html">RAnchor</a><br />
|
|
<a href="../objects/bpoint.html">bPoint</a><br />
|
|
<a href="../objects/component.html">RComponent</a><br />
|
|
<a href="../objects/contour.html">RContour</a><br />
|
|
<a href="../objects/point.html">RPoint</a><br />
|
|
<a href="../objects/segment.html">RSegment</a><br />
|
|
<a href="buildingaccents.html">Building accents</a><br />
|
|
<a href="fontlabremote.html">FontLab Remote</a><br />
|
|
<a href="generatefonts.html">Generate Fonts</a><br />
|
|
<a href="index.html">How To</a><br />
|
|
<a href="lowlevel.html">How to get to FontLab stuff</a><br />
|
|
<a href="scripting.html">Scripting</a><br />
|
|
<a href="usepens.html">Using Pens</a><br />
|
|
<a href="usethelib.html">Using the lib</a><br />
|
|
<a href="usetransformations.html">Using transformations</a><br />
|
|
<a href="world.html">The world module</a><br />
|
|
|
|
</p>
|
|
</div>
|
|
<div class="footer">
|
|
<a href="../feedback.html">
|
|
Feedback
|
|
</a>
|
|
<br />
|
|
<a href="../map.html">
|
|
Sitemap
|
|
</a>
|
|
<br />
|
|
Please also refer to the
|
|
<a href="../download/license.html">
|
|
Legal
|
|
</a>
|
|
<br />
|
|
Copyright 2003-2005 RoboFab
|
|
<br />
|
|
version 1.1.1
|
|
</div>
|
|
|
|
|
|
|
|
<div class="content">
|
|
<h1>Understanding Contours and Segments</h1>
|
|
<p>
|
|
Now, this is an important part of RoboFab so pay attention. In the world of digital font formats we have several different kinds of ways of describing outlines. Bezier curves for PostScript fonts, Quadratic curves for TrueType fonts. Each with their own peculiarities. RoboFab is format agnostic so it should be able to store all postscript and all truetype points. The structure here is meant to be able to do all that.
|
|
</p>
|
|
<p>
|
|
Diagrams by Tal Leming.
|
|
</p>
|
|
<h3>Contours</h3>
|
|
<p>
|
|
A glyph can contain one or more contours. Depending on what you want to do, there are different ways of looking at the data of the contour, the points, the line segments. The RContour object is way to the outlines. A description of the <a href="../objects/contour.html">RContour</a> object.
|
|
</p>
|
|
<br />
|
|
<img src="../objects/contours.jpg" alt="contour" width="300" height="300" />
|
|
<br />
|
|
<pre># take a glyph (one with outlines obviously)
|
|
c = CurrentGlyph()
|
|
# get to contours by index:
|
|
print c[0]
|
|
>>> < RContour for Mailer-Regular.a[0] >
|
|
|
|
print len(c[0])
|
|
>>> 15
|
|
# 15? 15 of what?
|
|
</pre> <h3>Segments</h3>
|
|
<p>
|
|
This circle consists of a couple of segments, each a piece of of the contour. A contour is a sequence of segments, you can iterate through a contour to get segments. A contour also has methods for adding and deleting segments.
|
|
<br />
|
|
<img src="../objects/contours_segments.jpg" alt="segments" width="300" height="300" />
|
|
<br />
|
|
</p>
|
|
<pre># segment code example
|
|
</pre>
|
|
<p>
|
|
In turn, a segment is made up of a sequence of points. Any number of off-curve points followed by an on-curve point. For the PostScript-centric designers: in TrueType outlines it is allowed to have any number of off-curve points before an on-curve. These points know whether they need to be rendered as bezier of quadratic curves. A description of the <a href="../objects/segment.html">RSegment</a> object.
|
|
<br />
|
|
<img src="../objects/contours_segments_points.jpg" alt="segments" width="300" height="300" />
|
|
<br />
|
|
</p>
|
|
<h3>Points</h3>
|
|
<p>
|
|
Another way to look at a contour is as a sequence of on-curve and off-curve points. This is the approach taken by glyph.drawPoints() and PointPen. A description of the <a href="../objects/point.html">RPoint</a> object.
|
|
</p>
|
|
<br />
|
|
<img src="../objects/contours_points.jpg" alt="segments" width="300" height="300" />
|
|
<br />
|
|
<pre>
|
|
# get straight to the points in a contour through the points attribute
|
|
g = CurrentGlyph()
|
|
for aPt in g[0].points:
|
|
>>> < RPoint for Special-Bold.A[0][0] >
|
|
< RPoint for Special-Bold[1][1] >
|
|
etc..
|
|
</pre> <h3>bPoints</h3>
|
|
<p>
|
|
This is another way to look at contours and its parts: bPoints behave very much like RoboFog points used to do. A point object has an incoming bcp, an on-curve ("anchor point" fog called it) and an outgoing bcp. This approach has been added for folks more at ease with the RoboFog structure. Note: if the contour contains series of off-curve points, bPoints won't help you. A description of the <a href="../objects/bpoint.html">bPoint</a> object.
|
|
</p>
|
|
<br />
|
|
<img src="../objects/contours_bpoints.jpg" alt="segments" width="300" height="300" />
|
|
<br />
|
|
<pre>
|
|
# bpoints
|
|
c = CurrentGlyph()
|
|
for aPt in c[0].bPoints:
|
|
print aPt.anchor
|
|
print aPt.bcpIn
|
|
print aPt.bcpOut
|
|
print aPt.type
|
|
>>> ...
|
|
etc..
|
|
</pre>
|
|
</div>
|
|
</body>
|
|
</html> |