File: bezier.html

package info (click to toggle)
fontforge 1%3A20230101~dfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 63,260 kB
  • sloc: ansic: 462,618; python: 6,916; cpp: 214; objc: 122; sh: 101; makefile: 55; xml: 11
file content (293 lines) | stat: -rw-r--r-- 18,719 bytes parent folder | download | duplicates (3)
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
<HTML>
<HEAD>
  <!-- Created with AOLpress/2.0 -->
  <!-- AP: Created on: 18-Dec-2000 -->
  <!-- AP: Last modified: 5-Apr-2006 -->
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<!--<TITLE>B&eacute;zier Splines</TITLE>-->
    <TITLE>B&eacute;zier スプライン</TITLE>
  <LINK REL="icon" href="../../_static/fftype16.png">
  <LINK REL="stylesheet" TYPE="text/css" HREF="FontForge.css">
</HEAD>
<BODY>
<DIV id="in">
  <H1 ALIGN=Center>
<!--  B&eacute;zier<SUP><SMALL><A HREF="#bezier">1</A></SMALL></SUP> Splines -->
      B&eacute;zier<SUP><SMALL><A HREF="#bezier">1</A></SMALL></SUP> スプライン
  </H1>
  <P>
  <IMG src="../../_images/splines.gif" WIDTH="172" HEIGHT="179" ALIGN="Left"><!-- Technically
  PostScript uses cubic B&eacute;zier splines. Each control point determines
  the slope of the spline at the corresponding end point. TrueType uses quadratic
  B&eacute;zier splines, in these there is only one control point between two
  end points and that point determines the slope of the spline at both end
  points. Both formats also use lines (which are linear B&eacute;zier splines).
   -->
  技術的には、PostScript は 3 次 B&eacute;zier スプラインを使用します。各制御点は、対応する端点におけるスプラインの傾きを決定します。TrueType が使用している 2 次 B&eacute;zier スプラインでは、2 個の端点の間には 1 個の制御点しかなく、その点が隣接する両方の端点における傾きを決定します。両フォーマットとも直線 (これは線形な B&eacute;zier スプラインです) も併用します。
  <P>
  <IMG src="../../_images/quadbezier.gif" WIDTH="113" HEIGHT="88" ALIGN="Right"><!--It is also
  possible to have other degree B&eacute;zier splines. For a quartic spline
  there would be 3 control points, for a quintic 4 control points, etc. Of
  these only the linear, quadratic and cubic splines are interesting to us--
  those used by TrueType and PostScript. -->
  他の次数の B&eacute;zier スプラインを作成することも可能です。4 次スプラインでは 3 個の制御点が存在し、5 次スプラインでは 4 個の制御点が、という具合です。そのなかで我々が関心をもっているのは線形, 2 次と 3 次のスプラインです——それらは TrueType と PostScript で使用されています。
  <P>
<!--
  The examples at left are cubic splines with two control points, each determining
  the slope at the nearest end point, while the example at right shows a quadratic
  spline with one control point used to determine the slopes at both end points.
  -->
  左の例は 2 個の制御点をもつ 3 次スプラインで、それぞれ近い側の端点における傾きを決定しています。一方、右に示した例は 2 次スプラインで、1 個の制御点が両側の端点における傾きを決定しています。
  <P>
<!--
  In general if there are n+1 points labeled P<SUB>0</SUB>, P<SUB>1</SUB>,
  ... P<SUB>n</SUB>, with P<SUB>0</SUB> and P<SUB>n</SUB> the end points (and
  all the others control points) then the equation of the B&eacute;zier spline
  between them is: <IMG SRC="Bezier.gif" WIDTH="137" HEIGHT="56" ALIGN="Middle">.
  If there are two points then this is just the line between the two end points,
  if three then the quadratic spline used by TrueType, if four then the cubic
  spline used by PostScript. -->
  一般的に、P<SUB>0</SUB>, P<SUB>1</SUB>,... P<SUB>n</SUB> というラベルのついた (n+1) 個の点がある場合、P<SUB>0</SUB> と P<SUB>n</SUB> が端点となり (その他はすべて制御点です)、B&eacute;zier スプラインを定義する等式は、<IMG src="../../_images/bezier.gif" WIDTH="137" HEIGHT="56" ALIGN="Middle"> となります。点が 2 個のときは、これは単に 2 個の端点を結ぶ線分となります。点が 3 個のときは TrueType で用いられている 2 次スプラインで、4 個のときは PostScript で用いられている 3 次スプラインです。
  <P>
