:pserver:cvsanon@mok.lvcm.com:/CVS/ReactOS reactos
[reactos.git] / subsys / win32k / freetype / docs / ft2faq.html
1 <html>
2 <head>
3 <title>FreeType 2 FAQ</title>
4 <basefont face="Georgia, Arial, Helvetica, Geneva">
5 <style content="text/css">
6   P { text-align=justify }
7   H1 { text-align=center }
8   H2 { text-align=center }
9   LI { text-align=justify }
10 </style>
11 </head>
12
13 <body text="#000000"
14       bgcolor="#FFFFFF"
15       link="#0000EF"
16       vlink="#51188E"
17       alink="#FF0000">
18
19
20 <font size=1>http://www.freetype.org</font><p>
21
22 <center>
23   <a href="freetype.html">
24   <img src="image/freetype.jpg" width=550 height=105 alt="The FreeType Project" border=0></a>
25   <h1>The FreeType 2 FAQ</h1>
26 </center>
27
28 <center><table width=750 cellspacing=10 cellpadding=30><tr><td>
29 <hr><p>
30
31 DOCUMENT INDEX:<br>
32 <ul>
33   <li><p><a href="#general">General</a>
34     <ul>
35       <li><a href="#general-dead">I thought the FreeType project was dead. It this true?</a></li>
36       <li><a href="#general-long">Why did it take so long to release FreeType 2?</a></li>
37       <li><a href="#general-unix">Is FreeType 2 a Unix-only project?</a></li>
38       <li><a href="#general-x11">When will X11 support anti-aliased glyphs?</a></li>
39       <li><a href="#general-ft1">Is FreeType 2 backwards compatible with 1.x?</a></li>
40       <li><a href="#general-edit">Can I use FreeType 2 to edit fonts or create new ones?</a></li>
41     </ul></p>
42   </li>
43   <li><p><a href="#builds">Compilation & Configuration</a>
44     <ul>
45       <li><a href="#builds-compile">How do I compile the FreeType 2 library?</a></li>
46       <li><a href="#builds-config">How do I configure my library build?</a></li>
47       <li><a href="#builds-modules">How do I select the modules I need?</a></li>
48       <li><a href="#builds-flat">How do I compile all FreeType 2 files in a single directory?</a></li>
49     </ul>
50   </p></li>
51   <li><p><a href="#library">Using the FreeType 2 library</a></p></li>
52   <li><p><a href="#autohint">The FreeType 2 Autohinter</a>
53     <ul>
54       <li><a href="#autohint-license">Under which license is the auto-hinter released ?</a></li>
55       <li><a href="#autohint-work">How does auto-hinting work in FreeType 2 ?</a></li>
56       <li><a href="#autohint-cjk">Why doesn't the auto-hinter work well with CJK fonts ?</a></li>
57     </ul>
58   </p></li>
59   <li><p><a href="#other">Other questions</a>
60     <ul>
61       <li><a href="#other-antialias">What is the anti-aliasing algorithm used in the FreeType 2 renderer?</a></li>
62       <li><a href="#other-opentype">When will FreeType 2 support OpenType ?</a></li>
63     </ul></p>
64   </li>
65 </ul><p>
66
67
68 <hr><p>
69
70 <table width="100%" cellspacing=5><tr bgcolor="#CCCCEE"><td>
71 <h2 align=center><a name="general">General questions & answers</h2>
72 </td></tr><tr><td>
73
74 <a name="general-dead">
75 <h3>I.1. I though the FreeType project was dead. Is this true?</h3>
76 <ul>
77   <p>Well, not exactly :-) It's true that the TrueType patents issues
78      have been less than a graceful event to handle but it didn't not
79      really killed the project per se, as Apple hasn't made an official
80      statement yet regarding the use of the patented "technology" in
81      open source projects (or other products).</p>
82
83   <p>We have thus continued updating FreeType 1.x, and started developping
84      FreeType 2 with the idea of providing this time a completely patent
85      free font engine. However, we largely preferred not to broadly
86      communicate about it until we've got a satisfying implementation
87      to show.</p>
88 </ul>
89
90
91 <a name="general-long">
92 <h3>I.2. Why did it take so long to release FreeType 2?</h3>
93 <ul>
94   <p>Several factors come to mind. The first one is that FreeType 2 is
95      a much more complex and dense project that was mostly developed
96      on non-working hours. And surely some important changes in the
97      life (like marriage, new jobs and kids) of some the FreeType
98      developers cannot be ignored :-)</p>
99
100   <p>A second one is that a first version of the library was designed
101      one year ago (and already worked with a multitude of font drivers),
102      though with a design that was judged by its authors as well as
103      beta testers as not enough flexible or consistent. In short, it worked
104      well but we were not exactly proud of it (call us perfectionists).
105      It has then be significantly reworked to become what we're now
106      distributing as FreeType 2</p>
107
108   <p>Finally, it would have been hard to distribute such a library without
109      an alternative technology to replace the patented bytecode interpreter.
110      This involved significant research work that could only be performed
111      correctly full-time, and we had to found a company to fund such a
112      development and still make it available under a BSD-like license.
113      Huge thanks to <a href="http://www.catharon.com">Catharon Productions, Inc.</a>
114      for their commitment to this project.</p>
115
116   <p>And of course, we added support for more font files, and we'll
117      continue to as long as the specs are available and that we find an
118      interest in it. For example,  FreeType 2 is to date the only
119      software library available on the market that supports the new
120      Adobe "CEF" font format.</p>
121 </ul>
122
123 <a name="general-unix">
124 <h3>I.3. Is FreeType 2 a Unix-only project?</h3>
125 <ul>
126   <p>Absolutely not, even though many people still seem to think so :-)
127      FreeType 2, just like version 1.x, can be compiled on any platform with
128      an ANSI compiler. Some beta versions of the library are even heavily
129      used in brand new OSes (see the <a href="http://www.atheos.cx">AtheOS
130      </a> screenshots for examples).</p>
131
132   <p>The library is itself mainly developped on several platforms
133      (Windows & Linux, though a great deal has also been achieved on OS/2)
134      and the code is highly generic and modular to adapt even the most
135      strict environments like low-memory embedded systems.</p>
136
137 </ul>
138
139 <a name="general-x11">
140 <h3>I.4. When will X11/XFree support anti-aliased text?</h3>
141 <ul>
142   <p>This question isn't exactly related to FreeType as we have no direct
143      connection to the XFree people, but we've been asked so frequently
144      about it that it deserves a prominent place in this FAQ :-)</p>
145
146   <p>FreeType has been capable of anti-aliasing since version 1.0. The
147      reason why XFree doesn't support it is directly related to the
148      limitations of the design and specification of X11. More specifically:</p>
149
150   <ul>
151     <li><p>
152        X11 assumes that all glyph images are monochrome bitmaps,
153        hence the X font library and server are unable to send anything
154        else to the X server.
155     </p></li>
156
157     <li><p>
158        Even if the X font library/server was able to generate anti-aliased
159        bitmaps (and this has been already done through extensions), the X
160        rendering model doesn't allow translucent composition of "gray" pixmaps
161        onto an arbitrary drawable.
162     </p></li>
163   </ul>
164
165   <p>As both the font and rendering models of X11 are limited, it's basically
166      impossible to draw anti-aliased glyphs without performing <em>huge</em>
167      hacks within the server.</p>
168
169   <p>Note that Keith Packard, from XFree fame, has recently started working
170      on a new rendering model for X11 in order to support new features
171      (mainly transparency and anti-aliased fonts). This will be provided
172      through protocol extensions. The question of knowing wether legacy X
173      applications will be able to display anti-aliased text is still very
174      uncertain.
175      </p>
176 </ul>
177
178 <a name="general-ft1">
179 <h3>I.5. Is FreeType 2 backwards compatible with FreeType 1.x?</h3>
180 <ul>
181   <p>Not directly, though we had the project to provide an optional binary
182      compatibility layer on top of it in order to easily re-link applications
183      with the new version. However, this idea has been dropped as it is
184      possible to install and use the two versions independtly on any
185      system (read: no namespace conflicts).</p>
186
187   <p>The FreeType 2 API is a lot simpler than the one in 1.x while being
188      much more powerful. We thus encourage you to adapt your source code
189      to it as this should not involve much work.</p>
190
191 </ul>
192
193 <a name="general-edit">
194 <h3>I.6. Can I use FreeType 2 to edit fonts or create new ones?</h3>
195 <ul>
196   <p>The answer is a definitive NO, because the library was specifically
197      designed to <em>read</em> font files with small code size and very
198      low memory usage.</p>
199
200   <p>We thus do not plan to support editing or creation in the font
201      engine in any way, as this would imply a complete rewrite. This
202      doesn't mean that we won't introduce a font editing/creation library
203      in the future, as this really depends on how many people are asking
204      for it (or how much they would be willing to pay for it), as well as
205      the time of the FreeType developers.</p>
206
207   <p>Do not expect anything in this direction until we officially announce
208      something though. There are other axis of development for this project
209      (like text-layout capabilities, glyph caching, etc..) that may be more
210      important to us at the moment..</p>
211 </ul>
212
213 </td></tr></table>
214
215 <table width="100%" cellspacing=5><tr bgcolor="#CCCCEE"><td>
216 <h2 align=center><a name="builds">Compilation & Configuration</h2>
217 </td></tr><tr><td>
218
219 <a name="builds-compile">
220 <h3>II.1. How do I compile the FreeType 2 library?</h3>
221 <ul>
222   <p>The library can be compiled in various ways, and a detailed documentation
223      is available in the file "<tt>freetype2/docs/BUILD</tt>". However, we'll
224      summarize the process to a few cases:</p>
225
226   <h3>a. by using the command-line 2 build system</h3>
227
228   <p>The engine comes with a sophisticated build system that is used
229      to configure and compile a build of the library. You'll need
230      <em>GNU Make</em> installed on your platform (NOTE: It will <b>not</b>
231      work with other Make tools).</p>
232
233   <p>Basically, you'll need to invoke <tt>make</tt> a first time in the
234      top-level FreeType 2 directory in order to setup the build. This will
235      detect your current platform and choose a configuration sub-makefile to
236      drive the build. A specific compiler can be selected on some platforms
237      by providing an additional target. For example, on Win32:</p>
238
239   <ul>
240     <li><b><tt>make visualc</tt></b> will select the Visual C++ compiler</li>
241     <li><b><tt>make lcc</tt></b> will select the Win32-lcc compiler</li>
242   </ul>
243
244   <p>Note that on Unix, the first time make is called, a configure script
245      located in "<tt>freetype2/builds/unix</tt>" will be run in order to
246      automatically detect the platform & compiler.</p>
247
248   <p>A summary will be displayed showing the detected platform and compiler
249      selected. You'll then be able to start the build by invoking <tt>make</tt>
250      a second time. In case of problem, consult the <tt>BUILD</tt> document.</p>
251
252
253   <h3>b. by direct compilation</h3>
254
255   <p>You can also directly compile the library from the command line by
256      using these simple rules:</p>
257
258   <ul>
259     <li><p>
260        You should place the directories "<tt>freetype2/include</tt>" and
261        "<tt>freetype2/src</tt>" in your include path in order to compile
262        any component of the library. You can also add the system-specific
263        build directory (i.e. "<tt>builds/<em>system</em>/</tt>") in the
264        case where an alternate implementation of some of the components
265        is available there (e.g. the memory-mapped i/o implementation
266        on some Unix systems).
267     </p></li>
268
269     <li><p>
270        The components of the library are located in sub-directories of
271        "<tt>src</tt>", for example: "<tt>src/base</tt>",
272        "<tt>src/truetype</tt>", etc..
273     </p></li>
274
275     <li><p>
276        Each component is normally compiled through a single C file that
277        "wraps" other sources in the component's directory. For example,
278        your should compile the TrueType font driver by compiling the
279        file "<tt>src/truetype/truetype.c</tt>". The list of C files to
280        compile for a feature-complete build of the library is given in
281        the <tt>BUILD</tt> document.
282     </p></li>
283   </ul>
284
285   <h3>c. in a graphical IDE</h3>
286   <ul>
287     <p>Well, the process is vastly similar to the one described in b.,
288        except that you need to set the include paths, source code paths,
289        etc.. in dialog boxes before running the compilation.
290     </p>
291   </ul>
292
293 </ul>
294
295 <a name="builds-config">
296 <h3>II.2. How do I configure my build of the library?</h3>
297 <ul>
298   <p>Each build of the library is configured through two header files
299      located in "<tt>include/freetype/config</tt>":</p>
300
301   <ul>
302     <li><p><b><tt>ftoption.h</tt></b><br>
303         This file contains various configuration macros whose definition
304         can be toggled on a per-build basis. Each macro is heavily
305         commented in this file's comment, and we invite you to refer
306         to it directly.</p></li>
307
308     <li><p><b><tt>ftmodule.h</tt></b><br>
309         This file contains the list of all the modules that are initially
310         registered (added) when the function <b><tt>FT_Init_FreeType</tt></b>
311         is called. See the next answer to know how to change it and
312         why it may be important.</p></li>
313   </ul>
314
315   <p>Alternatively, some specific implementations of some FT2 components
316      can be provided in a "<tt>builds/<em>system</em>/</tt>" directory
317      (e.g. the Unix-specific <tt>ftsystem.c</tt> that uses memory-mapped
318      file for i/o).</p>
319 </ul>
320
321 <a name="builds-modules">
322 <h3>II.3. How do I select the modules I need in my build?</h3>
323 <ul>
324   <p>The function <tt><b>FT_Init_FreeType</b></tt> creates a new instance
325      of the FT2 library and registers a set of "default" modules before
326      returning to the calling application. Its default implementation
327      is in the file "<tt>src/base/ftinit.c</tt>".</p>
328
329   <p>The list of default modules used by <tt>ftinit.c</tt> is located in
330      the configuration file "<tt>include/freetype/config/ftmodule.h</tt>".
331      It is normally automatically generated by the build system by
332      invoking the "<tt><b>make modules</b></tt>" command in the top
333      level FT2 directory (note: only works with GNU Make, you can
334      edit the file by hand otherwise). It does so by parsing all
335      sub-directories of "<tt>src</tt>" that contain a file named
336      <tt>module.mk</tt>.</p>
337
338   <p>Note that a specific port or project is free to provide its own
339      implementation of <tt>ftinit.c</tt> in order to ensure a different
340      initialisation sequence. For example, one could do something like:</p>
341
342   <ul>
343     <li><p>compile each module as a shared library (DLL or .so) with
344            a common "entry point" to retrieve a pointer to its
345            module class (there is already some code that allows this
346            when compiling each module).</p></li>
347
348     <li><p>place these modules in a directory like
349           "<tt>/usr/lib/freetype2/modules/</tt>"</p></li>
350
351     <li><p>provide an implementation of <tt>ftinit.c</tt> that would
352            scan the directory for valid modules.</p></li>
353   </ul>
354
355   <p>This example only emphasize the flexibility that is left to
356      developers when building the library.</p>
357
358 </ul>
359
360 <a name="builds-flat">
361 <h3>II.4. How do I compile all FreeType 2 files in a single directory?</h3>
362 <ul>
363   <p>Some projects may need, for the sake of simplicity or ease of
364      building, to compile the FT2 library with all source files
365      copied to a single directory. This is possible.</p>
366
367   <p>To do so, you'll need to copy all source files located under
368      "<tt>src</tt>" to your own directory (you must retain the
369      include files in a distinct hierarchy though), then compile
370      each of the FreeType 2 component with the macro
371      <tt><b>FT_FLAT_COMPILE</b></tt>. This will change the way
372      <tt><b>#include</b></tt> works during the build.</p>
373 </ul>
374
375 </td></tr></table>
376
377 <table width="100%" cellspacing=5><tr bgcolor="#CCCCEE"><td>
378 <h2 align=center><a name="library">Using the FreeType 2 library</h2>
379 </td></tr><tr><td>
380
381 </td></tr></table>
382
383 <table width="100%" cellspacing=5><tr bgcolor="#CCCCEE"><td>
384 <h2 align=center><a name="autohint">The FreeType 2 auto-hinter</h2>
385 </td></tr><tr><td>
386
387 <a name="autohint-license">
388 <h3>IV.1. Under which license is the FreeType 2 auto-hinter released</h3>
389 <ul>
390   <p>The auto-hinter was initially designed and implemented under contract
391      for <a href="http://www.catharon.com">Catharon Productions, Inc</a>
392      which gladly accepted to released it under an open-source license
393      compatible with the FreeType one.</p>
394
395   <p>This license can be found in "<tt>src/autohint/CatharonLicense.txt</tt>"
396      and requires that you cite Catharon Productions in your documentation
397      (just like you do with FreeType) when using the auto-hinting module.</p>
398
399   <p>Other than that, you still have the same freedom than with the good old
400      FreeType license. Enjoy !</p>
401 </ul>
402
403 <a name="autohint-work">
404 <h3>IV.2. How does the auto-hinter works ?</h3>
405 <ul>
406   <p>Well, a complete description would be difficult. Have a look at the
407      dedicated <a href="autohinting/index.html">auto-hinter pages</a> on the FreeType
408      site, as they describe most of its details with graphics and explanations.
409      You could also look at the source code if you want to :-)</p>
410
411   <p>To give a few details, the auto-hinter is used to perform grid-fitting
412      on scalable font formats that use bezier outlines as their primary glyph
413      image format (this means nearly all scalable font formats today). When
414      a given font driver doesn't provide its own hinter, the auto-hinter is
415      used by default. When a format-specific hinter is provided, it is still
416      possible to use the auto-hinter using the
417      <tt><b>FT_LOAD_FORCE_AUTOHINT</b></tt> bit flag when calling
418      <tt>FT_Load_Glyph</tt>.</p>
419
420   <p>The auto-hinter currently doesn't use external hints to do its job,
421      as it automatically computes global metrics (when it "opens" a font
422      for the first time) and glyph "hints" from their outline. Note that
423      we plan the ability to specify external hints, given that it is based
424      on a constraint system. That could be used to support native hints
425      in Type 1/Type 2 fonts, for example.</p>
426 </ul>
427
428 <a name="autohint-cjk">
429 <h3>IV.3. Why does the auto-hinter doesn't work correctly with CJK fonts ?</h3>
430 <ul>
431   <p>The auto-hinter was first designed to manage and hint latin-based fonts,
432      as they consist of most of the fonts available today. It doesn't hint
433      asian fonts, as well as a few other complex scripts, because we didn't
434      put enough research on the topic yet. Hinting CJK isn't really more
435      difficult than latin, just different with a set of different constraints
436      (basically, more distortion of glyphs is acceptable as long as certain
437      features like triple-stem positions are respected more strictly..).</p>
438
439   <p>We thus plan to handle such a case rather rapidly.. Please be patient.</p>
440 </ul>
441
442
443 </td></tr></table>
444
445 <table width="100%" cellspacing=5><tr bgcolor="#CCCCEE"><td>
446 <h2 align=center><a name="other">Other questions</h2>
447 </td></tr><tr><td>
448
449 <a name="other-antialias">
450 <h3>V.1. What is the anti-aliasing algorithm used by FreeType 2 ?</h3>
451 <ul>
452   <p>The algorithm has been specifically designed for FreeType. It is
453      based on ideas that were originally found in the implementation
454      of the <a href="http://www.levien.com/libart">libArt</a> graphics
455      library to compute the <em>exact pixel coverage</em> of a vector
456      image with absolutely now sub-sampling/filtering.
457      </p>
458
459   <p>However, these two implementations are radically distinct and use
460      vastly different models. The FreeType 2 renderer is optimized
461      specifically for rendering small complex shapes, like glyphs, at
462      very high speed while using very few memory; while libArt shines
463      at general shape/polygon processing, especially large ones.</p>
464
465   <p>The FT2 anti-aliasing renderer is indeed <em>faster</em> than the
466      monochrome renderer for small character sizes (typically &lt; 20 pixels).
467      This is explained because the monochrome renderer must perform two
468      passes on the outline in order to perform drop-out control according
469      to the TrueType spec (we could drop this requirement later though).</p>
470
471   <p>We'll try to document its design in a later document, though this is
472      not a priority for now.</p>
473 </ul>
474
475 <a name="other-opentype">
476 <h3>V.2. When will FreeType 2 support OpenType ?</h3>
477 <ul>
478   <p>Well, the engine already reads OpenType/CFF files perfectly. What it
479      doesn't do is handle "OpenType Layout" tables yet.</p>
480      
481   <p>FreeType 1 comes with a set of extensions that are used to load
482      and manage OpenType Layout tables. It even has a demonstration program
483      named "<tt>ftstrtto</tt>" used to demonstrate its capabilities that
484      runs pretty smooth.</p>
485      
486   <p>For FreeType 2, we have decided that the layout operations provided
487      through these tables is better placed in a specific text-layout library,
488      (many people having asked for such a thing). This new engine would not
489      depend on FT2 explicitely and will be developed as a separate project.
490      We plan to announce it in a few weeks with all gory details,
491      once the definitive 2.0 release of FreeType has been made.</p>
492 </ul>
493
494 </td></tr></table>
495
496 <hr>
497 <p>
498 <a href="index.html">Back to FreeType homepage</a><p>
499
500 </td></tr></table>
501 </body>
502 </html>