<!--
  A cubic B&eacute;zier curve may be viewed as: -->
  3 次 B&eacute;zier 曲線はのように表示することができます:
  <BLOCKQUOTE>
    x = a<SUB>x</SUB>*t<SUP>3</SUP> + b<SUB>x</SUB>*t<SUP>2</SUP> +
    c<SUB>x</SUB>*t +d<SUB>x</SUB><BR>
    y = a<SUB>y</SUB>*t<SUP>3</SUP> + b<SUB>y</SUB>*t<SUP>2</SUP> +
    c<SUB>y</SUB>*t +d<SUB>y</SUB>
  </BLOCKQUOTE>
  <P>
<!--
  Where -->
  ここで
  <TABLE CELLPADDING="2">
    <TR>
      <TD>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
      <TD>d<SUB>x </SUB>= P0.x</TD>
      <TD>d<SUB>y</SUB> = P0.y</TD>
    </TR>
    <TR>
      <TD></TD>
      <TD>c<SUB>x</SUB> = 3*P1.x-3*P0.x</TD>
      <TD>c<SUB>y</SUB> = 3*P1.y-3*P0.y</TD>
    </TR>
    <TR>
      <TD></TD>
      <TD>b<SUB>x</SUB> = 3*P2.x-6*P1.x+3*P0.x</TD>
      <TD>b<SUB>y</SUB> = 3*P2.y-6*P1.y+3*P0.y</TD>
    </TR>
    <TR>
      <TD></TD>
      <TD>a<SUB>x</SUB> = P3.x-3*P2.x+3*P1.x-P0.x</TD>
      <TD>a<SUB>y</SUB> = P3.y-3*P2.y+3*P1.y-P0.y</TD>
    </TR>
  </TABLE>
  です。
  <P>
<!--
  And a quadratic B&eacute;zier curve: -->
  また、2 次 B&eacute;zier 曲線は以下のようになります:
  <TABLE CELLPADDING="2">
    <TR>
      <TD>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
      <TD>d<SUB>x </SUB>= P0.x</TD>
      <TD>d<SUB>y</SUB> = P0.y</TD>
    </TR>
    <TR>
      <TD></TD>
      <TD>c<SUB>x</SUB> = 2*P1.x-2*P0.x</TD>
      <TD>c<SUB>y</SUB> = 2*P1.y-2*P0.y</TD>
    </TR>
    <TR>
      <TD></TD>
      <TD>b<SUB>x</SUB> = P2.x-2*P1.x+P0.x</TD>
      <TD>b<SUB>y</SUB> = P2.y-2*P1.y+P0.y</TD>
    </TR>
  </TABLE>
  <P>
<!--
  And a line: -->
  そして直線は以下のとおりです:
  <TABLE CELLPADDING="2">
    <TR>
      <TD>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
      <TD>d<SUB>x </SUB>= P0.x</TD>
      <TD>d<SUB>y</SUB> = P0.y</TD>
    </TR>
    <TR>
      <TD></TD>
      <TD>c<SUB>x</SUB> = P1.x-P0.x</TD>
      <TD>c<SUB>y</SUB> = P1.y-P0.y</TD>
    </TR>
  </TABLE>
  <H2>
<!--  Converting <A NAME="ttf2ps">TrueType to PostScript</A>-->
      <A NAME="ttf2ps">TrueType を PostScript に</A>変換する方法
  </H2>
  <P>
<!--
  Lines convert with no math whatsoever. -->
  直線のフォーマット変換には数学は一切必要ありません.
  <P>
<!--
  Any quadratic spline can be expressed as a cubic (where the cubic term is
  zero). The end points of the cubic will be the same as the quadratic's. -->
  任意の 2 次スプラインは 3 次の表現をもちます (その場合、3 次の項が 0 となる)。3 次のときの端点は 2 次のときと同じです。
  <BLOCKQUOTE>
    CP<SUB>0</SUB> = QP<SUB>0</SUB><BR>
    CP<SUB>3</SUB> = QP<SUB>2</SUB>
  </BLOCKQUOTE>
  <P>
<!--
  The two control points for the cubic are: -->
  3 次表現での 2 個の制御点は、以下のようになります。
  <BLOCKQUOTE>
    CP<SUB>1</SUB> = QP<SUB>0</SUB> + 2/3
    *(QP<SUB>1</SUB>-QP<SUB>0</SUB>)<BR>
    CP<SUB>2</SUB> = CP<SUB>1</SUB> + 1/3 *(QP<SUB>2</SUB>-QP<SUB>0</SUB>)
  </BLOCKQUOTE>
  <P>
<!--
  So converting from TrueType to PostScript is trivial. There is a slight error
  introduced due to rounding, but it is unlikely to be noticeable. -->
  ですから、TrueType から PostScript への変換は自明です。丸めに伴う微小な誤差はありますが、それはほとんど気づかない程度のものです。
  <P>
<!--
  (Anish Mehta points out that in truetype it is possible to specify points
  which are in the middle of a pixel (ie. with an x or y value ending in 1/2).
  These will also introduce rounding errors when converted to postscript, but
  here the solution is simple: Scale the em-square of the font by a factor
  of 2 and the problem vanishes). -->
  (Anish Mehta から、TrueType ではピクセルの中間に位置する点を指定する (すなわち、x や y の値が 1/2 の端数をもつ) ことができるという指摘を受けました。これも PostScript への変換を行うときに丸め誤差を持ち込む原因となり得ます。しかし解決方法は単純です: フォントの EM 正方形を 2 倍に拡大すれば、問題はなくなります)。
  <H2>
<!--  Converting <A NAME="ps2ttf">Postscript to TrueType</A>-->
      <A NAME="ps2ttf">PostScript を TrueType に</A>変換する方法
  </H2>
  <P>
<!--
  Most cubic splines cannot be represented exactly by a quadratic (or even
  by a series of quadratics). The best that can be done is to approximate the
  cubic to within some margin of error. Here is a way to do that: -->
  ほとんどすべての 3 次スプラインは 2 次スプラインで正確に表現することができません (それどころか、2 次スプラインを連結しても表現できません)。可能な最良の手段は、3 次曲線をある程度の許容誤差の範囲で近似することです。ここにそれを行う方法を示します:
  <P>
<!--
  Given a cubic spline. Look at two points on the spline. Then there is only
  one possible quadratic spline between those two points which has the desired
  slope at those two points. (the one quadratic has its end points as the end
  points of the interval, and its control point is determined by the intersections
  of the lines tangent to the cubic at the start and end of the interval). -->
  3 次スプラインが与えられたとしましょう。スプライン上の 2 個の点に注目しましょう。その場合、それらの 2 点における傾きが求める値であるスプラインは、それら 2 個の点の間に 1 本しか引くことができません。(その 2 次曲線は、その区間の端点を端点とし、その制御点は、3 次曲線のその区間の始点と終点における接線の交点です)。
  <P>
<!--
  <IMG src="../../_images/cubic2quad.png" WIDTH="482" HEIGHT="180" ALIGN="Right">I cannot
  prove this, but have determined empirically (after being told it worked)
  that if a cubic spline - - like the quarter ellipse at right - - is divided
  "evenly" into n quadratic splines (here n==3) then the control points will
  have the nice property that the on-curve points are exactly mid-way between
  control points - - this means that truetype can represent them as interpolated
  points. An even division means means that each sub-point is placed where
  t=i/n (where 0&lt;i&lt;n). -->
  <IMG src="../../_images/cubic2quad.png" WIDTH="482" HEIGHT="180" ALIGN="Right">私はこれを証明できていませんが、3 次スプラインを——右図の 4 分の 1 楕円のごとく、n 本の 2 次スプライン (図では、n=3) へと——「均等に」分割すれば、その制御点同士の中点が曲線上の点となるのにちょうどよい比率になるということが (そう教えられて) 経験的な測定結果により知られています。これはつまり、TrueType ではそれらが補間された点として表現できるということになります。(「均等な」分割とは、t=i/n (ただし 0&lt;i&lt;n) の位置に点を置くことを指します。)
  <P>
<!--
  FontForge first checks to see if the curve is already a quadratic - - this
  might happen if the cubic originally came from a truetype font. If it is
  it simply converts the control point. -->
  FontForge は、曲線が既に 2 次曲線で表現可能になっているかを最初にチェックします——TrueType から変換して 3 次曲線を作った場合、そのような事が起こるでしょう。それに該当する場合、制御点を単純に変換するだけです。
  <P>
<!--
  Otherwise FontForge start inserting points. It begins by inserting a single
  point mid-way on the spline. If this produces a good approximation it stops,
  otherwise it tries again with two, three ... additional points. -->
  それ以外の場合、FontForge は点の挿入を開始します。まず最初に、スプラインの中央に 1 個の点を追加することから始めます。もし十分によい近似が得られるならそこで停止します。不十分ならば 2 個、3 個……と点の個数を増やして近似をやり直します。
  <P>
<!--
  On each test it will round the control points to integer values because truetype
  output requires this (note that it does not do this to the on-curve points,
  they are interpolated between control points and will be ok if the control
  points are). Then it checks to see if the resultant quadratics are close
  to the original curve. -->
  TrueType の座標値は整数しする必要があるので、毎回の検査時には、制御点を整数値に丸めます (曲線上の点に対してはこれを行わないことに注意してください。これは制御点の中点として補間されるので、制御点が整数になっていれば十分なのです)。次に、その結果として生成された 2 次曲線が元の曲線に近いかどうかをチェックします。
  <P>
<!--
  FontForge may also break the curve at its points of inflection (because no
  quadratic can have one there should be a point there to start a new quadratic)
  and apply the above algorithm to the components. -->
  FontForge は、曲線の変曲点に新しく点を加えて分割を行う可能性があります (2 次曲線の曲率方向は一定なので、通常は曲率方向が変化する点から先を新しい 2 次曲線に分け、それぞれに上記のアルゴリズムを適用する必要があるだろうからです)。
  <P>
<!--
  If FontForge can find no good approximation using the above algorithm it
  will fall back to its old method, which is: -->
  FontForge が上記のアルゴリズムを使用してうまく近似ができなかった場合、従来の方法に移行します。その手順は以下の通りです:
  <P>
<!--
  Start from the end of the spline and every so often (ie. within the margin
  of error) check to see if the one permissible quadratic approximation actually
  matches the cubic closely enough . -->
  スプライン上の片方の端点から始め、時折 (すなわち、許容誤差の範囲内で) ある許される 2 次近似が本当に、3 次曲線に十分密接に合致しているかをチェックします。
  <P>
<!--
  If this approximation works then keep it as part of the result, and continue
  the process by advancing our start point along to the cubic spline to the
  end of the quadratic we just created. -->
  もしこの近似がうまく行ったら、結果の一部としてそれらを保存し、開始点を 3 次スプラインに沿って、私たちがいま作成した 2 次曲線の端点に向かって延長します。
  <P>
<!--
  (There are some slight complexities introduced because there may not be a
  quadratic approximation at a given point (if the tangents happen to be parallel)
  or because the approximation happens to be linear, but these are easily dealt
  with). -->
  (指定された点において 2 次近似が存在するとは限らない (例えば交点がたまたま交点だった場合など) ため、何らかの微妙な複雑さが含まれている場合があります。しかしこれらは簡単に解消することができます)。
  <P>
<!--
  It may, of course, happen that the "cubic" we are given is actually a quadratic
  (if it's third degree term is 0), the most likely cause is that the font
  came from a truetype source. In that case the control point for the quadratic
  is at: -->
  もちろん、場合によっては、与えられた“3 次曲線”が実際には 2 次曲線であることもあります (3 次の項が 0 である場合)。その最もありふれた原因は、そのフォントの元データが TrueType である場合です。この場合、2 次曲線の制御点は以下のようになります:
  <BLOCKQUOTE>
    QP<SUB>1</SUB> = CP<SUB>0</SUB> + 3/2 * (CP<SUB>1</SUB> - CP<SUB>0</SUB>)
  </BLOCKQUOTE>
  <P>
<!--
  Other sources I have read on the net suggest checking the cubic spline for
  points of inflection (which quadratic splines cannot have) and forcing breaks
  there. To my eye this actually makes the result worse, it uses more points
  and the approximation does not look as close as it does when ignoring the
  points of inflection. So I ignore them. -->
  私がネット上で読んだ他の情報源では、3 次スプラインに変曲点 (これは 2 次曲線には存在しません) があるかどうかをチェックし、そこで強制的に分割することを提案しています。私の目には、この方法は実際にはより悪い結果をもたらすように見えます。より多くの点が必要になり、近似結果は、変曲点を無視したときほど元の線に近くないように見えます。そういうわけで、その提案は無視することにしました。
  <H2>
<!--  Open Type, another solution-->
      OpenType, もう一つの解決法
  </H2>
  <P>
<!--
  Adobe and Microsoft decided to produce one font format which could hold either
  a true type font or a postscript font. This is called Open Type. It is
  essentially a superset of TrueType. Any TrueType font is a valid Open Type
  font, but Open Type fonts can also contain postscript. Anything that supports
  Open Type will not require converting between PostScript and True Type. -->
  Adobe と Microsoft は TrueType フォントと PostScript フォントのどちらを格納することも可能なフォントフォーマットを作成することに決定しました。これは OpenType と呼ばれています。これは本質的には TrueType の拡張です。すべての TrueType フォントは正しい OpenType フォントですが、 OpenType フォントは PostScript を含むこともできます。OpenType をサポートするシステムではどれも、PostScript と TrueType の間の変換を必要としないでしょう。
  <H3>
<!--  See Also-->
      参照
  </H3>
  <UL>
    <LI>
<!--  <A HREF="pfaeditmath.html">FontForge's math</A>-->
      <A HREF="pfaeditmath.html">FontForge の数学</A>
  </UL>
  <P>
  <P>
<!--
  <SUP><A NAME="bezier">1 </A></SUP>B&eacute;zier splines were developed by
  Pierre B&eacute;zier (1910-1999). -->
  <SUP><A NAME="bezier">1 </A></SUP>B&eacute;zier スプラインは Pierre B&eacute;zier (1910-1999) によって開発されました。
  <P>
  <P ALIGN=Center>
  — <A HREF="sfdformat.html">前</A> — <A HREF="overview.html">目次</A> —
  <A HREF="corpchar.html">次</A> —
</DIV>
</BODY></HTML>