mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-08-28 19:26:16 +00:00
Freetype 2
svn path=/trunk/; revision=1854
This commit is contained in:
@@ -0,0 +1,904 @@
|
||||
LATEST CHANGES
|
||||
|
||||
- deactivated the trueType bytecode interpreter by default
|
||||
|
||||
- deactivated the "src/type1" font driver. Now "src/type1z" is
|
||||
used by default..
|
||||
|
||||
- updates to the build system. We now compile the library correctly
|
||||
under Unix system through "configure" which is automatically called
|
||||
on the first "make" invocation.
|
||||
|
||||
- added the auto-hinting module !!. Fixing some bugs here and there..
|
||||
|
||||
- found some bugs in the composite loader (seac) of the Type1-based
|
||||
font drivers..
|
||||
|
||||
- renamed the directory "freetype2/config" to "freetype2/builds" and
|
||||
updated all relevant files..
|
||||
|
||||
- found a memory leak in the "type1" driver
|
||||
|
||||
- incorporated Tom's patches to support flex operators correctly
|
||||
in OpenType/CFF fonts.. Now all I need is to support pure CFF
|
||||
and CEF fonts to be done with this driver.. :-)
|
||||
|
||||
- added the Windows FNT/FON driver in "src/winfonts". For now,
|
||||
it always "simulates" a Unicode charmap, so it shouldn't be
|
||||
considered completed right now..
|
||||
|
||||
It's there to be more a proof of concept than anything else
|
||||
anyway. The driver is a single C source file, that compiles
|
||||
to 3 Kb of code..
|
||||
|
||||
I'm still working on the PCF/BDF drivers.. but I'm too lazy
|
||||
to finish them now..
|
||||
|
||||
|
||||
- CHANGES TO THE HIGH-LEVEL API
|
||||
|
||||
o FT_Get_Kerning has a new parameter that allows you to select
|
||||
the coordinates of the kerning vector ( font units, scaled,
|
||||
scaled + grid-fitted ).
|
||||
|
||||
o the outline functions are now in <freetype/ftoutln.h> and not
|
||||
part of <freetype/freetype.h> anymore
|
||||
|
||||
o <freetype/ftmodule.h> now contains declarations for
|
||||
FT_New_Library, FT_Done_Library, FT_Add_Default_Modules
|
||||
|
||||
o the so-called convenience functions have moved from "ftoutln.c"
|
||||
to "ftglyph.c", and are thus available with this optional component
|
||||
of the library. They are declared in <freetype/ftglyph.h> now..
|
||||
|
||||
o anti-aliased rendering is now the default for FT_Render_Glyph
|
||||
(i.e. corresponds to render_mode == 0 == ft_render_mode_normal).
|
||||
To generate a monochrome bitmap, use ft_render_mode_mono, or the
|
||||
FT_LOAD_MONOCHROME flag in FT_Load_Glyph/FT_Load_Char.
|
||||
|
||||
FT_LOAD_ANTI_ALIAS is still defined, but values to 0.
|
||||
|
||||
o <freetype/freetype.h> now include <freetype/config/ftconfig.h>,
|
||||
solving a few headaches :-)
|
||||
|
||||
o the type FT_GlyphSlotRec has now a "library" field.
|
||||
|
||||
|
||||
|
||||
- CHANGES TO THE "ftglyph.h" API
|
||||
|
||||
This API has been severely modified in order to make it simpler,
|
||||
clearer, and more efficient. It certainly now looks like a real
|
||||
"glyph factory" object, and allows client applications to manage
|
||||
(i.e. transform, bbox and render) glyph images without ever knowing
|
||||
their original format.
|
||||
|
||||
- added support for CID-keyed fonts to the CFF driver.
|
||||
maybe support for pure CFF + CEF fonts should come in ??
|
||||
|
||||
|
||||
- cleaned up source code in order to avoid two functions with the
|
||||
same name. Also changed the names of the files in "type1z" from
|
||||
"t1XXXX" to "z1XXXX" in order to avoid any conflicts.
|
||||
|
||||
"make multi" now works well :-)
|
||||
|
||||
Also removed the use of "cidafm" for now, even if the source files
|
||||
are still there. This functionality will certainly go into a specific
|
||||
module..
|
||||
|
||||
|
||||
|
||||
- ADDED SUPPORT FOR THE AUTO-HINTER
|
||||
|
||||
It works :-) I have a demo program which simply is a copy of "ftview"
|
||||
that does a FT_Add_Module( library, &autohinter_module_class ) after
|
||||
library initialisation, and Type 1 & OpenType/CFF fonts are now hinted.
|
||||
|
||||
CID fonts are not hinted, as they include no charmap and the auto-hinter
|
||||
doesn't include "generic" global metrics computations yet..
|
||||
|
||||
Now, I need to release this thing to the FreeType 2 source..
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
- CHANGES TO THE RENDERER MODULES
|
||||
|
||||
the monochrome and smooth renderers are now in two distinct directories,
|
||||
namely "src/raster1" and "src/smooth". Note that the old "src/renderer"
|
||||
is now gone..
|
||||
|
||||
I ditched the 5-gray-levels renderers. Basically, it involved a simple
|
||||
#define toggle in 'src/raster1/ftraster.c'
|
||||
|
||||
FT_Render_Glyph, FT_Outline_Render & FT_Outline_Get_Bitmap now select
|
||||
the best renderer available, depending on render mode. If the current
|
||||
renderer for a given glyph image format isn't capable of supporting
|
||||
the render mode, another one will be found in the library's list.
|
||||
|
||||
This means that client applications do not need to switch or set the
|
||||
renderers themselves (as in the latest change), they'll get what they
|
||||
want automatically... At last..
|
||||
|
||||
Changed the demo programs accordingly..
|
||||
|
||||
|
||||
|
||||
- MAJOR INTERNAL REDESIGN:
|
||||
|
||||
A lot of internal modifications have been performed lately on the
|
||||
source in order to provide the following enhancements:
|
||||
|
||||
- more generic module support:
|
||||
|
||||
The FT_Module type is now defined to represent a handle to a given
|
||||
module. The file <freetype/ftmodule.h> contains the FT_Module_Class
|
||||
definition, as well as the module-loading public API
|
||||
|
||||
The FT_Driver type is still defined, and still represents a pointer
|
||||
to a font driver. Note that FT_Add_Driver is replaced by FT_Add_Module,
|
||||
FT_Get_Driver by FT_Get_Module, etc..
|
||||
|
||||
|
||||
- support for generic glyph image types:
|
||||
|
||||
The FT_Renderer type is a pointer to a module used to perform various
|
||||
operations on glyph image.
|
||||
|
||||
Each renderer is capable of handling images in a single format
|
||||
(e.g. ft_glyph_format_outline). Its functions are used to:
|
||||
|
||||
- transform an glyph image
|
||||
- render a glyph image into a bitmap
|
||||
- return the control box (dimensions) of a given glyph image
|
||||
|
||||
|
||||
The scan converters "ftraster.c" and "ftgrays.c" have been moved
|
||||
to the new directory "src/renderer", and are used to provide two
|
||||
default renderer modules.
|
||||
|
||||
One corresponds to the "standard" scan-converter, the other to the
|
||||
"smooth" one.
|
||||
|
||||
The current renderer can be set through the new function
|
||||
FT_Set_Renderer.
|
||||
|
||||
The old raster-related function FT_Set_Raster, FT_Get_Raster and
|
||||
FT_Set_Raster_Mode have now disappeared, in favor of the new:
|
||||
|
||||
FT_Get_Renderer
|
||||
FT_Set_Renderer
|
||||
|
||||
see the file <freetype/ftrender.h> for more details..
|
||||
|
||||
These changes were necessary to properly support different scalable
|
||||
formats in the future, like bi-color glyphs, etc..
|
||||
|
||||
|
||||
- glyph loader object:
|
||||
|
||||
A new internal object, called a 'glyph loader' has been introduced
|
||||
in the base layer. It is used by all scalable format font drivers
|
||||
to load glyphs and composites.
|
||||
|
||||
This object has been created to reduce the code size of each driver,
|
||||
as each one of them basically re-implemented its functionality.
|
||||
|
||||
See <freetype/internal/ftobjs.h> and the FT_GlyphLoader type for
|
||||
more information..
|
||||
|
||||
|
||||
|
||||
- FT_GlyphSlot had new fields:
|
||||
|
||||
In order to support extended features (see below), the FT_GlyphSlot
|
||||
structure has a few new fields:
|
||||
|
||||
linearHoriAdvance: this field gives the linearly scaled (i.e.
|
||||
scaled but unhinted) advance width for the glyph,
|
||||
expressed as a 16.16 fixed pixel value. This
|
||||
is useful to perform WYSIWYG text.
|
||||
|
||||
linearVertAdvance: this field gives the linearly scaled advance
|
||||
height for the glyph (relevant in vertical glyph
|
||||
layouts only). This is useful to perform
|
||||
WYSIWYG text.
|
||||
|
||||
Note that the two above field replace the removed "metrics2" field
|
||||
in the glyph slot.
|
||||
|
||||
advance: this field is a vector that gives the transformed
|
||||
advance for the glyph. By default, it corresponds
|
||||
to the advance width, unless FT_LOAD_VERTICAL_LAYOUT
|
||||
was specified when calling FT_Load_Glyph or FT_Load_Char
|
||||
|
||||
bitmap_left: this field gives the distance in integer pixels from
|
||||
the current pen position to the left-most pixel of
|
||||
a glyph image WHEN IT IS A BITMAP. It is only valid
|
||||
when the "format" field is set to
|
||||
"ft_glyph_format_bitmap", for example, after calling
|
||||
the new function FT_Render_Glyph.
|
||||
|
||||
bitmap_top: this field gives the distance in integer pixels from
|
||||
the current pen position (located on the baseline) to
|
||||
the top-most pixel of the glyph image WHEN IT IS A
|
||||
BITMAP. Positive values correspond to upwards Y.
|
||||
|
||||
loader: this is a new private field for the glyph slot. Client
|
||||
applications should not touch it..
|
||||
|
||||
|
||||
- support for transforms and direct rendering in FT_Load_Glyph:
|
||||
|
||||
Most of the functionality found in <freetype/ftglyph.h> has been
|
||||
moved to the core library. Hence, the following:
|
||||
|
||||
- a transform can be specified for a face through FT_Set_Transform.
|
||||
this transform is applied by FT_Load_Glyph to scalable glyph images
|
||||
(i.e. NOT TO BITMAPS) before the function returns, unless the
|
||||
bit flag FT_LOAD_IGNORE_TRANSFORM was set in the load flags..
|
||||
|
||||
|
||||
- once a glyph image has been loaded, it can be directly converted to
|
||||
a bitmap by using the new FT_Render_Glyph function. Note that this
|
||||
function takes the glyph image from the glyph slot, and converts
|
||||
it to a bitmap whose properties are returned in "face.glyph.bitmap",
|
||||
"face.glyph.bitmap_left" and "face.glyph.bitmap_top". The original
|
||||
native image might be lost after the conversion.
|
||||
|
||||
|
||||
- when using the new bit flag FT_LOAD_RENDER, the FT_Load_Glyph
|
||||
and FT_Load_Char functions will call FT_Render_Glyph automatically
|
||||
when needed.
|
||||
|
||||
|
||||
|
||||
|
||||
- reformated all modules source code in order to get rid of the basic
|
||||
data types redifinitions (i.e. "TT_Int" instead of "FT_Int", "T1_Fixed"
|
||||
instead of "FT_Fixed"). Hence the format-specific prefixes like "TT_",
|
||||
"T1_", "T2_" and "CID_" are only used for relevant structures..
|
||||
|
||||
============================================================================
|
||||
OLD CHANGES FOR BETA 7
|
||||
|
||||
- bug-fixed the OpenType/CFF parser. It now loads and displays my two
|
||||
fonts nicely, but I'm pretty certain that more testing is needed :-)
|
||||
|
||||
- fixed the crummy Type 1 hinter, it now handles accented characters
|
||||
correctly (well, the accent is not always well placed, but that's
|
||||
another problem..)
|
||||
|
||||
- added the CID-keyed Type 1 driver in "src/cid". Works pretty well for
|
||||
only 13 Kb of code ;-) Doesn't read AFM files though, nor the really
|
||||
useful CMAP files..
|
||||
|
||||
- fixed two bugs in the smooth renderer (src/base/ftgrays.c). Thanks to
|
||||
Boris Letocha for spotting them and providing a fix..
|
||||
|
||||
- fixed potential "divide by zero" bugs in ftcalc.c.. my god..
|
||||
|
||||
- added source code for the OpenType/CFF driver (still incomplete though..)
|
||||
|
||||
- modified the SFNT driver slightly to perform more robust header
|
||||
checks in TT_Load_SFNT_Header. This prevents certain font files
|
||||
(e.g. some Type 1 Multiple Masters) from being incorrectly "recognized"
|
||||
as TrueType font files..
|
||||
|
||||
- moved a lot of stuff from the TrueType driver to the SFNT module,
|
||||
this allows greater code re-use between font drivers (e.g. TrueType,
|
||||
OpenType, Compact-TrueType, etc..)
|
||||
|
||||
- added a tiny segment cache to the SFNT Charmap 4 decoder, in order
|
||||
to minimally speed it up..
|
||||
|
||||
- added support for Multiple Master fonts in "type1z". There is also
|
||||
a new file named <freetype/ftmm.h> which defines functions to
|
||||
manage them from client applications.
|
||||
|
||||
The new file "src/base/ftmm.c" is also optional to the engine..
|
||||
|
||||
- various formatting changes (e.g. EXPORT_DEF -> FT_EXPORT_DEF) +
|
||||
small bug fixes in FT_Load_Glyph, the "type1" driver, etc..
|
||||
|
||||
- a minor fix to the Type 1 driver to let them apply the font matrix
|
||||
correctly (used for many oblique fonts..)
|
||||
|
||||
- some fixes for 64-bit systems (mainly changing some FT_TRACE calls
|
||||
to use %p instead of %lx).. Thanks to Karl Robillard
|
||||
|
||||
- fixed some bugs in the sbit loader (src/base/sfnt/ttsbit.c) + added
|
||||
a new flag, FT_LOAD_CROP_BITMAP to query that bitmaps be cropped when
|
||||
loaded from a file (maybe I should move the bitmap cropper to the
|
||||
base layer ??).
|
||||
|
||||
- changed the default number of gray levels of the smooth renderer to
|
||||
256 (instead of the previous 128). Of course, the human eye can't
|
||||
see any difference ;-)
|
||||
|
||||
- removed TT_MAX_SUBGLYPHS, there is no static limit on the number of
|
||||
subglyphs in a TrueType font now..
|
||||
|
||||
=============================================================================
|
||||
OLD CHANGES 16 May 2000
|
||||
|
||||
- tagged "BETA-6" in the CVS tree. This one is a serious release candidate
|
||||
even though it doesn't incorporate the auto-hinter yet..
|
||||
|
||||
- various obsolete files were removed, and copyright header updated
|
||||
|
||||
- finally updated the standard raster to fix the monochrome rendering bug
|
||||
+ re-enable support for 5-gray levels anti-aliasing (suck, suck..)
|
||||
|
||||
- created new header files, and modified sources accordingly:
|
||||
|
||||
<freetype/fttypes.h> - simple FreeType types, without the API
|
||||
<freetype/internal/ftmemory.h> - definition of memory-management macros
|
||||
|
||||
- added the "DSIG" (OpenType Digital Signature) tag to <freetype/tttags.h>
|
||||
|
||||
- light update/cleaning of the build system + changes to the sources in
|
||||
order to get rid of _all_ compiler warnings with three compilers, i.e:
|
||||
|
||||
gcc with "-ansi -pedantic -Wall -W", Visual C++ with "/W3 /WX"
|
||||
and LCC
|
||||
|
||||
IMPORTANT NOTE FOR WIN32-LCC USERS:
|
||||
|
|
||||
| It seems the C pre-processor that comes with LCC is broken, it
|
||||
| doesn't recognize the ANSI standard directives # and ## correctly
|
||||
| when one of the argument is a macro. Also, something like:
|
||||
|
|
||||
| #define F(x) print##x
|
||||
|
|
||||
| F(("hello"))
|
||||
|
|
||||
| will get incorrectly translated to:
|
||||
|
|
||||
| print "hello")
|
||||
|
|
||||
| by its pre-processor. For this reason, you simply cannot build
|
||||
| FreeType 2 in debug mode with this compiler..
|
||||
|
||||
|
||||
- yet another massive grunt work. I've changed the definition of the
|
||||
EXPORT_DEF, EXPORT_FUNC, BASE_DEF & BASE_FUNC macros. These now take
|
||||
an argument, which is the function's return value type.
|
||||
|
||||
This is necessary to compile FreeType as a DLL on Windows and OS/2.
|
||||
Depending on the compiler used, a compiler-specific keyword like __export
|
||||
or __system must be placed before (VisualC++) or after (BorlandC++)
|
||||
the type..
|
||||
|
||||
Of course, this needed a lot of changes throughout the source code
|
||||
to make it compile again... All cleaned up now, apparently..
|
||||
|
||||
Note also that there is a new EXPORT_VAR macro defined to allow the
|
||||
_declaration_ of an exportable public (constant) variable. This is the
|
||||
case of the raster interfaces (see ftraster.h and ftgrays.h), as well
|
||||
as each module's interface (see sfdriver.h, psdriver.h, etc..)
|
||||
|
||||
- new feature: it is now possible to pass extra parameters to font
|
||||
drivers when creating a new face object. For now, this
|
||||
capability is unused. It could however prove to be useful
|
||||
in a near future..
|
||||
|
||||
the FT_Open_Args structure was changes, as well as the internal
|
||||
driver interface (the specific "init_face" module function has now
|
||||
a different signature).
|
||||
|
||||
- updated the tutorial (not finished though).
|
||||
- updated the top-level BUILD document
|
||||
|
||||
- fixed a potential memory leak that could occur when loading embedded
|
||||
bitmaps.
|
||||
|
||||
- added the declaration of FT_New_Memory_Face in <freetype/freetype.h>, as
|
||||
it was missing from the public header (the implementation was already
|
||||
in "ftobjs.c").
|
||||
|
||||
- the file <freetype/fterrors.h> has been seriously updated in order to
|
||||
allow the automatic generation of error message tables. See the comments
|
||||
within it for more information.
|
||||
|
||||
- major directory hierarchy re-organisation. This was done for two things:
|
||||
|
||||
* first, to ease the "manual" compilation of the library by requiring
|
||||
at lot less include paths :-)
|
||||
|
||||
* second, to allow external programs to effectively access internal
|
||||
data fields. For example, this can be extremely useful if someone
|
||||
wants to write a font producer or a font manager on top of FreeType.
|
||||
|
||||
Basically, you should now use the 'freetype/' prefix for header inclusion,
|
||||
as in:
|
||||
|
||||
#include <freetype/freetype.h>
|
||||
#include <freetype/ftglyph.h>
|
||||
|
||||
Some new include sub-directories are available:
|
||||
|
||||
a. the "freetype/config" directory, contains two files used to
|
||||
configure the build of the library. Client applications should
|
||||
not need to look at these normally, but they can if they want.
|
||||
|
||||
#include <freetype/config/ftoption.h>
|
||||
#include <freetype/config/ftconfig.h>
|
||||
|
||||
b. the "freetype/internal" directory, contains header files that
|
||||
describes library internals. These are the header files that were
|
||||
previously found in the "src/base" and "src/shared" directories.
|
||||
|
||||
|
||||
As usual, the build system and the demos have been updated to reflect
|
||||
the change..
|
||||
|
||||
Here's a layout of the new directory hierarchy:
|
||||
|
||||
TOP
|
||||
include/
|
||||
freetype/
|
||||
freetype.h
|
||||
...
|
||||
config/
|
||||
ftoption.h
|
||||
ftconfig.h
|
||||
ftmodule.h
|
||||
|
||||
internal/
|
||||
ftobjs.h
|
||||
ftstream.h
|
||||
ftcalc.h
|
||||
...
|
||||
|
||||
src/
|
||||
base/
|
||||
...
|
||||
|
||||
sfnt/
|
||||
psnames/
|
||||
truetype/
|
||||
type1/
|
||||
type1z/
|
||||
|
||||
|
||||
Compiling a module is now much easier, for example, the following should
|
||||
work when in the TOP directory on an ANSI build:
|
||||
|
||||
gcc -c -I./include -I./src/base src/base/ftbase.c
|
||||
gcc -c -I./include -I./src/sfnt src/sfnt/sfnt.c
|
||||
etc..
|
||||
|
||||
(of course, using -Iconfig/<system> if you provide system-specific
|
||||
configuration files).
|
||||
|
||||
|
||||
- updated the structure of FT_Outline_Funcs in order to allow
|
||||
direct coordinate scaling within the outline decomposition routine
|
||||
(this is important for virtual "on" points with TrueType outlines)
|
||||
+ updates to the rasters to support this..
|
||||
|
||||
- updated the OS/2 table loading code in "src/sfnt/ttload.c" in order
|
||||
to support version 2 of the table (see OpenType 1.2 spec)
|
||||
|
||||
- created "include/tttables.h" and "include/t1tables.h" to allow
|
||||
client applications to access some of the SFNT and T1 tables of a
|
||||
face with a procedural interface (see FT_Get_Sfnt_Table())
|
||||
+ updates to internal source files to reflect the change..
|
||||
|
||||
- some cleanups in the source code to get rid of warnings when compiling
|
||||
with the "-Wall -W -ansi -pedantic" options in gcc.
|
||||
|
||||
- debugged and moved the smooth renderer to "src/base/ftgrays.c" and
|
||||
its header to "include/ftgrays.h"
|
||||
|
||||
- updated TT_MAX_SUBGLYPHS to 96 as some CJK fonts have composites with
|
||||
up to 80 sub-glyphs !! Thanks to Werner
|
||||
|
||||
================================================================================
|
||||
OLD CHANGES - 14-apr-2000
|
||||
|
||||
- fixed a bug in the TrueType glyph loader that prevented the correct
|
||||
loading of some CJK glyphs in mingli.ttf
|
||||
|
||||
- improved the standard Type 1 hinter in "src/type1"
|
||||
|
||||
- fixed two bugs in the experimental Type 1 driver in "src/type1z"
|
||||
to handle the new XFree86 4.0 fonts (and a few other ones..)
|
||||
|
||||
- the smooth renderer is now complete and supports sub-banding
|
||||
to render large glyphs at high speed. However, it is still located
|
||||
in "demos/src/ftgrays.c" and should move to the library itself
|
||||
in the next beta.. NOTE: The smooth renderer doesn't compile in
|
||||
stand-alone mode anymore, but this should be fixed RSN..
|
||||
|
||||
- introduced convenience functions to more easily deal with glyph
|
||||
images, see "include/ftglyph.h" for more details, as well as the
|
||||
new demo program named "demos/src/ftstring.c" that demonstrates
|
||||
its use
|
||||
|
||||
- implemented FT_LOAD_NO_RECURSE in both the TrueType and Type 1
|
||||
drivers (this is required by the auto-hinter to improve its results).
|
||||
|
||||
- changed the raster interface, in order to allow client applications
|
||||
to provide their own span-drawing callbacks. However, only the
|
||||
smooth renderer supports this. See "FT_Raster_Params" in the
|
||||
file "include/ftimage.h"
|
||||
|
||||
- fixed a small bug in FT_MulFix that caused incorrect transform
|
||||
computation !!
|
||||
|
||||
- Note: The tutorial is out-of-date, grumpf.. :-(
|
||||
|
||||
================================================================================
|
||||
OLD CHANGES - 12-mar-2000
|
||||
|
||||
- changed the layout of configuration files : now, all ANSI configuration
|
||||
files are located in "freetype2/config". System-specific over-rides
|
||||
can be placed in "freetype2/config/<system>".
|
||||
|
||||
- moved all configuration macros to "config/ftoption.h"
|
||||
|
||||
- improvements in the Type 1 driver with AFM support
|
||||
|
||||
- changed the fields in the FT_Outline structure : the old "flags"
|
||||
array is re-named "tags", while all ancient flags are encoded into
|
||||
a single unsigned int named "flags".
|
||||
|
||||
- introduced new flags in FT_Outline.flags (see ft_outline_.... enums in
|
||||
"ftimage.h").
|
||||
|
||||
- changed outline functions to "FT_Outline_<action>" syntax
|
||||
|
||||
- added a smooth anti-alias renderer to the demonstration programs
|
||||
- added Mac graphics driver (thanks Just)
|
||||
|
||||
- FT_Open_Face changed in order to received a pointer to a FT_Open_Args
|
||||
descriptor..
|
||||
|
||||
- various cleanups, a few more API functions implemented (see FT_Attach_File)
|
||||
|
||||
- updated some docs
|
||||
|
||||
================================================================================
|
||||
OLD CHANGES - 22-feb-2000
|
||||
|
||||
- introduced the "psnames" module. It is used to:
|
||||
|
||||
o convert a Postscript glyph name into the equivalent Unicode
|
||||
character code (used by the Type 1 driver(s) to synthetize
|
||||
on the fly a Unicode charmap).
|
||||
|
||||
o provide an interface to retrieve the Postscript names of
|
||||
the Macintosh, Adobe Standard & Adobe Expert character codes.
|
||||
(the Macintosh names are used by the SFNT-module postscript
|
||||
names support routines, while the other two tables are used
|
||||
by the Type 1 driver(s)).
|
||||
|
||||
- introduced the "type1z" alternate Type 1 driver. This is a (still
|
||||
experimental) driver for the Type 1 format that will ultimately
|
||||
replace the one in "src/type1". It uses pattern matching to load
|
||||
data from the font, instead of a finite state analyzer. It works
|
||||
much better than the "old" driver with "broken" fonts. It is also
|
||||
much smaller (under 15 Kb).
|
||||
|
||||
- the Type 1 drivers (both in "src/type1" and "src/type1z") are
|
||||
nearly complete. They both provide automatic Unicode charmap
|
||||
synthesis through the "psnames" module. No re-encoding vector
|
||||
is needed. (note that they still leak memory due to some code
|
||||
missing, and I'm getting lazy).
|
||||
|
||||
Trivial AFM support has been added to read kerning information
|
||||
but wasn't exactly tested as it should ;-)
|
||||
|
||||
- The TrueType glyph loader has been seriously rewritten (see the
|
||||
file "src/truetype/ttgload.c". It is now much, much simpler as
|
||||
well as easier to read, maintain and understand :-) Preliminary
|
||||
versions introduced a memory leak that has been reported by Jack
|
||||
Davis, and is now fixed..
|
||||
|
||||
- introduced the new "ft_glyph_format_plotter", used to represent
|
||||
stroked outlines like Windows "Vector" fonts, and certain Type 1
|
||||
fonts like "Hershey". The corresponding raster will be written
|
||||
soon.
|
||||
|
||||
- FT_New_Memory_Face is gone. Likewise, FT_Open_Face has a new
|
||||
interface that uses a structure to describe the input stream,
|
||||
the driver (if required), etc..
|
||||
|
||||
TODO
|
||||
- Write FT_Get_Glyph_Bitmap and FT_Load_Glyph_Bitmap
|
||||
|
||||
- Add a function like FT_Load_Character( face, char_code, load_flags )
|
||||
that would really embbed a call to FT_Get_Char_Index then FT_Load_Glyph
|
||||
to ease developer's work.
|
||||
|
||||
- Update the tutorial !!
|
||||
- consider adding support for Multiple Master fonts in the Type 1
|
||||
drivers.
|
||||
|
||||
- Test the AFM routines of the Type 1 drivers to check that kerning
|
||||
information is returned correctly.
|
||||
|
||||
- write a decent auto-gridding component !! We need this to release
|
||||
FreeType 2.0 gold !
|
||||
|
||||
|
||||
----- less urgent needs : ----------
|
||||
- add a CFF/Type2 driver
|
||||
- add a BDF driver
|
||||
- add a FNT/PCF/HBF driver
|
||||
- add a Speedo driver from the X11 sources
|
||||
|
||||
|
||||
==============================================================================
|
||||
OLDER CHANGES - 27-jan-2000
|
||||
|
||||
- updated the "sfnt" module interface to allow several SFNT-based
|
||||
drivers to co-exist peacefully
|
||||
|
||||
- updated the "T1_Face" type to better separate Postscript font content
|
||||
from the rest of the FT_Face structure. Might be used later by the
|
||||
CFF/Type2 driver..
|
||||
|
||||
- added an experimental replacement Type 1 driver featuring advanced
|
||||
(and speedy) pattern matching to retrieve the data from postscript
|
||||
fonts.
|
||||
|
||||
- very minor changes in the implementation of FT_Set_Char_Size and
|
||||
FT_Set_Pixel_Sizes (they now implement default to ligthen the
|
||||
font driver's code).
|
||||
|
||||
|
||||
=============================================================================
|
||||
OLD MESSAGE
|
||||
|
||||
This file summarizes the changes that occured since the last "beta" of FreeType 2.
|
||||
Because the list is important, it has been divided into separate sections:
|
||||
|
||||
Table Of Contents:
|
||||
|
||||
I High-Level Interface (easier !)
|
||||
II Directory Structure
|
||||
III Glyph Image Formats
|
||||
IV Build System
|
||||
V Portability
|
||||
VI Font Drivers
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
High-Level Interface :
|
||||
|
||||
The high-level API has been considerably simplified. Here is how :
|
||||
|
||||
- resource objects have disappeared. this means that face objects can
|
||||
now be created with a single function call (see FT_New_Face and
|
||||
FT_Open_Face)
|
||||
|
||||
- when calling either FT_New_Face & FT_Open_Face, a size object and a
|
||||
glyph slot object are automatically created for the face, and can be
|
||||
accessed through "face->glyph" and "face->size" if one really needs to.
|
||||
In most cases, there's no need to call FT_New_Size or FT_New_Glyph.
|
||||
|
||||
- similarly, FT_Load_Glyph now only takes a "face" argument (instead of
|
||||
a glyph slot and a size). Also, it's "result" parameter is gone, as
|
||||
the glyph image type is returned in the field "face->glyph.format"
|
||||
|
||||
- the list of available charmaps is directly accessible through
|
||||
"face->charmaps", counting "face->num_charmaps" elements. Each
|
||||
charmap has an 'encoding' field which specifies which known encoding
|
||||
it deals with. Valid values are, for example :
|
||||
|
||||
ft_encoding_unicode (for ASCII, Latin-1 and Unicode)
|
||||
ft_encoding_apple_roman
|
||||
ft_encoding_sjis
|
||||
ft_encoding_adobe_standard
|
||||
ft_encoding_adobe_expert
|
||||
|
||||
other values may be added in the future. Each charmap still holds its
|
||||
"platform_id" and "encoding_id" values in case the encoding is too
|
||||
exotic for the current library
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
Directory Structure:
|
||||
|
||||
Should seem obvious to most of you:
|
||||
|
||||
freetype/
|
||||
config/ -- configuration sub-makefiles
|
||||
ansi/
|
||||
unix/ -- platform-specific configuration files
|
||||
win32/
|
||||
os2/
|
||||
msdos/
|
||||
|
||||
include/ -- public header files, those to be included directly
|
||||
by client apps
|
||||
|
||||
src/ -- sources of the library
|
||||
base/ -- the base layer
|
||||
sfnt/ -- the sfnt "driver" (see the drivers section below)
|
||||
truetype/ -- the truetype driver
|
||||
type1/ -- the type1 driver
|
||||
shared/ -- some header files shared between drivers
|
||||
|
||||
demos/ -- demos/tools
|
||||
|
||||
docs/ -- documentation (a bit empty for now)
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
Glyph Image Formats :
|
||||
|
||||
Drivers are now able to register new glyph image formats within the library.
|
||||
For now, the base layer supports of course bitmaps and vector outlines, but
|
||||
one could imagine something different like colored bitmaps, bi-color
|
||||
vectors or wathever else (Metafonts anyone ??).
|
||||
|
||||
See the file `include/ftimage.h'. Note also that the type FT_Raster_Map is
|
||||
gone, and is now replaced by FT_Bitmap, which should encompass all known
|
||||
bitmap types.
|
||||
|
||||
Each new image format must provide at least one "raster", i.e. a module
|
||||
capable of transforming the glyph image into a bitmap. It's also possible
|
||||
to change the default raster used for a given glyph image format.
|
||||
|
||||
The default outline scan-converter now uses 128 levels of grays by default,
|
||||
which tends to smooth many things. Note that the demo programs have been
|
||||
updated significantly in order to display these..
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
Build system :
|
||||
|
||||
You still need GNU Make to build the library. The build system has been
|
||||
very seriously re-vamped in order to provide things like :
|
||||
|
||||
- automatic host platform detection (reverting to 'config/ansi'
|
||||
if it is not detected, with pseudo-standard compilation flags)
|
||||
|
||||
- the ability to compile from the Makefiles with very different and
|
||||
exotic compilers. Note that linking the library can be difficult for
|
||||
some platforms.
|
||||
|
||||
For example, the file `config/win32/lcclib.bat' is invoked by the
|
||||
build system to create the ".lib" file with LCC-Win32 because its
|
||||
librarian has too many flaws to be invoked directly from the Makefile.
|
||||
|
||||
Here's how it works :
|
||||
|
||||
- the first time you type `make', the build system runs a series of
|
||||
sub-makefiles in order to detect your host platform. It then dumps
|
||||
what it found, and creates a file called `config.mk' in the current
|
||||
directory. This is a sub-Makefile used to define many important Make
|
||||
variables used to build the library.
|
||||
|
||||
- the second time, the build system detects the `config.mk' then use it
|
||||
to build the library. All object files go into 'obj' by default, as
|
||||
well as the library file, but this can easily be changed.
|
||||
|
||||
Note that you can run "make setup" to force another host platform detection
|
||||
even if a `config.mk' is present in the current directory. Another solution
|
||||
is simply to delete the file, then re-run make.
|
||||
|
||||
Finally, the default compiler for all platforms is gcc (for now, this will
|
||||
hopefully changed in the future). You can however specify a different
|
||||
compiler by specifying it after the 'setup' target as in :
|
||||
|
||||
gnumake setup lcc on Win32 to use the LCC compiler
|
||||
gnumake setup visualc on Win32 to use Visual C++
|
||||
|
||||
See the file `config/<system>/detect.mk' for a list of supported compilers
|
||||
for your platforms.
|
||||
|
||||
It should be relatively easy to write new detection rules files and
|
||||
config.mk..
|
||||
|
||||
Finally, to build the demo programs, go to `demos' and launch GNU Make,
|
||||
it will use the `config.mk' in the top directory to build the test
|
||||
programs..
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
Portability :
|
||||
|
||||
In the previous beta, a single FT_System object was used to encompass
|
||||
all low-level operations like thread synchronisation, memory management
|
||||
and i/o access. This has been greatly simplified :
|
||||
|
||||
- thread synchronisation has been dropped, for the simple reason that
|
||||
the library is already re-entrant, and that if you really need two
|
||||
threads accessing the same FT_Library, you should really synchronize
|
||||
access to it yourself with a simple mutex.
|
||||
|
||||
- memory management is performed through a very simple object called
|
||||
"FT_Memory", which really is a table containing a table of pointers
|
||||
to functions like malloc, realloc and free as well as some user data
|
||||
(closure).
|
||||
|
||||
- resources have disappeared (they created more problems than they
|
||||
solved), and i/o management have been simplified greatly as a
|
||||
result. Streams are defined through FT_Stream objects, which can
|
||||
be either memory-based or disk-based.
|
||||
|
||||
Note that each face has its own stream, which is closed only when
|
||||
the face object is destroyed. Hence, a function like TT_Flush_Face
|
||||
in 1.x cannot be directly supported. However, if you really need
|
||||
something like this, you can easily tailor your own streams to achieve
|
||||
the same feature at a lower level (and use FT_Open_Face instead of
|
||||
FT_New_Face to create the face).
|
||||
|
||||
See the file "include/ftsystem.h" for more details, as well as the
|
||||
implementations found in "config/unix" and "config/ansi".
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
Font Drivers :
|
||||
|
||||
|
||||
The Font Driver interface has been modified in order to support
|
||||
extensions & versioning.
|
||||
|
||||
|
||||
The list of the font drivers that are statically linked to the
|
||||
library at compile time is managed through a new configuration file
|
||||
called `config/<platform>/ftmodule.h'.
|
||||
|
||||
This file is autogenerated when invoking `make modules'. This target
|
||||
will parse all sub-directories of 'src', looking for a "module.mk"
|
||||
rules file, used to describe the driver to the build system.
|
||||
|
||||
Hence, one should call `make modules' each time a font driver is added
|
||||
or removed from the `src' directory.
|
||||
|
||||
|
||||
Finally, this version provides a "pseudo-driver" in `src/sfnt'. This
|
||||
driver doesn't support font files directly, but provides services used
|
||||
by all TrueType-like font drivers. Hence, its code is shared between
|
||||
the TrueType & OpenType font formats, and possibly more formats to
|
||||
come if we're lucky..
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
Extensions support :
|
||||
|
||||
The extensions support is inspired by the one found in 1.x.
|
||||
|
||||
Now, each font driver has its own "extension registry", which lists
|
||||
which extensions are available for the font faces managed by the driver.
|
||||
|
||||
Extension ids are now strings, rather than 4-byte tags, as this is
|
||||
usually more readable..
|
||||
|
||||
Each extension has:
|
||||
- some data, associated to each face object
|
||||
- an interface (table of function pointers)
|
||||
|
||||
An extension that is format-specific should simply register itself
|
||||
to the correct font driver. Here is some example code:
|
||||
|
||||
// Registering an extensions
|
||||
//
|
||||
FT_Error FT_Init_XXXX_Extension( FT_Library library )
|
||||
{
|
||||
FT_DriverInterface* tt_driver;
|
||||
|
||||
driver = FT_Get_Driver( library, "truetype" );
|
||||
if (!driver) return FT_Err_Unimplemented_Feature;
|
||||
|
||||
return FT_Register_Extension( driver, &extension_class );
|
||||
}
|
||||
|
||||
|
||||
// Implementing the extensions
|
||||
//
|
||||
FT_Error FT_Proceed_Extension_XXX( FT_Face face )
|
||||
{
|
||||
FT_XXX_Extension ext;
|
||||
FT_XXX_Extension_Interface ext_interface;
|
||||
|
||||
ext = FT_Get_Extension( face, "extensionid", &ext_interface );
|
||||
if (!ext) return error;
|
||||
|
||||
return ext_interface->do_it(ext);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ahangles.h */
|
||||
/* */
|
||||
/* A routine used to compute vector angles with limited accuracy */
|
||||
/* and very high speed (body). */
|
||||
/* */
|
||||
/* Copyright 2000 Catharon Productions Inc. */
|
||||
/* Author: David Turner */
|
||||
/* */
|
||||
/* This file is part of the Catharon Typography Project and shall only */
|
||||
/* be used, modified, and distributed under the terms of the Catharon */
|
||||
/* Open Source License that should come with this file under the name */
|
||||
/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/* Note that this license is compatible with the FreeType license. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "ahangles.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <autohint/ahangles.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* the following table has been automatically generated with */
|
||||
/* the `mather.py' Python script */
|
||||
|
||||
const AH_Angle ah_arctan[1L << AH_ATAN_BITS] =
|
||||
{
|
||||
0, 0, 1, 1, 1, 2, 2, 2,
|
||||
3, 3, 3, 3, 4, 4, 4, 5,
|
||||
5, 5, 6, 6, 6, 7, 7, 7,
|
||||
8, 8, 8, 9, 9, 9, 10, 10,
|
||||
10, 10, 11, 11, 11, 12, 12, 12,
|
||||
13, 13, 13, 14, 14, 14, 14, 15,
|
||||
15, 15, 16, 16, 16, 17, 17, 17,
|
||||
18, 18, 18, 18, 19, 19, 19, 20,
|
||||
20, 20, 21, 21, 21, 21, 22, 22,
|
||||
22, 23, 23, 23, 24, 24, 24, 24,
|
||||
25, 25, 25, 26, 26, 26, 26, 27,
|
||||
27, 27, 28, 28, 28, 28, 29, 29,
|
||||
29, 30, 30, 30, 30, 31, 31, 31,
|
||||
31, 32, 32, 32, 33, 33, 33, 33,
|
||||
34, 34, 34, 34, 35, 35, 35, 35,
|
||||
36, 36, 36, 36, 37, 37, 37, 38,
|
||||
38, 38, 38, 39, 39, 39, 39, 40,
|
||||
40, 40, 40, 41, 41, 41, 41, 42,
|
||||
42, 42, 42, 42, 43, 43, 43, 43,
|
||||
44, 44, 44, 44, 45, 45, 45, 45,
|
||||
46, 46, 46, 46, 46, 47, 47, 47,
|
||||
47, 48, 48, 48, 48, 48, 49, 49,
|
||||
49, 49, 50, 50, 50, 50, 50, 51,
|
||||
51, 51, 51, 51, 52, 52, 52, 52,
|
||||
52, 53, 53, 53, 53, 53, 54, 54,
|
||||
54, 54, 54, 55, 55, 55, 55, 55,
|
||||
56, 56, 56, 56, 56, 57, 57, 57,
|
||||
57, 57, 57, 58, 58, 58, 58, 58,
|
||||
59, 59, 59, 59, 59, 59, 60, 60,
|
||||
60, 60, 60, 61, 61, 61, 61, 61,
|
||||
61, 62, 62, 62, 62, 62, 62, 63,
|
||||
63, 63, 63, 63, 63, 64, 64, 64
|
||||
};
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
AH_Angle ah_angle( FT_Vector* v )
|
||||
{
|
||||
FT_Pos dx, dy;
|
||||
AH_Angle angle;
|
||||
|
||||
|
||||
dx = v->x;
|
||||
dy = v->y;
|
||||
|
||||
/* check trivial cases */
|
||||
if ( dy == 0 )
|
||||
{
|
||||
angle = 0;
|
||||
if ( dx < 0 )
|
||||
angle = AH_PI;
|
||||
return angle;
|
||||
}
|
||||
else if ( dx == 0 )
|
||||
{
|
||||
angle = AH_HALF_PI;
|
||||
if ( dy < 0 )
|
||||
angle = -AH_HALF_PI;
|
||||
return angle;
|
||||
}
|
||||
|
||||
angle = 0;
|
||||
if ( dx < 0 )
|
||||
{
|
||||
dx = -v->x;
|
||||
dy = -v->y;
|
||||
angle = AH_PI;
|
||||
}
|
||||
|
||||
if ( dy < 0 )
|
||||
{
|
||||
FT_Pos tmp;
|
||||
|
||||
|
||||
tmp = dx;
|
||||
dx = -dy;
|
||||
dy = tmp;
|
||||
angle -= AH_HALF_PI;
|
||||
}
|
||||
|
||||
if ( dx == 0 && dy == 0 )
|
||||
return 0;
|
||||
|
||||
if ( dx == dy )
|
||||
angle += AH_PI / 4;
|
||||
else if ( dx > dy )
|
||||
angle += ah_arctan[FT_DivFix( dy, dx ) >> ( 16 - AH_ATAN_BITS )];
|
||||
else
|
||||
angle += AH_HALF_PI -
|
||||
ah_arctan[FT_DivFix( dx, dy ) >> ( 16 - AH_ATAN_BITS )];
|
||||
|
||||
if ( angle > AH_PI )
|
||||
angle -= AH_2PI;
|
||||
|
||||
return angle;
|
||||
}
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,63 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ahangles.h */
|
||||
/* */
|
||||
/* A routine used to compute vector angles with limited accuracy */
|
||||
/* and very high speed (specification). */
|
||||
/* */
|
||||
/* Copyright 2000 Catharon Productions Inc. */
|
||||
/* Author: David Turner */
|
||||
/* */
|
||||
/* This file is part of the Catharon Typography Project and shall only */
|
||||
/* be used, modified, and distributed under the terms of the Catharon */
|
||||
/* Open Source License that should come with this file under the name */
|
||||
/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/* Note that this license is compatible with the FreeType license. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef AHANGLES_H
|
||||
#define AHANGLES_H
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "ahtypes.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <autohint/ahtypes.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#include <freetype/internal/ftobjs.h>
|
||||
|
||||
|
||||
/* PI expressed in ah_angles -- we don't really need an important */
|
||||
/* precision, so 256 should be enough */
|
||||
#define AH_PI 256
|
||||
#define AH_2PI ( AH_PI * 2 )
|
||||
#define AH_HALF_PI ( AH_PI / 2 )
|
||||
#define AH_2PIMASK ( AH_2PI - 1 )
|
||||
|
||||
/* the number of bits used to express an arc tangent; */
|
||||
/* see the structure of the lookup table */
|
||||
#define AH_ATAN_BITS 8
|
||||
|
||||
extern
|
||||
const AH_Angle ah_arctan[1L << AH_ATAN_BITS];
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
AH_Angle ah_angle( FT_Vector* v );
|
||||
|
||||
|
||||
#endif /* AHANGLES_H */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,402 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ahglobal.c */
|
||||
/* */
|
||||
/* Routines used to compute global metrics automatically (body). */
|
||||
/* */
|
||||
/* Copyright 2000 Catharon Productions Inc. */
|
||||
/* Author: David Turner */
|
||||
/* */
|
||||
/* This file is part of the Catharon Typography Project and shall only */
|
||||
/* be used, modified, and distributed under the terms of the Catharon */
|
||||
/* Open Source License that should come with this file under the name */
|
||||
/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/* Note that this license is compatible with the FreeType license. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "ahglobal.h"
|
||||
#include "ahglyph.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <autohint/ahglobal.h>
|
||||
#include <autohint/ahglyph.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#define MAX_TEST_CHARACTERS 12
|
||||
|
||||
static
|
||||
const char* blue_chars[ah_blue_max] =
|
||||
{
|
||||
"THEZOCQS",
|
||||
"HEZLOCUS",
|
||||
"xzroesc",
|
||||
"xzroesc",
|
||||
"pqgjy"
|
||||
};
|
||||
|
||||
|
||||
/* simple insertion sort */
|
||||
static
|
||||
void sort_values( FT_Int count,
|
||||
FT_Pos* table )
|
||||
{
|
||||
FT_Int i, j, swap;
|
||||
|
||||
|
||||
for ( i = 1; i < count; i++ )
|
||||
{
|
||||
for ( j = i; j > 1; j-- )
|
||||
{
|
||||
if ( table[j] > table[j - 1] )
|
||||
break;
|
||||
|
||||
swap = table[j];
|
||||
table[j] = table[j - 1];
|
||||
table[j - 1] = swap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
FT_Error ah_hinter_compute_blues( AH_Hinter* hinter )
|
||||
{
|
||||
AH_Blue blue;
|
||||
AH_Globals* globals = &hinter->globals->design;
|
||||
FT_Pos flats [MAX_TEST_CHARACTERS];
|
||||
FT_Pos rounds[MAX_TEST_CHARACTERS];
|
||||
FT_Int num_flats;
|
||||
FT_Int num_rounds;
|
||||
|
||||
FT_Face face;
|
||||
FT_GlyphSlot glyph;
|
||||
FT_Error error;
|
||||
FT_CharMap charmap;
|
||||
|
||||
|
||||
face = hinter->face;
|
||||
glyph = face->glyph;
|
||||
|
||||
/* save current charmap */
|
||||
charmap = face->charmap;
|
||||
|
||||
/* do we have a Unicode charmap in there? */
|
||||
error = FT_Select_Charmap( face, ft_encoding_unicode );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
/* we compute the blues simply by loading each character from the */
|
||||
/* 'blue_chars[blues]' string, then compute its top-most and */
|
||||
/* bottom-most points */
|
||||
|
||||
AH_LOG(( "blue zones computation\n" ));
|
||||
AH_LOG(( "------------------------------------------------\n" ));
|
||||
|
||||
for ( blue = ah_blue_capital_top; blue < ah_blue_max; blue++ )
|
||||
{
|
||||
const char* p = blue_chars[blue];
|
||||
const char* limit = p + MAX_TEST_CHARACTERS;
|
||||
FT_Pos *blue_ref, *blue_shoot;
|
||||
|
||||
|
||||
AH_LOG(( "blue %3d: ", blue ));
|
||||
|
||||
num_flats = 0;
|
||||
num_rounds = 0;
|
||||
|
||||
for ( ; p < limit; p++ )
|
||||
{
|
||||
FT_UInt glyph_index;
|
||||
FT_Vector* extremum;
|
||||
FT_Vector* points;
|
||||
FT_Vector* point_limit;
|
||||
FT_Vector* point;
|
||||
FT_Bool round;
|
||||
|
||||
|
||||
/* exit if we reach the end of the string */
|
||||
if ( !*p )
|
||||
break;
|
||||
|
||||
AH_LOG(( "`%c'", *p ));
|
||||
|
||||
/* load the character in the face -- skip unknown or empty ones */
|
||||
glyph_index = FT_Get_Char_Index( face, (FT_UInt)*p );
|
||||
if ( glyph_index == 0 )
|
||||
continue;
|
||||
|
||||
error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE );
|
||||
if ( error || glyph->outline.n_points <= 0 )
|
||||
continue;
|
||||
|
||||
/* now compute min or max point indices and coordinates */
|
||||
points = glyph->outline.points;
|
||||
point_limit = points + glyph->outline.n_points;
|
||||
point = points;
|
||||
extremum = point;
|
||||
point++;
|
||||
|
||||
if ( AH_IS_TOP_BLUE( blue ) )
|
||||
{
|
||||
for ( ; point < point_limit; point++ )
|
||||
if ( point->y > extremum->y )
|
||||
extremum = point;
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( ; point < point_limit; point++ )
|
||||
if ( point->y < extremum->y )
|
||||
extremum = point;
|
||||
}
|
||||
|
||||
AH_LOG(( "%5d", (int)extremum->y ));
|
||||
|
||||
/* now, check whether the point belongs to a straight or round */
|
||||
/* segment; we first need to find in which contour the extremum */
|
||||
/* lies, then see its previous and next points */
|
||||
{
|
||||
FT_Int index = extremum - points;
|
||||
FT_Int n;
|
||||
FT_Int first, last, prev, next, end;
|
||||
FT_Pos dist;
|
||||
|
||||
|
||||
last = -1;
|
||||
first = 0;
|
||||
|
||||
for ( n = 0; n < glyph->outline.n_contours; n++ )
|
||||
{
|
||||
end = glyph->outline.contours[n];
|
||||
if ( end >= index )
|
||||
{
|
||||
last = end;
|
||||
break;
|
||||
}
|
||||
first = end + 1;
|
||||
}
|
||||
|
||||
/* XXX: should never happen! */
|
||||
if ( last < 0 )
|
||||
continue;
|
||||
|
||||
/* now look for the previous and next points that are not on the */
|
||||
/* same Y coordinate. Threshold the `closeness'... */
|
||||
|
||||
prev = index;
|
||||
next = prev;
|
||||
|
||||
do
|
||||
{
|
||||
if ( prev > first )
|
||||
prev--;
|
||||
else
|
||||
prev = last;
|
||||
|
||||
dist = points[prev].y - extremum->y;
|
||||
if ( dist < -5 || dist > 5 )
|
||||
break;
|
||||
|
||||
} while ( prev != index );
|
||||
|
||||
do
|
||||
{
|
||||
if ( next < last )
|
||||
next++;
|
||||
else
|
||||
next = first;
|
||||
|
||||
dist = points[next].y - extremum->y;
|
||||
if ( dist < -5 || dist > 5 )
|
||||
break;
|
||||
|
||||
} while ( next != index );
|
||||
|
||||
/* now, set the `round' flag depending on the segment's kind */
|
||||
round =
|
||||
FT_CURVE_TAG( glyph->outline.tags[prev] ) != FT_Curve_Tag_On ||
|
||||
FT_CURVE_TAG( glyph->outline.tags[next] ) != FT_Curve_Tag_On ;
|
||||
|
||||
AH_LOG(( "%c ", round ? 'r' : 'f' ));
|
||||
}
|
||||
|
||||
if ( round )
|
||||
rounds[num_rounds++] = extremum->y;
|
||||
else
|
||||
flats[num_flats++] = extremum->y;
|
||||
}
|
||||
|
||||
AH_LOG(( "\n" ));
|
||||
|
||||
/* we have computed the contents of the `rounds' and `flats' tables, */
|
||||
/* now determine the reference and overshoot position of the blue; */
|
||||
/* we simply take the median value after a simple short */
|
||||
sort_values( num_rounds, rounds );
|
||||
sort_values( num_flats, flats );
|
||||
|
||||
blue_ref = globals->blue_refs + blue;
|
||||
blue_shoot = globals->blue_shoots + blue;
|
||||
if ( num_flats == 0 && num_rounds == 0 )
|
||||
{
|
||||
*blue_ref = -10000;
|
||||
*blue_shoot = -10000;
|
||||
}
|
||||
else if ( num_flats == 0 )
|
||||
{
|
||||
*blue_ref =
|
||||
*blue_shoot = rounds[num_rounds / 2];
|
||||
}
|
||||
else if ( num_rounds == 0 )
|
||||
{
|
||||
*blue_ref =
|
||||
*blue_shoot = flats[num_flats / 2];
|
||||
}
|
||||
else
|
||||
{
|
||||
*blue_ref = flats[num_flats / 2];
|
||||
*blue_shoot = rounds[num_rounds / 2];
|
||||
}
|
||||
|
||||
/* there are sometimes problems: if the overshoot position of top */
|
||||
/* zones is under its reference position, or the opposite for bottom */
|
||||
/* zones. We must thus check everything there and correct the errors */
|
||||
if ( *blue_shoot != *blue_ref )
|
||||
{
|
||||
FT_Pos ref = *blue_ref;
|
||||
FT_Pos shoot = *blue_shoot;
|
||||
FT_Bool over_ref = ( shoot > ref );
|
||||
|
||||
|
||||
if ( AH_IS_TOP_BLUE( blue ) ^ over_ref )
|
||||
*blue_shoot = *blue_ref = ( shoot + ref ) / 2;
|
||||
}
|
||||
|
||||
AH_LOG(( "-- ref = %ld, shoot = %ld\n", *blue_ref, *blue_shoot ));
|
||||
}
|
||||
|
||||
/* reset original face charmap */
|
||||
FT_Set_Charmap( face, charmap );
|
||||
error = 0;
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
FT_Error ah_hinter_compute_widths( AH_Hinter* hinter )
|
||||
{
|
||||
/* scan the array of segments in each direction */
|
||||
AH_Outline* outline = hinter->glyph;
|
||||
AH_Segment* segments;
|
||||
AH_Segment* limit;
|
||||
AH_Globals* globals = &hinter->globals->design;
|
||||
FT_Pos* widths;
|
||||
FT_Int dimension;
|
||||
FT_Int* p_num_widths;
|
||||
FT_Error error = 0;
|
||||
FT_Pos edge_distance_threshold = 32000;
|
||||
|
||||
|
||||
globals->num_widths = 0;
|
||||
globals->num_heights = 0;
|
||||
|
||||
/* For now, compute the standard width and height from the `o' */
|
||||
/* character. I started computing the stem width of the `i' and the */
|
||||
/* stem height of the "-", but it wasn't too good. Moreover, we now */
|
||||
/* have a single character that gives us standard width and height. */
|
||||
{
|
||||
FT_UInt glyph_index;
|
||||
|
||||
|
||||
glyph_index = FT_Get_Char_Index( hinter->face, 'o' );
|
||||
if ( glyph_index == 0 )
|
||||
return 0;
|
||||
|
||||
error = FT_Load_Glyph( hinter->face, glyph_index, FT_LOAD_NO_SCALE );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
error = ah_outline_load( hinter->glyph, hinter->face );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
ah_outline_compute_segments( hinter->glyph );
|
||||
ah_outline_link_segments( hinter->glyph );
|
||||
}
|
||||
|
||||
segments = outline->horz_segments;
|
||||
limit = segments + outline->num_hsegments;
|
||||
widths = globals->heights;
|
||||
p_num_widths = &globals->num_heights;
|
||||
|
||||
for ( dimension = 1; dimension >= 0; dimension-- )
|
||||
{
|
||||
AH_Segment* seg = segments;
|
||||
AH_Segment* link;
|
||||
FT_Int num_widths = 0;
|
||||
|
||||
|
||||
for ( ; seg < limit; seg++ )
|
||||
{
|
||||
link = seg->link;
|
||||
/* we only consider stem segments there! */
|
||||
if ( link && link->link == seg && link > seg )
|
||||
{
|
||||
FT_Int dist;
|
||||
|
||||
|
||||
dist = seg->pos - link->pos;
|
||||
if ( dist < 0 )
|
||||
dist = -dist;
|
||||
|
||||
if ( num_widths < 12 )
|
||||
widths[num_widths++] = dist;
|
||||
}
|
||||
}
|
||||
|
||||
sort_values( num_widths, widths );
|
||||
*p_num_widths = num_widths;
|
||||
|
||||
/* we will now try to find the smallest width */
|
||||
if ( num_widths > 0 && widths[0] < edge_distance_threshold )
|
||||
edge_distance_threshold = widths[0];
|
||||
|
||||
segments = outline->vert_segments;
|
||||
limit = segments + outline->num_vsegments;
|
||||
widths = globals->widths;
|
||||
p_num_widths = &globals->num_widths;
|
||||
|
||||
}
|
||||
|
||||
/* Now, compute the edge distance threshold as a fraction of the */
|
||||
/* smallest width in the font. Set it in `hinter.glyph' too! */
|
||||
if ( edge_distance_threshold == 32000 )
|
||||
edge_distance_threshold = 50;
|
||||
|
||||
/* let's try 20% */
|
||||
hinter->glyph->edge_distance_threshold = edge_distance_threshold / 5;
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
FT_Error ah_hinter_compute_globals( AH_Hinter* hinter )
|
||||
{
|
||||
return ah_hinter_compute_widths( hinter ) ||
|
||||
ah_hinter_compute_blues ( hinter );
|
||||
}
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,52 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ahglobal.h */
|
||||
/* */
|
||||
/* Routines used to compute global metrics automatically */
|
||||
/* (specification). */
|
||||
/* */
|
||||
/* Copyright 2000 Catharon Productions Inc. */
|
||||
/* Author: David Turner */
|
||||
/* */
|
||||
/* This file is part of the Catharon Typography Project and shall only */
|
||||
/* be used, modified, and distributed under the terms of the Catharon */
|
||||
/* Open Source License that should come with this file under the name */
|
||||
/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/* Note that this license is compatible with the FreeType license. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef AHGLOBAL_H
|
||||
#define AHGLOBAL_H
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "ahtypes.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <autohint/ahtypes.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#include <freetype/internal/ftobjs.h> /* for LOCAL_DEF/LOCAL_FUNC */
|
||||
|
||||
|
||||
#define AH_IS_TOP_BLUE( b ) ( (b) == ah_blue_capital_top || \
|
||||
(b) == ah_blue_small_top )
|
||||
|
||||
|
||||
/* compute global metrics automatically */
|
||||
LOCAL_DEF
|
||||
FT_Error ah_hinter_compute_globals( AH_Hinter* hinter );
|
||||
|
||||
|
||||
#endif /* AHGLOBAL_H */
|
||||
|
||||
|
||||
/* END */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,93 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ahglyph.h */
|
||||
/* */
|
||||
/* Routines used to load and analyze a given glyph before hinting */
|
||||
/* (specification). */
|
||||
/* */
|
||||
/* Copyright 2000 Catharon Productions Inc. */
|
||||
/* Author: David Turner */
|
||||
/* */
|
||||
/* This file is part of the Catharon Typography Project and shall only */
|
||||
/* be used, modified, and distributed under the terms of the Catharon */
|
||||
/* Open Source License that should come with this file under the name */
|
||||
/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/* Note that this license is compatible with the FreeType license. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef AHGLYPH_H
|
||||
#define AHGLYPH_H
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "ahtypes.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <autohint/ahtypes.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
typedef enum AH_UV_
|
||||
{
|
||||
ah_uv_fxy,
|
||||
ah_uv_fyx,
|
||||
ah_uv_oxy,
|
||||
ah_uv_oyx,
|
||||
ah_uv_ox,
|
||||
ah_uv_oy,
|
||||
ah_uv_yx,
|
||||
ah_uv_xy /* should always be last! */
|
||||
|
||||
} AH_UV;
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
void ah_setup_uv( AH_Outline* outline,
|
||||
AH_UV source );
|
||||
|
||||
|
||||
/* AH_Outline functions - they should be typically called in this order */
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error ah_outline_new( FT_Memory memory,
|
||||
AH_Outline** aoutline );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error ah_outline_load( AH_Outline* outline,
|
||||
FT_Face face );
|
||||
|
||||
LOCAL_DEF
|
||||
void ah_outline_compute_segments( AH_Outline* outline );
|
||||
|
||||
LOCAL_DEF
|
||||
void ah_outline_link_segments( AH_Outline* outline );
|
||||
|
||||
LOCAL_DEF
|
||||
void ah_outline_detect_features( AH_Outline* outline );
|
||||
|
||||
LOCAL_DEF
|
||||
void ah_outline_compute_blue_edges( AH_Outline* outline,
|
||||
AH_Face_Globals* globals );
|
||||
|
||||
LOCAL_DEF
|
||||
void ah_outline_scale_blue_edges( AH_Outline* outline,
|
||||
AH_Face_Globals* globals );
|
||||
|
||||
LOCAL_DEF
|
||||
void ah_outline_save( AH_Outline* outline, AH_Loader* loader );
|
||||
|
||||
LOCAL_DEF
|
||||
void ah_outline_done( AH_Outline* outline );
|
||||
|
||||
|
||||
#endif /* AHGLYPH_H */
|
||||
|
||||
|
||||
/* END */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,72 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ahhint.h */
|
||||
/* */
|
||||
/* Glyph hinter (declaration). */
|
||||
/* */
|
||||
/* Copyright 2000 Catharon Productions Inc. */
|
||||
/* Author: David Turner */
|
||||
/* */
|
||||
/* This file is part of the Catharon Typography Project and shall only */
|
||||
/* be used, modified, and distributed under the terms of the Catharon */
|
||||
/* Open Source License that should come with this file under the name */
|
||||
/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/* Note that this license is compatible with the FreeType license. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef AHHINT_H
|
||||
#define AHHINT_H
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "ahglobal.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <autohint/ahglobal.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#define AH_HINT_DEFAULT 0
|
||||
#define AH_HINT_NO_ALIGNMENT 1
|
||||
#define AH_HINT_NO_HORZ_EDGES 0x20000L
|
||||
#define AH_HINT_NO_VERT_EDGES 0x40000L
|
||||
|
||||
|
||||
/* create a new empty hinter object */
|
||||
FT_Error ah_hinter_new( FT_Library library,
|
||||
AH_Hinter** ahinter );
|
||||
|
||||
/* Load a hinted glyph in the hinter */
|
||||
FT_Error ah_hinter_load_glyph( AH_Hinter* hinter,
|
||||
FT_GlyphSlot slot,
|
||||
FT_Size size,
|
||||
FT_UInt glyph_index,
|
||||
FT_Int load_flags );
|
||||
|
||||
/* finalize a hinter object */
|
||||
void ah_hinter_done( AH_Hinter* hinter );
|
||||
|
||||
LOCAL_DEF
|
||||
void ah_hinter_done_face_globals( AH_Face_Globals* globals );
|
||||
|
||||
void ah_hinter_get_global_hints( AH_Hinter* hinter,
|
||||
FT_Face face,
|
||||
void** global_hints,
|
||||
long* global_len );
|
||||
|
||||
void ah_hinter_done_global_hints( AH_Hinter* hinter,
|
||||
void* global_hints );
|
||||
|
||||
|
||||
#endif /* AHHINT_H */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,124 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ahloader.h */
|
||||
/* */
|
||||
/* Glyph loader for the auto-hinting module (declaration only). */
|
||||
/* */
|
||||
/* Copyright 2000 Catharon Productions Inc. */
|
||||
/* Author: David Turner */
|
||||
/* */
|
||||
/* This file is part of the Catharon Typography Project and shall only */
|
||||
/* be used, modified, and distributed under the terms of the Catharon */
|
||||
/* Open Source License that should come with this file under the name */
|
||||
/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/* Note that this license is compatible with the FreeType license. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* This defines the AH_GlyphLoader type in two different ways: */
|
||||
/* */
|
||||
/* - If the module is compiled within FreeType 2, the type is simply a */
|
||||
/* typedef to FT_GlyphLoader. */
|
||||
/* */
|
||||
/* - If the module is compiled as a standalone object, AH_GlyphLoader */
|
||||
/* has its own implementation. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#ifndef AHLOADER_H
|
||||
#define AHLOADER_H
|
||||
|
||||
|
||||
#ifdef _STANDALONE_
|
||||
|
||||
typedef struct AH_GlyphLoad_
|
||||
{
|
||||
FT_Outline outline; /* outline */
|
||||
FT_UInt num_subglyphs; /* number of subglyphs */
|
||||
FT_SubGlyph* subglyphs; /* subglyphs */
|
||||
FT_Vector* extra_points; /* extra points table */
|
||||
|
||||
} AH_GlyphLoad;
|
||||
|
||||
|
||||
struct AH_GlyphLoader_
|
||||
{
|
||||
FT_Memory memory;
|
||||
FT_UInt max_points;
|
||||
FT_UInt max_contours;
|
||||
FT_UInt max_subglyphs;
|
||||
FT_Bool use_extra;
|
||||
|
||||
AH_GlyphLoad base;
|
||||
AH_GlyphLoad current;
|
||||
|
||||
void* other; /* for possible future extensions */
|
||||
};
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error AH_GlyphLoader_New( FT_Memory memory,
|
||||
AH_GlyphLoader** aloader );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error AH_GlyphLoader_Create_Extra( AH_GlyphLoader* loader );
|
||||
|
||||
LOCAL_DEF
|
||||
void AH_GlyphLoader_Done( AH_GlyphLoader* loader );
|
||||
|
||||
LOCAL_DEF
|
||||
void AH_GlyphLoader_Reset( AH_GlyphLoader* loader );
|
||||
|
||||
LOCAL_DEF
|
||||
void AH_GlyphLoader_Rewind( AH_GlyphLoader* loader );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error AH_GlyphLoader_Check_Points( AH_GlyphLoader* loader,
|
||||
FT_UInt n_points,
|
||||
FT_UInt n_contours );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error AH_GlyphLoader_Check_Subglyphs( AH_GlyphLoader* loader,
|
||||
FT_UInt n_subs );
|
||||
|
||||
LOCAL_DEF
|
||||
void AH_GlyphLoader_Prepare( AH_GlyphLoader* loader );
|
||||
|
||||
LOCAL_DEF
|
||||
void AH_GlyphLoader_Add( AH_GlyphLoader* loader );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error AH_GlyphLoader_Copy_Points( AH_GlyphLoader* target,
|
||||
FT_GlyphLoader* source );
|
||||
|
||||
#else /* _STANDALONE */
|
||||
|
||||
#include <freetype/internal/ftobjs.h>
|
||||
|
||||
#define AH_Load FT_GlyphLoad
|
||||
#define AH_Loader FT_GlyphLoader
|
||||
|
||||
#define ah_loader_new FT_GlyphLoader_New
|
||||
#define ah_loader_done FT_GlyphLoader_Done
|
||||
#define ah_loader_reset FT_GlyphLoader_Reset
|
||||
#define ah_loader_rewind FT_GlyphLoader_Rewind
|
||||
#define ah_loader_create_extra FT_GlyphLoader_Create_Extra
|
||||
#define ah_loader_check_points FT_GlyphLoader_Check_Points
|
||||
#define ah_loader_check_subglyphs FT_GlyphLoader_Check_Subglyphs
|
||||
#define ah_loader_prepare FT_GlyphLoader_Prepare
|
||||
#define ah_loader_add FT_GlyphLoader_Add
|
||||
#define ah_loader_copy_points FT_GlyphLoader_Copy_Points
|
||||
|
||||
#endif /* _STANDALONE_ */
|
||||
|
||||
#endif /* AHLOADER_H */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,127 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ahmodule.c */
|
||||
/* */
|
||||
/* Auto-hinting module implementation (declaration). */
|
||||
/* */
|
||||
/* Copyright 2000 Catharon Productions Inc. */
|
||||
/* Author: David Turner */
|
||||
/* */
|
||||
/* This file is part of the Catharon Typography Project and shall only */
|
||||
/* be used, modified, and distributed under the terms of the Catharon */
|
||||
/* Open Source License that should come with this file under the name */
|
||||
/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/* Note that this license is compatible with the FreeType license. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#include <freetype/ftmodule.h>
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "ahhint.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <autohint/ahhint.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct FT_AutoHinterRec_
|
||||
{
|
||||
FT_ModuleRec root;
|
||||
AH_Hinter* hinter;
|
||||
|
||||
} FT_AutoHinterRec;
|
||||
|
||||
|
||||
static
|
||||
FT_Error ft_autohinter_init( FT_AutoHinter module )
|
||||
{
|
||||
return ah_hinter_new( module->root.library, &module->hinter );
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void ft_autohinter_done( FT_AutoHinter module )
|
||||
{
|
||||
ah_hinter_done( module->hinter );
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
FT_Error ft_autohinter_load( FT_AutoHinter module,
|
||||
FT_GlyphSlot slot,
|
||||
FT_Size size,
|
||||
FT_UInt glyph_index,
|
||||
FT_ULong load_flags )
|
||||
{
|
||||
return ah_hinter_load_glyph( module->hinter,
|
||||
slot, size, glyph_index, load_flags );
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void ft_autohinter_reset( FT_AutoHinter module,
|
||||
FT_Face face )
|
||||
{
|
||||
UNUSED( module );
|
||||
|
||||
if ( face->autohint.data )
|
||||
ah_hinter_done_face_globals( (AH_Face_Globals*)(face->autohint.data) );
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void ft_autohinter_get_globals( FT_AutoHinter module,
|
||||
FT_Face face,
|
||||
void** global_hints,
|
||||
long* global_len )
|
||||
{
|
||||
ah_hinter_get_global_hints( module->hinter, face,
|
||||
global_hints, global_len );
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void ft_autohinter_done_globals( FT_AutoHinter module,
|
||||
void* global_hints )
|
||||
{
|
||||
ah_hinter_done_global_hints( module->hinter, global_hints );
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
const FT_AutoHinter_Interface autohinter_interface =
|
||||
{
|
||||
ft_autohinter_reset,
|
||||
ft_autohinter_load,
|
||||
ft_autohinter_get_globals,
|
||||
ft_autohinter_done_globals
|
||||
};
|
||||
|
||||
|
||||
const FT_Module_Class autohint_module_class =
|
||||
{
|
||||
ft_module_hinter,
|
||||
sizeof ( FT_AutoHinterRec ),
|
||||
|
||||
"autohinter",
|
||||
0x10000L, /* version 1.0 of the autohinter */
|
||||
0x20000L, /* requires FreeType 2.0 or above */
|
||||
|
||||
(const void*)&autohinter_interface,
|
||||
|
||||
(FT_Module_Constructor)ft_autohinter_init,
|
||||
(FT_Module_Destructor) ft_autohinter_done,
|
||||
(FT_Module_Requester) 0
|
||||
};
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,32 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ahmodule.h */
|
||||
/* */
|
||||
/* Auto-hinting module (declaration). */
|
||||
/* */
|
||||
/* Copyright 2000 Catharon Productions Inc. */
|
||||
/* Author: David Turner */
|
||||
/* */
|
||||
/* This file is part of the Catharon Typography Project and shall only */
|
||||
/* be used, modified, and distributed under the terms of the Catharon */
|
||||
/* Open Source License that should come with this file under the name */
|
||||
/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/* Note that this license is compatible with the FreeType license. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef AHMODULE_H
|
||||
#define AHMODULE_H
|
||||
|
||||
#include <freetype/ftmodule.h>
|
||||
|
||||
FT_EXPORT_VAR( const FT_Module_Class ) autohint_module_class;
|
||||
|
||||
#endif /* AHMODULE_H */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,889 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ahoptim.c */
|
||||
/* */
|
||||
/* FreeType auto hinting outline optimization (body). */
|
||||
/* */
|
||||
/* Copyright 2000 Catharon Productions Inc. */
|
||||
/* Author: David Turner */
|
||||
/* */
|
||||
/* This file is part of the Catharon Typography Project and shall only */
|
||||
/* be used, modified, and distributed under the terms of the Catharon */
|
||||
/* Open Source License that should come with this file under the name */
|
||||
/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/* Note that this license is compatible with the FreeType license. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* This module is in charge of optimising the outlines produced by the */
|
||||
/* auto-hinter in direct mode. This is required at small pixel sizes in */
|
||||
/* order to ensure coherent spacing, among other things.. */
|
||||
/* */
|
||||
/* The technique used in this module is a simplified simulated */
|
||||
/* annealing. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#include <freetype/internal/ftobjs.h> /* for ALLOC_ARRAY() and FREE() */
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "ahoptim.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <autohint/ahoptim.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* define this macro to use brute force optimisation -- this is slow, */
|
||||
/* but a good way to perfect the distortion function `by hand' through */
|
||||
/* tweaking */
|
||||
#define AH_BRUTE_FORCE
|
||||
|
||||
|
||||
#define xxxAH_DEBUG_OPTIM
|
||||
|
||||
|
||||
#undef LOG
|
||||
#ifdef AH_DEBUG_OPTIM
|
||||
|
||||
#define LOG( x ) optim_log##x
|
||||
|
||||
#else
|
||||
|
||||
#define LOG( x )
|
||||
|
||||
#endif /* AH_DEBUG_OPTIM */
|
||||
|
||||
|
||||
#ifdef AH_DEBUG_OPTIM
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define FLOAT( x ) ( (float)( (x) / 64.0 ) )
|
||||
|
||||
static
|
||||
void optim_log( const char* fmt, ... )
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
|
||||
va_start( ap, fmt );
|
||||
/* vprintf( fmt, ap ); FIXME */
|
||||
va_end( ap );
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void AH_Dump_Stems( AH_Optimizer* optimizer )
|
||||
{
|
||||
int n;
|
||||
AH_Stem* stem;
|
||||
|
||||
|
||||
stem = optimizer->stems;
|
||||
for ( n = 0; n < optimizer->num_stems; n++, stem++ )
|
||||
{
|
||||
LOG(( " %c%2d [%.1f:%.1f]={%.1f:%.1f}="
|
||||
"<%1.f..%1.f> force=%.1f speed=%.1f\n",
|
||||
optimizer->vertical ? 'V' : 'H', n,
|
||||
FLOAT( stem->edge1->opos ), FLOAT( stem->edge2->opos ),
|
||||
FLOAT( stem->edge1->pos ), FLOAT( stem->edge2->pos ),
|
||||
FLOAT( stem->min_pos ), FLOAT( stem->max_pos ),
|
||||
FLOAT( stem->force ), FLOAT( stem->velocity ) ));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void AH_Dump_Stems2( AH_Optimizer* optimizer )
|
||||
{
|
||||
int n;
|
||||
AH_Stem* stem;
|
||||
|
||||
|
||||
stem = optimizer->stems;
|
||||
for ( n = 0; n < optimizer->num_stems; n++, stem++ )
|
||||
{
|
||||
LOG(( " %c%2d [%.1f]=<%1.f..%1.f> force=%.1f speed=%.1f\n",
|
||||
optimizer->vertical ? 'V' : 'H', n,
|
||||
FLOAT( stem->pos ),
|
||||
FLOAT( stem->min_pos ), FLOAT( stem->max_pos ),
|
||||
FLOAT( stem->force ), FLOAT( stem->velocity ) ));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void AH_Dump_Springs( AH_Optimizer* optimizer )
|
||||
{
|
||||
int n;
|
||||
AH_Spring* spring;
|
||||
AH_Stem* stems;
|
||||
|
||||
|
||||
spring = optimizer->springs;
|
||||
stems = optimizer->stems;
|
||||
LOG(( "%cSprings ", optimizer->vertical ? 'V' : 'H' ));
|
||||
|
||||
for ( n = 0; n < optimizer->num_springs; n++, spring++ )
|
||||
{
|
||||
LOG(( " [%d-%d:%.1f:%1.f:%.1f]",
|
||||
spring->stem1 - stems, spring->stem2 - stems,
|
||||
FLOAT( spring->owidth ),
|
||||
FLOAT( spring->stem2->pos -
|
||||
( spring->stem1->pos + spring->stem1->width ) ),
|
||||
FLOAT( spring->tension ) ));
|
||||
}
|
||||
|
||||
LOG(( "\n" ));
|
||||
}
|
||||
|
||||
#endif /* AH_DEBUG_OPTIM */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** COMPUTE STEMS AND SPRINGS IN AN OUTLINE ****/
|
||||
/**** ****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
static
|
||||
int valid_stem_segments( AH_Segment* seg1,
|
||||
AH_Segment* seg2 )
|
||||
{
|
||||
return seg1->serif == 0 &&
|
||||
seg2 &&
|
||||
seg2->link == seg1 &&
|
||||
seg1->pos < seg2->pos &&
|
||||
seg1->min_coord <= seg2->max_coord &&
|
||||
seg2->min_coord <= seg1->max_coord;
|
||||
}
|
||||
|
||||
|
||||
/* compute all stems in an outline */
|
||||
static
|
||||
int optim_compute_stems( AH_Optimizer* optimizer )
|
||||
{
|
||||
AH_Outline* outline = optimizer->outline;
|
||||
FT_Fixed scale;
|
||||
FT_Memory memory = optimizer->memory;
|
||||
FT_Error error = 0;
|
||||
FT_Int dimension;
|
||||
AH_Edge* edges;
|
||||
AH_Edge* edge_limit;
|
||||
AH_Stem** p_stems;
|
||||
FT_Int* p_num_stems;
|
||||
|
||||
|
||||
edges = outline->horz_edges;
|
||||
edge_limit = edges + outline->num_hedges;
|
||||
scale = outline->y_scale;
|
||||
|
||||
p_stems = &optimizer->horz_stems;
|
||||
p_num_stems = &optimizer->num_hstems;
|
||||
|
||||
for ( dimension = 1; dimension >= 0; dimension-- )
|
||||
{
|
||||
AH_Stem* stems = 0;
|
||||
FT_Int num_stems = 0;
|
||||
AH_Edge* edge;
|
||||
|
||||
|
||||
/* first of all, count the number of stems in this direction */
|
||||
for ( edge = edges; edge < edge_limit; edge++ )
|
||||
{
|
||||
AH_Segment* seg = edge->first;
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
if (valid_stem_segments( seg, seg->link ) )
|
||||
num_stems++;
|
||||
|
||||
seg = seg->edge_next;
|
||||
|
||||
} while ( seg != edge->first );
|
||||
}
|
||||
|
||||
/* now allocate the stems and build their table */
|
||||
if ( num_stems > 0 )
|
||||
{
|
||||
AH_Stem* stem;
|
||||
|
||||
|
||||
if ( ALLOC_ARRAY( stems, num_stems, AH_Stem ) )
|
||||
goto Exit;
|
||||
|
||||
stem = stems;
|
||||
for ( edge = edges; edge < edge_limit; edge++ )
|
||||
{
|
||||
AH_Segment* seg = edge->first;
|
||||
AH_Segment* seg2;
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
seg2 = seg->link;
|
||||
if ( valid_stem_segments( seg, seg2 ) )
|
||||
{
|
||||
AH_Edge* edge1 = seg->edge;
|
||||
AH_Edge* edge2 = seg2->edge;
|
||||
|
||||
|
||||
stem->edge1 = edge1;
|
||||
stem->edge2 = edge2;
|
||||
stem->opos = edge1->opos;
|
||||
stem->pos = edge1->pos;
|
||||
stem->owidth = edge2->opos - edge1->opos;
|
||||
stem->width = edge2->pos - edge1->pos;
|
||||
|
||||
/* compute min_coord and max_coord */
|
||||
{
|
||||
FT_Pos min_coord = seg->min_coord;
|
||||
FT_Pos max_coord = seg->max_coord;
|
||||
|
||||
|
||||
if ( seg2->min_coord > min_coord )
|
||||
min_coord = seg2->min_coord;
|
||||
|
||||
if ( seg2->max_coord < max_coord )
|
||||
max_coord = seg2->max_coord;
|
||||
|
||||
stem->min_coord = min_coord;
|
||||
stem->max_coord = max_coord;
|
||||
}
|
||||
|
||||
/* compute minimum and maximum positions for stem -- */
|
||||
/* note that the left-most/bottom-most stem has always */
|
||||
/* a fixed position */
|
||||
if ( stem == stems || edge1->blue_edge || edge2->blue_edge )
|
||||
{
|
||||
/* this stem cannot move; it is snapped to a blue edge */
|
||||
stem->min_pos = stem->pos;
|
||||
stem->max_pos = stem->pos;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* this edge can move; compute its min and max positions */
|
||||
FT_Pos pos1 = stem->opos;
|
||||
FT_Pos pos2 = pos1 + stem->owidth - stem->width;
|
||||
FT_Pos min1 = pos1 & -64;
|
||||
FT_Pos min2 = pos2 & -64;
|
||||
|
||||
|
||||
stem->min_pos = min1;
|
||||
stem->max_pos = min1 + 64;
|
||||
if ( min2 < min1 )
|
||||
stem->min_pos = min2;
|
||||
else
|
||||
stem->max_pos = min2 + 64;
|
||||
|
||||
/* XXX: just to see what it does */
|
||||
stem->max_pos += 64;
|
||||
|
||||
/* just for the case where direct hinting did some */
|
||||
/* incredible things (e.g. blue edge shifts) */
|
||||
if ( stem->min_pos > stem->pos )
|
||||
stem->min_pos = stem->pos;
|
||||
|
||||
if ( stem->max_pos < stem->pos )
|
||||
stem->max_pos = stem->pos;
|
||||
}
|
||||
|
||||
stem->velocity = 0;
|
||||
stem->force = 0;
|
||||
|
||||
stem++;
|
||||
}
|
||||
seg = seg->edge_next;
|
||||
|
||||
} while ( seg != edge->first );
|
||||
}
|
||||
}
|
||||
|
||||
*p_stems = stems;
|
||||
*p_num_stems = num_stems;
|
||||
|
||||
edges = outline->vert_edges;
|
||||
edge_limit = edges + outline->num_vedges;
|
||||
scale = outline->x_scale;
|
||||
|
||||
p_stems = &optimizer->vert_stems;
|
||||
p_num_stems = &optimizer->num_vstems;
|
||||
}
|
||||
|
||||
Exit:
|
||||
|
||||
#ifdef AH_DEBUG_OPTIM
|
||||
AH_Dump_Stems( optimizer );
|
||||
#endif
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/* returns the spring area between two stems, 0 if none */
|
||||
static
|
||||
FT_Pos stem_spring_area( AH_Stem* stem1,
|
||||
AH_Stem* stem2 )
|
||||
{
|
||||
FT_Pos area1 = stem1->max_coord - stem1->min_coord;
|
||||
FT_Pos area2 = stem2->max_coord - stem2->min_coord;
|
||||
FT_Pos min = stem1->min_coord;
|
||||
FT_Pos max = stem1->max_coord;
|
||||
FT_Pos area;
|
||||
|
||||
|
||||
/* order stems */
|
||||
if ( stem2->opos <= stem1->opos + stem1->owidth )
|
||||
return 0;
|
||||
|
||||
if ( min < stem2->min_coord )
|
||||
min = stem2->min_coord;
|
||||
|
||||
if ( max < stem2->max_coord )
|
||||
max = stem2->max_coord;
|
||||
|
||||
area = ( max-min );
|
||||
if ( 2 * area < area1 && 2 * area < area2 )
|
||||
area = 0;
|
||||
|
||||
return area;
|
||||
}
|
||||
|
||||
|
||||
/* compute all springs in an outline */
|
||||
static
|
||||
int optim_compute_springs( AH_Optimizer* optimizer )
|
||||
{
|
||||
/* basically, a spring exists between two stems if most of their */
|
||||
/* surface is aligned */
|
||||
FT_Memory memory = optimizer->memory;
|
||||
|
||||
AH_Stem* stems;
|
||||
AH_Stem* stem_limit;
|
||||
AH_Stem* stem;
|
||||
int dimension;
|
||||
int error = 0;
|
||||
|
||||
FT_Int* p_num_springs;
|
||||
AH_Spring** p_springs;
|
||||
|
||||
|
||||
stems = optimizer->horz_stems;
|
||||
stem_limit = stems + optimizer->num_hstems;
|
||||
|
||||
p_springs = &optimizer->horz_springs;
|
||||
p_num_springs = &optimizer->num_hsprings;
|
||||
|
||||
for ( dimension = 1; dimension >= 0; dimension-- )
|
||||
{
|
||||
FT_Int num_springs = 0;
|
||||
AH_Spring* springs = 0;
|
||||
|
||||
|
||||
/* first of all, count stem springs */
|
||||
for ( stem = stems; stem + 1 < stem_limit; stem++ )
|
||||
{
|
||||
AH_Stem* stem2;
|
||||
|
||||
|
||||
for ( stem2 = stem+1; stem2 < stem_limit; stem2++ )
|
||||
if ( stem_spring_area( stem, stem2 ) )
|
||||
num_springs++;
|
||||
}
|
||||
|
||||
/* then allocate and build the springs table */
|
||||
if ( num_springs > 0 )
|
||||
{
|
||||
AH_Spring* spring;
|
||||
|
||||
|
||||
/* allocate table of springs */
|
||||
if ( ALLOC_ARRAY( springs, num_springs, AH_Spring ) )
|
||||
goto Exit;
|
||||
|
||||
/* fill the springs table */
|
||||
spring = springs;
|
||||
for ( stem = stems; stem+1 < stem_limit; stem++ )
|
||||
{
|
||||
AH_Stem* stem2;
|
||||
FT_Pos area;
|
||||
|
||||
|
||||
for ( stem2 = stem + 1; stem2 < stem_limit; stem2++ )
|
||||
{
|
||||
area = stem_spring_area( stem, stem2 );
|
||||
if ( area )
|
||||
{
|
||||
/* add a new spring here */
|
||||
spring->stem1 = stem;
|
||||
spring->stem2 = stem2;
|
||||
spring->owidth = stem2->opos - ( stem->opos + stem->owidth );
|
||||
spring->tension = 0;
|
||||
|
||||
spring++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*p_num_springs = num_springs;
|
||||
*p_springs = springs;
|
||||
|
||||
stems = optimizer->vert_stems;
|
||||
stem_limit = stems + optimizer->num_vstems;
|
||||
|
||||
p_springs = &optimizer->vert_springs;
|
||||
p_num_springs = &optimizer->num_vsprings;
|
||||
}
|
||||
|
||||
Exit:
|
||||
|
||||
#ifdef AH_DEBUG_OPTIM
|
||||
AH_Dump_Springs( optimizer );
|
||||
#endif
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** OPTIMIZE THROUGH MY STRANGE SIMULATED ANNEALING ALGO ;-) ****/
|
||||
/**** ****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef AH_BRUTE_FORCE
|
||||
|
||||
/* compute all spring tensions */
|
||||
static
|
||||
void optim_compute_tensions( AH_Optimizer* optimizer )
|
||||
{
|
||||
AH_Spring* spring = optimizer->springs;
|
||||
AH_Spring* limit = spring + optimizer->num_springs;
|
||||
|
||||
|
||||
for ( ; spring < limit; spring++ )
|
||||
{
|
||||
AH_Stem* stem1 = spring->stem1;
|
||||
AH_Stem* stem2 = spring->stem2;
|
||||
FT_Int status;
|
||||
|
||||
FT_Pos width;
|
||||
FT_Pos tension;
|
||||
FT_Pos sign;
|
||||
|
||||
|
||||
/* compute the tension; it simply is -K*(new_width-old_width) */
|
||||
width = stem2->pos - ( stem1->pos + stem1->width );
|
||||
tension = width - spring->owidth;
|
||||
|
||||
sign = 1;
|
||||
if ( tension < 0 )
|
||||
{
|
||||
sign = -1;
|
||||
tension = -tension;
|
||||
}
|
||||
|
||||
if ( width <= 0 )
|
||||
tension = 32000;
|
||||
else
|
||||
tension = ( tension << 10 ) / width;
|
||||
|
||||
tension = -sign * FT_MulFix( tension, optimizer->tension_scale );
|
||||
spring->tension = tension;
|
||||
|
||||
/* now, distribute tension among the englobing stems, if they */
|
||||
/* are able to move */
|
||||
status = 0;
|
||||
if ( stem1->pos <= stem1->min_pos )
|
||||
status |= 1;
|
||||
if ( stem2->pos >= stem2->max_pos )
|
||||
status |= 2;
|
||||
|
||||
if ( !status )
|
||||
tension /= 2;
|
||||
|
||||
if ( ( status & 1 ) == 0 )
|
||||
stem1->force -= tension;
|
||||
|
||||
if ( ( status & 2 ) == 0 )
|
||||
stem2->force += tension;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* compute all stem movements -- returns 0 if nothing moved */
|
||||
static
|
||||
int optim_compute_stem_movements( AH_Optimizer* optimizer )
|
||||
{
|
||||
AH_Stem* stems = optimizer->stems;
|
||||
AH_Stem* limit = stems + optimizer->num_stems;
|
||||
AH_Stem* stem = stems;
|
||||
int moved = 0;
|
||||
|
||||
|
||||
/* set initial forces to velocity */
|
||||
for ( stem = stems; stem < limit; stem++ )
|
||||
{
|
||||
stem->force = stem->velocity;
|
||||
stem->velocity /= 2; /* XXX: Heuristics */
|
||||
}
|
||||
|
||||
/* compute the sum of forces applied on each stem */
|
||||
optim_compute_tensions( optimizer );
|
||||
|
||||
#ifdef AH_DEBUG_OPTIM
|
||||
AH_Dump_Springs( optimizer );
|
||||
AH_Dump_Stems2( optimizer );
|
||||
#endif
|
||||
|
||||
/* now, see whether something can move */
|
||||
for ( stem = stems; stem < limit; stem++ )
|
||||
{
|
||||
if ( stem->force > optimizer->tension_threshold )
|
||||
{
|
||||
/* there is enough tension to move the stem to the right */
|
||||
if ( stem->pos < stem->max_pos )
|
||||
{
|
||||
stem->pos += 64;
|
||||
stem->velocity = stem->force / 2;
|
||||
moved = 1;
|
||||
}
|
||||
else
|
||||
stem->velocity = 0;
|
||||
}
|
||||
else if ( stem->force < optimizer->tension_threshold )
|
||||
{
|
||||
/* there is enough tension to move the stem to the left */
|
||||
if ( stem->pos > stem->min_pos )
|
||||
{
|
||||
stem->pos -= 64;
|
||||
stem->velocity = stem->force / 2;
|
||||
moved = 1;
|
||||
}
|
||||
else
|
||||
stem->velocity = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* return 0 if nothing moved */
|
||||
return moved;
|
||||
}
|
||||
|
||||
#endif /* AH_BRUTE_FORCE */
|
||||
|
||||
|
||||
/* compute current global distortion from springs */
|
||||
static
|
||||
FT_Pos optim_compute_distortion( AH_Optimizer* optimizer )
|
||||
{
|
||||
AH_Spring* spring = optimizer->springs;
|
||||
AH_Spring* limit = spring + optimizer->num_springs;
|
||||
FT_Pos distortion = 0;
|
||||
|
||||
|
||||
for ( ; spring < limit; spring++ )
|
||||
{
|
||||
AH_Stem* stem1 = spring->stem1;
|
||||
AH_Stem* stem2 = spring->stem2;
|
||||
FT_Pos width;
|
||||
|
||||
width = stem2->pos - ( stem1->pos + stem1->width );
|
||||
width -= spring->owidth;
|
||||
if ( width < 0 )
|
||||
width = -width;
|
||||
|
||||
distortion += width;
|
||||
}
|
||||
|
||||
return distortion;
|
||||
}
|
||||
|
||||
|
||||
/* record stems configuration in `best of' history */
|
||||
static
|
||||
void optim_record_configuration( AH_Optimizer* optimizer )
|
||||
{
|
||||
FT_Pos distortion;
|
||||
AH_Configuration* configs = optimizer->configs;
|
||||
AH_Configuration* limit = configs + optimizer->num_configs;
|
||||
AH_Configuration* config;
|
||||
|
||||
|
||||
distortion = optim_compute_distortion( optimizer );
|
||||
LOG(( "config distortion = %.1f ", FLOAT( distortion * 64 ) ));
|
||||
|
||||
/* check that we really need to add this configuration to our */
|
||||
/* sorted history */
|
||||
if ( limit > configs && limit[-1].distortion < distortion )
|
||||
{
|
||||
LOG(( "ejected\n" ));
|
||||
return;
|
||||
}
|
||||
|
||||
/* add new configuration at the end of the table */
|
||||
{
|
||||
int n;
|
||||
|
||||
|
||||
config = limit;
|
||||
if ( optimizer->num_configs < AH_MAX_CONFIGS )
|
||||
optimizer->num_configs++;
|
||||
else
|
||||
config--;
|
||||
|
||||
config->distortion = distortion;
|
||||
|
||||
for ( n = 0; n < optimizer->num_stems; n++ )
|
||||
config->positions[n] = optimizer->stems[n].pos;
|
||||
}
|
||||
|
||||
/* move the current configuration towards the front of the list */
|
||||
/* when necessary -- yes this is slow bubble sort ;-) */
|
||||
while ( config > configs && config[0].distortion < config[-1].distortion )
|
||||
{
|
||||
AH_Configuration temp;
|
||||
|
||||
|
||||
config--;
|
||||
temp = config[0];
|
||||
config[0] = config[1];
|
||||
config[1] = temp;
|
||||
}
|
||||
LOG(( "recorded!\n" ));
|
||||
}
|
||||
|
||||
|
||||
#ifdef AH_BRUTE_FORCE
|
||||
|
||||
/* optimize outline in a single direction */
|
||||
static
|
||||
void optim_compute( AH_Optimizer* optimizer )
|
||||
{
|
||||
int n;
|
||||
FT_Bool moved;
|
||||
|
||||
AH_Stem* stem = optimizer->stems;
|
||||
AH_Stem* limit = stem + optimizer->num_stems;
|
||||
|
||||
|
||||
/* empty, exit */
|
||||
if ( stem >= limit )
|
||||
return;
|
||||
|
||||
optimizer->num_configs = 0;
|
||||
|
||||
stem = optimizer->stems;
|
||||
for ( ; stem < limit; stem++ )
|
||||
stem->pos = stem->min_pos;
|
||||
|
||||
do
|
||||
{
|
||||
/* record current configuration */
|
||||
optim_record_configuration( optimizer );
|
||||
|
||||
/* now change configuration */
|
||||
moved = 0;
|
||||
for ( stem = optimizer->stems; stem < limit; stem++ )
|
||||
{
|
||||
if ( stem->pos < stem->max_pos )
|
||||
{
|
||||
stem->pos += 64;
|
||||
moved = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
stem->pos = stem->min_pos;
|
||||
}
|
||||
} while ( moved );
|
||||
|
||||
/* now, set the best stem positions */
|
||||
for ( n = 0; n < optimizer->num_stems; n++ )
|
||||
{
|
||||
AH_Stem* stem = optimizer->stems + n;
|
||||
FT_Pos pos = optimizer->configs[0].positions[n];
|
||||
|
||||
|
||||
stem->edge1->pos = pos;
|
||||
stem->edge2->pos = pos + stem->width;
|
||||
|
||||
stem->edge1->flags |= ah_edge_done;
|
||||
stem->edge2->flags |= ah_edge_done;
|
||||
}
|
||||
}
|
||||
|
||||
#else /* AH_BRUTE_FORCE */
|
||||
|
||||
/* optimize outline in a single direction */
|
||||
static
|
||||
void optim_compute( AH_Optimizer* optimizer )
|
||||
{
|
||||
int n, counter, counter2;
|
||||
|
||||
|
||||
optimizer->num_configs = 0;
|
||||
optimizer->tension_scale = 0x80000L;
|
||||
optimizer->tension_threshold = 64;
|
||||
|
||||
/* record initial configuration threshold */
|
||||
optim_record_configuration( optimizer );
|
||||
|
||||
counter = 0;
|
||||
for ( counter2 = optimizer->num_stems*8; counter2 >= 0; counter2-- )
|
||||
{
|
||||
if ( counter == 0 )
|
||||
counter = 2 * optimizer->num_stems;
|
||||
|
||||
if ( !optim_compute_stem_movements( optimizer ) )
|
||||
break;
|
||||
|
||||
optim_record_configuration( optimizer );
|
||||
|
||||
counter--;
|
||||
if ( counter == 0 )
|
||||
optimizer->tension_scale /= 2;
|
||||
}
|
||||
|
||||
/* now, set the best stem positions */
|
||||
for ( n = 0; n < optimizer->num_stems; n++ )
|
||||
{
|
||||
AH_Stem* stem = optimizer->stems + n;
|
||||
FT_Pos pos = optimizer->configs[0].positions[n];
|
||||
|
||||
|
||||
stem->edge1->pos = pos;
|
||||
stem->edge2->pos = pos + stem->width;
|
||||
|
||||
stem->edge1->flags |= ah_edge_done;
|
||||
stem->edge2->flags |= ah_edge_done;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* AH_BRUTE_FORCE */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** HIGH-LEVEL OPTIMIZER API ****/
|
||||
/**** ****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/* releases the optimization data */
|
||||
void AH_Optimizer_Done( AH_Optimizer* optimizer )
|
||||
{
|
||||
if ( optimizer )
|
||||
{
|
||||
FT_Memory memory = optimizer->memory;
|
||||
|
||||
|
||||
FREE( optimizer->horz_stems );
|
||||
FREE( optimizer->vert_stems );
|
||||
FREE( optimizer->horz_springs );
|
||||
FREE( optimizer->vert_springs );
|
||||
FREE( optimizer->positions );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* loads the outline into the optimizer */
|
||||
int AH_Optimizer_Init( AH_Optimizer* optimizer,
|
||||
AH_Outline* outline,
|
||||
FT_Memory memory )
|
||||
{
|
||||
FT_Error error;
|
||||
|
||||
|
||||
MEM_Set( optimizer, 0, sizeof ( *optimizer ) );
|
||||
optimizer->outline = outline;
|
||||
optimizer->memory = memory;
|
||||
|
||||
LOG(( "initializing new optimizer\n" ));
|
||||
/* compute stems and springs */
|
||||
error = optim_compute_stems ( optimizer ) ||
|
||||
optim_compute_springs( optimizer );
|
||||
if ( error )
|
||||
goto Fail;
|
||||
|
||||
/* allocate stem positions history and configurations */
|
||||
{
|
||||
int n, max_stems;
|
||||
|
||||
|
||||
max_stems = optimizer->num_hstems;
|
||||
if ( max_stems < optimizer->num_vstems )
|
||||
max_stems = optimizer->num_vstems;
|
||||
|
||||
if ( ALLOC_ARRAY( optimizer->positions,
|
||||
max_stems * AH_MAX_CONFIGS, FT_Pos ) )
|
||||
goto Fail;
|
||||
|
||||
optimizer->num_configs = 0;
|
||||
for ( n = 0; n < AH_MAX_CONFIGS; n++ )
|
||||
optimizer->configs[n].positions = optimizer->positions +
|
||||
n * max_stems;
|
||||
}
|
||||
|
||||
return error;
|
||||
|
||||
Fail:
|
||||
AH_Optimizer_Done( optimizer );
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/* compute optimal outline */
|
||||
void AH_Optimizer_Compute( AH_Optimizer* optimizer )
|
||||
{
|
||||
optimizer->num_stems = optimizer->num_hstems;
|
||||
optimizer->stems = optimizer->horz_stems;
|
||||
optimizer->num_springs = optimizer->num_hsprings;
|
||||
optimizer->springs = optimizer->horz_springs;
|
||||
|
||||
if ( optimizer->num_springs > 0 )
|
||||
{
|
||||
LOG(( "horizontal optimization ------------------------\n" ));
|
||||
optim_compute( optimizer );
|
||||
}
|
||||
|
||||
optimizer->num_stems = optimizer->num_vstems;
|
||||
optimizer->stems = optimizer->vert_stems;
|
||||
optimizer->num_springs = optimizer->num_vsprings;
|
||||
optimizer->springs = optimizer->vert_springs;
|
||||
|
||||
if ( optimizer->num_springs )
|
||||
{
|
||||
LOG(( "vertical optimization --------------------------\n" ));
|
||||
optim_compute( optimizer );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,136 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ahoptim.h */
|
||||
/* */
|
||||
/* FreeType auto hinting outline optimization (declaration). */
|
||||
/* */
|
||||
/* Copyright 2000 Catharon Productions Inc. */
|
||||
/* Author: David Turner */
|
||||
/* */
|
||||
/* This file is part of the Catharon Typography Project and shall only */
|
||||
/* be used, modified, and distributed under the terms of the Catharon */
|
||||
/* Open Source License that should come with this file under the name */
|
||||
/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/* Note that this license is compatible with the FreeType license. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef AHOPTIM_H
|
||||
#define AHOPTIM_H
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "ahtypes.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <autohint/ahtypes.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* the maximal number of stem configurations to record */
|
||||
/* during optimization */
|
||||
#define AH_MAX_CONFIGS 8
|
||||
|
||||
|
||||
typedef struct AH_Stem_
|
||||
{
|
||||
FT_Pos pos; /* current position */
|
||||
FT_Pos velocity; /* current velocity */
|
||||
FT_Pos force; /* sum of current forces */
|
||||
FT_Pos width; /* normalized width */
|
||||
|
||||
FT_Pos min_pos; /* minimum grid position */
|
||||
FT_Pos max_pos; /* maximum grid position */
|
||||
|
||||
AH_Edge* edge1; /* left/bottom edge */
|
||||
AH_Edge* edge2; /* right/top edge */
|
||||
|
||||
FT_Pos opos; /* original position */
|
||||
FT_Pos owidth; /* original width */
|
||||
|
||||
FT_Pos min_coord; /* minimum coordinate */
|
||||
FT_Pos max_coord; /* maximum coordinate */
|
||||
|
||||
} AH_Stem;
|
||||
|
||||
|
||||
/* A spring between two stems */
|
||||
typedef struct AH_Spring_
|
||||
{
|
||||
AH_Stem* stem1;
|
||||
AH_Stem* stem2;
|
||||
FT_Pos owidth; /* original width */
|
||||
FT_Pos tension; /* current tension */
|
||||
|
||||
} AH_Spring;
|
||||
|
||||
|
||||
/* A configuration records the position of each stem at a given time */
|
||||
/* as well as the associated distortion */
|
||||
typedef struct AH_Configuration_
|
||||
{
|
||||
FT_Pos* positions;
|
||||
FT_Long distortion;
|
||||
|
||||
} AH_Configuration;
|
||||
|
||||
|
||||
typedef struct AH_Optimizer_
|
||||
{
|
||||
FT_Memory memory;
|
||||
AH_Outline* outline;
|
||||
|
||||
FT_Int num_hstems;
|
||||
AH_Stem* horz_stems;
|
||||
|
||||
FT_Int num_vstems;
|
||||
AH_Stem* vert_stems;
|
||||
|
||||
FT_Int num_hsprings;
|
||||
FT_Int num_vsprings;
|
||||
AH_Spring* horz_springs;
|
||||
AH_Spring* vert_springs;
|
||||
|
||||
FT_Int num_configs;
|
||||
AH_Configuration configs[AH_MAX_CONFIGS];
|
||||
FT_Pos* positions;
|
||||
|
||||
/* during each pass, use these instead */
|
||||
FT_Int num_stems;
|
||||
AH_Stem* stems;
|
||||
|
||||
FT_Int num_springs;
|
||||
AH_Spring* springs;
|
||||
FT_Bool vertical;
|
||||
|
||||
FT_Fixed tension_scale;
|
||||
FT_Pos tension_threshold;
|
||||
|
||||
} AH_Optimizer;
|
||||
|
||||
|
||||
/* loads the outline into the optimizer */
|
||||
int AH_Optimizer_Init( AH_Optimizer* optimizer,
|
||||
AH_Outline* outline,
|
||||
FT_Memory memory );
|
||||
|
||||
|
||||
/* compute optimal outline */
|
||||
void AH_Optimizer_Compute( AH_Optimizer* optimizer );
|
||||
|
||||
|
||||
/* release the optimization data */
|
||||
void AH_Optimizer_Done( AH_Optimizer* optimizer );
|
||||
|
||||
|
||||
#endif /* AHOPTIM_H */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,492 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ahtypes.h */
|
||||
/* */
|
||||
/* General types and definitions for the auto-hint module */
|
||||
/* (specification only). */
|
||||
/* */
|
||||
/* Copyright 2000 Catharon Productions Inc. */
|
||||
/* Author: David Turner */
|
||||
/* */
|
||||
/* This file is part of the Catharon Typography Project and shall only */
|
||||
/* be used, modified, and distributed under the terms of the Catharon */
|
||||
/* Open Source License that should come with this file under the name */
|
||||
/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/* Note that this license is compatible with the FreeType license. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef AHTYPES_H
|
||||
#define AHTYPES_H
|
||||
|
||||
|
||||
#include <freetype/internal/ftobjs.h> /* for freetype.h + LOCAL_DEF etc. */
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "ahloader.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <autohint/ahloader.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#define xxAH_DEBUG
|
||||
|
||||
|
||||
#ifdef AH_DEBUG
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define AH_LOG( x ) printf##x
|
||||
|
||||
#else
|
||||
|
||||
#define AH_LOG( x ) do ; while ( 0 ) /* nothing */
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** COMPILE-TIME BUILD OPTIONS ****/
|
||||
/**** ****/
|
||||
/**** Toggle these configuration macros to experiment with `features' ****/
|
||||
/**** of the auto-hinter. ****/
|
||||
/**** ****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* If this option is defined, only strong interpolation will be used to */
|
||||
/* place the points between edges. Otherwise, `smooth' points are */
|
||||
/* detected and later hinted through weak interpolation to correct some */
|
||||
/* unpleasant artefacts. */
|
||||
/* */
|
||||
#undef AH_OPTION_NO_WEAK_INTERPOLATION
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* If this option is defined, only weak interpolation will be used to */
|
||||
/* place the points between edges. Otherwise, `strong' points are */
|
||||
/* detected and later hinted through strong interpolation to correct */
|
||||
/* some unpleasant artefacts. */
|
||||
/* */
|
||||
#undef AH_OPTION_NO_STRONG_INTERPOLATION
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Undefine this macro if you don't want to hint the metrics. There is */
|
||||
/* no reason to do this (at least for non-CJK scripts), except for */
|
||||
/* experimentation. */
|
||||
/* */
|
||||
#define AH_HINT_METRICS
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Define this macro if you do not want to insert extra edges at a */
|
||||
/* glyph's x and y extremum (if there isn't one already available). */
|
||||
/* This helps to reduce a number of artefacts and allows hinting of */
|
||||
/* metrics. */
|
||||
/* */
|
||||
#undef AH_OPTION_NO_EXTREMUM_EDGES
|
||||
|
||||
|
||||
/* don't touch for now */
|
||||
#define AH_MAX_WIDTHS 12
|
||||
#define AH_MAX_HEIGHTS 12
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** TYPE DEFINITIONS ****/
|
||||
/**** ****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/* see agangles.h */
|
||||
typedef FT_Int AH_Angle;
|
||||
|
||||
|
||||
/* hint flags */
|
||||
#define ah_flah_none 0
|
||||
|
||||
/* bezier control points flags */
|
||||
#define ah_flah_conic 1
|
||||
#define ah_flah_cubic 2
|
||||
#define ah_flah_control ( ah_flah_conic | ah_flah_cubic )
|
||||
|
||||
/* extrema flags */
|
||||
#define ah_flah_extrema_x 4
|
||||
#define ah_flah_extrema_y 8
|
||||
|
||||
/* roundness */
|
||||
#define ah_flah_round_x 16
|
||||
#define ah_flah_round_y 32
|
||||
|
||||
/* touched */
|
||||
#define ah_flah_touch_x 64
|
||||
#define ah_flah_touch_y 128
|
||||
|
||||
/* weak interpolation */
|
||||
#define ah_flah_weak_interpolation 256
|
||||
|
||||
typedef FT_Int AH_Flags;
|
||||
|
||||
|
||||
/* edge hint flags */
|
||||
#define ah_edge_normal 0
|
||||
#define ah_edge_round 1
|
||||
#define ah_edge_serif 2
|
||||
#define ah_edge_done 4
|
||||
|
||||
typedef FT_Int AH_Edge_Flags;
|
||||
|
||||
|
||||
/* hint directions -- the values are computed so that two vectors are */
|
||||
/* in opposite directions iff `dir1+dir2 == 0' */
|
||||
#define ah_dir_none 4
|
||||
#define ah_dir_right 1
|
||||
#define ah_dir_left -1
|
||||
#define ah_dir_up 2
|
||||
#define ah_dir_down -2
|
||||
|
||||
typedef FT_Int AH_Direction;
|
||||
|
||||
|
||||
typedef struct AH_Point AH_Point;
|
||||
typedef struct AH_Segment AH_Segment;
|
||||
typedef struct AH_Edge AH_Edge;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* AH_Point */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to model an outline point to the AH_Outline type. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* flags :: The current point hint flags. */
|
||||
/* */
|
||||
/* ox, oy :: The current original scaled coordinates. */
|
||||
/* */
|
||||
/* fx, fy :: The current coordinates in font units. */
|
||||
/* */
|
||||
/* x, y :: The current hinter coordinates. */
|
||||
/* */
|
||||
/* u, v :: Point coordinates -- meaning varies with context. */
|
||||
/* */
|
||||
/* in_dir :: The direction of the inwards vector (prev->point). */
|
||||
/* */
|
||||
/* out_dir :: The direction of the outwards vector (point->next). */
|
||||
/* */
|
||||
/* in_angle :: The angle of the inwards vector. */
|
||||
/* */
|
||||
/* out_angle :: The angle of the outwards vector. */
|
||||
/* */
|
||||
/* next :: The next point in same contour. */
|
||||
/* */
|
||||
/* prev :: The previous point in same contour. */
|
||||
/* */
|
||||
struct AH_Point
|
||||
{
|
||||
AH_Flags flags; /* point flags used by hinter */
|
||||
FT_Pos ox, oy;
|
||||
FT_Pos fx, fy;
|
||||
FT_Pos x, y;
|
||||
FT_Pos u, v;
|
||||
|
||||
AH_Direction in_dir; /* direction of inwards vector */
|
||||
AH_Direction out_dir; /* direction of outwards vector */
|
||||
|
||||
AH_Angle in_angle;
|
||||
AH_Angle out_angle;
|
||||
|
||||
AH_Point* next; /* next point in contour */
|
||||
AH_Point* prev; /* previous point in contour */
|
||||
};
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* AH_Segment */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to describe an edge segment to the auto-hinter. */
|
||||
/* A segment is simply a sequence of successive points located on the */
|
||||
/* same horizontal or vertical `position', in a given direction. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* flags :: The segment edge flags (straight, rounded, etc.). */
|
||||
/* */
|
||||
/* dir :: The segment direction. */
|
||||
/* */
|
||||
/* first :: The first point in the segment. */
|
||||
/* */
|
||||
/* last :: The last point in the segment. */
|
||||
/* */
|
||||
/* contour :: A pointer to the first point of the segment's */
|
||||
/* contour. */
|
||||
/* */
|
||||
/* pos :: The segment position in font units. */
|
||||
/* */
|
||||
/* size :: The segment size. */
|
||||
/* */
|
||||
/* edge :: The edge of the current segment. */
|
||||
/* */
|
||||
/* edge_next :: The next segment on the same edge. */
|
||||
/* */
|
||||
/* link :: The pairing segment for this edge. */
|
||||
/* */
|
||||
/* serif :: The primary segment for serifs. */
|
||||
/* */
|
||||
/* num_linked :: The number of other segments that link to this one. */
|
||||
/* */
|
||||
/* score :: Used to score the segment when selecting them. */
|
||||
/* */
|
||||
struct AH_Segment
|
||||
{
|
||||
AH_Edge_Flags flags;
|
||||
AH_Direction dir;
|
||||
|
||||
AH_Point* first; /* first point in edge segment */
|
||||
AH_Point* last; /* last point in edge segment */
|
||||
AH_Point** contour; /* ptr to first point of segment's contour */
|
||||
|
||||
FT_Pos pos; /* position of segment */
|
||||
FT_Pos min_coord; /* minimum coordinate of segment */
|
||||
FT_Pos max_coord; /* maximum coordinate of segment */
|
||||
|
||||
AH_Edge* edge;
|
||||
AH_Segment* edge_next;
|
||||
|
||||
AH_Segment* link; /* link segment */
|
||||
AH_Segment* serif; /* primary segment for serifs */
|
||||
FT_Pos num_linked; /* number of linked segments */
|
||||
FT_Int score;
|
||||
};
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* AH_Edge */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to describe an edge, which really is a horizontal */
|
||||
/* or vertical coordinate to be hinted depending on the segments */
|
||||
/* located on it. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* flags :: The segment edge flags (straight, rounded, etc.). */
|
||||
/* */
|
||||
/* dir :: The main segment direction on this edge. */
|
||||
/* */
|
||||
/* first :: The first edge segment. */
|
||||
/* */
|
||||
/* last :: The last edge segment. */
|
||||
/* */
|
||||
/* fpos :: The original edge position in font units. */
|
||||
/* */
|
||||
/* opos :: The original scaled edge position. */
|
||||
/* */
|
||||
/* pos :: The hinted edge position. */
|
||||
/* */
|
||||
/* link :: The linked edge. */
|
||||
/* */
|
||||
/* serif :: The serif edge. */
|
||||
/* */
|
||||
/* num_paired :: The number of other edges that pair to this one. */
|
||||
/* */
|
||||
/* score :: Used to score the edge when selecting them. */
|
||||
/* */
|
||||
/* blue_edge :: Indicate the blue zone edge this edge is related to. */
|
||||
/* Only set for some of the horizontal edges in a Latin */
|
||||
/* font. */
|
||||
/* */
|
||||
struct AH_Edge
|
||||
{
|
||||
AH_Edge_Flags flags;
|
||||
AH_Direction dir;
|
||||
|
||||
AH_Segment* first;
|
||||
AH_Segment* last;
|
||||
|
||||
FT_Pos fpos;
|
||||
FT_Pos opos;
|
||||
FT_Pos pos;
|
||||
|
||||
AH_Edge* link;
|
||||
AH_Edge* serif;
|
||||
FT_Int num_linked;
|
||||
|
||||
FT_Int score;
|
||||
FT_Pos* blue_edge;
|
||||
};
|
||||
|
||||
|
||||
/* an outline as seen by the hinter */
|
||||
typedef struct AH_Outline_
|
||||
{
|
||||
FT_Memory memory;
|
||||
|
||||
AH_Direction vert_major_dir; /* vertical major direction */
|
||||
AH_Direction horz_major_dir; /* horizontal major direction */
|
||||
|
||||
FT_Fixed x_scale;
|
||||
FT_Fixed y_scale;
|
||||
FT_Pos edge_distance_threshold;
|
||||
|
||||
FT_Int max_points;
|
||||
FT_Int num_points;
|
||||
AH_Point* points;
|
||||
|
||||
FT_Int max_contours;
|
||||
FT_Int num_contours;
|
||||
AH_Point** contours;
|
||||
|
||||
FT_Int num_hedges;
|
||||
AH_Edge* horz_edges;
|
||||
|
||||
FT_Int num_vedges;
|
||||
AH_Edge* vert_edges;
|
||||
|
||||
FT_Int num_hsegments;
|
||||
AH_Segment* horz_segments;
|
||||
|
||||
FT_Int num_vsegments;
|
||||
AH_Segment* vert_segments;
|
||||
|
||||
} AH_Outline;
|
||||
|
||||
|
||||
#define ah_blue_capital_top 0 /* THEZOCQS */
|
||||
#define ah_blue_capital_bottom ( ah_blue_capital_top + 1 ) /* HEZLOCUS */
|
||||
#define ah_blue_small_top ( ah_blue_capital_bottom + 1 ) /* xzroesc */
|
||||
#define ah_blue_small_bottom ( ah_blue_small_top + 1 ) /* xzroesc */
|
||||
#define ah_blue_small_minor ( ah_blue_small_bottom + 1 ) /* pqgjy */
|
||||
#define ah_blue_max ( ah_blue_small_minor + 1 )
|
||||
|
||||
typedef FT_Int AH_Blue;
|
||||
|
||||
|
||||
#define ah_hinter_monochrome 1
|
||||
#define ah_hinter_optimize 2
|
||||
|
||||
typedef FT_Int AH_Hinter_Flags;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* AH_Globals */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Holds the global metrics for a given font face (be it in design */
|
||||
/* units or scaled pixel values). */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* num_widths :: The number of widths. */
|
||||
/* */
|
||||
/* num_heights :: The number of heights. */
|
||||
/* */
|
||||
/* widths :: Snap widths, including standard one. */
|
||||
/* */
|
||||
/* heights :: Snap height, including standard one. */
|
||||
/* */
|
||||
/* blue_refs :: The reference positions of blue zones. */
|
||||
/* */
|
||||
/* blue_shoots :: The overshoot positions of blue zones. */
|
||||
/* */
|
||||
typedef struct AH_Globals_
|
||||
{
|
||||
FT_Int num_widths;
|
||||
FT_Int num_heights;
|
||||
|
||||
FT_Pos widths [AH_MAX_WIDTHS];
|
||||
FT_Pos heights[AH_MAX_HEIGHTS];
|
||||
|
||||
FT_Pos blue_refs [ah_blue_max];
|
||||
FT_Pos blue_shoots[ah_blue_max];
|
||||
|
||||
} AH_Globals;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* AH_Face_Globals */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Holds the complete global metrics for a given font face (i.e., the */
|
||||
/* design units version + a scaled version + the current scales */
|
||||
/* used). */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* face :: A handle to the source face object */
|
||||
/* */
|
||||
/* design :: The globals in font design units. */
|
||||
/* */
|
||||
/* scaled :: Scaled globals in sub-pixel values. */
|
||||
/* */
|
||||
/* x_scale :: The current horizontal scale. */
|
||||
/* */
|
||||
/* y_scale :: The current vertical scale. */
|
||||
/* */
|
||||
typedef struct AH_Face_Globals_
|
||||
{
|
||||
FT_Face face;
|
||||
AH_Globals design;
|
||||
AH_Globals scaled;
|
||||
FT_Fixed x_scale;
|
||||
FT_Fixed y_scale;
|
||||
FT_Bool control_overshoot;
|
||||
|
||||
} AH_Face_Globals;
|
||||
|
||||
|
||||
typedef struct AH_Hinter
|
||||
{
|
||||
FT_Memory memory;
|
||||
AH_Hinter_Flags flags;
|
||||
|
||||
FT_Int algorithm;
|
||||
FT_Face face;
|
||||
|
||||
AH_Face_Globals* globals;
|
||||
|
||||
AH_Outline* glyph;
|
||||
|
||||
AH_Loader* loader;
|
||||
FT_Vector pp1;
|
||||
FT_Vector pp2;
|
||||
|
||||
} AH_Hinter;
|
||||
|
||||
|
||||
#endif /* AHTYPES_H */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,45 @@
|
||||
#define FT_FLAT_COMPILE
|
||||
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* autohint.c */
|
||||
/* */
|
||||
/* Automatic Hinting wrapper (body only). */
|
||||
/* */
|
||||
/* Copyright 2000 Catharon Productions Inc. */
|
||||
/* Author: David Turner */
|
||||
/* */
|
||||
/* This file is part of the Catharon Typography Project and shall only */
|
||||
/* be used, modified, and distributed under the terms of the Catharon */
|
||||
/* Open Source License that should come with this file under the name */
|
||||
/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/* Note that this license is compatible with the FreeType license. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#define FT_MAKE_OPTION_SINGLE_OBJECT
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "ahangles.c"
|
||||
#include "ahglyph.c"
|
||||
#include "ahglobal.c"
|
||||
#include "ahhint.c"
|
||||
#include "ahmodule.c"
|
||||
|
||||
#else
|
||||
|
||||
#include <autohint/ahangles.c>
|
||||
#include <autohint/ahglyph.c>
|
||||
#include <autohint/ahglobal.c>
|
||||
#include <autohint/ahhint.c>
|
||||
#include <autohint/ahmodule.c>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,134 @@
|
||||
#
|
||||
# FreeType 2 configuration rules for a `normal' ANSI compiler
|
||||
#
|
||||
|
||||
|
||||
# Copyright 1996-2000 by
|
||||
# David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
#
|
||||
# This file is part of the FreeType project, and may only be used, modified,
|
||||
# and distributed under the terms of the FreeType project license,
|
||||
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
|
||||
# indicate that you have read the license and understand and accept it
|
||||
# fully.
|
||||
|
||||
|
||||
ifndef TOP
|
||||
TOP := .
|
||||
endif
|
||||
|
||||
DELETE := rm -f
|
||||
SEP := /
|
||||
HOSTSEP := $(SEP)
|
||||
BUILD := $(TOP)/builds/ansi
|
||||
PLATFORM := ansi
|
||||
|
||||
# The directory where all object files are placed.
|
||||
#
|
||||
# Note that this is not $(TOP)/obj!
|
||||
# This lets you build the library in your own directory with something like
|
||||
#
|
||||
# set TOP=.../path/to/freetype2/top/dir...
|
||||
# mkdir obj
|
||||
# make -f $TOP/Makefile setup [options]
|
||||
# make -f $TOP/Makefile
|
||||
#
|
||||
OBJ_DIR := obj
|
||||
|
||||
|
||||
# The directory where all library files are placed.
|
||||
#
|
||||
# By default, this is the same as $(OBJ_DIR), however, this can be changed
|
||||
# to suit particular needs.
|
||||
#
|
||||
LIB_DIR := $(OBJ_DIR)
|
||||
|
||||
|
||||
# The object file extension (for standard and static libraries). This can be
|
||||
# .o, .tco, .obj, etc., depending on the platform.
|
||||
#
|
||||
O := o
|
||||
SO := o
|
||||
|
||||
# The library file extension (for standard and static libraries). This can
|
||||
# be .a, .lib, etc., depending on the platform.
|
||||
#
|
||||
A := a
|
||||
SA := a
|
||||
|
||||
|
||||
# The name of the final library file. Note that the DOS-specific Makefile
|
||||
# uses a shorter (8.3) name.
|
||||
#
|
||||
LIBRARY := libfreetype
|
||||
|
||||
|
||||
# Path inclusion flag. Some compilers use a different flag than `-I' to
|
||||
# specify an additional include path. Examples are `/i=' or `-J'.
|
||||
#
|
||||
I := -I
|
||||
|
||||
|
||||
# C flag used to define a macro before the compilation of a given source
|
||||
# object. Usually is `-D' like in `-DDEBUG'.
|
||||
#
|
||||
D := -D
|
||||
|
||||
|
||||
# The link flag used to specify a given library file on link. Note that
|
||||
# this is only used to compile the demo programs, not the library itself.
|
||||
#
|
||||
L := -l
|
||||
|
||||
|
||||
# Target flag.
|
||||
#
|
||||
T := -o # Don't remove this comment line! We need the space after `-o'.
|
||||
|
||||
|
||||
# C flags
|
||||
#
|
||||
# These should concern: debug output, optimization & warnings.
|
||||
#
|
||||
# Use the ANSIFLAGS variable to define the compiler flags used to enfore
|
||||
# ANSI compliance.
|
||||
#
|
||||
ifndef CFLAGS
|
||||
CFLAGS := -c
|
||||
endif
|
||||
|
||||
# ANSIFLAGS: Put there the flags used to make your compiler ANSI-compliant.
|
||||
#
|
||||
ANSIFLAGS :=
|
||||
|
||||
|
||||
ifdef BUILD_FREETYPE
|
||||
|
||||
# Now include the main sub-makefile. It contains all the rules used to
|
||||
# build the library with the previous variables defined.
|
||||
#
|
||||
include $(TOP)/builds/freetype.mk
|
||||
|
||||
# The cleanup targets.
|
||||
#
|
||||
clean_freetype: clean_freetype_std
|
||||
distclean_freetype: distclean_freetype_std
|
||||
|
||||
# Librarian to use to build the static library
|
||||
#
|
||||
FT_LIBRARIAN := $(AR) -r
|
||||
|
||||
|
||||
# This final rule is used to link all object files into a single library.
|
||||
# It is part of the system-specific sub-Makefile because not all
|
||||
# librarians accept a simple syntax like
|
||||
#
|
||||
# librarian library_file {list of object files}
|
||||
#
|
||||
$(FT_LIBRARY): $(OBJECTS_LIST)
|
||||
-$(DELETE) $@
|
||||
$(FT_LIBRARIAN) $@ $(OBJECTS_LIST)
|
||||
|
||||
endif
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,130 @@
|
||||
#
|
||||
# FreeType 2 host platform detection rules
|
||||
#
|
||||
|
||||
|
||||
# Copyright 1996-2000 by
|
||||
# David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
#
|
||||
# This file is part of the FreeType project, and may only be used, modified,
|
||||
# and distributed under the terms of the FreeType project license,
|
||||
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
|
||||
# indicate that you have read the license and understand and accept it
|
||||
# fully.
|
||||
|
||||
|
||||
# This sub-Makefile is in charge of detecting the current platform. It sets
|
||||
# the following variables:
|
||||
#
|
||||
# BUILD The configuration and system-specific directory. Usually
|
||||
# `freetype/builds/$(PLATFORM)' but can be different for
|
||||
# custom builds of the library.
|
||||
#
|
||||
# The following variables must be defined in system specific `detect.mk'
|
||||
# files:
|
||||
#
|
||||
# PLATFORM The detected platform. This will default to `ansi' if
|
||||
# auto-detection fails.
|
||||
# CONFIG_FILE The configuration sub-makefile to use. This usually depends
|
||||
# on the compiler defined in the `CC' environment variable.
|
||||
# DELETE The shell command used to remove a given file.
|
||||
# COPY The shell command used to copy one file.
|
||||
# SEP The platform-specific directory separator.
|
||||
# CC The compiler to use.
|
||||
#
|
||||
# You need to set the following variable(s) before calling it:
|
||||
#
|
||||
# TOP The top-most directory in the FreeType library source
|
||||
# hierarchy. If not defined, it will default to `.'.
|
||||
|
||||
# If TOP is not defined, default it to `.'
|
||||
#
|
||||
ifndef TOP
|
||||
TOP := .
|
||||
endif
|
||||
|
||||
# Set auto-detection default to `ansi' resp. UNIX-like operating systems.
|
||||
# Note that we delay the evaluation of $(BUILD_CONFIG_), $(BUILD), and
|
||||
# $(CONFIG_RULES).
|
||||
#
|
||||
PLATFORM := ansi
|
||||
DELETE := $(RM)
|
||||
COPY := cp
|
||||
SEP := /
|
||||
|
||||
BUILD_CONFIG_ = $(TOP)$(SEP)builds$(SEP)
|
||||
BUILD = $(BUILD_CONFIG_)$(PLATFORM)
|
||||
CONFIG_RULES = $(BUILD)$(SEP)$(CONFIG_FILE)
|
||||
|
||||
# We define the BACKSLASH variable to hold a single back-slash character.
|
||||
# This is needed because a line like
|
||||
#
|
||||
# SEP := \
|
||||
#
|
||||
# does not work with GNU Make (the backslash is interpreted as a line
|
||||
# continuation). While a line like
|
||||
#
|
||||
# SEP := \\
|
||||
#
|
||||
# really defines $(SEP) as `\' on Unix, and `\\' on Dos and Windows!
|
||||
#
|
||||
BACKSLASH := $(strip \ )
|
||||
|
||||
# Now, include all detection rule files found in the `builds/<system>'
|
||||
# directories. Note that the calling order of the various `detect.mk' files
|
||||
# isn't predictable.
|
||||
#
|
||||
include $(wildcard $(BUILD_CONFIG_)*/detect.mk)
|
||||
|
||||
# In case no detection rule file was successful, use the default.
|
||||
#
|
||||
ifndef CONFIG_FILE
|
||||
CONFIG_FILE := ansi.mk
|
||||
setup: std_setup
|
||||
endif
|
||||
|
||||
# The following targets are equivalent, with the exception that they use
|
||||
# a slightly different syntax for the `echo' command.
|
||||
#
|
||||
# std_setup: defined for most (i.e. Unix-like) platforms
|
||||
# dos_setup: defined for Dos-ish platforms like Dos, Windows & OS/2
|
||||
#
|
||||
.PHONY: std_setup dos_setup
|
||||
|
||||
std_setup:
|
||||
@echo ""
|
||||
@echo "FreeType build system -- automatic system detection"
|
||||
@echo ""
|
||||
@echo "The following settings are used:"
|
||||
@echo ""
|
||||
@echo " platform $(PLATFORM)"
|
||||
@echo " compiler $(CC)"
|
||||
@echo " configuration directory $(BUILD)"
|
||||
@echo " configuration rules $(CONFIG_RULES)"
|
||||
@echo ""
|
||||
@echo "If this does not correspond to your system or settings please remove the file"
|
||||
@echo "\`$(CONFIG_MK)' from this directory then read the INSTALL file for help."
|
||||
@echo ""
|
||||
@echo "Otherwise, simply type \`make' again to build the library."
|
||||
@echo ""
|
||||
@$(COPY) $(CONFIG_RULES) $(CONFIG_MK)
|
||||
|
||||
dos_setup:
|
||||
@echo ÿ
|
||||
@echo FreeType build system -- automatic system detection
|
||||
@echo ÿ
|
||||
@echo The following settings are used:
|
||||
@echo ÿ
|
||||
@echo ÿÿplatformÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ$(PLATFORM)
|
||||
@echo ÿÿcompilerÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ$(CC)
|
||||
@echo ÿÿconfiguration directoryÿÿÿÿÿÿ$(BUILD)
|
||||
@echo ÿÿconfiguration rulesÿÿÿÿÿÿÿÿÿÿ$(CONFIG_RULES)
|
||||
@echo ÿ
|
||||
@echo If this does not correspond to your system or settings please remove the file
|
||||
@echo '$(CONFIG_MK)' from this directory then read the INSTALL file for help.
|
||||
@echo ÿ
|
||||
@echo Otherwise, simply type 'make' again to build the library.
|
||||
@echo ÿ
|
||||
@$(COPY) $(subst /,\,$(CONFIG_RULES) $(CONFIG_MK)) > nul
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,87 @@
|
||||
#
|
||||
# FreeType 2 configuration file to detect a DOS host platform.
|
||||
#
|
||||
|
||||
|
||||
# Copyright 1996-2000 by
|
||||
# David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
#
|
||||
# This file is part of the FreeType project, and may only be used, modified,
|
||||
# and distributed under the terms of the FreeType project license,
|
||||
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
|
||||
# indicate that you have read the license and understand and accept it
|
||||
# fully.
|
||||
|
||||
|
||||
# We test for the COMSPEC environment variable, then run the `ver'
|
||||
# command-line program to see if its output contains the word `Dos'.
|
||||
#
|
||||
# If this is true, we are running a Dos-ish platform (or an emulation).
|
||||
#
|
||||
ifeq ($(PLATFORM),ansi)
|
||||
|
||||
ifdef COMSPEC
|
||||
|
||||
is_dos := $(findstring Dos,$(shell ver))
|
||||
|
||||
# We try to recognize a Dos session under OS/2. The `ver' command
|
||||
# returns `Operating System/2 ...' there, so `is_dos' should be empty.
|
||||
#
|
||||
# To recognize a Dos session under OS/2, we check COMSPEC for the
|
||||
# substring `MDOS\COMMAND'
|
||||
#
|
||||
ifeq ($(is_dos),)
|
||||
is_dos := $(findstring MDOS\COMMAND,$(COMSPEC))
|
||||
endif
|
||||
|
||||
ifneq ($(is_dos),)
|
||||
|
||||
PLATFORM := dos
|
||||
DELETE := del
|
||||
COPY := copy
|
||||
|
||||
# Use DJGPP (i.e. gcc) by default.
|
||||
#
|
||||
CONFIG_FILE := dos-gcc.mk
|
||||
SEP := /
|
||||
ifndef CC
|
||||
CC := gcc
|
||||
endif
|
||||
|
||||
# additionally, we provide hooks for various other compilers
|
||||
#
|
||||
ifneq ($(findstring turboc,$(MAKECMDGOALS)),) # Turbo C
|
||||
CONFIG_FILE := dos-tcc.mk
|
||||
SEP := $(BACKSLASH)
|
||||
CC := tcc
|
||||
.PHONY: turboc
|
||||
endif
|
||||
|
||||
ifneq ($(findstring watcom,$(MAKECMDGOALS)),) # Watcom C/C++
|
||||
CONFIG_FILE := dos-wat.mk
|
||||
SEP := $(BACKSLASH)
|
||||
CC := wcc386
|
||||
.PHONY: watcom
|
||||
endif
|
||||
|
||||
ifneq ($(findstring borlandc16,$(MAKECMDGOALS)),) # Borland C/C++ 16-bit
|
||||
CONFIG_FILE := dos-bcc.mk
|
||||
SEP := $(BACKSLASH)
|
||||
CC := bcc
|
||||
.PHONY: borlandc16
|
||||
endif
|
||||
|
||||
ifneq ($(findstring borlandc,$(MAKECMDGOALS)),) # Borland C/C++ 32-bit
|
||||
CONFIG_FILE := dos-bcc.mk
|
||||
SEP := $(BACKSLASH)
|
||||
CC := bcc32
|
||||
.PHONY: borlandc
|
||||
endif
|
||||
|
||||
setup: dos_setup
|
||||
|
||||
endif # test Dos
|
||||
endif # test COMSPEC
|
||||
endif # test PLATFORM
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,134 @@
|
||||
#
|
||||
# FreeType 2 configuration rules for the DJGPP compiler
|
||||
#
|
||||
|
||||
|
||||
# Copyright 1996-2000 by
|
||||
# David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
#
|
||||
# This file is part of the FreeType project, and may only be used, modified,
|
||||
# and distributed under the terms of the FreeType project license,
|
||||
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
|
||||
# indicate that you have read the license and understand and accept it
|
||||
# fully.
|
||||
|
||||
|
||||
ifndef TOP
|
||||
TOP := .
|
||||
endif
|
||||
|
||||
DELETE := rm -f
|
||||
SEP := /
|
||||
HOSTSEP := $(strip \ )
|
||||
BUILD := $(TOP)/builds/dos
|
||||
PLATFORM := dos
|
||||
|
||||
# The directory where all object files are placed.
|
||||
#
|
||||
# Note that this is not $(TOP)/obj!
|
||||
# This lets you build the library in your own directory with something like
|
||||
#
|
||||
# set TOP=.../path/to/freetype2/top/dir...
|
||||
# mkdir obj
|
||||
# make -f %TOP%/Makefile setup [options]
|
||||
# make -f %TOP%/Makefile
|
||||
#
|
||||
OBJ_DIR := obj
|
||||
|
||||
|
||||
# The directory where all library files are placed.
|
||||
#
|
||||
# By default, this is the same as $(OBJ_DIR), however, this can be changed
|
||||
# to suit particular needs.
|
||||
#
|
||||
LIB_DIR := $(OBJ_DIR)
|
||||
|
||||
|
||||
# The object file extension (for standard and static libraries). This can be
|
||||
# .o, .tco, .obj, etc., depending on the platform.
|
||||
#
|
||||
O := o
|
||||
SO := o
|
||||
|
||||
# The library file extension (for standard and static libraries). This can
|
||||
# be .a, .lib, etc., depending on the platform.
|
||||
#
|
||||
A := a
|
||||
SA := a
|
||||
|
||||
|
||||
# The name of the final library file. Note that the DOS-specific Makefile
|
||||
# uses a shorter (8.3) name.
|
||||
#
|
||||
LIBRARY := libfreetype
|
||||
|
||||
|
||||
# Path inclusion flag. Some compilers use a different flag than `-I' to
|
||||
# specify an additional include path. Examples are `/i=' or `-J'.
|
||||
#
|
||||
I := -I
|
||||
|
||||
|
||||
# C flag used to define a macro before the compilation of a given source
|
||||
# object. Usually is `-D' like in `-DDEBUG'.
|
||||
#
|
||||
D := -D
|
||||
|
||||
|
||||
# The link flag used to specify a given library file on link. Note that
|
||||
# this is only used to compile the demo programs, not the library itself.
|
||||
#
|
||||
L := -l
|
||||
|
||||
|
||||
# Target flag.
|
||||
#
|
||||
T := -o # Don't remove this comment line! We need the space after `-o'.
|
||||
|
||||
|
||||
# C flags
|
||||
#
|
||||
# These should concern: debug output, optimization & warnings.
|
||||
#
|
||||
# Use the ANSIFLAGS variable to define the compiler flags used to enfore
|
||||
# ANSI compliance.
|
||||
#
|
||||
ifndef CFLAGS
|
||||
CFLAGS := -c -g -O6 -Wall
|
||||
endif
|
||||
|
||||
# ANSIFLAGS: Put there the flags used to make your compiler ANSI-compliant.
|
||||
#
|
||||
ANSIFLAGS := -ansi -pedantic
|
||||
|
||||
|
||||
ifdef BUILD_FREETYPE
|
||||
|
||||
# Now include the main sub-makefile. It contains all the rules used to
|
||||
# build the library with the previous variables defined.
|
||||
#
|
||||
include $(TOP)/builds/freetype.mk
|
||||
|
||||
# The cleanup targets.
|
||||
#
|
||||
clean_freetype: clean_freetype_dos
|
||||
distclean_freetype: distclean_freetype_dos
|
||||
|
||||
# Librarian to use to build the static library
|
||||
#
|
||||
FT_LIBRARIAN := $(AR) -r
|
||||
|
||||
|
||||
# This final rule is used to link all object files into a single library.
|
||||
# It is part of the system-specific sub-Makefile because not all
|
||||
# librarians accept a simple syntax like:
|
||||
#
|
||||
# librarian library_file {list of object files}
|
||||
#
|
||||
$(FT_LIBRARY): $(OBJECTS_LIST)
|
||||
-$(DELETE) $@
|
||||
$(FT_LIBRARIAN) $@ $(OBJECTS_LIST)
|
||||
|
||||
endif
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,279 @@
|
||||
#
|
||||
# FreeType 2 library sub-Makefile
|
||||
#
|
||||
|
||||
|
||||
# Copyright 1996-2000 by
|
||||
# David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
#
|
||||
# This file is part of the FreeType project, and may only be used, modified,
|
||||
# and distributed under the terms of the FreeType project license,
|
||||
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
|
||||
# indicate that you have read the license and understand and accept it
|
||||
# fully.
|
||||
|
||||
|
||||
# DO NOT INVOKE THIS MAKEFILE DIRECTLY! IT IS MEANT TO BE INCLUDED BY
|
||||
# OTHER MAKEFILES.
|
||||
|
||||
|
||||
# The following variables (set by other Makefile components, in the
|
||||
# environment, or on the command line) are used:
|
||||
#
|
||||
# BUILD The architecture dependent directory,
|
||||
# e.g. `$(TOP)/builds/unix'.
|
||||
#
|
||||
# OBJ_DIR The directory in which object files are created.
|
||||
#
|
||||
# LIB_DIR The directory in which the library is created.
|
||||
#
|
||||
# INCLUDES A list of directories to be included additionally.
|
||||
# Usually empty.
|
||||
#
|
||||
# CFLAGS Compilation flags. This overrides the default settings
|
||||
# in the platform-specific configuration files.
|
||||
#
|
||||
# FTSYS_SRC If set, its value is used as the name of a replacement
|
||||
# file for `src/base/ftsystem.c'.
|
||||
#
|
||||
# FTDEBUG_SRC If set, its value is used as the name of a replacement
|
||||
# file for `src/base/ftdebug.c'. [For a normal build, this
|
||||
# file does nothing.]
|
||||
#
|
||||
# FT_MODULE_LIST The file which contains the list of modules for the
|
||||
# current build. Usually, this is automatically created by
|
||||
# `modules.mk'.
|
||||
#
|
||||
# BASE_OBJ_S
|
||||
# BASE_OBJ_M A list of base objects (for single object and multiple
|
||||
# object builds, respectively). Set up in
|
||||
# `src/base/rules.mk'.
|
||||
#
|
||||
# BASE_EXT_OBJ A list of base extension objects. Set up in
|
||||
# `src/base/rules.mk'.
|
||||
#
|
||||
# DRV_OBJ_S
|
||||
# DRV_OBJ_M A list of driver objects (for single object and multiple
|
||||
# object builds, respectively). Set up cumulatively in
|
||||
# `src/<driver>/rules.mk'.
|
||||
#
|
||||
# CLEAN
|
||||
# DISTCLEAN The sub-makefiles can append additional stuff to these two
|
||||
# variables which is to be removed for the `clean' resp.
|
||||
# `distclean' target.
|
||||
#
|
||||
# TOP, SEP,
|
||||
# LIBRARY, CC,
|
||||
# A, I, O, T Check `config.mk' for details.
|
||||
|
||||
|
||||
# The targets `objects' and `library' are defined at the end of this
|
||||
# Makefile after all other rules have been included.
|
||||
#
|
||||
.PHONY: single objects library
|
||||
|
||||
# default target -- build single objects and library
|
||||
#
|
||||
single: objects library
|
||||
|
||||
# `multi' target -- build multiple objects and library
|
||||
#
|
||||
multi: objects library
|
||||
|
||||
|
||||
# The FreeType source directory, usually `./src'.
|
||||
#
|
||||
SRC := $(TOP)$(SEP)src
|
||||
|
||||
|
||||
# The directory where the base layer components are placed, usually
|
||||
# `./src/base'.
|
||||
#
|
||||
BASE_DIR := $(SRC)$(SEP)base
|
||||
|
||||
|
||||
# A few short-cuts in order to avoid typing $(SEP) all the time for the
|
||||
# directory separator.
|
||||
#
|
||||
# For example: $(SRC_) equals to `./src/' where `.' is $(TOP).
|
||||
#
|
||||
#
|
||||
SRC_ := $(SRC)$(SEP)
|
||||
BASE_ := $(BASE_DIR)$(SEP)
|
||||
OBJ_ := $(OBJ_DIR)$(SEP)
|
||||
LIB_ := $(LIB_DIR)$(SEP)
|
||||
PUBLIC_ := $(TOP)$(SEP)include$(SEP)freetype$(SEP)
|
||||
INTERNAL_ := $(PUBLIC_)internal$(SEP)
|
||||
CONFIG_ := $(PUBLIC_)config$(SEP)
|
||||
|
||||
|
||||
# The final name of the library file.
|
||||
#
|
||||
FT_LIBRARY := $(LIB_)$(LIBRARY).$A
|
||||
|
||||
|
||||
# include paths
|
||||
#
|
||||
# IMPORTANT NOTE: The architecture-dependent directory must ALWAYS be placed
|
||||
# in front of the include list. Porters are then able to
|
||||
# put their own version of some of the FreeType components
|
||||
# in the `freetype/builds/<system>' directory, as these
|
||||
# files will override the default sources.
|
||||
#
|
||||
INCLUDES := $(BUILD) $(TOP)$(SEP)include $(SRC)
|
||||
|
||||
INCLUDE_FLAGS = $(INCLUDES:%=$I%)
|
||||
|
||||
|
||||
# C flags used for the compilation of an object file. This must include at
|
||||
# least the paths for the `base' and `builds/<system>' directories;
|
||||
# debug/optimization/warning flags + ansi compliance if needed.
|
||||
#
|
||||
FT_CFLAGS = $(CFLAGS) $(INCLUDE_FLAGS)
|
||||
FT_CC = $(CC) $(FT_CFLAGS)
|
||||
FT_COMPILE = $(CC) $(ANSIFLAGS) $(FT_CFLAGS)
|
||||
|
||||
|
||||
# Include the `modules' rules file.
|
||||
#
|
||||
include $(TOP)/builds/modules.mk
|
||||
|
||||
|
||||
# Initialize the list of objects.
|
||||
#
|
||||
OBJECTS_LIST :=
|
||||
|
||||
|
||||
# Define $(PUBLIC_H) as the list of all public header files located in
|
||||
# `$(TOP)/include/freetype'. $(BASE_H) and $(CONFIG_H) are defined
|
||||
# similarly.
|
||||
#
|
||||
# This is used to simplify the dependency rules -- if one of these files
|
||||
# changes, the whole library is recompiled.
|
||||
#
|
||||
PUBLIC_H := $(wildcard $(PUBLIC_)*.h)
|
||||
BASE_H := $(wildcard $(INTERNAL_)*.h)
|
||||
CONFIG_H := $(wildcard $(CONFIG_)*.h)
|
||||
|
||||
FREETYPE_H := $(PUBLIC_H) $(BASE_H) $(CONFIG_H)
|
||||
|
||||
|
||||
# ftsystem component
|
||||
#
|
||||
ifndef FTSYS_SRC
|
||||
FTSYS_SRC = $(BASE_)ftsystem.c
|
||||
endif
|
||||
|
||||
FTSYS_OBJ = $(OBJ_)ftsystem.$O
|
||||
|
||||
OBJECTS_LIST += $(FTSYS_OBJ)
|
||||
|
||||
$(FTSYS_OBJ): $(FTSYS_SRC) $(FREETYPE_H)
|
||||
$(FT_COMPILE) $T$@ $<
|
||||
|
||||
|
||||
# ftdebug component
|
||||
#
|
||||
ifndef FTDEBUG_SRC
|
||||
FTDEBUG_SRC = $(BASE_)ftdebug.c
|
||||
endif
|
||||
|
||||
FTDEBUG_OBJ = $(OBJ_)ftdebug.$O
|
||||
|
||||
OBJECTS_LIST += $(FTDEBUG_OBJ)
|
||||
|
||||
$(FTDEBUG_OBJ): $(FTDEBUG_SRC) $(FREETYPE_H)
|
||||
$(FT_COMPILE) $T$@ $<
|
||||
|
||||
|
||||
# Include all rule files from FreeType components.
|
||||
#
|
||||
include $(wildcard $(SRC)/*/rules.mk)
|
||||
|
||||
|
||||
# ftinit component
|
||||
#
|
||||
# The C source `ftinit.c' contains the FreeType initialization routines.
|
||||
# It is able to automatically register one or more drivers when the API
|
||||
# function FT_Init_FreeType() is called.
|
||||
#
|
||||
# The set of initial drivers is determined by the driver Makefiles
|
||||
# includes above. Each driver Makefile updates the FTINIT_xxx lists
|
||||
# which contain additional include paths and macros used to compile the
|
||||
# single `ftinit.c' source.
|
||||
#
|
||||
FTINIT_SRC := $(BASE_)ftinit.c
|
||||
FTINIT_OBJ := $(OBJ_)ftinit.$O
|
||||
|
||||
OBJECTS_LIST += $(FTINIT_OBJ)
|
||||
|
||||
$(FTINIT_OBJ): $(FTINIT_SRC) $(FREETYPE_H) $(FT_MODULE_LIST)
|
||||
$(FT_COMPILE) $T$@ $<
|
||||
|
||||
|
||||
# All FreeType library objects
|
||||
#
|
||||
# By default, we include the base layer extensions. These could be
|
||||
# omitted on builds which do not want them.
|
||||
#
|
||||
OBJ_M = $(BASE_OBJ_M) $(BASE_EXT_OBJ) $(DRV_OBJS_M)
|
||||
OBJ_S = $(BASE_OBJ_S) $(BASE_EXT_OBJ) $(DRV_OBJS_S)
|
||||
|
||||
|
||||
# The target `multi' on the Make command line indicates that we want to
|
||||
# compile each source file independently.
|
||||
#
|
||||
# Otherwise, each module/driver is compiled in a single object file through
|
||||
# source file inclusion (see `src/base/ftbase.c' or
|
||||
# `src/truetype/truetype.c' for examples).
|
||||
#
|
||||
BASE_OBJECTS := $(OBJECTS_LIST)
|
||||
|
||||
ifneq ($(findstring multi,$(MAKECMDGOALS)),)
|
||||
OBJECTS_LIST += $(OBJ_M)
|
||||
else
|
||||
OBJECTS_LIST += $(OBJ_S)
|
||||
endif
|
||||
|
||||
objects: $(OBJECTS_LIST)
|
||||
|
||||
library: $(FT_LIBRARY)
|
||||
|
||||
.c.$O:
|
||||
$(FT_COMPILE) $T$@ $<
|
||||
|
||||
|
||||
# Standard cleaning and distclean rules. These are not accepted
|
||||
# on all systems though.
|
||||
#
|
||||
clean_freetype_std:
|
||||
-$(DELETE) $(BASE_OBJECTS) $(OBJ_M) $(OBJ_S) $(CLEAN)
|
||||
|
||||
distclean_freetype_std: clean_freetype_std
|
||||
-$(DELETE) $(FT_LIBRARY)
|
||||
-$(DELETE) *.orig *~ core *.core $(DISTCLEAN)
|
||||
|
||||
# The Dos command shell does not support very long list of arguments, so
|
||||
# we are stuck with wildcards.
|
||||
#
|
||||
clean_freetype_dos:
|
||||
-$(DELETE) $(subst $(SEP),$(HOSTSEP),$(OBJ_))*.$O $(CLEAN) 2> nul
|
||||
|
||||
distclean_freetype_dos: clean_freetype_dos
|
||||
-$(DELETE) $(subst $(SEP),$(HOSTSEP),$(FT_LIBRARY)) $(DISTCLEAN) 2> nul
|
||||
|
||||
# Remove configuration file (used for distclean).
|
||||
#
|
||||
remove_config_mk:
|
||||
-$(DELETE) $(subst $(SEP),$(HOSTSEP),$(CONFIG_MK))
|
||||
|
||||
|
||||
# The `config.mk' file must define `clean_freetype' and
|
||||
# `distclean_freetype'. Implementations may use to relay these to either
|
||||
# the `std' or `dos' versions from above, or simply provide their own
|
||||
# implementation.
|
||||
#
|
||||
clean: clean_freetype
|
||||
distclean: distclean_freetype remove_config_mk
|
||||
|
||||
# EOF
|
||||
Binary file not shown.
@@ -0,0 +1,11 @@
|
||||
This folder contains supporting code and CodeWarrior Pro 4 project
|
||||
files to build the FreeType library.
|
||||
|
||||
Notes:
|
||||
The library will be built as a static lib in the obj/ folder.
|
||||
|
||||
Just van Rossum, <[email protected]>
|
||||
|
||||
DISCLAIMER: this subdirectory is *not* being maintained by the
|
||||
FreeType team, but by Just van Rossum. It's being released under
|
||||
the same terms as FreeType (see LICENSE.TXT).
|
||||
@@ -0,0 +1,75 @@
|
||||
#
|
||||
# FreeType 2 modules sub-Makefile
|
||||
#
|
||||
|
||||
# Copyright 1996-2000 by
|
||||
# David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
#
|
||||
# This file is part of the FreeType project, and may only be used, modified,
|
||||
# and distributed under the terms of the FreeType project license,
|
||||
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
|
||||
# indicate that you have read the license and understand and accept it
|
||||
# fully.
|
||||
|
||||
|
||||
# DO NOT INVOKE THIS MAKEFILE DIRECTLY! IT IS MEANT TO BE INCLUDED BY
|
||||
# OTHER MAKEFILES.
|
||||
|
||||
|
||||
# This file is in charge of handling the generation of the modules list
|
||||
# file.
|
||||
|
||||
.PHONY: make_module_list clean_module_list remake_module_list
|
||||
|
||||
# MODULE_LIST, as its name suggests, indicates where the modules list
|
||||
# resides. For now, it is in `include/freetype/config/ftmodule.h'.
|
||||
#
|
||||
ifndef FT_MODULE_LIST
|
||||
FT_MODULE_LIST := $(TOP)$(SEP)include$(SEP)freetype$(SEP)config$(SEP)ftmodule.h
|
||||
endif
|
||||
|
||||
# To build the modules list, we invoke the `make_module_list' target.
|
||||
#
|
||||
# This rule is commented out by default since FreeType comes already with
|
||||
# a ftmodule.h file.
|
||||
#
|
||||
#$(FT_MODULE_LIST): make_module_list
|
||||
|
||||
# Before the modules list file can be generated, we must remove the file in
|
||||
# order to `clean' the list.
|
||||
#
|
||||
clean_module_list:
|
||||
@-$(DELETE) $(subst $(SEP),$(HOSTSEP),$(FT_MODULE_LIST))
|
||||
@-echo Regenerating the modules list in $(FT_MODULE_LIST)...
|
||||
|
||||
make_module_list: clean_module_list
|
||||
@echo done.
|
||||
|
||||
|
||||
# Trailing spaces are protected with a `#' sign to avoid accidental
|
||||
# removing.
|
||||
#
|
||||
ifneq ($(findstring $(PLATFORM),dos win32 win16 os2),)
|
||||
OPEN_MODULE := @echo #
|
||||
CLOSE_MODULE := >> $(subst $(SEP),$(HOSTSEP),$(FT_MODULE_LIST))
|
||||
else
|
||||
OPEN_MODULE := @echo "
|
||||
CLOSE_MODULE := " >> $(FT_MODULE_LIST)
|
||||
endif
|
||||
|
||||
# $(OPEN_DRIVER) & $(CLOSE_DRIVER) are used to specify a given font driver
|
||||
# in the `module.mk' rules file.
|
||||
#
|
||||
OPEN_DRIVER := $(OPEN_MODULE)FT_USE_MODULE(
|
||||
CLOSE_DRIVER := )$(CLOSE_MODULE)
|
||||
|
||||
ECHO_DRIVER := @echo "* module: #
|
||||
ECHO_DRIVER_DESC := (
|
||||
ECHO_DRIVER_DONE := )"
|
||||
|
||||
# Each `module.mk' in the `src' sub-dirs is used to add one rule to the
|
||||
# target `make_module_list'.
|
||||
#
|
||||
include $(wildcard $(TOP)/src/*/module.mk)
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,62 @@
|
||||
#
|
||||
# FreeType 2 configuration file to detect an OS/2 host platform.
|
||||
#
|
||||
|
||||
|
||||
# Copyright 1996-2000 by
|
||||
# David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
#
|
||||
# This file is part of the FreeType project, and may only be used, modified,
|
||||
# and distributed under the terms of the FreeType project license,
|
||||
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
|
||||
# indicate that you have read the license and understand and accept it
|
||||
# fully.
|
||||
|
||||
|
||||
ifeq ($(PLATFORM),ansi)
|
||||
|
||||
ifdef OS2_SHELL
|
||||
|
||||
PLATFORM := os2
|
||||
COPY := copy
|
||||
DELETE := del
|
||||
|
||||
CONFIG_FILE := os2-gcc.mk # gcc-emx by default
|
||||
SEP := /
|
||||
|
||||
# additionally, we provide hooks for various other compilers
|
||||
#
|
||||
ifneq ($(findstring visualage,$(MAKECMDGOALS)),) # Visual Age C++
|
||||
CONFIG_FILE := os2-icc.mk
|
||||
SEP := $(BACKSLASH)
|
||||
CC := icc
|
||||
.PHONY: visualage
|
||||
endif
|
||||
|
||||
ifneq ($(findstring watcom,$(MAKECMDGOALS)),) # Watcom C/C++
|
||||
CONFIG_FILE := os2-wat.mk
|
||||
SEP := $(BACKSLASH)
|
||||
CC := wcc386
|
||||
.PHONY: watcom
|
||||
endif
|
||||
|
||||
ifneq ($(findstring borlandc,$(MAKECMDGOALS)),) # Borland C++ 32-bit
|
||||
CONFIG_FILE := os2-bcc.mk
|
||||
SEP := $(BACKSLASH)
|
||||
CC := bcc32
|
||||
.PHONY: borlandc
|
||||
endif
|
||||
|
||||
ifneq ($(findstring devel,$(MAKECMDGOALS)),) # development target
|
||||
CONFIG_FILE := os2-dev.mk
|
||||
CC := gcc
|
||||
SEP := /
|
||||
devel: setup
|
||||
endif
|
||||
|
||||
setup: dos_setup
|
||||
|
||||
endif # test OS2_SHELL
|
||||
endif # test PLATFORM
|
||||
|
||||
#EOF
|
||||
@@ -0,0 +1,137 @@
|
||||
#
|
||||
# FreeType 2 configuration rules for OS/2 + gcc
|
||||
#
|
||||
# Development version without optimizations.
|
||||
#
|
||||
|
||||
|
||||
# Copyright 1996-2000 by
|
||||
# David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
#
|
||||
# This file is part of the FreeType project, and may only be used, modified,
|
||||
# and distributed under the terms of the FreeType project license,
|
||||
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
|
||||
# indicate that you have read the license and understand and accept it
|
||||
# fully.
|
||||
|
||||
|
||||
ifndef TOP
|
||||
TOP := .
|
||||
endif
|
||||
|
||||
DELETE := del
|
||||
SEP := /
|
||||
HOSTSEP := $(strip \ )
|
||||
BUILD := $(TOP)/builds/os2
|
||||
PLATFORM := os2
|
||||
CC := gcc
|
||||
|
||||
# The directory where all object files are placed.
|
||||
#
|
||||
# Note that this is not $(TOP)/obj!
|
||||
# This lets you build the library in your own directory with something like
|
||||
#
|
||||
# set TOP=.../path/to/freetype2/top/dir...
|
||||
# mkdir obj
|
||||
# make -f %TOP%/Makefile setup [options]
|
||||
# make -f %TOP%/Makefile
|
||||
#
|
||||
OBJ_DIR := obj
|
||||
|
||||
|
||||
# The directory where all library files are placed.
|
||||
#
|
||||
# By default, this is the same as $(OBJ_DIR), however, this can be changed
|
||||
# to suit particular needs.
|
||||
#
|
||||
LIB_DIR := $(OBJ_DIR)
|
||||
|
||||
|
||||
# The object file extension (for standard and static libraries). This can be
|
||||
# .o, .tco, .obj, etc., depending on the platform.
|
||||
#
|
||||
O := o
|
||||
SO := o
|
||||
|
||||
# The library file extension (for standard and static libraries). This can
|
||||
# be .a, .lib, etc., depending on the platform.
|
||||
#
|
||||
A := a
|
||||
SA := a
|
||||
|
||||
|
||||
# The name of the final library file. Note that the DOS-specific Makefile
|
||||
# uses a shorter (8.3) name.
|
||||
#
|
||||
LIBRARY := libfreetype
|
||||
|
||||
|
||||
# Path inclusion flag. Some compilers use a different flag than `-I' to
|
||||
# specify an additional include path. Examples are `/i=' or `-J'.
|
||||
#
|
||||
I := -I
|
||||
|
||||
|
||||
# C flag used to define a macro before the compilation of a given source
|
||||
# object. Usually is `-D' like in `-DDEBUG'.
|
||||
#
|
||||
D := -D
|
||||
|
||||
|
||||
# The link flag used to specify a given library file on link. Note that
|
||||
# this is only used to compile the demo programs, not the library itself.
|
||||
#
|
||||
L := -l
|
||||
|
||||
|
||||
# Target flag.
|
||||
#
|
||||
T := -o # Don't remove this comment line! We need the space after `-o'.
|
||||
|
||||
|
||||
# C flags
|
||||
#
|
||||
# These should concern: debug output, optimization & warnings.
|
||||
#
|
||||
# Use the ANSIFLAGS variable to define the compiler flags used to enfore
|
||||
# ANSI compliance.
|
||||
#
|
||||
ifndef CFLAGS
|
||||
CFLAGS := -c -g -O0 -Wall
|
||||
endif
|
||||
|
||||
# ANSIFLAGS: Put there the flags used to make your compiler ANSI-compliant.
|
||||
#
|
||||
ANSIFLAGS := -ansi -pedantic
|
||||
|
||||
|
||||
ifdef BUILD_FREETYPE
|
||||
|
||||
# Now include the main sub-makefile. It contains all the rules used to
|
||||
# build the library with the previous variables defined.
|
||||
#
|
||||
include $(TOP)/builds/freetype.mk
|
||||
|
||||
# The cleanup targets.
|
||||
#
|
||||
clean_freetype: clean_freetype_dos
|
||||
distclean_freetype: distclean_freetype_dos
|
||||
|
||||
# Librarian to use to build the static library
|
||||
#
|
||||
FT_LIBRARIAN := $(AR) -r
|
||||
|
||||
|
||||
# This final rule is used to link all object files into a single library.
|
||||
# It is part of the system-specific sub-Makefile because not all
|
||||
# librarians accept a simple syntax like
|
||||
#
|
||||
# librarian library_file {list of object files}
|
||||
#
|
||||
$(FT_LIBRARY): $(OBJECTS_LIST)
|
||||
-$(DELETE) $(subst $(SEP),$(HOSTSEP),$(FT_LIBRARY)) 2> nul
|
||||
$(FT_LIBRARIAN) $@ $(OBJECTS_LIST)
|
||||
|
||||
endif
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,135 @@
|
||||
#
|
||||
# FreeType 2 configuration rules for OS/2 + gcc
|
||||
#
|
||||
|
||||
|
||||
# Copyright 1996-2000 by
|
||||
# David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
#
|
||||
# This file is part of the FreeType project, and may only be used, modified,
|
||||
# and distributed under the terms of the FreeType project license,
|
||||
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
|
||||
# indicate that you have read the license and understand and accept it
|
||||
# fully.
|
||||
|
||||
|
||||
ifndef TOP
|
||||
TOP := .
|
||||
endif
|
||||
|
||||
DELETE := del
|
||||
SEP := /
|
||||
HOSTSEP := $(strip \ )
|
||||
BUILD := $(TOP)/builds/os2
|
||||
PLATFORM := os2
|
||||
CC := gcc
|
||||
|
||||
# The directory where all object files are placed.
|
||||
#
|
||||
# Note that this is not $(TOP)/obj!
|
||||
# This lets you build the library in your own directory with something like
|
||||
#
|
||||
# set TOP=.../path/to/freetype2/top/dir...
|
||||
# mkdir obj
|
||||
# make -f %TOP%/Makefile setup [options]
|
||||
# make -f %TOP%/Makefile
|
||||
#
|
||||
OBJ_DIR := obj
|
||||
|
||||
|
||||
# The directory where all library files are placed.
|
||||
#
|
||||
# By default, this is the same as $(OBJ_DIR), however, this can be changed
|
||||
# to suit particular needs.
|
||||
#
|
||||
LIB_DIR := $(OBJ_DIR)
|
||||
|
||||
|
||||
# The object file extension (for standard and static libraries). This can be
|
||||
# .o, .tco, .obj, etc., depending on the platform.
|
||||
#
|
||||
O := o
|
||||
SO := o
|
||||
|
||||
# The library file extension (for standard and static libraries). This can
|
||||
# be .a, .lib, etc., depending on the platform.
|
||||
#
|
||||
A := a
|
||||
SA := a
|
||||
|
||||
|
||||
# The name of the final library file. Note that the DOS-specific Makefile
|
||||
# uses a shorter (8.3) name.
|
||||
#
|
||||
LIBRARY := libfreetype
|
||||
|
||||
|
||||
# Path inclusion flag. Some compilers use a different flag than `-I' to
|
||||
# specify an additional include path. Examples are `/i=' or `-J'.
|
||||
#
|
||||
I := -I
|
||||
|
||||
|
||||
# C flag used to define a macro before the compilation of a given source
|
||||
# object. Usually is `-D' like in `-DDEBUG'.
|
||||
#
|
||||
D := -D
|
||||
|
||||
|
||||
# The link flag used to specify a given library file on link. Note that
|
||||
# this is only used to compile the demo programs, not the library itself.
|
||||
#
|
||||
L := -l
|
||||
|
||||
|
||||
# Target flag.
|
||||
#
|
||||
T := -o # Don't remove this comment line! We need the space after `-o'.
|
||||
|
||||
|
||||
# C flags
|
||||
#
|
||||
# These should concern: debug output, optimization & warnings.
|
||||
#
|
||||
# Use the ANSIFLAGS variable to define the compiler flags used to enfore
|
||||
# ANSI compliance.
|
||||
#
|
||||
ifndef CFLAGS
|
||||
CFLAGS := -c -g -O6 -Wall
|
||||
endif
|
||||
|
||||
# ANSIFLAGS: Put there the flags used to make your compiler ANSI-compliant.
|
||||
#
|
||||
ANSIFLAGS := -ansi -pedantic
|
||||
|
||||
|
||||
ifdef BUILD_FREETYPE
|
||||
|
||||
# Now include the main sub-makefile. It contains all the rules used to
|
||||
# build the library with the previous variables defined.
|
||||
#
|
||||
include $(TOP)/builds/freetype.mk
|
||||
|
||||
# The cleanup targets.
|
||||
#
|
||||
clean_freetype: clean_freetype_dos
|
||||
distclean_freetype: distclean_freetype_dos
|
||||
|
||||
# Librarian to use to build the static library
|
||||
#
|
||||
FT_LIBRARIAN := $(AR) -r
|
||||
|
||||
|
||||
# This final rule is used to link all object files into a single library.
|
||||
# It is part of the system-specific sub-Makefile because not all
|
||||
# librarians accept a simple syntax like
|
||||
#
|
||||
# librarian library_file {list of object files}
|
||||
#
|
||||
$(FT_LIBRARY): $(OBJECTS_LIST)
|
||||
-$(DELETE) $(subst $(SEP),$(HOSTSEP),$(FT_LIBRARY)) 2> nul
|
||||
$(FT_LIBRARIAN) $@ $(OBJECTS_LIST)
|
||||
|
||||
endif
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,430 @@
|
||||
## libtool.m4 - Configure libtool for the target system. -*-Shell-script-*-
|
||||
## Copyright (C) 1996-1999 Free Software Foundation, Inc.
|
||||
## Originally by Gordon Matzigkeit <[email protected]>, 1996
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
## the Free Software Foundation; either version 2 of the License, or
|
||||
## (at your option) any later version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful, but
|
||||
## WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
## General Public License for more details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License
|
||||
## along with this program; if not, write to the Free Software
|
||||
## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## As a special exception to the GNU General Public License, if you
|
||||
## distribute this file as part of a program that contains a
|
||||
## configuration script generated by Autoconf, you may include it under
|
||||
## the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# serial 40 AC_PROG_LIBTOOL
|
||||
AC_DEFUN(AC_PROG_LIBTOOL,
|
||||
[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
|
||||
|
||||
# Save cache, so that ltconfig can load it
|
||||
AC_CACHE_SAVE
|
||||
|
||||
# Actually configure libtool. ac_aux_dir is where install-sh is found.
|
||||
CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
|
||||
LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
|
||||
LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \
|
||||
DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \
|
||||
${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
|
||||
$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \
|
||||
|| AC_MSG_ERROR([libtool configure failed])
|
||||
|
||||
# Reload cache, that may have been modified by ltconfig
|
||||
AC_CACHE_LOAD
|
||||
|
||||
# This can be used to rebuild libtool when needed
|
||||
LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh"
|
||||
|
||||
# Always use our own libtool.
|
||||
LIBTOOL='$(SHELL) $(top_builddir)/libtool'
|
||||
AC_SUBST(LIBTOOL)dnl
|
||||
|
||||
# Redirect the config.log output again, so that the ltconfig log is not
|
||||
# clobbered by the next message.
|
||||
exec 5>>./config.log
|
||||
])
|
||||
|
||||
AC_DEFUN(AC_LIBTOOL_SETUP,
|
||||
[AC_PREREQ(2.13)dnl
|
||||
AC_REQUIRE([AC_ENABLE_SHARED])dnl
|
||||
AC_REQUIRE([AC_ENABLE_STATIC])dnl
|
||||
AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl
|
||||
AC_REQUIRE([AC_CANONICAL_HOST])dnl
|
||||
AC_REQUIRE([AC_CANONICAL_BUILD])dnl
|
||||
AC_REQUIRE([AC_PROG_RANLIB])dnl
|
||||
AC_REQUIRE([AC_PROG_CC])dnl
|
||||
AC_REQUIRE([AC_PROG_LD])dnl
|
||||
AC_REQUIRE([AC_PROG_NM])dnl
|
||||
AC_REQUIRE([AC_PROG_LN_S])dnl
|
||||
dnl
|
||||
|
||||
case "$target" in
|
||||
NONE) lt_target="$host" ;;
|
||||
*) lt_target="$target" ;;
|
||||
esac
|
||||
|
||||
# Check for any special flags to pass to ltconfig.
|
||||
libtool_flags="--cache-file=$cache_file"
|
||||
test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
|
||||
test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
|
||||
test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install"
|
||||
test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc"
|
||||
test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
|
||||
ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN],
|
||||
[libtool_flags="$libtool_flags --enable-dlopen"])
|
||||
ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
|
||||
[libtool_flags="$libtool_flags --enable-win32-dll"])
|
||||
AC_ARG_ENABLE(libtool-lock,
|
||||
[ --disable-libtool-lock avoid locking (might break parallel builds)])
|
||||
test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock"
|
||||
test x"$silent" = xyes && libtool_flags="$libtool_flags --silent"
|
||||
|
||||
# Some flags need to be propagated to the compiler or linker for good
|
||||
# libtool support.
|
||||
case "$lt_target" in
|
||||
*-*-irix6*)
|
||||
# Find out which ABI we are using.
|
||||
echo '[#]line __oline__ "configure"' > conftest.$ac_ext
|
||||
if AC_TRY_EVAL(ac_compile); then
|
||||
case "`/usr/bin/file conftest.o`" in
|
||||
*32-bit*)
|
||||
LD="${LD-ld} -32"
|
||||
;;
|
||||
*N32*)
|
||||
LD="${LD-ld} -n32"
|
||||
;;
|
||||
*64-bit*)
|
||||
LD="${LD-ld} -64"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
rm -rf conftest*
|
||||
;;
|
||||
|
||||
*-*-sco3.2v5*)
|
||||
# On SCO OpenServer 5, we need -belf to get full-featured binaries.
|
||||
SAVE_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS -belf"
|
||||
AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
|
||||
[AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])])
|
||||
if test x"$lt_cv_cc_needs_belf" != x"yes"; then
|
||||
# this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
|
||||
CFLAGS="$SAVE_CFLAGS"
|
||||
fi
|
||||
;;
|
||||
|
||||
ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
|
||||
[*-*-cygwin* | *-*-mingw*)
|
||||
AC_CHECK_TOOL(DLLTOOL, dlltool, false)
|
||||
AC_CHECK_TOOL(AS, as, false)
|
||||
AC_CHECK_TOOL(OBJDUMP, objdump, false)
|
||||
;;
|
||||
])
|
||||
esac
|
||||
])
|
||||
|
||||
# AC_LIBTOOL_DLOPEN - enable checks for dlopen support
|
||||
AC_DEFUN(AC_LIBTOOL_DLOPEN, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])])
|
||||
|
||||
# AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's
|
||||
AC_DEFUN(AC_LIBTOOL_WIN32_DLL, [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])])
|
||||
|
||||
# AC_ENABLE_SHARED - implement the --enable-shared flag
|
||||
# Usage: AC_ENABLE_SHARED[(DEFAULT)]
|
||||
# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to
|
||||
# `yes'.
|
||||
AC_DEFUN(AC_ENABLE_SHARED, [dnl
|
||||
define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
|
||||
AC_ARG_ENABLE(shared,
|
||||
changequote(<<, >>)dnl
|
||||
<< --enable-shared[=PKGS] build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT],
|
||||
changequote([, ])dnl
|
||||
[p=${PACKAGE-default}
|
||||
case "$enableval" in
|
||||
yes) enable_shared=yes ;;
|
||||
no) enable_shared=no ;;
|
||||
*)
|
||||
enable_shared=no
|
||||
# Look at the argument we got. We use all the common list separators.
|
||||
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
|
||||
for pkg in $enableval; do
|
||||
if test "X$pkg" = "X$p"; then
|
||||
enable_shared=yes
|
||||
fi
|
||||
done
|
||||
IFS="$ac_save_ifs"
|
||||
;;
|
||||
esac],
|
||||
enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl
|
||||
])
|
||||
|
||||
# AC_DISABLE_SHARED - set the default shared flag to --disable-shared
|
||||
AC_DEFUN(AC_DISABLE_SHARED, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
|
||||
AC_ENABLE_SHARED(no)])
|
||||
|
||||
# AC_ENABLE_STATIC - implement the --enable-static flag
|
||||
# Usage: AC_ENABLE_STATIC[(DEFAULT)]
|
||||
# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to
|
||||
# `yes'.
|
||||
AC_DEFUN(AC_ENABLE_STATIC, [dnl
|
||||
define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
|
||||
AC_ARG_ENABLE(static,
|
||||
changequote(<<, >>)dnl
|
||||
<< --enable-static[=PKGS] build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT],
|
||||
changequote([, ])dnl
|
||||
[p=${PACKAGE-default}
|
||||
case "$enableval" in
|
||||
yes) enable_static=yes ;;
|
||||
no) enable_static=no ;;
|
||||
*)
|
||||
enable_static=no
|
||||
# Look at the argument we got. We use all the common list separators.
|
||||
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
|
||||
for pkg in $enableval; do
|
||||
if test "X$pkg" = "X$p"; then
|
||||
enable_static=yes
|
||||
fi
|
||||
done
|
||||
IFS="$ac_save_ifs"
|
||||
;;
|
||||
esac],
|
||||
enable_static=AC_ENABLE_STATIC_DEFAULT)dnl
|
||||
])
|
||||
|
||||
# AC_DISABLE_STATIC - set the default static flag to --disable-static
|
||||
AC_DEFUN(AC_DISABLE_STATIC, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
|
||||
AC_ENABLE_STATIC(no)])
|
||||
|
||||
|
||||
# AC_ENABLE_FAST_INSTALL - implement the --enable-fast-install flag
|
||||
# Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)]
|
||||
# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to
|
||||
# `yes'.
|
||||
AC_DEFUN(AC_ENABLE_FAST_INSTALL, [dnl
|
||||
define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl
|
||||
AC_ARG_ENABLE(fast-install,
|
||||
changequote(<<, >>)dnl
|
||||
<< --enable-fast-install[=PKGS] optimize for fast installation [default=>>AC_ENABLE_FAST_INSTALL_DEFAULT],
|
||||
changequote([, ])dnl
|
||||
[p=${PACKAGE-default}
|
||||
case "$enableval" in
|
||||
yes) enable_fast_install=yes ;;
|
||||
no) enable_fast_install=no ;;
|
||||
*)
|
||||
enable_fast_install=no
|
||||
# Look at the argument we got. We use all the common list separators.
|
||||
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
|
||||
for pkg in $enableval; do
|
||||
if test "X$pkg" = "X$p"; then
|
||||
enable_fast_install=yes
|
||||
fi
|
||||
done
|
||||
IFS="$ac_save_ifs"
|
||||
;;
|
||||
esac],
|
||||
enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl
|
||||
])
|
||||
|
||||
# AC_ENABLE_FAST_INSTALL - set the default to --disable-fast-install
|
||||
AC_DEFUN(AC_DISABLE_FAST_INSTALL, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
|
||||
AC_ENABLE_FAST_INSTALL(no)])
|
||||
|
||||
# AC_PROG_LD - find the path to the GNU or non-GNU linker
|
||||
AC_DEFUN(AC_PROG_LD,
|
||||
[AC_ARG_WITH(gnu-ld,
|
||||
[ --with-gnu-ld assume the C compiler uses GNU ld [default=no]],
|
||||
test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
|
||||
AC_REQUIRE([AC_PROG_CC])dnl
|
||||
AC_REQUIRE([AC_CANONICAL_HOST])dnl
|
||||
AC_REQUIRE([AC_CANONICAL_BUILD])dnl
|
||||
ac_prog=ld
|
||||
if test "$ac_cv_prog_gcc" = yes; then
|
||||
# Check if gcc -print-prog-name=ld gives a path.
|
||||
AC_MSG_CHECKING([for ld used by GCC])
|
||||
ac_prog=`($CC -print-prog-name=ld) 2>&5`
|
||||
case "$ac_prog" in
|
||||
# Accept absolute paths.
|
||||
changequote(,)dnl
|
||||
[\\/]* | [A-Za-z]:[\\/]*)
|
||||
re_direlt='/[^/][^/]*/\.\./'
|
||||
changequote([,])dnl
|
||||
# Canonicalize the path of ld
|
||||
ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
|
||||
while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
|
||||
ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
|
||||
done
|
||||
test -z "$LD" && LD="$ac_prog"
|
||||
;;
|
||||
"")
|
||||
# If it fails, then pretend we aren't using GCC.
|
||||
ac_prog=ld
|
||||
;;
|
||||
*)
|
||||
# If it is relative, then search for the first ld in PATH.
|
||||
with_gnu_ld=unknown
|
||||
;;
|
||||
esac
|
||||
elif test "$with_gnu_ld" = yes; then
|
||||
AC_MSG_CHECKING([for GNU ld])
|
||||
else
|
||||
AC_MSG_CHECKING([for non-GNU ld])
|
||||
fi
|
||||
AC_CACHE_VAL(ac_cv_path_LD,
|
||||
[if test -z "$LD"; then
|
||||
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
|
||||
for ac_dir in $PATH; do
|
||||
test -z "$ac_dir" && ac_dir=.
|
||||
if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
|
||||
ac_cv_path_LD="$ac_dir/$ac_prog"
|
||||
# Check to see if the program is GNU ld. I'd rather use --version,
|
||||
# but apparently some GNU ld's only accept -v.
|
||||
# Break only if it was the GNU/non-GNU ld that we prefer.
|
||||
if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
|
||||
test "$with_gnu_ld" != no && break
|
||||
else
|
||||
test "$with_gnu_ld" != yes && break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
IFS="$ac_save_ifs"
|
||||
else
|
||||
ac_cv_path_LD="$LD" # Let the user override the test with a path.
|
||||
fi])
|
||||
LD="$ac_cv_path_LD"
|
||||
if test -n "$LD"; then
|
||||
AC_MSG_RESULT($LD)
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
|
||||
AC_PROG_LD_GNU
|
||||
])
|
||||
|
||||
AC_DEFUN(AC_PROG_LD_GNU,
|
||||
[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
|
||||
[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
|
||||
if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
|
||||
ac_cv_prog_gnu_ld=yes
|
||||
else
|
||||
ac_cv_prog_gnu_ld=no
|
||||
fi])
|
||||
])
|
||||
|
||||
# AC_PROG_NM - find the path to a BSD-compatible name lister
|
||||
AC_DEFUN(AC_PROG_NM,
|
||||
[AC_MSG_CHECKING([for BSD-compatible nm])
|
||||
AC_CACHE_VAL(ac_cv_path_NM,
|
||||
[if test -n "$NM"; then
|
||||
# Let the user override the test.
|
||||
ac_cv_path_NM="$NM"
|
||||
else
|
||||
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
|
||||
for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
|
||||
test -z "$ac_dir" && ac_dir=.
|
||||
if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; then
|
||||
# Check to see if the nm accepts a BSD-compat flag.
|
||||
# Adding the `sed 1q' prevents false positives on HP-UX, which says:
|
||||
# nm: unknown option "B" ignored
|
||||
if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
|
||||
ac_cv_path_NM="$ac_dir/nm -B"
|
||||
break
|
||||
elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
|
||||
ac_cv_path_NM="$ac_dir/nm -p"
|
||||
break
|
||||
else
|
||||
ac_cv_path_NM=${ac_cv_path_NM="$ac_dir/nm"} # keep the first match, but
|
||||
continue # so that we can try to find one that supports BSD flags
|
||||
fi
|
||||
fi
|
||||
done
|
||||
IFS="$ac_save_ifs"
|
||||
test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
|
||||
fi])
|
||||
NM="$ac_cv_path_NM"
|
||||
AC_MSG_RESULT([$NM])
|
||||
])
|
||||
|
||||
# AC_CHECK_LIBM - check for math library
|
||||
AC_DEFUN(AC_CHECK_LIBM,
|
||||
[AC_REQUIRE([AC_CANONICAL_HOST])dnl
|
||||
LIBM=
|
||||
case "$lt_target" in
|
||||
*-*-beos* | *-*-cygwin*)
|
||||
# These system don't have libm
|
||||
;;
|
||||
*-ncr-sysv4.3*)
|
||||
AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
|
||||
AC_CHECK_LIB(m, main, LIBM="$LIBM -lm")
|
||||
;;
|
||||
*)
|
||||
AC_CHECK_LIB(m, main, LIBM="-lm")
|
||||
;;
|
||||
esac
|
||||
])
|
||||
|
||||
# AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for
|
||||
# the libltdl convenience library, adds --enable-ltdl-convenience to
|
||||
# the configure arguments. Note that LIBLTDL is not AC_SUBSTed, nor
|
||||
# is AC_CONFIG_SUBDIRS called. If DIR is not provided, it is assumed
|
||||
# to be `${top_builddir}/libltdl'. Make sure you start DIR with
|
||||
# '${top_builddir}/' (note the single quotes!) if your package is not
|
||||
# flat, and, if you're not using automake, define top_builddir as
|
||||
# appropriate in the Makefiles.
|
||||
AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
|
||||
case "$enable_ltdl_convenience" in
|
||||
no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
|
||||
"") enable_ltdl_convenience=yes
|
||||
ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
|
||||
esac
|
||||
LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdlc.la
|
||||
INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl'])
|
||||
])
|
||||
|
||||
# AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for
|
||||
# the libltdl installable library, and adds --enable-ltdl-install to
|
||||
# the configure arguments. Note that LIBLTDL is not AC_SUBSTed, nor
|
||||
# is AC_CONFIG_SUBDIRS called. If DIR is not provided, it is assumed
|
||||
# to be `${top_builddir}/libltdl'. Make sure you start DIR with
|
||||
# '${top_builddir}/' (note the single quotes!) if your package is not
|
||||
# flat, and, if you're not using automake, define top_builddir as
|
||||
# appropriate in the Makefiles.
|
||||
# In the future, this macro may have to be called after AC_PROG_LIBTOOL.
|
||||
AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
|
||||
AC_CHECK_LIB(ltdl, main,
|
||||
[test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no],
|
||||
[if test x"$enable_ltdl_install" = xno; then
|
||||
AC_MSG_WARN([libltdl not installed, but installation disabled])
|
||||
else
|
||||
enable_ltdl_install=yes
|
||||
fi
|
||||
])
|
||||
if test x"$enable_ltdl_install" = x"yes"; then
|
||||
ac_configure_args="$ac_configure_args --enable-ltdl-install"
|
||||
LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdl.la
|
||||
INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl'])
|
||||
else
|
||||
ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
|
||||
LIBLTDL="-lltdl"
|
||||
INCLTDL=
|
||||
fi
|
||||
])
|
||||
|
||||
dnl old names
|
||||
AC_DEFUN(AM_PROG_LIBTOOL, [indir([AC_PROG_LIBTOOL])])dnl
|
||||
AC_DEFUN(AM_ENABLE_SHARED, [indir([AC_ENABLE_SHARED], $@)])dnl
|
||||
AC_DEFUN(AM_ENABLE_STATIC, [indir([AC_ENABLE_STATIC], $@)])dnl
|
||||
AC_DEFUN(AM_DISABLE_SHARED, [indir([AC_DISABLE_SHARED], $@)])dnl
|
||||
AC_DEFUN(AM_DISABLE_STATIC, [indir([AC_DISABLE_STATIC], $@)])dnl
|
||||
AC_DEFUN(AM_PROG_LD, [indir([AC_PROG_LD])])dnl
|
||||
AC_DEFUN(AM_PROG_NM, [indir([AC_PROG_NM])])dnl
|
||||
|
||||
dnl This is just to silence aclocal about the macro not being used
|
||||
ifelse([AC_DISABLE_FAST_INSTALL])dnl
|
||||
+1273
File diff suppressed because it is too large
Load Diff
+1319
File diff suppressed because it is too large
Load Diff
+2514
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,74 @@
|
||||
dnl This file is part of the FreeType project.
|
||||
dnl
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
dnl
|
||||
|
||||
AC_INIT(ftconfig.in)
|
||||
|
||||
dnl Configuration file -- stay in 8.3 limit
|
||||
AC_CONFIG_HEADER(ftconfig.h:ftconfig.in)
|
||||
|
||||
version_info='6:0:0'
|
||||
AC_SUBST(version_info)
|
||||
|
||||
dnl checks for system type
|
||||
AC_CANONICAL_SYSTEM
|
||||
|
||||
dnl checks for programs
|
||||
AC_PROG_CC
|
||||
AC_PROG_CPP
|
||||
|
||||
dnl get Compiler flags right.
|
||||
if test "x$CC" = xgcc; then
|
||||
XX_CFLAGS="-Wall"
|
||||
XX_ANSIFLAGS="-pedantic -ansi"
|
||||
else
|
||||
case "$host" in
|
||||
*-dec-osf*)
|
||||
XX_CFLAGS="-std1 -O2 -g3"
|
||||
XX_ANSIFLAGS=
|
||||
;;
|
||||
*)
|
||||
XX_CFLAGS=
|
||||
XX_ANSIFLAGS=
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
AC_SUBST(XX_CFLAGS)
|
||||
AC_SUBST(XX_ANSIFLAGS)
|
||||
|
||||
AC_CHECK_PROG(RMF, rm, rm -f)
|
||||
AC_CHECK_PROG(RMDIR, rmdir, rmdir)
|
||||
AC_PROG_INSTALL
|
||||
|
||||
dnl checks for header files
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS(fcntl.h unistd.h)
|
||||
|
||||
dnl checks for typedefs, structures, and compiler characteristics
|
||||
AC_C_CONST
|
||||
AC_CHECK_SIZEOF(int)
|
||||
AC_CHECK_SIZEOF(long)
|
||||
|
||||
dnl Checks for library functions.
|
||||
|
||||
dnl Here we check whether we can use our mmap file component.
|
||||
AC_FUNC_MMAP
|
||||
if test "$ac_cv_func_mmap_fixed_mapped" != yes; then
|
||||
FTSYS_SRC='$(BASE_)ftsystem.c'
|
||||
else
|
||||
FTSYS_SRC='$(BUILD)/ftsystem.c'
|
||||
fi
|
||||
AC_SUBST(FTSYS_SRC)
|
||||
|
||||
AC_CHECK_FUNCS(memcpy memmove)
|
||||
|
||||
AM_PROG_LIBTOOL
|
||||
|
||||
dnl create the Unix-specific sub-Makefile `builds/unix/unix.mk' that will be
|
||||
dnl used by the build system
|
||||
dnl
|
||||
AC_OUTPUT(unix.mk:unix.in)
|
||||
|
||||
|
||||
dnl end of configure.in
|
||||
@@ -0,0 +1,59 @@
|
||||
#
|
||||
# FreeType 2 configuration file to detect a UNIX host platform.
|
||||
#
|
||||
|
||||
|
||||
# Copyright 1996-2000 by
|
||||
# David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
#
|
||||
# This file is part of the FreeType project, and may only be used, modified,
|
||||
# and distributed under the terms of the FreeType project license,
|
||||
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
|
||||
# indicate that you have read the license and understand and accept it
|
||||
# fully.
|
||||
|
||||
|
||||
ifeq ($(PLATFORM),ansi)
|
||||
|
||||
has_init := $(strip $(wildcard /sbin/init))
|
||||
ifneq ($(has_init),)
|
||||
|
||||
PLATFORM := unix
|
||||
COPY := cp
|
||||
DELETE := rm -f
|
||||
|
||||
# If a Unix platform is detected, the configure script is called and
|
||||
# `unix.mk' is created.
|
||||
#
|
||||
# Arguments to `configure' should be in the CFG variable. Example:
|
||||
#
|
||||
# make CFG="--prefix=/usr --disable-static"
|
||||
#
|
||||
# If you need to set CFLAGS or LDFLAGS, do it here also.
|
||||
#
|
||||
# Feel free to add support for other platform specific compilers in this
|
||||
# directory (e.g. solaris.mk + changes here to detect the platform).
|
||||
#
|
||||
CONFIG_FILE := unix.mk
|
||||
setup: unix.mk
|
||||
unix: setup
|
||||
|
||||
# If `devel' is the requested target, use `-g -O0' as the default value
|
||||
# for CFLAGS if CFLAGS isn't set.
|
||||
#
|
||||
ifneq ($(findstring devel,$(MAKECMDGOALS)),)
|
||||
ifndef CFLAGS
|
||||
USE_CFLAGS := CFLAGS="-g -O0"
|
||||
endif
|
||||
devel: setup
|
||||
endif
|
||||
|
||||
setup: std_setup
|
||||
|
||||
unix.mk: builds/unix/unix.in
|
||||
cd builds/unix; $(USE_CFLAGS) ./configure $(CFG)
|
||||
|
||||
endif # test Unix
|
||||
endif # test PLATFORM
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,172 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftconfig.in */
|
||||
/* */
|
||||
/* UNIX-specific configuration file (specification only). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* This header file contains a number of macro definitions that are used */
|
||||
/* by the rest of the engine. Most of the macros here are automatically */
|
||||
/* determined at compile time, and you should not need to change it to */
|
||||
/* port FreeType, except to compile the library with a non-ANSI */
|
||||
/* compiler. */
|
||||
/* */
|
||||
/* Note however that if some specific modifications are needed, we */
|
||||
/* advise you to place a modified copy in your build directory. */
|
||||
/* */
|
||||
/* The build directory is usually `freetype/builds/<system>', and */
|
||||
/* contains system-specific files that are always included first when */
|
||||
/* building the library. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTCONFIG_H
|
||||
#define FTCONFIG_H
|
||||
|
||||
|
||||
/* Include the header file containing all developer build options */
|
||||
#include <freetype/config/ftoption.h>
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* PLATFORM-SPECIFIC CONFIGURATION MACROS */
|
||||
/* */
|
||||
/* These macros can be toggled to suit a specific system. The current */
|
||||
/* ones are defaults used to compile FreeType in an ANSI C environment */
|
||||
/* (16bit compilers are also supported). Copy this file to your own */
|
||||
/* `freetype/builds/<system>' directory, and edit it to port the engine. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#define HAVE_UNISTD_H 0
|
||||
#define HAVE_FCNTL_H 0
|
||||
|
||||
#define SIZEOF_INT 2
|
||||
#define SIZEOF_LONG 2
|
||||
|
||||
|
||||
#define FT_SIZEOF_INT SIZEOF_INT
|
||||
#define FT_SIZEOF_LONG SIZEOF_LONG
|
||||
|
||||
|
||||
/* Preferred alignment of data */
|
||||
#define FT_ALIGNMENT 8
|
||||
|
||||
|
||||
/* UNUSED is a macro used to indicate that a given parameter is not used */
|
||||
/* -- this is only used to get rid of unpleasant compiler warnings */
|
||||
#ifndef FT_UNUSED
|
||||
#define FT_UNUSED( arg ) ( (arg) = (arg) )
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* AUTOMATIC CONFIGURATION MACROS */
|
||||
/* */
|
||||
/* These macros are computed from the ones defined above. Don't touch */
|
||||
/* their definition, unless you know precisely what you are doing. No */
|
||||
/* porter should need to mess with them. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* IntN types */
|
||||
/* */
|
||||
/* Used to guarantee the size of some specific integers. */
|
||||
/* */
|
||||
typedef signed short FT_Int16;
|
||||
typedef unsigned short FT_UInt16;
|
||||
|
||||
#if FT_SIZEOF_INT == 4
|
||||
|
||||
typedef signed int FT_Int32;
|
||||
typedef unsigned int FT_UInt32;
|
||||
|
||||
#elif FT_SIZEOF_LONG == 4
|
||||
|
||||
typedef signed long FT_Int32;
|
||||
typedef unsigned long FT_UInt32;
|
||||
|
||||
#else
|
||||
#error "no 32bit type found -- please check your configuration files"
|
||||
#endif
|
||||
|
||||
#if FT_SIZEOF_LONG == 8
|
||||
|
||||
/* FT_LONG64 must be defined if a 64-bit type is available */
|
||||
#define FT_LONG64
|
||||
#define FT_INT64 long
|
||||
|
||||
#else
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Many compilers provide the non-ANSI `long long' 64-bit type. You can */
|
||||
/* activate it by defining the FTCALC_USE_LONG_LONG macro in */
|
||||
/* `ftoption.h'. */
|
||||
/* */
|
||||
/* Note that this will produce many -ansi warnings during library */
|
||||
/* compilation, and that in many cases, the generated code will be */
|
||||
/* neither smaller nor faster! */
|
||||
/* */
|
||||
#ifdef FTCALC_USE_LONG_LONG
|
||||
|
||||
#define FT_LONG64
|
||||
#define FT_INT64 long long
|
||||
|
||||
#endif /* FTCALC_USE_LONG_LONG */
|
||||
#endif /* FT_SIZEOF_LONG == 8 */
|
||||
|
||||
|
||||
#ifdef FT_MAKE_OPTION_SINGLE_OBJECT
|
||||
#define LOCAL_DEF static
|
||||
#define LOCAL_FUNC static
|
||||
#else
|
||||
#define LOCAL_DEF extern
|
||||
#define LOCAL_FUNC /* nothing */
|
||||
#endif
|
||||
|
||||
#ifdef FT_MAKE_OPTION_SINGLE_LIBRARY_OBJECT
|
||||
#define BASE_DEF( x ) static x
|
||||
#define BASE_FUNC( x ) static x
|
||||
#else
|
||||
#define BASE_DEF( x ) extern x
|
||||
#define BASE_FUNC( x ) extern x
|
||||
#endif
|
||||
|
||||
#ifndef FT_EXPORT_DEF
|
||||
#define FT_EXPORT_DEF( x ) extern x
|
||||
#endif
|
||||
|
||||
#ifndef FT_EXPORT_FUNC
|
||||
#define FT_EXPORT_FUNC( x ) extern x
|
||||
#endif
|
||||
|
||||
#ifndef FT_EXPORT_VAR
|
||||
#define FT_EXPORT_VAR( x ) extern x
|
||||
#endif
|
||||
|
||||
#endif /* FTCONFIG_H */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,306 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftsystem.c */
|
||||
/* */
|
||||
/* Unix-specific FreeType low-level system interface (body). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#include <ftconfig.h>
|
||||
#include <freetype/internal/ftdebug.h>
|
||||
#include <freetype/ftsystem.h>
|
||||
#include <freetype/fterrors.h>
|
||||
#include <freetype/fttypes.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/* memory-mapping includes and definitions */
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <sys/mman.h>
|
||||
#ifndef MAP_FILE
|
||||
#define MAP_FILE 0x00
|
||||
#endif
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* The prototype for munmap() is not provided on SunOS. This needs to */
|
||||
/* have a check added later to see if the GNU C library is being used. */
|
||||
/* If so, then this prototype is not needed. */
|
||||
/* */
|
||||
#if defined( __sun__ ) && !defined( SVR4 ) && !defined( __SVR4 )
|
||||
extern int munmap( caddr_t addr,
|
||||
int len );
|
||||
#endif
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* MEMORY MANAGEMENT INTERFACE */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* ft_alloc */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The memory allocation function. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* memory :: A pointer to the memory object. */
|
||||
/* size :: The requested size in bytes. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* block :: The address of newly allocated block. */
|
||||
/* */
|
||||
static
|
||||
void* ft_alloc( FT_Memory memory,
|
||||
long size )
|
||||
{
|
||||
FT_UNUSED( memory );
|
||||
|
||||
return malloc( size );
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* ft_realloc */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The memory reallocation function. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* memory :: A pointer to the memory object. */
|
||||
/* */
|
||||
/* cur_size :: The current size of the allocated memory block. */
|
||||
/* */
|
||||
/* new_size :: The newly requested size in bytes. */
|
||||
/* */
|
||||
/* block :: The current address of the block in memory. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* The address of the reallocated memory block. */
|
||||
/* */
|
||||
static
|
||||
void* ft_realloc( FT_Memory memory,
|
||||
long cur_size,
|
||||
long new_size,
|
||||
void* block )
|
||||
{
|
||||
FT_UNUSED( memory );
|
||||
FT_UNUSED( cur_size );
|
||||
|
||||
return realloc( block, new_size );
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* ft_free */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The memory release function. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* memory :: A pointer to the memory object. */
|
||||
/* */
|
||||
/* block :: The address of block in memory to be freed. */
|
||||
/* */
|
||||
static
|
||||
void ft_free( FT_Memory memory,
|
||||
void* block )
|
||||
{
|
||||
FT_UNUSED( memory );
|
||||
|
||||
free( block );
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* RESOURCE MANAGEMENT INTERFACE */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
|
||||
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
|
||||
/* messages during execution. */
|
||||
/* */
|
||||
#undef FT_COMPONENT
|
||||
#define FT_COMPONENT trace_io
|
||||
|
||||
/* We use the macro STREAM_FILE for convenience to extract the */
|
||||
/* system-specific stream handle from a given FreeType stream object */
|
||||
#define STREAM_FILE( stream ) ( (FILE*)stream->descriptor.pointer )
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* ft_close_stream */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The function to close a stream. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* stream :: A pointer to the stream object. */
|
||||
/* */
|
||||
static
|
||||
void ft_close_stream( FT_Stream stream )
|
||||
{
|
||||
munmap ( stream->descriptor.pointer, stream->size );
|
||||
|
||||
stream->descriptor.pointer = NULL;
|
||||
stream->size = 0;
|
||||
stream->base = 0;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_New_Stream */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Creates a new stream object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* filepathname :: The name of the stream (usually a file) to be */
|
||||
/* opened. */
|
||||
/* */
|
||||
/* stream :: A pointer to the stream object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( FT_Error ) FT_New_Stream( const char* filepathname,
|
||||
FT_Stream stream )
|
||||
{
|
||||
int file;
|
||||
struct stat stat_buf;
|
||||
|
||||
|
||||
if ( !stream )
|
||||
return FT_Err_Invalid_Stream_Handle;
|
||||
|
||||
/* open the file */
|
||||
file = open( filepathname, O_RDONLY );
|
||||
if ( file < 0 )
|
||||
{
|
||||
FT_ERROR(( "FT_New_Stream:" ));
|
||||
FT_ERROR(( " could not open `%s'\n", filepathname ));
|
||||
return FT_Err_Cannot_Open_Resource;
|
||||
}
|
||||
|
||||
if ( fstat( file, &stat_buf ) < 0 )
|
||||
{
|
||||
FT_ERROR(( "FT_New_Stream:" ));
|
||||
FT_ERROR(( " could not `fstat' file `%s'\n", filepathname ));
|
||||
goto Fail_Map;
|
||||
}
|
||||
|
||||
stream->size = stat_buf.st_size;
|
||||
stream->pos = 0;
|
||||
stream->base = mmap( NULL,
|
||||
stream->size,
|
||||
PROT_READ,
|
||||
MAP_FILE | MAP_PRIVATE,
|
||||
file,
|
||||
0 );
|
||||
|
||||
if ( (long)stream->base == -1 )
|
||||
{
|
||||
FT_ERROR(( "FT_New_Stream:" ));
|
||||
FT_ERROR(( " could not `mmap' file `%s'\n", filepathname ));
|
||||
goto Fail_Map;
|
||||
}
|
||||
|
||||
close( file );
|
||||
|
||||
stream->descriptor.pointer = stream->base;
|
||||
stream->pathname.pointer = (char*)filepathname;
|
||||
|
||||
stream->close = ft_close_stream;
|
||||
stream->read = 0;
|
||||
|
||||
FT_TRACE1(( "FT_New_Stream:" ));
|
||||
FT_TRACE1(( " opened `%s' (%d bytes) successfully\n",
|
||||
filepathname, stream->size ));
|
||||
|
||||
return FT_Err_Ok;
|
||||
|
||||
Fail_Map:
|
||||
close( file );
|
||||
|
||||
stream->base = NULL;
|
||||
stream->size = 0;
|
||||
stream->pos = 0;
|
||||
|
||||
return FT_Err_Cannot_Open_Stream;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_New_Memory */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Creates a new memory object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* A pointer to the new memory object. 0 in case of error. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( FT_Memory ) FT_New_Memory( void )
|
||||
{
|
||||
FT_Memory memory;
|
||||
|
||||
|
||||
memory = (FT_Memory)malloc( sizeof ( *memory ) );
|
||||
if ( memory )
|
||||
{
|
||||
memory->user = 0;
|
||||
memory->alloc = ft_alloc;
|
||||
memory->realloc = ft_realloc;
|
||||
memory->free = ft_free;
|
||||
}
|
||||
|
||||
return memory;
|
||||
}
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,250 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
# install - install a program, script, or datafile
|
||||
# This comes from X11R5 (mit/util/scripts/install.sh).
|
||||
#
|
||||
# Copyright 1991 by the Massachusetts Institute of Technology
|
||||
#
|
||||
# Permission to use, copy, modify, distribute, and sell this software and its
|
||||
# documentation for any purpose is hereby granted without fee, provided that
|
||||
# the above copyright notice appear in all copies and that both that
|
||||
# copyright notice and this permission notice appear in supporting
|
||||
# documentation, and that the name of M.I.T. not be used in advertising or
|
||||
# publicity pertaining to distribution of the software without specific,
|
||||
# written prior permission. M.I.T. makes no representations about the
|
||||
# suitability of this software for any purpose. It is provided "as is"
|
||||
# without express or implied warranty.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# `make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch. It can only install one file at a time, a restriction
|
||||
# shared with many OS's install programs.
|
||||
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit="${DOITPROG-}"
|
||||
|
||||
|
||||
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||
|
||||
mvprog="${MVPROG-mv}"
|
||||
cpprog="${CPPROG-cp}"
|
||||
chmodprog="${CHMODPROG-chmod}"
|
||||
chownprog="${CHOWNPROG-chown}"
|
||||
chgrpprog="${CHGRPPROG-chgrp}"
|
||||
stripprog="${STRIPPROG-strip}"
|
||||
rmprog="${RMPROG-rm}"
|
||||
mkdirprog="${MKDIRPROG-mkdir}"
|
||||
|
||||
transformbasename=""
|
||||
transform_arg=""
|
||||
instcmd="$mvprog"
|
||||
chmodcmd="$chmodprog 0755"
|
||||
chowncmd=""
|
||||
chgrpcmd=""
|
||||
stripcmd=""
|
||||
rmcmd="$rmprog -f"
|
||||
mvcmd="$mvprog"
|
||||
src=""
|
||||
dst=""
|
||||
dir_arg=""
|
||||
|
||||
while [ x"$1" != x ]; do
|
||||
case $1 in
|
||||
-c) instcmd="$cpprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-d) dir_arg=true
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-m) chmodcmd="$chmodprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-s) stripcmd="$stripprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
*) if [ x"$src" = x ]
|
||||
then
|
||||
src=$1
|
||||
else
|
||||
# this colon is to work around a 386BSD /bin/sh bug
|
||||
:
|
||||
dst=$1
|
||||
fi
|
||||
shift
|
||||
continue;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ x"$src" = x ]
|
||||
then
|
||||
echo "install: no input file specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]; then
|
||||
dst=$src
|
||||
src=""
|
||||
|
||||
if [ -d $dst ]; then
|
||||
instcmd=:
|
||||
else
|
||||
instcmd=mkdir
|
||||
fi
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
|
||||
if [ -f $src -o -d $src ]
|
||||
then
|
||||
true
|
||||
else
|
||||
echo "install: $src does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ x"$dst" = x ]
|
||||
then
|
||||
echo "install: no destination specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# If destination is a directory, append the input filename; if your system
|
||||
# does not like double slashes in filenames, you may need to add some logic
|
||||
|
||||
if [ -d $dst ]
|
||||
then
|
||||
dst="$dst"/`basename $src`
|
||||
else
|
||||
true
|
||||
fi
|
||||
fi
|
||||
|
||||
## this sed command emulates the dirname command
|
||||
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
||||
|
||||
# Make sure that the destination directory exists.
|
||||
# this part is taken from Noah Friedman's mkinstalldirs script
|
||||
|
||||
# Skip lots of stat calls in the usual case.
|
||||
if [ ! -d "$dstdir" ]; then
|
||||
defaultIFS='
|
||||
'
|
||||
IFS="${IFS-${defaultIFS}}"
|
||||
|
||||
oIFS="${IFS}"
|
||||
# Some sh's can't handle IFS=/ for some reason.
|
||||
IFS='%'
|
||||
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
|
||||
IFS="${oIFS}"
|
||||
|
||||
pathcomp=''
|
||||
|
||||
while [ $# -ne 0 ] ; do
|
||||
pathcomp="${pathcomp}${1}"
|
||||
shift
|
||||
|
||||
if [ ! -d "${pathcomp}" ] ;
|
||||
then
|
||||
$mkdirprog "${pathcomp}"
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
pathcomp="${pathcomp}/"
|
||||
done
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]
|
||||
then
|
||||
$doit $instcmd $dst &&
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
|
||||
else
|
||||
|
||||
# If we're going to rename the final executable, determine the name now.
|
||||
|
||||
if [ x"$transformarg" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
dstfile=`basename $dst $transformbasename |
|
||||
sed $transformarg`$transformbasename
|
||||
fi
|
||||
|
||||
# don't allow the sed command to completely eliminate the filename
|
||||
|
||||
if [ x"$dstfile" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# Make a temp file name in the proper directory.
|
||||
|
||||
dsttmp=$dstdir/#inst.$$#
|
||||
|
||||
# Move or copy the file name to the temp name
|
||||
|
||||
$doit $instcmd $src $dsttmp &&
|
||||
|
||||
trap "rm -f ${dsttmp}" 0 &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits
|
||||
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $instcmd $src $dsttmp" command.
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
|
||||
$doit $rmcmd -f $dstdir/$dstfile &&
|
||||
$doit $mvcmd $dsttmp $dstdir/$dstfile
|
||||
|
||||
fi &&
|
||||
|
||||
|
||||
exit 0
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,40 @@
|
||||
#! /bin/sh
|
||||
# mkinstalldirs --- make directory hierarchy
|
||||
# Author: Noah Friedman <[email protected]>
|
||||
# Created: 1993-05-16
|
||||
# Public domain
|
||||
|
||||
# $Id: mkinstalldirs,v 1.1 2001/05/02 12:21:30 jfilby Exp $
|
||||
|
||||
errstatus=0
|
||||
|
||||
for file
|
||||
do
|
||||
set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
|
||||
shift
|
||||
|
||||
pathcomp=
|
||||
for d
|
||||
do
|
||||
pathcomp="$pathcomp$d"
|
||||
case "$pathcomp" in
|
||||
-* ) pathcomp=./$pathcomp ;;
|
||||
esac
|
||||
|
||||
if test ! -d "$pathcomp"; then
|
||||
echo "mkdir $pathcomp" 1>&2
|
||||
|
||||
mkdir "$pathcomp" || lasterr=$?
|
||||
|
||||
if test ! -d "$pathcomp"; then
|
||||
errstatus=$lasterr
|
||||
fi
|
||||
fi
|
||||
|
||||
pathcomp="$pathcomp/"
|
||||
done
|
||||
done
|
||||
|
||||
exit $errstatus
|
||||
|
||||
# mkinstalldirs ends here
|
||||
@@ -0,0 +1,216 @@
|
||||
#
|
||||
# FreeType 2 configuration rules templates for Unix + configure
|
||||
#
|
||||
|
||||
|
||||
# Copyright 1996-2000 by
|
||||
# David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
#
|
||||
# This file is part of the FreeType project, and may only be used, modified,
|
||||
# and distributed under the terms of the FreeType project license,
|
||||
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
|
||||
# indicate that you have read the license and understand and accept it
|
||||
# fully.
|
||||
|
||||
|
||||
ifndef TOP
|
||||
TOP := .
|
||||
endif
|
||||
|
||||
DELETE := @RMF@
|
||||
DELDIR := @RMDIR@
|
||||
SEP := /
|
||||
HOSTSEP := $(SEP)
|
||||
BUILD := $(TOP)/builds/unix
|
||||
PLATFORM := unix
|
||||
CC := @CC@
|
||||
|
||||
INSTALL := @INSTALL@
|
||||
INSTALL_DATA := @INSTALL_DATA@
|
||||
MKINSTALLDIRS := $(BUILD)/mkinstalldirs
|
||||
|
||||
LIBTOOL := $(BUILD)/libtool
|
||||
|
||||
|
||||
# don't use `:=' here since the path stuff will be included after this file
|
||||
#
|
||||
FTSYS_SRC = @FTSYS_SRC@
|
||||
|
||||
DISTCLEAN += $(BUILD)/config.cache \
|
||||
$(BUILD)/config.log \
|
||||
$(BUILD)/config.status \
|
||||
$(BUILD)/unix.mk \
|
||||
$(BUILD)/ftconfig.h \
|
||||
$(LIBTOOL)
|
||||
|
||||
|
||||
# Standard installation variables.
|
||||
#
|
||||
prefix := @prefix@
|
||||
exec_prefix := @exec_prefix@
|
||||
libdir := @libdir@
|
||||
bindir := @bindir@
|
||||
includedir := @includedir@
|
||||
|
||||
version_info := @version_info@
|
||||
|
||||
|
||||
# The directory where all object files are placed.
|
||||
#
|
||||
# Note that this is not $(TOP)/obj!
|
||||
# This lets you build the library in your own directory with something like
|
||||
#
|
||||
# set TOP=.../path/to/freetype2/top/dir...
|
||||
# mkdir obj
|
||||
# make -f $TOP/Makefile setup [options]
|
||||
# make -f $TOP/Makefile
|
||||
#
|
||||
OBJ_DIR := obj
|
||||
|
||||
|
||||
# The directory where all library files are placed.
|
||||
#
|
||||
# By default, this is the same as $(OBJ_DIR), however, this can be changed
|
||||
# to suit particular needs.
|
||||
#
|
||||
LIB_DIR := $(OBJ_DIR)
|
||||
|
||||
|
||||
# The object file extension (for standard and static libraries). This can be
|
||||
# .o, .tco, .obj, etc., depending on the platform.
|
||||
#
|
||||
O := lo
|
||||
SO := o
|
||||
|
||||
# The library file extension (for standard and static libraries). This can
|
||||
# be .a, .lib, etc., depending on the platform.
|
||||
#
|
||||
A := la
|
||||
SA := a
|
||||
|
||||
|
||||
# The name of the final library file. Note that the DOS-specific Makefile
|
||||
# uses a shorter (8.3) name.
|
||||
#
|
||||
LIBRARY := libfreetype
|
||||
|
||||
|
||||
# Path inclusion flag. Some compilers use a different flag than `-I' to
|
||||
# specify an additional include path. Examples are `/i=' or `-J'.
|
||||
#
|
||||
I := -I
|
||||
|
||||
|
||||
# C flag used to define a macro before the compilation of a given source
|
||||
# object. Usually is `-D' like in `-DDEBUG'.
|
||||
#
|
||||
D := -D
|
||||
|
||||
|
||||
# The link flag used to specify a given library file on link. Note that
|
||||
# this is only used to compile the demo programs, not the library itself.
|
||||
#
|
||||
L := -l
|
||||
|
||||
|
||||
# Target flag.
|
||||
#
|
||||
T := -o # Don't remove this comment line! We need the space after `-o'.
|
||||
|
||||
|
||||
# C flags
|
||||
#
|
||||
# These should concern: debug output, optimization & warnings.
|
||||
#
|
||||
# Use the ANSIFLAGS variable to define the compiler flags used to enfore
|
||||
# ANSI compliance.
|
||||
#
|
||||
CFLAGS := -c @XX_CFLAGS@ @CFLAGS@
|
||||
|
||||
# ANSIFLAGS: Put there the flags used to make your compiler ANSI-compliant.
|
||||
#
|
||||
ANSIFLAGS := @XX_ANSIFLAGS@
|
||||
|
||||
# C compiler to use -- we use libtool!
|
||||
#
|
||||
#
|
||||
CCraw := $(CC)
|
||||
CC := $(LIBTOOL) --mode=compile $(CCraw)
|
||||
|
||||
# Linker flags.
|
||||
#
|
||||
LDFLAGS := @LDFLAGS@
|
||||
|
||||
|
||||
ifdef BUILD_FREETYPE
|
||||
|
||||
# Now include the main sub-makefile. It contains all the rules used to
|
||||
# build the library with the previous variables defined.
|
||||
#
|
||||
include $(TOP)/builds/freetype.mk
|
||||
|
||||
|
||||
# The cleanup targets.
|
||||
#
|
||||
clean_freetype: clean_freetype_unix
|
||||
distclean_freetype: distclean_freetype_unix
|
||||
|
||||
|
||||
# Unix installation and deinstallation targets.
|
||||
install: $(FT_LIBRARY)
|
||||
$(MKINSTALLDIRS) $(libdir) \
|
||||
$(includedir)/freetype/config \
|
||||
$(includedir)/freetype/internal
|
||||
$(LIBTOOL) --mode=install $(INSTALL) $(FT_LIBRARY) $(libdir)
|
||||
-for P in $(PUBLIC_H) ; do \
|
||||
$(INSTALL_DATA) $$P $(includedir)/freetype ; \
|
||||
done
|
||||
-for P in $(BASE_H) ; do \
|
||||
$(INSTALL_DATA) $$P $(includedir)/freetype/internal ; \
|
||||
done
|
||||
-for P in $(CONFIG_H) ; do \
|
||||
$(INSTALL_DATA) $$P $(includedir)/freetype/config ; \
|
||||
done
|
||||
|
||||
uninstall:
|
||||
-$(LIBTOOL) --mode=uninstall $(RM) $(libdir)/$(LIBRARY).$A
|
||||
-$(DELETE) $(includedir)/freetype/config/*
|
||||
-$(DELDIR) $(includedir)/freetype/config
|
||||
-$(DELETE) $(includedir)/freetype/internal/*
|
||||
-$(DELDIR) $(includedir)/freetype/internal
|
||||
-$(DELETE) $(includedir)/freetype/*
|
||||
-$(DELDIR) $(includedir)/freetype
|
||||
|
||||
|
||||
# Unix cleaning and distclean rules.
|
||||
#
|
||||
clean_freetype_unix:
|
||||
-$(DELETE) $(BASE_OBJECTS) $(OBJ_M) $(OBJ_S)
|
||||
-$(DELETE) $(subst $O,$(SO),$(BASE_OBJECTS) $(OBJ_M) $(OBJ_S)) \
|
||||
$(CLEAN)
|
||||
|
||||
distclean_freetype_unix: clean_freetype_unix
|
||||
-$(DELETE) $(FT_LIBRARY)
|
||||
-$(DELETE) $(OBJ_DIR)/.libs/*
|
||||
-$(DELDIR) $(OBJ_DIR)/.libs
|
||||
-$(DELETE) *.orig *~ core *.core $(DISTCLEAN)
|
||||
|
||||
|
||||
# Librarian to use to build the library
|
||||
#
|
||||
FT_LIBRARIAN := $(LIBTOOL) --mode=link $(CCraw)
|
||||
|
||||
|
||||
# This final rule is used to link all object files into a single library.
|
||||
# It is part of the system-specific sub-Makefile because not all
|
||||
# librarians accept a simple syntax like
|
||||
#
|
||||
# librarian library_file {list of object files}
|
||||
#
|
||||
$(FT_LIBRARY): $(OBJECTS_LIST)
|
||||
$(FT_LIBRARIAN) -o $@ $(OBJECTS_LIST) \
|
||||
-rpath $(libdir) -version-info $(version_info)
|
||||
|
||||
endif
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,90 @@
|
||||
#
|
||||
# FreeType 2 configuration file to detect a Win32 host platform.
|
||||
#
|
||||
|
||||
|
||||
# Copyright 1996-2000 by
|
||||
# David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
#
|
||||
# This file is part of the FreeType project, and may only be used, modified,
|
||||
# and distributed under the terms of the FreeType project license,
|
||||
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
|
||||
# indicate that you have read the license and understand and accept it
|
||||
# fully.
|
||||
|
||||
|
||||
ifeq ($(PLATFORM),ansi)
|
||||
|
||||
# Detecting Windows NT is easy, as the OS variable must be defined and
|
||||
# contains `Windows_NT'. Untested with Windows 2K, but I guess it should
|
||||
# work...
|
||||
#
|
||||
ifeq ($(OS),Windows_NT)
|
||||
is_windows := 1
|
||||
|
||||
# We test for the COMSPEC environment variable, then run the `ver'
|
||||
# command-line program to see if its output contains the word `Windows'.
|
||||
#
|
||||
# If this is true, we are running a win32 platform (or an emulation).
|
||||
#
|
||||
else
|
||||
ifdef COMSPEC
|
||||
is_windows := $(findstring Windows,$(strip $(shell ver)))
|
||||
endif
|
||||
endif # test NT
|
||||
|
||||
ifdef is_windows
|
||||
|
||||
PLATFORM := win32
|
||||
DELETE := del
|
||||
COPY := copy
|
||||
|
||||
CONFIG_FILE := w32-gcc.mk # gcc Makefile by default
|
||||
SEP := /
|
||||
ifeq ($(firstword $(CC)),cc)
|
||||
CC := gcc
|
||||
endif
|
||||
|
||||
# additionally, we provide hooks for various other compilers
|
||||
#
|
||||
ifneq ($(findstring visualc,$(MAKECMDGOALS)),) # Visual C/C++
|
||||
CONFIG_FILE := w32-vcc.mk
|
||||
SEP := $(BACKSLASH)
|
||||
CC := cl
|
||||
visualc: setup
|
||||
endif
|
||||
|
||||
ifneq ($(findstring watcom,$(MAKECMDGOALS)),) # Watcom C/C++
|
||||
CONFIG_FILE := w32-wat.mk
|
||||
SEP := $(BACKSLASH)
|
||||
CC := wcc386
|
||||
watcom: setup
|
||||
endif
|
||||
|
||||
ifneq ($(findstring visualage,$(MAKECMDGOALS)),) # Visual Age C++
|
||||
CONFIG_FILE := w32-icc.mk
|
||||
SEP := $(BACKSLASH)
|
||||
CC := icc
|
||||
visualage: setup
|
||||
endif
|
||||
|
||||
ifneq ($(findstring lcc,$(MAKECMDGOALS)),) # LCC-Win32
|
||||
CONFIG_FILE := w32-lcc.mk
|
||||
SEP := $(BACKSLASH)
|
||||
CC := lcc
|
||||
lcc: setup
|
||||
endif
|
||||
|
||||
ifneq ($(findstring devel,$(MAKECMDGOALS)),) # development target
|
||||
CONFIG_FILE := w32-dev.mk
|
||||
CC := gcc
|
||||
SEP := /
|
||||
devel: setup
|
||||
endif
|
||||
|
||||
setup: dos_setup
|
||||
|
||||
endif # test is_windows
|
||||
endif # test PLATFORM
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,140 @@
|
||||
#
|
||||
# FreeType 2 Configuration rules for Win32 + GCC
|
||||
#
|
||||
# Development version without optimizations.
|
||||
#
|
||||
|
||||
|
||||
# Copyright 1996-2000 by
|
||||
# David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
#
|
||||
# This file is part of the FreeType project, and may only be used, modified,
|
||||
# and distributed under the terms of the FreeType project license,
|
||||
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
|
||||
# indicate that you have read the license and understand and accept it
|
||||
# fully.
|
||||
#
|
||||
# NOTE: This version requires that GNU Make is invoked from the Windows
|
||||
# Shell (_not_ Cygwin BASH)!
|
||||
#
|
||||
|
||||
ifndef TOP
|
||||
TOP := .
|
||||
endif
|
||||
|
||||
DELETE := del
|
||||
SEP := /
|
||||
HOSTSEP := $(strip \ )
|
||||
BUILD := $(TOP)/builds/win32
|
||||
PLATFORM := win32
|
||||
CC := gcc
|
||||
|
||||
# The directory where all object files are placed.
|
||||
#
|
||||
# Note that this is not $(TOP)/obj!
|
||||
# This lets you build the library in your own directory with something like
|
||||
#
|
||||
# set TOP=.../path/to/freetype2/top/dir...
|
||||
# mkdir obj
|
||||
# make -f %TOP%/Makefile setup [options]
|
||||
# make -f %TOP%/Makefile
|
||||
#
|
||||
OBJ_DIR := obj
|
||||
|
||||
|
||||
# The directory where all library files are placed.
|
||||
#
|
||||
# By default, this is the same as $(OBJ_DIR), however, this can be changed
|
||||
# to suit particular needs.
|
||||
#
|
||||
LIB_DIR := $(OBJ_DIR)
|
||||
|
||||
|
||||
# The object file extension (for standard and static libraries). This can be
|
||||
# .o, .tco, .obj, etc., depending on the platform.
|
||||
#
|
||||
O := o
|
||||
SO := o
|
||||
|
||||
# The library file extension (for standard and static libraries). This can
|
||||
# be .a, .lib, etc., depending on the platform.
|
||||
#
|
||||
A := a
|
||||
SA := a
|
||||
|
||||
|
||||
# The name of the final library file. Note that the DOS-specific Makefile
|
||||
# uses a shorter (8.3) name.
|
||||
#
|
||||
LIBRARY := libfreetype
|
||||
|
||||
|
||||
# Path inclusion flag. Some compilers use a different flag than `-I' to
|
||||
# specify an additional include path. Examples are `/i=' or `-J'.
|
||||
#
|
||||
I := -I
|
||||
|
||||
|
||||
# C flag used to define a macro before the compilation of a given source
|
||||
# object. Usually is `-D' like in `-DDEBUG'.
|
||||
#
|
||||
D := -D
|
||||
|
||||
|
||||
# The link flag used to specify a given library file on link. Note that
|
||||
# this is only used to compile the demo programs, not the library itself.
|
||||
#
|
||||
L := -l
|
||||
|
||||
|
||||
# Target flag.
|
||||
#
|
||||
T := -o # Don't remove this comment line! We need the space after `-o'.
|
||||
|
||||
|
||||
# C flags
|
||||
#
|
||||
# These should concern: debug output, optimization & warnings.
|
||||
#
|
||||
# Use the ANSIFLAGS variable to define the compiler flags used to enfore
|
||||
# ANSI compliance.
|
||||
#
|
||||
ifndef CFLAGS
|
||||
CFLAGS := -c -g -O0 -Wall -W
|
||||
endif
|
||||
|
||||
# ANSIFLAGS: Put there the flags used to make your compiler ANSI-compliant.
|
||||
#
|
||||
ANSIFLAGS := -ansi -pedantic
|
||||
|
||||
|
||||
ifdef BUILD_FREETYPE
|
||||
|
||||
# Now include the main sub-makefile. It contains all the rules used to
|
||||
# build the library with the previous variables defined.
|
||||
#
|
||||
include $(TOP)/builds/freetype.mk
|
||||
|
||||
# The cleanup targets.
|
||||
#
|
||||
clean_freetype: clean_freetype_dos
|
||||
distclean_freetype: distclean_freetype_dos
|
||||
|
||||
# Librarian to use to build the static library
|
||||
#
|
||||
FT_LIBRARIAN := $(AR) -r
|
||||
|
||||
|
||||
# This final rule is used to link all object files into a single library.
|
||||
# It is part of the system-specific sub-Makefile because not all
|
||||
# librarians accept a simple syntax like
|
||||
#
|
||||
# librarian library_file {list of object files}
|
||||
#
|
||||
$(FT_LIBRARY): $(OBJECTS_LIST)
|
||||
-$(DELETE) $(subst $(SEP),$(HOSTSEP),$(FT_LIBRARY)) 2> nul
|
||||
$(FT_LIBRARIAN) $@ $(OBJECTS_LIST)
|
||||
|
||||
endif
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,138 @@
|
||||
#
|
||||
# FreeType 2 Configuration rules for Win32 + GCC
|
||||
#
|
||||
|
||||
|
||||
# Copyright 1996-2000 by
|
||||
# David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
#
|
||||
# This file is part of the FreeType project, and may only be used, modified,
|
||||
# and distributed under the terms of the FreeType project license,
|
||||
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
|
||||
# indicate that you have read the license and understand and accept it
|
||||
# fully.
|
||||
#
|
||||
# NOTE: This version requires that GNU Make is invoked from the Windows
|
||||
# Shell (_not_ Cygwin BASH)!
|
||||
#
|
||||
|
||||
ifndef TOP
|
||||
TOP := .
|
||||
endif
|
||||
|
||||
DELETE := del
|
||||
SEP := /
|
||||
HOSTSEP := $(strip \ )
|
||||
BUILD := $(TOP)/builds/win32
|
||||
PLATFORM := win32
|
||||
CC := gcc
|
||||
|
||||
# The directory where all object files are placed.
|
||||
#
|
||||
# Note that this is not $(TOP)/obj!
|
||||
# This lets you build the library in your own directory with something like
|
||||
#
|
||||
# set TOP=.../path/to/freetype2/top/dir...
|
||||
# mkdir obj
|
||||
# make -f %TOP%/Makefile setup [options]
|
||||
# make -f %TOP%/Makefile
|
||||
#
|
||||
OBJ_DIR := obj
|
||||
|
||||
|
||||
# The directory where all library files are placed.
|
||||
#
|
||||
# By default, this is the same as $(OBJ_DIR), however, this can be changed
|
||||
# to suit particular needs.
|
||||
#
|
||||
LIB_DIR := $(OBJ_DIR)
|
||||
|
||||
|
||||
# The object file extension (for standard and static libraries). This can be
|
||||
# .o, .tco, .obj, etc., depending on the platform.
|
||||
#
|
||||
O := o
|
||||
SO := o
|
||||
|
||||
# The library file extension (for standard and static libraries). This can
|
||||
# be .a, .lib, etc., depending on the platform.
|
||||
#
|
||||
A := a
|
||||
SA := a
|
||||
|
||||
|
||||
# The name of the final library file. Note that the DOS-specific Makefile
|
||||
# uses a shorter (8.3) name.
|
||||
#
|
||||
LIBRARY := libfreetype
|
||||
|
||||
|
||||
# Path inclusion flag. Some compilers use a different flag than `-I' to
|
||||
# specify an additional include path. Examples are `/i=' or `-J'.
|
||||
#
|
||||
I := -I
|
||||
|
||||
|
||||
# C flag used to define a macro before the compilation of a given source
|
||||
# object. Usually is `-D' like in `-DDEBUG'.
|
||||
#
|
||||
D := -D
|
||||
|
||||
|
||||
# The link flag used to specify a given library file on link. Note that
|
||||
# this is only used to compile the demo programs, not the library itself.
|
||||
#
|
||||
L := -l
|
||||
|
||||
|
||||
# Target flag.
|
||||
#
|
||||
T := -o # Don't remove this comment line! We need the space after `-o'.
|
||||
|
||||
|
||||
# C flags
|
||||
#
|
||||
# These should concern: debug output, optimization & warnings.
|
||||
#
|
||||
# Use the ANSIFLAGS variable to define the compiler flags used to enfore
|
||||
# ANSI compliance.
|
||||
#
|
||||
ifndef CFLAGS
|
||||
CFLAGS := -c -g -O6 -Wall
|
||||
endif
|
||||
|
||||
# ANSIFLAGS: Put there the flags used to make your compiler ANSI-compliant.
|
||||
#
|
||||
ANSIFLAGS := -ansi -pedantic
|
||||
|
||||
|
||||
ifdef BUILD_FREETYPE
|
||||
|
||||
# Now include the main sub-makefile. It contains all the rules used to
|
||||
# build the library with the previous variables defined.
|
||||
#
|
||||
include $(TOP)/builds/freetype.mk
|
||||
|
||||
# The cleanup targets.
|
||||
#
|
||||
clean_freetype: clean_freetype_dos
|
||||
distclean_freetype: distclean_freetype_dos
|
||||
|
||||
# Librarian to use to build the static library
|
||||
#
|
||||
FT_LIBRARIAN := $(AR) -r
|
||||
|
||||
|
||||
# This final rule is used to link all object files into a single library.
|
||||
# It is part of the system-specific sub-Makefile because not all
|
||||
# librarians accept a simple syntax like
|
||||
#
|
||||
# librarian library_file {list of object files}
|
||||
#
|
||||
$(FT_LIBRARY): $(OBJECTS_LIST)
|
||||
-$(DELETE) $(subst $(SEP),$(HOSTSEP),$(FT_LIBRARY)) 2> nul
|
||||
$(FT_LIBRARIAN) $@ $(OBJECTS_LIST)
|
||||
|
||||
endif
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,122 @@
|
||||
#
|
||||
# FreeType 2 Configuration rules for Win32 + IBM Visual Age C++
|
||||
#
|
||||
|
||||
|
||||
# Copyright 1996-2000 by
|
||||
# David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
#
|
||||
# This file is part of the FreeType project, and may only be used, modified,
|
||||
# and distributed under the terms of the FreeType project license,
|
||||
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
|
||||
# indicate that you have read the license and understand and accept it
|
||||
# fully.
|
||||
#
|
||||
|
||||
DELETE := del
|
||||
SEP := $(strip \ )
|
||||
HOSTSEP := $(strip \ )
|
||||
BUILD := $(TOP)$(SEP)config$(SEP)win32
|
||||
PLATFORM := win32
|
||||
CC := icc
|
||||
|
||||
# The directory where all object files are placed.
|
||||
#
|
||||
# Note that this is not $(TOP)/obj!
|
||||
# This lets you build the library in your own directory with something like
|
||||
#
|
||||
# set TOP=.../path/to/freetype2/top/dir...
|
||||
# mkdir obj
|
||||
# make -f %TOP%/Makefile setup [options]
|
||||
# make -f %TOP%/Makefile
|
||||
#
|
||||
OBJ_DIR := obj
|
||||
|
||||
|
||||
# The directory where all library files are placed.
|
||||
#
|
||||
# By default, this is the same as $(OBJ_DIR), however, this can be changed
|
||||
# to suit particular needs.
|
||||
#
|
||||
LIB_DIR := $(OBJ_DIR)
|
||||
|
||||
|
||||
# The object file extension (for standard and static libraries). This can be
|
||||
# .o, .tco, .obj, etc., depending on the platform.
|
||||
#
|
||||
O := obj
|
||||
SO := obj
|
||||
|
||||
# The library file extension (for standard and static libraries). This can
|
||||
# be .a, .lib, etc., depending on the platform.
|
||||
#
|
||||
A := lib
|
||||
SA := lib
|
||||
|
||||
|
||||
# The name of the final library file. Note that the DOS-specific Makefile
|
||||
# uses a shorter (8.3) name.
|
||||
#
|
||||
LIBRARY := freetype
|
||||
|
||||
|
||||
# Path inclusion flag. Some compilers use a different flag than `-I' to
|
||||
# specify an additional include path. Examples are `/i=' or `-J'.
|
||||
#
|
||||
I := /I
|
||||
|
||||
|
||||
# C flag used to define a macro before the compilation of a given source
|
||||
# object. Usually is `-D' like in `-DDEBUG'.
|
||||
#
|
||||
D := /D
|
||||
|
||||
|
||||
# The link flag used to specify a given library file on link. Note that
|
||||
# this is only used to compile the demo programs, not the library itself.
|
||||
#
|
||||
L := /Fl
|
||||
|
||||
|
||||
# Target flag.
|
||||
#
|
||||
T := /Fo
|
||||
|
||||
|
||||
# C flags
|
||||
#
|
||||
# These should concern: debug output, optimization & warnings.
|
||||
#
|
||||
ifndef CFLAGS
|
||||
CFLAGS := /Q- /Gd+ /O2 /G5 /W3 /C
|
||||
endif
|
||||
|
||||
# ANSIFLAGS: Put there the flags used to make your compiler ANSI-compliant.
|
||||
#
|
||||
ANSI_FLAGS := /Sa
|
||||
|
||||
|
||||
ifdef BUILD_FREETYPE
|
||||
|
||||
# Now include the main sub-makefile. It contains all the rules used to
|
||||
# build the library with the previous variables defined.
|
||||
#
|
||||
include $(TOP)/builds/freetype.mk
|
||||
|
||||
# The cleanup targets.
|
||||
#
|
||||
clean_freetype: clean_freetype_dos
|
||||
distclean_freetype: distclean_freetype_dos
|
||||
|
||||
# This final rule is used to link all object files into a single library.
|
||||
# It is part of the system-specific sub-Makefile because not all
|
||||
# librarians accept a simple syntax like
|
||||
#
|
||||
# librarian library_file {list of object files}
|
||||
#
|
||||
$(FT_LIBRARY): $(OBJECTS_LIST)
|
||||
lib /nologo /out:$@ $(OBJECTS_LIST)
|
||||
|
||||
endif
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,130 @@
|
||||
#
|
||||
# FreeType 2 Configuration rules for Win32 + LCC
|
||||
#
|
||||
|
||||
|
||||
# Copyright 1996-2000 by
|
||||
# David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
#
|
||||
# This file is part of the FreeType project, and may only be used, modified,
|
||||
# and distributed under the terms of the FreeType project license,
|
||||
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
|
||||
# indicate that you have read the license and understand and accept it
|
||||
# fully.
|
||||
|
||||
|
||||
ifndef TOP
|
||||
TOP := .
|
||||
endif
|
||||
|
||||
DELETE := del
|
||||
SEP := /
|
||||
HOSTSEP := $(strip \ )
|
||||
BUILD := $(TOP)/builds/win32
|
||||
PLATFORM := win32
|
||||
CC := lcc
|
||||
|
||||
# The directory where all object files are placed.
|
||||
#
|
||||
# Note that this is not $(TOP)/obj!
|
||||
# This lets you build the library in your own directory with something like
|
||||
#
|
||||
# set TOP=.../path/to/freetype2/top/dir...
|
||||
# mkdir obj
|
||||
# make -f %TOP%/Makefile setup [options]
|
||||
# make -f %TOP%/Makefile
|
||||
#
|
||||
OBJ_DIR := obj
|
||||
|
||||
|
||||
# The directory where all library files are placed.
|
||||
#
|
||||
# By default, this is the same as $(OBJ_DIR), however, this can be changed
|
||||
# to suit particular needs.
|
||||
#
|
||||
LIB_DIR := $(OBJ_DIR)
|
||||
|
||||
|
||||
# The object file extension (for standard and static libraries). This can be
|
||||
# .o, .tco, .obj, etc., depending on the platform.
|
||||
#
|
||||
O := obj
|
||||
SO := obj
|
||||
|
||||
# The library file extension (for standard and static libraries). This can
|
||||
# be .a, .lib, etc., depending on the platform.
|
||||
#
|
||||
A := lib
|
||||
SA := lib
|
||||
|
||||
|
||||
# The name of the final library file. Note that the DOS-specific Makefile
|
||||
# uses a shorter (8.3) name.
|
||||
#
|
||||
LIBRARY := freetype
|
||||
|
||||
|
||||
# Path inclusion flag. Some compilers use a different flag than `-I' to
|
||||
# specify an additional include path. Examples are `/i=' or `-J'.
|
||||
#
|
||||
I := -I
|
||||
|
||||
|
||||
# C flag used to define a macro before the compilation of a given source
|
||||
# object. Usually is `-D' like in `-DDEBUG'.
|
||||
#
|
||||
D := -D
|
||||
|
||||
|
||||
# The link flag used to specify a given library file on link. Note that
|
||||
# this is only used to compile the demo programs, not the library itself.
|
||||
#
|
||||
L := -Fl
|
||||
|
||||
|
||||
# Target flag.
|
||||
#
|
||||
T := -Fo
|
||||
|
||||
|
||||
# C flags
|
||||
#
|
||||
# These should concern: debug output, optimization & warnings.
|
||||
#
|
||||
# Use the ANSIFLAGS variable to define the compiler flags used to enfore
|
||||
# ANSI compliance.
|
||||
#
|
||||
ifndef CFLAGS
|
||||
CFLAGS := -c -g2 -O
|
||||
endif
|
||||
|
||||
# ANSIFLAGS: Put there the flags used to make your compiler ANSI-compliant.
|
||||
#
|
||||
ANSIFLAGS :=
|
||||
|
||||
|
||||
ifdef BUILD_FREETYPE
|
||||
|
||||
# Now include the main sub-makefile. It contains all the rules used to
|
||||
# build the library with the previous variables defined.
|
||||
#
|
||||
include $(TOP)/builds/freetype.mk
|
||||
|
||||
# The cleanup targets.
|
||||
#
|
||||
clean_freetype: clean_freetype_dos
|
||||
distclean_freetype: distclean_freetype_dos
|
||||
|
||||
# This final rule is used to link all object files into a single library.
|
||||
# It is part of the system-specific sub-Makefile because not all
|
||||
# librarians accept a simple syntax like
|
||||
#
|
||||
# librarian library_file {list of object files}
|
||||
#
|
||||
$(FT_LIBRARY): $(OBJECTS_LIST)
|
||||
lcclib /out:$(subst $(SEP),\\,$@) \
|
||||
$(subst $(SEP),\\,$(OBJECTS_LIST))
|
||||
|
||||
endif
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,129 @@
|
||||
#
|
||||
# FreeType 2 Configuration rules for Win32 + Visual C/C++
|
||||
#
|
||||
|
||||
|
||||
# Copyright 1996-2000 by
|
||||
# David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
#
|
||||
# This file is part of the FreeType project, and may only be used, modified,
|
||||
# and distributed under the terms of the FreeType project license,
|
||||
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
|
||||
# indicate that you have read the license and understand and accept it
|
||||
# fully.
|
||||
|
||||
|
||||
ifndef TOP
|
||||
TOP := .
|
||||
endif
|
||||
|
||||
DELETE := del
|
||||
SEP := /
|
||||
HOSTSEP := $(strip \ )
|
||||
BUILD := $(TOP)/builds/win32
|
||||
PLATFORM := win32
|
||||
CC := cl
|
||||
|
||||
# The directory where all object files are placed.
|
||||
#
|
||||
# Note that this is not $(TOP)/obj!
|
||||
# This lets you build the library in your own directory with something like
|
||||
#
|
||||
# set TOP=.../path/to/freetype2/top/dir...
|
||||
# mkdir obj
|
||||
# make -f %TOP%/Makefile setup [options]
|
||||
# make -f %TOP%/Makefile
|
||||
#
|
||||
OBJ_DIR := obj
|
||||
|
||||
|
||||
# The directory where all library files are placed.
|
||||
#
|
||||
# By default, this is the same as $(OBJ_DIR), however, this can be changed
|
||||
# to suit particular needs.
|
||||
#
|
||||
LIB_DIR := $(OBJ_DIR)
|
||||
|
||||
|
||||
# The object file extension (for standard and static libraries). This can be
|
||||
# .o, .tco, .obj, etc., depending on the platform.
|
||||
#
|
||||
O := obj
|
||||
SO := obj
|
||||
|
||||
# The library file extension (for standard and static libraries). This can
|
||||
# be .a, .lib, etc., depending on the platform.
|
||||
#
|
||||
A := lib
|
||||
SA := lib
|
||||
|
||||
|
||||
# The name of the final library file. Note that the DOS-specific Makefile
|
||||
# uses a shorter (8.3) name.
|
||||
#
|
||||
LIBRARY := freetype
|
||||
|
||||
|
||||
# Path inclusion flag. Some compilers use a different flag than `-I' to
|
||||
# specify an additional include path. Examples are `/i=' or `-J'.
|
||||
#
|
||||
I := /I
|
||||
|
||||
|
||||
# C flag used to define a macro before the compilation of a given source
|
||||
# object. Usually is `-D' like in `-DDEBUG'.
|
||||
#
|
||||
D := /D
|
||||
|
||||
|
||||
# The link flag used to specify a given library file on link. Note that
|
||||
# this is only used to compile the demo programs, not the library itself.
|
||||
#
|
||||
L := /Fl
|
||||
|
||||
|
||||
# Target flag.
|
||||
#
|
||||
T := /Fo
|
||||
|
||||
|
||||
# C flags
|
||||
#
|
||||
# These should concern: debug output, optimization & warnings.
|
||||
#
|
||||
# Use the ANSIFLAGS variable to define the compiler flags used to enfore
|
||||
# ANSI compliance.
|
||||
#
|
||||
ifndef CFLAGS
|
||||
CFLAGS := /nologo /c /Ox /G5 /W3 /WX
|
||||
endif
|
||||
|
||||
# ANSIFLAGS: Put there the flags used to make your compiler ANSI-compliant.
|
||||
#
|
||||
ANSIFLAGS := /Za
|
||||
|
||||
|
||||
ifdef BUILD_FREETYPE
|
||||
|
||||
# Now include the main sub-makefile. It contains all the rules used to
|
||||
# build the library with the previous variables defined.
|
||||
#
|
||||
include $(TOP)/builds/freetype.mk
|
||||
|
||||
# The cleanup targets.
|
||||
#
|
||||
clean_freetype: clean_freetype_dos
|
||||
distclean_freetype: distclean_freetype_dos
|
||||
|
||||
# This final rule is used to link all object files into a single library.
|
||||
# It is part of the system-specific sub-Makefile because not all
|
||||
# librarians accept a simple syntax like
|
||||
#
|
||||
# librarian library_file {list of object files}
|
||||
#
|
||||
$(FT_LIBRARY): $(OBJECTS_LIST)
|
||||
lib /nologo /out:$@ $(OBJECTS_LIST)
|
||||
|
||||
endif
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,42 @@
|
||||
#define FT_FLAT_COMPILE
|
||||
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* cff.c */
|
||||
/* */
|
||||
/* FreeType OpenType driver component (body only). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#define FT_MAKE_OPTION_SINGLE_OBJECT
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "t2driver.c" /* driver interface */
|
||||
#include "t2parse.c" /* token parser */
|
||||
#include "t2load.c" /* tables loader */
|
||||
#include "t2objs.c" /* object management */
|
||||
#include "t2gload.c" /* glyph loader */
|
||||
|
||||
#else
|
||||
|
||||
#include <cff/t2driver.c> /* driver interface */
|
||||
#include <cff/t2parse.c> /* token parser */
|
||||
#include <cff/t2load.c> /* tables loader */
|
||||
#include <cff/t2objs.c> /* object management */
|
||||
#include <cff/t2gload.c> /* glyph loader */
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,293 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* cidafm.c */
|
||||
/* */
|
||||
/* AFM support for CID-keyed fonts (body). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "cidafm.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <cid/cidafm.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#include <freetype/internal/ftstream.h>
|
||||
#include <freetype/internal/t1types.h>
|
||||
#include <freetype/internal/t1errors.h>
|
||||
|
||||
#include <stdlib.h> /* for qsort() */
|
||||
#include <string.h> /* for strcmp() */
|
||||
#include <ctype.h> /* for isalnum() */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
|
||||
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
|
||||
/* messages during execution. */
|
||||
/* */
|
||||
#undef FT_COMPONENT
|
||||
#define FT_COMPONENT trace_cidafm
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
void CID_Done_AFM( FT_Memory memory,
|
||||
CID_AFM* afm )
|
||||
{
|
||||
FREE( afm->kern_pairs );
|
||||
afm->num_pairs = 0;
|
||||
}
|
||||
|
||||
|
||||
#undef IS_KERN_PAIR
|
||||
#define IS_KERN_PAIR( p ) ( p[0] == 'K' && p[1] == 'P' )
|
||||
|
||||
#define IS_ALPHANUM( c ) ( isalnum( c ) || \
|
||||
c == '_' || \
|
||||
c == '.' )
|
||||
|
||||
|
||||
/* read a glyph name and return the equivalent glyph index */
|
||||
static
|
||||
FT_UInt afm_atoindex( FT_Byte** start,
|
||||
FT_Byte* limit,
|
||||
T1_Font* type1 )
|
||||
{
|
||||
FT_Byte* p = *start;
|
||||
FT_Int len;
|
||||
FT_UInt result = 0;
|
||||
char temp[64];
|
||||
|
||||
|
||||
/* skip whitespace */
|
||||
while ( ( *p == ' ' || *p == '\t' || *p == ':' || *p == ';' ) &&
|
||||
p < limit )
|
||||
p++;
|
||||
*start = p;
|
||||
|
||||
/* now, read glyph name */
|
||||
while ( IS_ALPHANUM( *p ) && p < limit )
|
||||
p++;
|
||||
|
||||
len = p - *start;
|
||||
|
||||
if ( len > 0 && len < 64 )
|
||||
{
|
||||
FT_Int n;
|
||||
|
||||
|
||||
/* copy glyph name to intermediate array */
|
||||
MEM_Copy( temp, *start, len );
|
||||
temp[len] = 0;
|
||||
|
||||
/* lookup glyph name in face array */
|
||||
for ( n = 0; n < type1->num_glyphs; n++ )
|
||||
{
|
||||
char* gname = (char*)type1->glyph_names[n];
|
||||
|
||||
|
||||
if ( gname && gname[0] == temp[0] && strcmp( gname, temp ) == 0 )
|
||||
{
|
||||
result = n;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
*start = p;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/* read an integer */
|
||||
static
|
||||
int afm_atoi( FT_Byte** start,
|
||||
FT_Byte* limit )
|
||||
{
|
||||
FT_Byte* p = *start;
|
||||
int sum = 0;
|
||||
int sign = 1;
|
||||
|
||||
|
||||
/* skip everything that is not a number */
|
||||
while ( p < limit && !isdigit( *p ) )
|
||||
{
|
||||
sign = 1;
|
||||
if ( *p == '-' )
|
||||
sign = -1;
|
||||
|
||||
p++;
|
||||
}
|
||||
|
||||
while ( p < limit && isdigit( *p ) )
|
||||
{
|
||||
sum = sum * 10 + ( *p - '0' );
|
||||
p++;
|
||||
}
|
||||
*start = p;
|
||||
|
||||
return sum * sign;
|
||||
}
|
||||
|
||||
|
||||
#undef KERN_INDEX
|
||||
#define KERN_INDEX( g1, g2 ) ( ( (FT_ULong)g1 << 16 ) | g2 )
|
||||
|
||||
|
||||
/* compare two kerning pairs */
|
||||
static
|
||||
int compare_kern_pairs( const void* a,
|
||||
const void* b )
|
||||
{
|
||||
CID_Kern_Pair* pair1 = (CID_Kern_Pair*)a;
|
||||
CID_Kern_Pair* pair2 = (CID_Kern_Pair*)b;
|
||||
|
||||
FT_ULong index1 = KERN_INDEX( pair1->glyph1, pair1->glyph2 );
|
||||
FT_ULong index2 = KERN_INDEX( pair2->glyph1, pair2->glyph2 );
|
||||
|
||||
|
||||
return ( index1 - index2 );
|
||||
}
|
||||
|
||||
|
||||
/* parse an AFM file -- for now, only read the kerning pairs */
|
||||
LOCAL_FUNC
|
||||
FT_Error CID_Read_AFM( FT_Face cid_face,
|
||||
FT_Stream stream )
|
||||
{
|
||||
FT_Error error;
|
||||
FT_Memory memory = stream->memory;
|
||||
FT_Byte* start;
|
||||
FT_Byte* limit;
|
||||
FT_Byte* p;
|
||||
FT_Int count = 0;
|
||||
CID_Kern_Pair* pair;
|
||||
T1_Font* type1 = &((T1_Face)t1_face)->type1;
|
||||
CID_AFM* afm = 0;
|
||||
|
||||
|
||||
if ( ACCESS_Frame( stream->size ) )
|
||||
return error;
|
||||
|
||||
start = (FT_Byte*)stream->cursor;
|
||||
limit = (FT_Byte*)stream->limit;
|
||||
p = start;
|
||||
|
||||
/* we are now going to count the occurrences of `KP' or `KPX' in */
|
||||
/* the AFM file. */
|
||||
count = 0;
|
||||
for ( p = start; p < limit - 3; p++ )
|
||||
{
|
||||
if ( IS_KERN_PAIR( p ) )
|
||||
count++;
|
||||
}
|
||||
|
||||
/* Actually, kerning pairs are simply optional! */
|
||||
if ( count == 0 )
|
||||
goto Exit;
|
||||
|
||||
/* allocate the pairs */
|
||||
if ( ALLOC( afm, sizeof ( *afm ) ) ||
|
||||
ALLOC_ARRAY( afm->kern_pairs, count, CID_Kern_Pair ) )
|
||||
goto Exit;
|
||||
|
||||
/* now, read each kern pair */
|
||||
pair = afm->kern_pairs;
|
||||
afm->num_pairs = count;
|
||||
|
||||
/* save in face object */
|
||||
((T1_Face)t1_face)->afm_data = afm;
|
||||
|
||||
for ( p = start; p < limit - 3; p++ )
|
||||
{
|
||||
if ( IS_KERN_PAIR( p ) )
|
||||
{
|
||||
FT_Byte* q;
|
||||
|
||||
|
||||
/* skip keyword (`KP' or `KPX') */
|
||||
q = p + 2;
|
||||
if ( *q == 'X' )
|
||||
q++;
|
||||
|
||||
pair->glyph1 = afm_atoindex( &q, limit, type1 );
|
||||
pair->glyph2 = afm_atoindex( &q, limit, type1 );
|
||||
pair->kerning.x = afm_atoi( &q, limit );
|
||||
|
||||
pair->kerning.y = 0;
|
||||
if ( p[2] != 'X' )
|
||||
pair->kerning.y = afm_atoi( &q, limit );
|
||||
|
||||
pair++;
|
||||
}
|
||||
}
|
||||
|
||||
/* now, sort the kern pairs according to their glyph indices */
|
||||
qsort( afm->kern_pairs, count, sizeof ( CID_Kern_Pair ),
|
||||
compare_kern_pairs );
|
||||
|
||||
Exit:
|
||||
if ( error )
|
||||
FREE( afm );
|
||||
|
||||
FORGET_Frame();
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/* find the kerning for a given glyph pair */
|
||||
LOCAL_FUNC
|
||||
void CID_Get_Kerning( CID_AFM* afm,
|
||||
FT_UInt glyph1,
|
||||
FT_UInt glyph2,
|
||||
FT_Vector* kerning )
|
||||
{
|
||||
CID_Kern_Pair *min, *mid, *max;
|
||||
FT_ULong index = KERN_INDEX( glyph1, glyph2 );
|
||||
|
||||
|
||||
/* simple binary search */
|
||||
min = afm->kern_pairs;
|
||||
max = min + afm->num_pairs - 1;
|
||||
|
||||
while ( min <= max )
|
||||
{
|
||||
FT_ULong midi;
|
||||
|
||||
|
||||
mid = min + ( max - min ) / 2;
|
||||
midi = KERN_INDEX( mid->glyph1, mid->glyph2 );
|
||||
if ( midi == index )
|
||||
{
|
||||
*kerning = mid->kerning;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( midi < index )
|
||||
min = mid + 1;
|
||||
else
|
||||
max = mid - 1;
|
||||
}
|
||||
|
||||
kerning->x = 0;
|
||||
kerning->y = 0;
|
||||
}
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,78 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* cidafm.h */
|
||||
/* */
|
||||
/* AFM support for CID-keyed fonts (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef CIDAFM_H
|
||||
#define CIDAFM_H
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "cidobjs.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <cid/cidobjs.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct CID_Kern_Pair_
|
||||
{
|
||||
FT_UInt glyph1;
|
||||
FT_UInt glyph2;
|
||||
FT_Vector kerning;
|
||||
|
||||
} CID_Kern_Pair;
|
||||
|
||||
typedef struct CID_AFM_
|
||||
{
|
||||
FT_UInt num_pairs;
|
||||
CID_Kern_Pair* kern_pairs;
|
||||
|
||||
} CID_AFM;
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error CID_Read_AFM( FT_Face cid_face,
|
||||
FT_Stream stream );
|
||||
|
||||
LOCAL_DEF
|
||||
void CID_Done_AFM( FT_Memory memory,
|
||||
CID_AFM* afm );
|
||||
|
||||
LOCAL_DEF
|
||||
void CID_Get_Kerning( CID_AFM* afm,
|
||||
FT_UInt glyph1,
|
||||
FT_UInt glyph2,
|
||||
FT_Vector* kerning );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* CIDAFM_H */
|
||||
|
||||
|
||||
/* END */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,198 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* cidgload.h */
|
||||
/* */
|
||||
/* OpenType Glyph Loader (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef CIDGLOAD_H
|
||||
#define CIDGLOAD_H
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "cidobjs.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <cid/cidobjs.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Structure> */
|
||||
/* CID_Builder */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used during glyph loading to store its outline. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* memory :: The current memory object. */
|
||||
/* */
|
||||
/* face :: The current face object. */
|
||||
/* */
|
||||
/* glyph :: The current glyph slot. */
|
||||
/* */
|
||||
/* current :: The current glyph outline. */
|
||||
/* */
|
||||
/* base :: The base glyph outline. */
|
||||
/* */
|
||||
/* max_points :: maximum points in builder outline */
|
||||
/* */
|
||||
/* max_contours :: Maximal number of contours in builder outline. */
|
||||
/* */
|
||||
/* last :: The last point position. */
|
||||
/* */
|
||||
/* scale_x :: The horizontal scale (FUnits to sub-pixels). */
|
||||
/* */
|
||||
/* scale_y :: The vertical scale (FUnits to sub-pixels). */
|
||||
/* */
|
||||
/* pos_x :: The horizontal translation (if composite glyph). */
|
||||
/* */
|
||||
/* pos_y :: The vertical translation (if composite glyph). */
|
||||
/* */
|
||||
/* left_bearing :: The left side bearing point. */
|
||||
/* */
|
||||
/* advance :: The horizontal advance vector. */
|
||||
/* */
|
||||
/* bbox :: Unused. */
|
||||
/* */
|
||||
/* path_begun :: A flag which indicates that a new path has begun. */
|
||||
/* */
|
||||
/* load_points :: If this flag is not set, no points are loaded. */
|
||||
/* */
|
||||
/* no_recurse :: Set but not used. */
|
||||
/* */
|
||||
/* error :: An error code that is only used to report memory */
|
||||
/* allocation problems. */
|
||||
/* */
|
||||
/* metrics_only :: A boolean indicating that we only want to compute */
|
||||
/* the metrics of a given glyph, not load all of its */
|
||||
/* points. */
|
||||
/* */
|
||||
typedef struct CID_Builder_
|
||||
{
|
||||
FT_Memory memory;
|
||||
CID_Face face;
|
||||
CID_GlyphSlot glyph;
|
||||
FT_GlyphLoader* loader;
|
||||
FT_Outline* base;
|
||||
FT_Outline* current;
|
||||
|
||||
FT_Vector last;
|
||||
|
||||
FT_Fixed scale_x;
|
||||
FT_Fixed scale_y;
|
||||
|
||||
FT_Pos pos_x;
|
||||
FT_Pos pos_y;
|
||||
|
||||
FT_Vector left_bearing;
|
||||
FT_Vector advance;
|
||||
|
||||
FT_BBox bbox; /* bounding box */
|
||||
FT_Bool path_begun;
|
||||
FT_Bool load_points;
|
||||
FT_Bool no_recurse;
|
||||
|
||||
FT_Error error; /* only used for memory errors */
|
||||
FT_Bool metrics_only;
|
||||
|
||||
} CID_Builder;
|
||||
|
||||
|
||||
/* execution context charstring zone */
|
||||
|
||||
typedef struct CID_Decoder_Zone_
|
||||
{
|
||||
FT_Byte* base;
|
||||
FT_Byte* limit;
|
||||
FT_Byte* cursor;
|
||||
|
||||
} CID_Decoder_Zone;
|
||||
|
||||
|
||||
typedef struct CID_Decoder_
|
||||
{
|
||||
CID_Builder builder;
|
||||
|
||||
FT_Int stack[T1_MAX_CHARSTRINGS_OPERANDS];
|
||||
FT_Int* top;
|
||||
|
||||
CID_Decoder_Zone zones[T1_MAX_SUBRS_CALLS + 1];
|
||||
CID_Decoder_Zone* zone;
|
||||
|
||||
FT_Matrix font_matrix;
|
||||
CID_Subrs* subrs;
|
||||
FT_UInt lenIV;
|
||||
|
||||
FT_Int flex_state;
|
||||
FT_Int num_flex_vectors;
|
||||
FT_Vector flex_vectors[7];
|
||||
|
||||
} CID_Decoder;
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
void CID_Init_Builder( CID_Builder* builder,
|
||||
CID_Face face,
|
||||
CID_Size size,
|
||||
CID_GlyphSlot glyph );
|
||||
|
||||
LOCAL_DEF
|
||||
void CID_Done_Builder( CID_Builder* builder );
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
void CID_Init_Decoder( CID_Decoder* decoder );
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
/* Compute the maximum advance width of a font through quick parsing */
|
||||
LOCAL_DEF
|
||||
FT_Error CID_Compute_Max_Advance( CID_Face face,
|
||||
FT_Int* max_advance );
|
||||
|
||||
#endif
|
||||
|
||||
/* This function is exported, because it is used by the T1Dump utility */
|
||||
LOCAL_DEF
|
||||
FT_Error CID_Parse_CharStrings( CID_Decoder* decoder,
|
||||
FT_Byte* charstring_base,
|
||||
FT_Int charstring_len );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error CID_Load_Glyph( CID_GlyphSlot glyph,
|
||||
CID_Size size,
|
||||
FT_Int glyph_index,
|
||||
FT_Int load_flags );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* CIDGLOAD_H */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,537 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* cidload.c */
|
||||
/* */
|
||||
/* CID-keyed Type1 font loader (body). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#include <freetype/internal/ftdebug.h>
|
||||
#include <freetype/config/ftconfig.h>
|
||||
#include <freetype/ftmm.h>
|
||||
|
||||
#include <freetype/internal/t1types.h>
|
||||
#include <freetype/internal/t1errors.h>
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "cidload.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <cid/cidload.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h> /* for isspace(), isalnum() */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
|
||||
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
|
||||
/* messages during execution. */
|
||||
/* */
|
||||
#undef FT_COMPONENT
|
||||
#define FT_COMPONENT trace_cidload
|
||||
|
||||
|
||||
/* read a single offset */
|
||||
LOCAL_FUNC
|
||||
FT_Long cid_get_offset( FT_Byte** start,
|
||||
FT_Byte offsize )
|
||||
{
|
||||
FT_Long result;
|
||||
FT_Byte* p = *start;
|
||||
|
||||
|
||||
for ( result = 0; offsize > 0; offsize-- )
|
||||
{
|
||||
result <<= 8;
|
||||
result |= *p++;
|
||||
}
|
||||
|
||||
*start = p;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
void cid_decrypt( FT_Byte* buffer,
|
||||
FT_Int length,
|
||||
FT_UShort seed )
|
||||
{
|
||||
while ( length > 0 )
|
||||
{
|
||||
FT_Byte plain;
|
||||
|
||||
|
||||
plain = ( *buffer ^ ( seed >> 8 ) );
|
||||
seed = ( *buffer + seed ) * 52845 + 22719;
|
||||
*buffer++ = plain;
|
||||
length--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/***** *****/
|
||||
/***** TYPE 1 SYMBOL PARSING *****/
|
||||
/***** *****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
static
|
||||
FT_Error cid_load_keyword( CID_Face face,
|
||||
CID_Loader* loader,
|
||||
const CID_Field_Rec* keyword )
|
||||
{
|
||||
FT_Error error;
|
||||
CID_Parser* parser = &loader->parser;
|
||||
FT_Byte* object;
|
||||
CID_Info* cid = &face->cid;
|
||||
|
||||
|
||||
/* if the keyword has a dedicated callback, call it */
|
||||
if ( keyword->type == t1_field_callback )
|
||||
{
|
||||
error = keyword->reader( face, parser );
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
/* we must now compute the address of our target object */
|
||||
switch ( keyword->location )
|
||||
{
|
||||
case t1_field_cid_info:
|
||||
object = (FT_Byte*)cid;
|
||||
break;
|
||||
|
||||
case t1_field_font_info:
|
||||
object = (FT_Byte*)&cid->font_info;
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
CID_FontDict* dict;
|
||||
|
||||
|
||||
if ( parser->num_dict < 0 )
|
||||
{
|
||||
FT_ERROR(( "cid_load_keyword: invalid use of `%s'!\n",
|
||||
keyword->ident ));
|
||||
error = T1_Err_Syntax_Error;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
dict = cid->font_dicts + parser->num_dict;
|
||||
switch ( keyword->location )
|
||||
{
|
||||
case t1_field_private:
|
||||
object = (FT_Byte*)&dict->private_dict;
|
||||
break;
|
||||
|
||||
default:
|
||||
object = (FT_Byte*)dict;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* now, load the keyword data in the object's field(s) */
|
||||
if ( keyword->type == t1_field_integer_array ||
|
||||
keyword->type == t1_field_fixed_array )
|
||||
error = CID_Load_Field_Table( parser, keyword, object );
|
||||
else
|
||||
error = CID_Load_Field( parser, keyword, object );
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
FT_Error parse_font_bbox( CID_Face face,
|
||||
CID_Parser* parser )
|
||||
{
|
||||
FT_Short temp[4];
|
||||
FT_BBox* bbox = &face->cid.font_bbox;
|
||||
|
||||
|
||||
(void)CID_ToCoordArray( parser, 4, temp );
|
||||
bbox->xMin = temp[0];
|
||||
bbox->yMin = temp[1];
|
||||
bbox->xMax = temp[2];
|
||||
bbox->yMax = temp[3];
|
||||
|
||||
return T1_Err_Ok; /* this is a callback function; */
|
||||
/* we must return an error code */
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
FT_Error parse_font_matrix( CID_Face face,
|
||||
CID_Parser* parser )
|
||||
{
|
||||
FT_Matrix* matrix;
|
||||
CID_FontDict* dict;
|
||||
FT_Fixed temp[4];
|
||||
|
||||
|
||||
if ( parser->num_dict >= 0 )
|
||||
{
|
||||
dict = face->cid.font_dicts + parser->num_dict;
|
||||
matrix = &dict->font_matrix;
|
||||
|
||||
(void)CID_ToFixedArray( parser, 4, temp, 3 );
|
||||
matrix->xx = temp[0];
|
||||
matrix->yx = temp[1];
|
||||
matrix->xy = temp[2];
|
||||
matrix->yy = temp[3];
|
||||
}
|
||||
|
||||
return T1_Err_Ok; /* this is a callback function; */
|
||||
/* we must return an error code */
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
FT_Error parse_fd_array( CID_Face face,
|
||||
CID_Parser* parser )
|
||||
{
|
||||
CID_Info* cid = &face->cid;
|
||||
FT_Memory memory = face->root.memory;
|
||||
FT_Error error = T1_Err_Ok;
|
||||
FT_Long num_dicts;
|
||||
|
||||
|
||||
num_dicts = CID_ToInt( parser );
|
||||
|
||||
if ( !cid->font_dicts )
|
||||
{
|
||||
FT_Int n;
|
||||
|
||||
|
||||
if ( ALLOC_ARRAY( cid->font_dicts, num_dicts, CID_FontDict ) )
|
||||
goto Exit;
|
||||
|
||||
cid->num_dicts = (FT_UInt)num_dicts;
|
||||
|
||||
/* don't forget to set a few defaults */
|
||||
for ( n = 0; n < cid->num_dicts; n++ )
|
||||
{
|
||||
CID_FontDict* dict = cid->font_dicts + n;
|
||||
|
||||
|
||||
/* default value for lenIV */
|
||||
dict->private_dict.lenIV = 4;
|
||||
}
|
||||
}
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
const CID_Field_Rec t1_field_records[] =
|
||||
{
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "cidtokens.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <cid/cidtokens.h>
|
||||
|
||||
#endif
|
||||
|
||||
{ 0, t1_field_cid_info, t1_field_none, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
|
||||
static
|
||||
int is_alpha( char c )
|
||||
{
|
||||
return ( isalnum( c ) ||
|
||||
c == '.' ||
|
||||
c == '_' );
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void skip_whitespace( CID_Parser* parser )
|
||||
{
|
||||
FT_Byte* cur = parser->cursor;
|
||||
|
||||
|
||||
while ( cur < parser->limit && isspace( *cur ) )
|
||||
cur++;
|
||||
|
||||
parser->cursor = cur;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
FT_Error parse_dict( CID_Face face,
|
||||
CID_Loader* loader,
|
||||
FT_Byte* base,
|
||||
FT_Long size )
|
||||
{
|
||||
CID_Parser* parser = &loader->parser;
|
||||
|
||||
|
||||
parser->cursor = base;
|
||||
parser->limit = base + size;
|
||||
parser->error = 0;
|
||||
|
||||
{
|
||||
FT_Byte* cur = base;
|
||||
FT_Byte* limit = cur + size;
|
||||
|
||||
|
||||
for ( ;cur < limit; cur++ )
|
||||
{
|
||||
/* look for `%ADOBeginFontDict' */
|
||||
if ( *cur == '%' && cur + 20 < limit &&
|
||||
strncmp( (char*)cur, "%ADOBeginFontDict", 17 ) == 0 )
|
||||
{
|
||||
cur += 17;
|
||||
|
||||
/* if /FDArray was found, then cid->num_dicts is > 0, and */
|
||||
/* we can start increasing parser->num_dict */
|
||||
if ( face->cid.num_dicts > 0 )
|
||||
parser->num_dict++;
|
||||
}
|
||||
/* look for immediates */
|
||||
else if ( *cur == '/' && cur + 2 < limit )
|
||||
{
|
||||
FT_Byte* cur2;
|
||||
FT_Int len;
|
||||
|
||||
|
||||
cur++;
|
||||
|
||||
cur2 = cur;
|
||||
while ( cur2 < limit && is_alpha( *cur2 ) )
|
||||
cur2++;
|
||||
|
||||
len = cur2 - cur;
|
||||
if ( len > 0 && len < 22 )
|
||||
{
|
||||
/* now compare the immediate name to the keyword table */
|
||||
const CID_Field_Rec* keyword = t1_field_records;
|
||||
|
||||
|
||||
for (;;)
|
||||
{
|
||||
FT_Byte* name;
|
||||
|
||||
|
||||
name = (FT_Byte*)keyword->ident;
|
||||
if ( !name )
|
||||
break;
|
||||
|
||||
if ( cur[0] == name[0] &&
|
||||
len == (FT_Int)strlen( (const char*)name ) )
|
||||
{
|
||||
FT_Int n;
|
||||
|
||||
|
||||
for ( n = 1; n < len; n++ )
|
||||
if ( cur[n] != name[n] )
|
||||
break;
|
||||
|
||||
if ( n >= len )
|
||||
{
|
||||
/* we found it - run the parsing callback */
|
||||
parser->cursor = cur2;
|
||||
skip_whitespace( parser );
|
||||
parser->error = cid_load_keyword( face, loader, keyword );
|
||||
if ( parser->error )
|
||||
return parser->error;
|
||||
|
||||
cur = parser->cursor;
|
||||
break;
|
||||
}
|
||||
}
|
||||
keyword++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return parser->error;
|
||||
}
|
||||
|
||||
|
||||
/* read the subrmap and the subrs of each font dict */
|
||||
static
|
||||
FT_Error cid_read_subrs( CID_Face face )
|
||||
{
|
||||
CID_Info* cid = &face->cid;
|
||||
FT_Memory memory = face->root.memory;
|
||||
FT_Stream stream = face->root.stream;
|
||||
FT_Error error;
|
||||
FT_Int n;
|
||||
CID_Subrs* subr;
|
||||
FT_UInt max_offsets = 0;
|
||||
FT_ULong* offsets = 0;
|
||||
|
||||
|
||||
if ( ALLOC_ARRAY( face->subrs, cid->num_dicts, CID_Subrs ) )
|
||||
goto Exit;
|
||||
|
||||
subr = face->subrs;
|
||||
for ( n = 0; n < cid->num_dicts; n++, subr++ )
|
||||
{
|
||||
CID_FontDict* dict = cid->font_dicts + n;
|
||||
FT_UInt count, num_subrs = dict->num_subrs;
|
||||
FT_ULong data_len;
|
||||
FT_Byte* p;
|
||||
|
||||
|
||||
/* reallocate offsets array if needed */
|
||||
if ( num_subrs + 1 > max_offsets )
|
||||
{
|
||||
FT_UInt new_max = ( num_subrs + 1 + 3 ) & -4;
|
||||
|
||||
|
||||
if ( REALLOC_ARRAY( offsets, max_offsets, new_max, FT_ULong ) )
|
||||
goto Fail;
|
||||
|
||||
max_offsets = new_max;
|
||||
}
|
||||
|
||||
/* read the subrmap's offsets */
|
||||
if ( FILE_Seek( cid->data_offset + dict->subrmap_offset ) ||
|
||||
ACCESS_Frame( ( num_subrs + 1 ) * dict->sd_bytes ) )
|
||||
goto Fail;
|
||||
|
||||
p = (FT_Byte*)stream->cursor;
|
||||
for ( count = 0; count <= num_subrs; count++ )
|
||||
offsets[count] = cid_get_offset( &p, (FT_Byte)dict->sd_bytes );
|
||||
|
||||
FORGET_Frame();
|
||||
|
||||
/* now, compute the size of subrs charstrings, */
|
||||
/* allocate, and read them */
|
||||
data_len = offsets[num_subrs] - offsets[0];
|
||||
|
||||
if ( ALLOC_ARRAY( subr->code, num_subrs + 1, FT_Byte* ) ||
|
||||
ALLOC( subr->code[0], data_len ) )
|
||||
goto Fail;
|
||||
|
||||
if ( FILE_Seek( cid->data_offset + offsets[0] ) ||
|
||||
FILE_Read( subr->code[0], data_len ) )
|
||||
goto Exit;
|
||||
|
||||
/* set up pointers */
|
||||
for ( count = 1; count <= num_subrs; count++ )
|
||||
{
|
||||
FT_UInt len;
|
||||
|
||||
|
||||
len = offsets[count] - offsets[count - 1];
|
||||
subr->code[count] = subr->code[count - 1] + len;
|
||||
}
|
||||
|
||||
/* decrypt subroutines */
|
||||
for ( count = 0; count < num_subrs; count++ )
|
||||
{
|
||||
FT_UInt len;
|
||||
|
||||
|
||||
len = offsets[count + 1] - offsets[count];
|
||||
cid_decrypt( subr->code[count], len, 4330 );
|
||||
}
|
||||
|
||||
subr->num_subrs = num_subrs;
|
||||
}
|
||||
|
||||
Exit:
|
||||
FREE( offsets );
|
||||
return error;
|
||||
|
||||
Fail:
|
||||
if ( face->subrs )
|
||||
{
|
||||
for ( n = 0; n < cid->num_dicts; n++ )
|
||||
{
|
||||
if ( face->subrs[n].code )
|
||||
FREE( face->subrs[n].code[0] );
|
||||
|
||||
FREE( face->subrs[n].code );
|
||||
}
|
||||
FREE( face->subrs );
|
||||
}
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void t1_init_loader( CID_Loader* loader,
|
||||
CID_Face face )
|
||||
{
|
||||
FT_UNUSED( face );
|
||||
|
||||
MEM_Set( loader, 0, sizeof ( *loader ) );
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void t1_done_loader( CID_Loader* loader )
|
||||
{
|
||||
CID_Parser* parser = &loader->parser;
|
||||
|
||||
|
||||
/* finalize parser */
|
||||
CID_Done_Parser( parser );
|
||||
}
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
FT_Error CID_Open_Face( CID_Face face )
|
||||
{
|
||||
CID_Loader loader;
|
||||
CID_Parser* parser;
|
||||
FT_Error error;
|
||||
|
||||
|
||||
t1_init_loader( &loader, face );
|
||||
|
||||
parser = &loader.parser;
|
||||
error = CID_New_Parser( parser, face->root.stream, face->root.memory );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
error = parse_dict( face, &loader,
|
||||
parser->postscript,
|
||||
parser->postscript_len );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
face->cid.data_offset = loader.parser.data_offset;
|
||||
error = cid_read_subrs( face );
|
||||
|
||||
Exit:
|
||||
t1_done_loader( &loader );
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,70 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* cidload.h */
|
||||
/* */
|
||||
/* CID-keyed Type1 font loader (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef CIDLOAD_H
|
||||
#define CIDLOAD_H
|
||||
|
||||
#include <freetype/internal/ftstream.h>
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "cidparse.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <cid/cidparse.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct CID_Loader_
|
||||
{
|
||||
CID_Parser parser; /* parser used to read the stream */
|
||||
FT_Int num_chars; /* number of characters in encoding */
|
||||
|
||||
} CID_Loader;
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Long cid_get_offset( FT_Byte** start,
|
||||
FT_Byte offsize );
|
||||
|
||||
LOCAL_DEF
|
||||
void cid_decrypt( FT_Byte* buffer,
|
||||
FT_Int length,
|
||||
FT_UShort seed );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error CID_Open_Face( CID_Face face );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* CIDLOAD_H */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,380 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* cidobjs.c */
|
||||
/* */
|
||||
/* CID objects manager (body). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#include <freetype/internal/ftdebug.h>
|
||||
#include <freetype/internal/ftstream.h>
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "cidgload.h"
|
||||
#include "cidload.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <cid/cidgload.h>
|
||||
#include <cid/cidload.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#include <freetype/internal/psnames.h>
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
|
||||
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
|
||||
/* messages during execution. */
|
||||
/* */
|
||||
#undef FT_COMPONENT
|
||||
#define FT_COMPONENT trace_cidobjs
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* FACE FUNCTIONS */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* CID_Done_Face */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Finalizes a given face object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A pointer to the face object to destroy. */
|
||||
/* */
|
||||
LOCAL_FUNC
|
||||
void CID_Done_Face( CID_Face face )
|
||||
{
|
||||
FT_Memory memory;
|
||||
|
||||
|
||||
if ( face )
|
||||
{
|
||||
CID_Info* cid = &face->cid;
|
||||
T1_FontInfo* info = &cid->font_info;
|
||||
|
||||
|
||||
memory = face->root.memory;
|
||||
|
||||
/* release FontInfo strings */
|
||||
FREE( info->version );
|
||||
FREE( info->notice );
|
||||
FREE( info->full_name );
|
||||
FREE( info->family_name );
|
||||
FREE( info->weight );
|
||||
|
||||
/* release font dictionaries */
|
||||
FREE( cid->font_dicts );
|
||||
cid->num_dicts = 0;
|
||||
|
||||
/* release other strings */
|
||||
FREE( cid->cid_font_name );
|
||||
FREE( cid->registry );
|
||||
FREE( cid->ordering );
|
||||
|
||||
face->root.family_name = 0;
|
||||
face->root.style_name = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* CID_Init_Face */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Initializes a given CID face object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* stream :: The source font stream. */
|
||||
/* */
|
||||
/* face_index :: The index of the font face in the resource. */
|
||||
/* */
|
||||
/* num_params :: Number of additional generic parameters. Ignored. */
|
||||
/* */
|
||||
/* params :: Additional generic parameters. Ignored. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* face :: The newly built face object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
LOCAL_FUNC
|
||||
FT_Error CID_Init_Face( FT_Stream stream,
|
||||
CID_Face face,
|
||||
FT_Int face_index,
|
||||
FT_Int num_params,
|
||||
FT_Parameter* params )
|
||||
{
|
||||
FT_Error error;
|
||||
PSNames_Interface* psnames;
|
||||
|
||||
FT_UNUSED( num_params );
|
||||
FT_UNUSED( params );
|
||||
FT_UNUSED( face_index );
|
||||
FT_UNUSED( stream );
|
||||
|
||||
|
||||
face->root.num_faces = 1;
|
||||
|
||||
psnames = (PSNames_Interface*)face->psnames;
|
||||
if ( !psnames )
|
||||
{
|
||||
psnames = (PSNames_Interface*)FT_Get_Module_Interface(
|
||||
FT_FACE_LIBRARY( face ), "psnames" );
|
||||
|
||||
face->psnames = psnames;
|
||||
}
|
||||
|
||||
/* open the tokenizer; this will also check the font format */
|
||||
if ( FILE_Seek( 0 ) )
|
||||
goto Exit;
|
||||
|
||||
error = CID_Open_Face( face );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
/* if we just wanted to check the format, leave successfully now */
|
||||
if ( face_index < 0 )
|
||||
goto Exit;
|
||||
|
||||
/* check the face index */
|
||||
if ( face_index != 0 )
|
||||
{
|
||||
FT_ERROR(( "CID_Init_Face: invalid face index\n" ));
|
||||
error = T1_Err_Invalid_Argument;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
/* Now, load the font program into the face object */
|
||||
{
|
||||
/* Init the face object fields */
|
||||
/* Now set up root face fields */
|
||||
{
|
||||
FT_Face root = (FT_Face)&face->root;
|
||||
|
||||
|
||||
root->num_glyphs = face->cid.cid_count;
|
||||
root->num_charmaps = 0;
|
||||
|
||||
root->face_index = face_index;
|
||||
root->face_flags = FT_FACE_FLAG_SCALABLE;
|
||||
|
||||
root->face_flags |= FT_FACE_FLAG_HORIZONTAL;
|
||||
|
||||
if ( face->cid.font_info.is_fixed_pitch )
|
||||
root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
|
||||
|
||||
/* XXX: TODO: add kerning with .afm support */
|
||||
|
||||
/* get style name -- be careful, some broken fonts only */
|
||||
/* have a /FontName dictionary entry! */
|
||||
root->family_name = face->cid.font_info.family_name;
|
||||
if ( root->family_name )
|
||||
{
|
||||
char* full = face->cid.font_info.full_name;
|
||||
char* family = root->family_name;
|
||||
|
||||
while ( *family && *full == *family )
|
||||
{
|
||||
family++;
|
||||
full++;
|
||||
}
|
||||
|
||||
root->style_name = ( *full == ' ' ) ? full + 1
|
||||
: (char *)"Regular";
|
||||
}
|
||||
else
|
||||
{
|
||||
/* do we have a `/FontName'? */
|
||||
if ( face->cid.cid_font_name )
|
||||
{
|
||||
root->family_name = face->cid.cid_font_name;
|
||||
root->style_name = "Regular";
|
||||
}
|
||||
}
|
||||
|
||||
/* no embedded bitmap support */
|
||||
root->num_fixed_sizes = 0;
|
||||
root->available_sizes = 0;
|
||||
|
||||
root->bbox = face->cid.font_bbox;
|
||||
root->units_per_EM = 1000;
|
||||
root->ascender = (FT_Short)face->cid.font_bbox.yMax;
|
||||
root->descender = -(FT_Short)face->cid.font_bbox.yMin;
|
||||
root->height = ( ( root->ascender + root->descender ) * 12 )
|
||||
/ 10;
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
/* now compute the maximum advance width */
|
||||
|
||||
root->max_advance_width = face->type1.private_dict.standard_width[0];
|
||||
|
||||
/* compute max advance width for proportional fonts */
|
||||
if ( !face->type1.font_info.is_fixed_pitch )
|
||||
{
|
||||
FT_Int max_advance;
|
||||
|
||||
|
||||
error = CID_Compute_Max_Advance( face, &max_advance );
|
||||
|
||||
/* in case of error, keep the standard width */
|
||||
if ( !error )
|
||||
root->max_advance_width = max_advance;
|
||||
else
|
||||
error = 0; /* clear error */
|
||||
}
|
||||
|
||||
root->max_advance_height = root->height;
|
||||
|
||||
#endif /* 0 */
|
||||
|
||||
root->underline_position = face->cid.font_info.underline_position;
|
||||
root->underline_thickness = face->cid.font_info.underline_thickness;
|
||||
|
||||
root->max_points = 0;
|
||||
root->max_contours = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
/* charmap support - synthetize unicode charmap when possible */
|
||||
{
|
||||
FT_Face root = &face->root;
|
||||
FT_CharMap charmap = face->charmaprecs;
|
||||
|
||||
|
||||
/* synthesize a Unicode charmap if there is support in the `psnames' */
|
||||
/* module */
|
||||
if ( face->psnames )
|
||||
{
|
||||
PSNames_Interface* psnames = (PSNames_Interface*)face->psnames;
|
||||
|
||||
|
||||
if ( psnames->unicode_value )
|
||||
{
|
||||
error = psnames->build_unicodes(
|
||||
root->memory,
|
||||
face->type1.num_glyphs,
|
||||
(const char**)face->type1.glyph_names,
|
||||
&face->unicode_map );
|
||||
if ( !error )
|
||||
{
|
||||
root->charmap = charmap;
|
||||
charmap->face = (FT_Face)face;
|
||||
charmap->encoding = ft_encoding_unicode;
|
||||
charmap->platform_id = 3;
|
||||
charmap->encoding_id = 1;
|
||||
charmap++;
|
||||
}
|
||||
|
||||
/* simply clear the error in case of failure (which really */
|
||||
/* means that out of memory or no unicode glyph names) */
|
||||
error = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* now, support either the standard, expert, or custom encodings */
|
||||
charmap->face = (FT_Face)face;
|
||||
charmap->platform_id = 7; /* a new platform id for Adobe fonts? */
|
||||
|
||||
switch ( face->type1.encoding_type )
|
||||
{
|
||||
case t1_encoding_standard:
|
||||
charmap->encoding = ft_encoding_adobe_standard;
|
||||
charmap->encoding_id = 0;
|
||||
break;
|
||||
|
||||
case t1_encoding_expert:
|
||||
charmap->encoding = ft_encoding_adobe_expert;
|
||||
charmap->encoding_id = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
charmap->encoding = ft_encoding_adobe_custom;
|
||||
charmap->encoding_id = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
root->charmaps = face->charmaps;
|
||||
root->num_charmaps = charmap - face->charmaprecs + 1;
|
||||
face->charmaps[0] = &face->charmaprecs[0];
|
||||
face->charmaps[1] = &face->charmaprecs[1];
|
||||
}
|
||||
|
||||
#endif /* 0 */
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* CID_Init_Driver */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Initializes a given CID driver object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* driver :: A handle to the target driver object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
LOCAL_FUNC
|
||||
FT_Error CID_Init_Driver( CID_Driver driver )
|
||||
{
|
||||
FT_UNUSED( driver );
|
||||
|
||||
return T1_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* CID_Done_Driver */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Finalizes a given CID driver. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* driver :: A handle to the target CID driver. */
|
||||
/* */
|
||||
LOCAL_DEF
|
||||
void CID_Done_Driver( CID_Driver driver )
|
||||
{
|
||||
FT_UNUSED( driver );
|
||||
}
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,141 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* cidobjs.h */
|
||||
/* */
|
||||
/* CID objects manager (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef CIDOBJS_H
|
||||
#define CIDOBJS_H
|
||||
|
||||
#include <freetype/internal/ftobjs.h>
|
||||
#include <freetype/config/ftconfig.h>
|
||||
#include <freetype/internal/t1errors.h>
|
||||
#include <freetype/internal/t1types.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* The following structures must be defined by the hinter */
|
||||
typedef struct CID_Size_Hints_ CID_Size_Hints;
|
||||
typedef struct CID_Glyph_Hints_ CID_Glyph_Hints;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* CID_Driver */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to a Type 1 driver object. */
|
||||
/* */
|
||||
typedef struct CID_DriverRec_* CID_Driver;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* CID_Size */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to a Type 1 size object. */
|
||||
/* */
|
||||
typedef struct CID_SizeRec_* CID_Size;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* CID_GlyphSlot */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to a Type 1 glyph slot object. */
|
||||
/* */
|
||||
typedef struct CID_GlyphSlotRec_* CID_GlyphSlot;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* CID_CharMap */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to a Type 1 character mapping object. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The Type 1 format doesn't use a charmap but an encoding table. */
|
||||
/* The driver is responsible for making up charmap objects */
|
||||
/* corresponding to these tables. */
|
||||
/* */
|
||||
typedef struct CID_CharMapRec_* CID_CharMap;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* HERE BEGINS THE TYPE 1 SPECIFIC STUFF */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
typedef struct CID_SizeRec_
|
||||
{
|
||||
FT_SizeRec root;
|
||||
FT_Bool valid;
|
||||
|
||||
} CID_SizeRec;
|
||||
|
||||
|
||||
typedef struct CID_GlyphSlotRec_
|
||||
{
|
||||
FT_GlyphSlotRec root;
|
||||
|
||||
FT_Bool hint;
|
||||
FT_Bool scaled;
|
||||
|
||||
FT_Fixed x_scale;
|
||||
FT_Fixed y_scale;
|
||||
|
||||
} CID_GlyphSlotRec;
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error CID_Init_Face( FT_Stream stream,
|
||||
CID_Face face,
|
||||
FT_Int face_index,
|
||||
FT_Int num_params,
|
||||
FT_Parameter* params );
|
||||
|
||||
LOCAL_DEF
|
||||
void CID_Done_Face( CID_Face face );
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error CID_Init_Driver( CID_Driver driver );
|
||||
|
||||
LOCAL_DEF
|
||||
void CID_Done_Driver( CID_Driver driver );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* CIDOBJS_H */
|
||||
|
||||
|
||||
/* END */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,353 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* cidparse.h */
|
||||
/* */
|
||||
/* CID-keyed Type1 parser (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef CIDPARSE_H
|
||||
#define CIDPARSE_H
|
||||
|
||||
#include <freetype/internal/t1types.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* CID_Table */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A CID_Table is a simple object used to store an array of objects */
|
||||
/* in a single memory block. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* block :: The address in memory of the growheap's block. This */
|
||||
/* can change between two object adds, due to the use */
|
||||
/* of `realloc()'. */
|
||||
/* */
|
||||
/* cursor :: The current top of the growheap within its block. */
|
||||
/* */
|
||||
/* capacity :: The current size of the heap block. Increments by */
|
||||
/* blocks of 1 kByte. */
|
||||
/* */
|
||||
/* init :: A boolean. Set when the table has been initialized */
|
||||
/* (the table user should set this field). */
|
||||
/* */
|
||||
/* max_elems :: The maximal number of elements in the table. */
|
||||
/* */
|
||||
/* num_elems :: The current number of elements (in use) in the table. */
|
||||
/* */
|
||||
/* elements :: A table of element addresses within the block. */
|
||||
/* */
|
||||
/* lengths :: A table of element sizes within the block. */
|
||||
/* */
|
||||
/* memory :: The memory object used for memory operations */
|
||||
/* (allocation resp. reallocation). */
|
||||
/* */
|
||||
typedef struct CID_Table_
|
||||
{
|
||||
FT_Byte* block; /* current memory block */
|
||||
FT_Int cursor; /* current cursor in memory block */
|
||||
FT_Int capacity; /* current size of memory block */
|
||||
FT_Long init;
|
||||
|
||||
FT_Int max_elems;
|
||||
FT_Int num_elems;
|
||||
FT_Byte** elements; /* addresses of table elements */
|
||||
FT_Int* lengths; /* lengths of table elements */
|
||||
|
||||
FT_Memory memory;
|
||||
|
||||
} CID_Table;
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error CID_New_Table( CID_Table* table,
|
||||
FT_Int count,
|
||||
CID_Memory memory );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error CID_Add_Table( CID_Table* table,
|
||||
FT_Int index,
|
||||
void* object,
|
||||
FT_Int length );
|
||||
|
||||
LOCAL_DEF
|
||||
void CID_Release_Table( CID_Table* table );
|
||||
|
||||
#endif /* 0 */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* CID_Parser */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A CID_Parser is an object used to parse a Type 1 fonts very */
|
||||
/* quickly. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* stream :: The current input stream. */
|
||||
/* */
|
||||
/* memory :: The current memory object. */
|
||||
/* */
|
||||
/* postscript :: A pointer to the data to be parsed. */
|
||||
/* */
|
||||
/* postscript_len :: The length of the data to be parsed. */
|
||||
/* */
|
||||
/* data_offset :: The start position of the binary data (i.e., the */
|
||||
/* end of the data to be parsed. */
|
||||
/* */
|
||||
/* cursor :: The current parser cursor. */
|
||||
/* */
|
||||
/* limit :: The current parser limit (i.e., the first byte */
|
||||
/* after the current dictionary). */
|
||||
/* */
|
||||
/* error :: The current parsing error. */
|
||||
/* */
|
||||
/* cid :: A structure which holds the information about */
|
||||
/* the current font. */
|
||||
/* */
|
||||
/* num_dict :: The number of font dictionaries. */
|
||||
/* */
|
||||
typedef struct CID_Parser_
|
||||
{
|
||||
FT_Stream stream;
|
||||
FT_Memory memory;
|
||||
|
||||
FT_Byte* postscript;
|
||||
FT_Int postscript_len;
|
||||
|
||||
FT_ULong data_offset;
|
||||
|
||||
FT_Byte* cursor;
|
||||
FT_Byte* limit;
|
||||
FT_Error error;
|
||||
|
||||
CID_Info* cid;
|
||||
FT_Int num_dict;
|
||||
|
||||
} CID_Parser;
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error CID_New_Parser( CID_Parser* parser,
|
||||
FT_Stream stream,
|
||||
FT_Memory memory );
|
||||
|
||||
LOCAL_DEF
|
||||
void CID_Done_Parser( CID_Parser* parser );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* PARSING ROUTINES */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Long CID_ToInt( CID_Parser* parser );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Int CID_ToCoordArray( CID_Parser* parser,
|
||||
FT_Int max_coords,
|
||||
FT_Short* coords );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Int CID_ToFixedArray( CID_Parser* parser,
|
||||
FT_Int max_values,
|
||||
FT_Fixed* values,
|
||||
FT_Int power_ten );
|
||||
|
||||
LOCAL_DEF
|
||||
void CID_Skip_Spaces( CID_Parser* parser );
|
||||
|
||||
|
||||
/* simple enumeration type used to identify token types */
|
||||
typedef enum CID_Token_Type_
|
||||
{
|
||||
t1_token_none = 0,
|
||||
t1_token_any,
|
||||
t1_token_string,
|
||||
t1_token_array,
|
||||
|
||||
/* do not remove */
|
||||
t1_token_max
|
||||
|
||||
} CID_Token_Type;
|
||||
|
||||
|
||||
/* a simple structure used to identify tokens */
|
||||
typedef struct CID_Token_Rec_
|
||||
{
|
||||
FT_Byte* start; /* first character of token in input stream */
|
||||
FT_Byte* limit; /* first character after the token */
|
||||
CID_Token_Type type; /* type of token */
|
||||
|
||||
} CID_Token_Rec;
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
void CID_ToToken( CID_Parser* parser,
|
||||
CID_Token_Rec* token );
|
||||
|
||||
|
||||
/* enumeration type used to identify object fields */
|
||||
typedef enum CID_Field_Type_
|
||||
{
|
||||
t1_field_none = 0,
|
||||
t1_field_bool,
|
||||
t1_field_integer,
|
||||
t1_field_fixed,
|
||||
t1_field_string,
|
||||
t1_field_integer_array,
|
||||
t1_field_fixed_array,
|
||||
t1_field_callback,
|
||||
|
||||
/* do not remove */
|
||||
t1_field_max
|
||||
|
||||
} CID_Field_Type;
|
||||
|
||||
typedef enum CID_Field_Location_
|
||||
{
|
||||
t1_field_cid_info,
|
||||
t1_field_font_dict,
|
||||
t1_field_font_info,
|
||||
t1_field_private,
|
||||
|
||||
/* do not remove */
|
||||
t1_field_location_max
|
||||
|
||||
} CID_Field_Location;
|
||||
|
||||
|
||||
typedef FT_Error (*CID_Field_Parser)( CID_Face face,
|
||||
CID_Parser* parser );
|
||||
|
||||
/* structure type used to model object fields */
|
||||
typedef struct CID_Field_Rec_
|
||||
{
|
||||
const char* ident; /* field identifier */
|
||||
CID_Field_Location location;
|
||||
CID_Field_Type type; /* type of field */
|
||||
CID_Field_Parser reader;
|
||||
FT_UInt offset; /* offset of field in object */
|
||||
FT_UInt size; /* size of field in bytes */
|
||||
FT_UInt array_max; /* maximal number of elements for */
|
||||
/* array */
|
||||
FT_UInt count_offset; /* offset of element count for */
|
||||
/* arrays */
|
||||
} CID_Field_Rec;
|
||||
|
||||
|
||||
#define CID_FIELD_REF( s, f ) ( ((s*)0)->f )
|
||||
|
||||
#define CID_NEW_SIMPLE_FIELD( _ident, _type, _fname ) \
|
||||
{ \
|
||||
_ident, T1CODE, _type, \
|
||||
0, \
|
||||
(FT_UInt)(char*)&CID_FIELD_REF( T1TYPE, _fname ), \
|
||||
sizeof ( CID_FIELD_REF( T1TYPE, _fname ) ), \
|
||||
0, 0 \
|
||||
},
|
||||
|
||||
#define CID_NEW_CALLBACK_FIELD( _ident, _reader ) \
|
||||
{ \
|
||||
_ident, T1CODE, t1_field_callback, \
|
||||
_reader, \
|
||||
0, 0, \
|
||||
0, 0 \
|
||||
},
|
||||
|
||||
#define CID_NEW_TABLE_FIELD( _ident, _type, _fname, _max ) \
|
||||
{ \
|
||||
_ident, T1CODE, _type, \
|
||||
0, \
|
||||
(FT_UInt)(char*)&CID_FIELD_REF( T1TYPE, _fname ), \
|
||||
sizeof ( CID_FIELD_REF( T1TYPE, _fname )[0] ), \
|
||||
_max, \
|
||||
(FT_UInt)(char*)&CID_FIELD_REF( T1TYPE, num_ ## _fname ) \
|
||||
},
|
||||
|
||||
#define CID_NEW_TABLE_FIELD2( _ident, _type, _fname, _max ) \
|
||||
{ \
|
||||
_ident, T1CODE, _type, \
|
||||
0, \
|
||||
(FT_UInt)(char*)&CID_FIELD_REF( T1TYPE, _fname ), \
|
||||
sizeof ( CID_FIELD_REF( T1TYPE, _fname )[0] ), \
|
||||
_max, 0 \
|
||||
},
|
||||
|
||||
|
||||
#define CID_FIELD_BOOL( _ident, _fname ) \
|
||||
CID_NEW_SIMPLE_FIELD( _ident, t1_field_bool, _fname )
|
||||
|
||||
#define CID_FIELD_NUM( _ident, _fname ) \
|
||||
CID_NEW_SIMPLE_FIELD( _ident, t1_field_integer, _fname )
|
||||
|
||||
#define CID_FIELD_FIXED( _ident, _fname ) \
|
||||
CID_NEW_SIMPLE_FIELD( _ident, t1_field_fixed, _fname )
|
||||
|
||||
#define CID_FIELD_STRING( _ident, _fname ) \
|
||||
CID_NEW_SIMPLE_FIELD( _ident, t1_field_string, _fname )
|
||||
|
||||
#define CID_FIELD_NUM_TABLE( _ident, _fname, _fmax ) \
|
||||
CID_NEW_TABLE_FIELD( _ident, t1_field_integer_array, \
|
||||
_fname, _fmax )
|
||||
|
||||
#define CID_FIELD_FIXED_TABLE( _ident, _fname, _fmax ) \
|
||||
CID_NEW_TABLE_FIELD( _ident, t1_field_fixed_array, \
|
||||
_fname, _fmax )
|
||||
|
||||
#define CID_FIELD_NUM_TABLE2( _ident, _fname, _fmax ) \
|
||||
CID_NEW_TABLE_FIELD2( _ident, t1_field_integer_array, \
|
||||
_fname, _fmax )
|
||||
|
||||
#define CID_FIELD_FIXED_TABLE2( _ident, _fname, _fmax ) \
|
||||
CID_NEW_TABLE_FIELD2( _ident, t1_field_fixed_array, \
|
||||
_fname, _fmax )
|
||||
|
||||
#define CID_FIELD_CALLBACK( _ident, _name ) \
|
||||
CID_NEW_CALLBACK_FIELD( _ident, parse_ ## _name )
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error CID_Load_Field( CID_Parser* parser,
|
||||
const CID_Field_Rec* field,
|
||||
void* object );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error CID_Load_Field_Table( CID_Parser* parser,
|
||||
const CID_Field_Rec* field,
|
||||
void* object );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* CIDPARSE_H */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,259 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* cidriver.c */
|
||||
/* */
|
||||
/* CID driver interface (body). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "cidriver.h"
|
||||
#include "cidgload.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <cid/cidriver.h>
|
||||
#include <cid/cidgload.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#include <freetype/internal/ftdebug.h>
|
||||
#include <freetype/internal/ftstream.h>
|
||||
#include <freetype/internal/psnames.h>
|
||||
|
||||
#include <string.h> /* for strcmp() */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
|
||||
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
|
||||
/* messages during execution. */
|
||||
/* */
|
||||
#undef FT_COMPONENT
|
||||
#define FT_COMPONENT trace_ciddriver
|
||||
|
||||
|
||||
static
|
||||
FT_Module_Interface CID_Get_Interface( FT_Driver driver,
|
||||
const FT_String* interface )
|
||||
{
|
||||
FT_UNUSED( driver );
|
||||
FT_UNUSED( interface );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#if 0 /* unimplemented yet */
|
||||
|
||||
static
|
||||
FT_Error cid_Get_Kerning( T1_Face face,
|
||||
FT_UInt left_glyph,
|
||||
FT_UInt right_glyph,
|
||||
FT_Vector* kerning )
|
||||
{
|
||||
CID_AFM* afm;
|
||||
|
||||
|
||||
kerning->x = 0;
|
||||
kerning->y = 0;
|
||||
|
||||
afm = (CID_AFM*)face->afm_data;
|
||||
if ( afm )
|
||||
CID_Get_Kerning( afm, left_glyph, right_glyph, kerning );
|
||||
|
||||
return T1_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
#endif /* 0 */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* Cid_Get_Char_Index */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Uses a charmap to return a given character code's glyph index. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* charmap :: A handle to the source charmap object. */
|
||||
/* */
|
||||
/* charcode :: The character code. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* Glyph index. 0 means `undefined character code'. */
|
||||
/* */
|
||||
static
|
||||
FT_UInt CID_Get_Char_Index( FT_CharMap charmap,
|
||||
FT_Long charcode )
|
||||
{
|
||||
T1_Face face;
|
||||
FT_UInt result = 0;
|
||||
PSNames_Interface* psnames;
|
||||
|
||||
|
||||
face = (T1_Face)charmap->face;
|
||||
psnames = (PSNames_Interface*)face->psnames;
|
||||
if ( psnames )
|
||||
switch ( charmap->encoding )
|
||||
{
|
||||
/*******************************************************************/
|
||||
/* */
|
||||
/* Unicode encoding support */
|
||||
/* */
|
||||
case ft_encoding_unicode:
|
||||
/* use the `PSNames' module to synthetize the Unicode charmap */
|
||||
result = psnames->lookup_unicode( &face->unicode_map,
|
||||
(FT_ULong)charcode );
|
||||
|
||||
/* the function returns 0xFFFF if the Unicode charcode has */
|
||||
/* no corresponding glyph. */
|
||||
if ( result == 0xFFFF )
|
||||
result = 0;
|
||||
goto Exit;
|
||||
|
||||
/*******************************************************************/
|
||||
/* */
|
||||
/* Custom Type 1 encoding */
|
||||
/* */
|
||||
case ft_encoding_adobe_custom:
|
||||
{
|
||||
T1_Encoding* encoding = &face->type1.encoding;
|
||||
|
||||
|
||||
if ( charcode >= encoding->code_first &&
|
||||
charcode <= encoding->code_last )
|
||||
result = encoding->char_index[charcode];
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
/* */
|
||||
/* Adobe Standard & Expert encoding support */
|
||||
/* */
|
||||
default:
|
||||
if ( charcode < 256 )
|
||||
{
|
||||
FT_UInt code;
|
||||
FT_Int n;
|
||||
const char* glyph_name;
|
||||
|
||||
|
||||
code = psnames->adobe_std_encoding[charcode];
|
||||
if ( charmap->encoding == ft_encoding_adobe_expert )
|
||||
code = psnames->adobe_expert_encoding[charcode];
|
||||
|
||||
glyph_name = psnames->adobe_std_strings( code );
|
||||
if ( !glyph_name )
|
||||
break;
|
||||
|
||||
for ( n = 0; n < face->type1.num_glyphs; n++ )
|
||||
{
|
||||
const char* gname = face->type1.glyph_names[n];
|
||||
|
||||
|
||||
if ( gname && gname[0] == glyph_name[0] &&
|
||||
strcmp( gname, glyph_name ) == 0 )
|
||||
{
|
||||
result = n;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Exit:
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
const FT_Driver_Class t1cid_driver_class =
|
||||
{
|
||||
/* first of all, the FT_Module_Class fields */
|
||||
{
|
||||
ft_module_font_driver | ft_module_driver_scalable,
|
||||
sizeof( FT_DriverRec ),
|
||||
"t1cid", /* module name */
|
||||
0x10000L, /* version 1.0 of driver */
|
||||
0x20000L, /* requires FreeType 2.0 */
|
||||
|
||||
0,
|
||||
|
||||
(FT_Module_Constructor)CID_Init_Driver,
|
||||
(FT_Module_Destructor) CID_Done_Driver,
|
||||
(FT_Module_Requester) CID_Get_Interface
|
||||
},
|
||||
|
||||
/* then the other font drivers fields */
|
||||
sizeof( CID_FaceRec ),
|
||||
sizeof( CID_SizeRec ),
|
||||
sizeof( CID_GlyphSlotRec ),
|
||||
|
||||
(FTDriver_initFace) CID_Init_Face,
|
||||
(FTDriver_doneFace) CID_Done_Face,
|
||||
|
||||
(FTDriver_initSize) 0,
|
||||
(FTDriver_doneSize) 0,
|
||||
(FTDriver_initGlyphSlot)0,
|
||||
(FTDriver_doneGlyphSlot)0,
|
||||
|
||||
(FTDriver_setCharSizes) 0,
|
||||
(FTDriver_setPixelSizes)0,
|
||||
|
||||
(FTDriver_loadGlyph) CID_Load_Glyph,
|
||||
(FTDriver_getCharIndex) CID_Get_Char_Index,
|
||||
|
||||
(FTDriver_getKerning) 0,
|
||||
(FTDriver_attachFile) 0,
|
||||
|
||||
(FTDriver_getAdvances) 0
|
||||
};
|
||||
|
||||
|
||||
#ifdef FT_CONFIG_OPTION_DYNAMIC_DRIVERS
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* getDriverClass */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This function is used when compiling the TrueType driver as a */
|
||||
/* shared library (`.DLL' or `.so'). It will be used by the */
|
||||
/* high-level library of FreeType to retrieve the address of the */
|
||||
/* driver's generic interface. */
|
||||
/* */
|
||||
/* It shouldn't be implemented in a static build, as each driver must */
|
||||
/* have the same function as an exported entry point. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* The address of the TrueType's driver generic interface. The */
|
||||
/* format-specific interface can then be retrieved through the method */
|
||||
/* interface->get_format_interface. */
|
||||
/* */
|
||||
EXPORT_FUNC( FT_Driver_Class* ) getDriverClass( void )
|
||||
{
|
||||
return &t1cid_driver_class;
|
||||
}
|
||||
|
||||
|
||||
#endif /* CONFIG_OPTION_DYNAMIC_DRIVERS */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,29 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* cidriver.h */
|
||||
/* */
|
||||
/* High-level CID driver interface (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef CIDRIVER_H
|
||||
#define CIDRIVER_H
|
||||
|
||||
#include <freetype/internal/ftdriver.h>
|
||||
|
||||
FT_EXPORT_VAR( const FT_Driver_Class ) t1cid_driver_class;
|
||||
|
||||
#endif /* CIDRIVER_H */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,99 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* cidtokens.h */
|
||||
/* */
|
||||
/* CID token definitions (specification only). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#undef T1TYPE
|
||||
#undef T1CODE
|
||||
#define T1TYPE CID_Info
|
||||
#define T1CODE t1_field_cid_info
|
||||
|
||||
CID_FIELD_STRING ( "CIDFontName", cid_font_name )
|
||||
CID_FIELD_NUM ( "CIDFontVersion", cid_version )
|
||||
CID_FIELD_NUM ( "CIDFontType", cid_font_type )
|
||||
CID_FIELD_STRING ( "Registry", registry )
|
||||
CID_FIELD_STRING ( "Ordering", ordering )
|
||||
CID_FIELD_NUM ( "Supplement", supplement )
|
||||
CID_FIELD_CALLBACK( "FontBBox", font_bbox )
|
||||
CID_FIELD_NUM ( "UIDBase", uid_base )
|
||||
CID_FIELD_CALLBACK( "FDArray", fd_array )
|
||||
CID_FIELD_NUM ( "CIDMapOffset", cidmap_offset )
|
||||
CID_FIELD_NUM ( "FDBytes", fd_bytes )
|
||||
CID_FIELD_NUM ( "GDBytes", gd_bytes )
|
||||
CID_FIELD_NUM ( "CIDCount", cid_count )
|
||||
|
||||
|
||||
#undef T1TYPE
|
||||
#undef T1CODE
|
||||
#define T1TYPE T1_FontInfo
|
||||
#define T1CODE t1_field_font_info
|
||||
|
||||
CID_FIELD_STRING( "version", version )
|
||||
CID_FIELD_STRING( "Notice", notice )
|
||||
CID_FIELD_STRING( "FullName", full_name )
|
||||
CID_FIELD_STRING( "FamilyName", family_name )
|
||||
CID_FIELD_STRING( "Weight", weight )
|
||||
CID_FIELD_FIXED ( "ItalicAngle", italic_angle )
|
||||
CID_FIELD_BOOL ( "isFixedPitch", is_fixed_pitch )
|
||||
CID_FIELD_NUM ( "UnderlinePosition", underline_position )
|
||||
CID_FIELD_NUM ( "UnderlineThickness", underline_thickness )
|
||||
|
||||
|
||||
#undef T1TYPE
|
||||
#undef T1CODE
|
||||
#define T1TYPE CID_FontDict
|
||||
#define T1CODE t1_field_font_dict
|
||||
|
||||
CID_FIELD_CALLBACK( "FontMatrix", font_matrix )
|
||||
CID_FIELD_NUM ( "PaintType", paint_type )
|
||||
CID_FIELD_NUM ( "FontType", font_type )
|
||||
CID_FIELD_NUM ( "SubrMapOffset", subrmap_offset )
|
||||
CID_FIELD_NUM ( "SDBytes", sd_bytes )
|
||||
CID_FIELD_NUM ( "SubrCount", num_subrs )
|
||||
CID_FIELD_NUM ( "lenBuildCharArray", len_buildchar )
|
||||
CID_FIELD_FIXED ( "ForceBoldThreshold", forcebold_threshold )
|
||||
CID_FIELD_FIXED ( "ExpansionFactor", expansion_factor )
|
||||
CID_FIELD_NUM ( "StrokeWidth", stroke_width )
|
||||
|
||||
|
||||
#undef T1TYPE
|
||||
#undef T1CODE
|
||||
#define T1TYPE T1_Private
|
||||
#define T1CODE t1_field_private
|
||||
|
||||
CID_FIELD_NUM ( "UniqueID", unique_id )
|
||||
CID_FIELD_NUM ( "lenIV", lenIV )
|
||||
CID_FIELD_NUM ( "LanguageGroup", language_group )
|
||||
CID_FIELD_NUM ( "password", password )
|
||||
|
||||
CID_FIELD_FIXED ( "BlueScale", blue_scale )
|
||||
CID_FIELD_NUM ( "BlueShift", blue_shift )
|
||||
CID_FIELD_NUM ( "BlueFuzz", blue_fuzz )
|
||||
|
||||
CID_FIELD_NUM_TABLE ( "BlueValues", blue_values, 14 )
|
||||
CID_FIELD_NUM_TABLE ( "OtherBlues", other_blues, 10 )
|
||||
CID_FIELD_NUM_TABLE ( "FamilyBlues", family_blues, 14 )
|
||||
CID_FIELD_NUM_TABLE ( "FamilyOtherBlues", family_other_blues, 10 )
|
||||
|
||||
CID_FIELD_NUM_TABLE2( "StdHW", standard_width, 1 )
|
||||
CID_FIELD_NUM_TABLE2( "StdVW", standard_height, 1 )
|
||||
CID_FIELD_NUM_TABLE2( "MinFeature", min_feature, 2 )
|
||||
|
||||
CID_FIELD_NUM_TABLE ( "StemSnapH", snap_widths, 12 )
|
||||
CID_FIELD_NUM_TABLE ( "StemSnapV", snap_heights, 12 )
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,703 @@
|
||||
/* $Id: ctype.c,v 1.1 2001/05/02 12:21:26 jfilby Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/rtl/ctype.c
|
||||
* PURPOSE: Character type and conversion functions
|
||||
* PROGRAMMERS: ???
|
||||
* Eric Kohl
|
||||
* HISTORY: ???: Created
|
||||
* 10/01/2000: Added missing functions and changed
|
||||
* all functions to use ctype table
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
#define upalpha ('A' - 'a')
|
||||
|
||||
|
||||
unsigned short _ctype[] = {
|
||||
0, /* <EOF>, 0xFFFF */
|
||||
_CONTROL, /* CTRL+@, 0x00 */
|
||||
_CONTROL, /* CTRL+A, 0x01 */
|
||||
_CONTROL, /* CTRL+B, 0x02 */
|
||||
_CONTROL, /* CTRL+C, 0x03 */
|
||||
_CONTROL, /* CTRL+D, 0x04 */
|
||||
_CONTROL, /* CTRL+E, 0x05 */
|
||||
_CONTROL, /* CTRL+F, 0x06 */
|
||||
_CONTROL, /* CTRL+G, 0x07 */
|
||||
_CONTROL, /* CTRL+H, 0x08 */
|
||||
_CONTROL | _SPACE, /* CTRL+I, 0x09 */
|
||||
_CONTROL | _SPACE, /* CTRL+J, 0x0a */
|
||||
_CONTROL | _SPACE, /* CTRL+K, 0x0b */
|
||||
_CONTROL | _SPACE, /* CTRL+L, 0x0c */
|
||||
_CONTROL | _SPACE, /* CTRL+M, 0x0d */
|
||||
_CONTROL, /* CTRL+N, 0x0e */
|
||||
_CONTROL, /* CTRL+O, 0x0f */
|
||||
_CONTROL, /* CTRL+P, 0x10 */
|
||||
_CONTROL, /* CTRL+Q, 0x11 */
|
||||
_CONTROL, /* CTRL+R, 0x12 */
|
||||
_CONTROL, /* CTRL+S, 0x13 */
|
||||
_CONTROL, /* CTRL+T, 0x14 */
|
||||
_CONTROL, /* CTRL+U, 0x15 */
|
||||
_CONTROL, /* CTRL+V, 0x16 */
|
||||
_CONTROL, /* CTRL+W, 0x17 */
|
||||
_CONTROL, /* CTRL+X, 0x18 */
|
||||
_CONTROL, /* CTRL+Y, 0x19 */
|
||||
_CONTROL, /* CTRL+Z, 0x1a */
|
||||
_CONTROL, /* CTRL+[, 0x1b */
|
||||
_CONTROL, /* CTRL+\, 0x1c */
|
||||
_CONTROL, /* CTRL+], 0x1d */
|
||||
_CONTROL, /* CTRL+^, 0x1e */
|
||||
_CONTROL, /* CTRL+_, 0x1f */
|
||||
_SPACE | _BLANK, /* ` ', 0x20 */
|
||||
_PUNCT, /* `!', 0x21 */
|
||||
_PUNCT, /* 0x22 */
|
||||
_PUNCT, /* `#', 0x23 */
|
||||
_PUNCT, /* `$', 0x24 */
|
||||
_PUNCT, /* `%', 0x25 */
|
||||
_PUNCT, /* `&', 0x26 */
|
||||
_PUNCT, /* 0x27 */
|
||||
_PUNCT, /* `(', 0x28 */
|
||||
_PUNCT, /* `)', 0x29 */
|
||||
_PUNCT, /* `*', 0x2a */
|
||||
_PUNCT, /* `+', 0x2b */
|
||||
_PUNCT, /* `,', 0x2c */
|
||||
_PUNCT, /* `-', 0x2d */
|
||||
_PUNCT, /* `.', 0x2e */
|
||||
_PUNCT, /* `/', 0x2f */
|
||||
_DIGIT | _HEX, /* `0', 0x30 */
|
||||
_DIGIT | _HEX, /* `1', 0x31 */
|
||||
_DIGIT | _HEX, /* `2', 0x32 */
|
||||
_DIGIT | _HEX, /* `3', 0x33 */
|
||||
_DIGIT | _HEX, /* `4', 0x34 */
|
||||
_DIGIT | _HEX, /* `5', 0x35 */
|
||||
_DIGIT | _HEX, /* `6', 0x36 */
|
||||
_DIGIT | _HEX, /* `7', 0x37 */
|
||||
_DIGIT | _HEX, /* `8', 0x38 */
|
||||
_DIGIT | _HEX, /* `9', 0x39 */
|
||||
_PUNCT, /* `:', 0x3a */
|
||||
_PUNCT, /* `;', 0x3b */
|
||||
_PUNCT, /* `<', 0x3c */
|
||||
_PUNCT, /* `=', 0x3d */
|
||||
_PUNCT, /* `>', 0x3e */
|
||||
_PUNCT, /* `?', 0x3f */
|
||||
_PUNCT, /* `@', 0x40 */
|
||||
_UPPER | _HEX, /* `A', 0x41 */
|
||||
_UPPER | _HEX, /* `B', 0x42 */
|
||||
_UPPER | _HEX, /* `C', 0x43 */
|
||||
_UPPER | _HEX, /* `D', 0x44 */
|
||||
_UPPER | _HEX, /* `E', 0x45 */
|
||||
_UPPER | _HEX, /* `F', 0x46 */
|
||||
_UPPER, /* `G', 0x47 */
|
||||
_UPPER, /* `H', 0x48 */
|
||||
_UPPER, /* `I', 0x49 */
|
||||
_UPPER, /* `J', 0x4a */
|
||||
_UPPER, /* `K', 0x4b */
|
||||
_UPPER, /* `L', 0x4c */
|
||||
_UPPER, /* `M', 0x4d */
|
||||
_UPPER, /* `N', 0x4e */
|
||||
_UPPER, /* `O', 0x4f */
|
||||
_UPPER, /* `P', 0x50 */
|
||||
_UPPER, /* `Q', 0x51 */
|
||||
_UPPER, /* `R', 0x52 */
|
||||
_UPPER, /* `S', 0x53 */
|
||||
_UPPER, /* `T', 0x54 */
|
||||
_UPPER, /* `U', 0x55 */
|
||||
_UPPER, /* `V', 0x56 */
|
||||
_UPPER, /* `W', 0x57 */
|
||||
_UPPER, /* `X', 0x58 */
|
||||
_UPPER, /* `Y', 0x59 */
|
||||
_UPPER, /* `Z', 0x5a */
|
||||
_PUNCT, /* `[', 0x5b */
|
||||
_PUNCT, /* 0x5c */
|
||||
_PUNCT, /* `]', 0x5d */
|
||||
_PUNCT, /* `^', 0x5e */
|
||||
_PUNCT, /* `_', 0x5f */
|
||||
_PUNCT, /* 0x60 */
|
||||
_LOWER | _HEX, /* `a', 0x61 */
|
||||
_LOWER | _HEX, /* `b', 0x62 */
|
||||
_LOWER | _HEX, /* `c', 0x63 */
|
||||
_LOWER | _HEX, /* `d', 0x64 */
|
||||
_LOWER | _HEX, /* `e', 0x65 */
|
||||
_LOWER | _HEX, /* `f', 0x66 */
|
||||
_LOWER, /* `g', 0x67 */
|
||||
_LOWER, /* `h', 0x68 */
|
||||
_LOWER, /* `i', 0x69 */
|
||||
_LOWER, /* `j', 0x6a */
|
||||
_LOWER, /* `k', 0x6b */
|
||||
_LOWER, /* `l', 0x6c */
|
||||
_LOWER, /* `m', 0x6d */
|
||||
_LOWER, /* `n', 0x6e */
|
||||
_LOWER, /* `o', 0x6f */
|
||||
_LOWER, /* `p', 0x70 */
|
||||
_LOWER, /* `q', 0x71 */
|
||||
_LOWER, /* `r', 0x72 */
|
||||
_LOWER, /* `s', 0x73 */
|
||||
_LOWER, /* `t', 0x74 */
|
||||
_LOWER, /* `u', 0x75 */
|
||||
_LOWER, /* `v', 0x76 */
|
||||
_LOWER, /* `w', 0x77 */
|
||||
_LOWER, /* `x', 0x78 */
|
||||
_LOWER, /* `y', 0x79 */
|
||||
_LOWER, /* `z', 0x7a */
|
||||
_PUNCT, /* `{', 0x7b */
|
||||
_PUNCT, /* `|', 0x7c */
|
||||
_PUNCT, /* `}', 0x7d */
|
||||
_PUNCT, /* `~', 0x7e */
|
||||
_CONTROL, /* 0x7f */
|
||||
0, /* 0x80 */
|
||||
0, /* 0x81 */
|
||||
0, /* 0x82 */
|
||||
0, /* 0x83 */
|
||||
0, /* 0x84 */
|
||||
0, /* 0x85 */
|
||||
0, /* 0x86 */
|
||||
0, /* 0x87 */
|
||||
0, /* 0x88 */
|
||||
0, /* 0x89 */
|
||||
0, /* 0x8a */
|
||||
0, /* 0x8b */
|
||||
0, /* 0x8c */
|
||||
0, /* 0x8d */
|
||||
0, /* 0x8e */
|
||||
0, /* 0x8f */
|
||||
0, /* 0x90 */
|
||||
0, /* 0x91 */
|
||||
0, /* 0x92 */
|
||||
0, /* 0x93 */
|
||||
0, /* 0x94 */
|
||||
0, /* 0x95 */
|
||||
0, /* 0x96 */
|
||||
0, /* 0x97 */
|
||||
0, /* 0x98 */
|
||||
0, /* 0x99 */
|
||||
0, /* 0x9a */
|
||||
0, /* 0x9b */
|
||||
0, /* 0x9c */
|
||||
0, /* 0x9d */
|
||||
0, /* 0x9e */
|
||||
0, /* 0x9f */
|
||||
0, /* 0xa0 */
|
||||
0, /* 0xa1 */
|
||||
0, /* 0xa2 */
|
||||
0, /* 0xa3 */
|
||||
0, /* 0xa4 */
|
||||
0, /* 0xa5 */
|
||||
0, /* 0xa6 */
|
||||
0, /* 0xa7 */
|
||||
0, /* 0xa8 */
|
||||
0, /* 0xa9 */
|
||||
0, /* 0xaa */
|
||||
0, /* 0xab */
|
||||
0, /* 0xac */
|
||||
0, /* 0xad */
|
||||
0, /* 0xae */
|
||||
0, /* 0xaf */
|
||||
0, /* 0xb0 */
|
||||
0, /* 0xb1 */
|
||||
0, /* 0xb2 */
|
||||
0, /* 0xb3 */
|
||||
0, /* 0xb4 */
|
||||
0, /* 0xb5 */
|
||||
0, /* 0xb6 */
|
||||
0, /* 0xb7 */
|
||||
0, /* 0xb8 */
|
||||
0, /* 0xb9 */
|
||||
0, /* 0xba */
|
||||
0, /* 0xbb */
|
||||
0, /* 0xbc */
|
||||
0, /* 0xbd */
|
||||
0, /* 0xbe */
|
||||
0, /* 0xbf */
|
||||
0, /* 0xc0 */
|
||||
0, /* 0xc1 */
|
||||
0, /* 0xc2 */
|
||||
0, /* 0xc3 */
|
||||
0, /* 0xc4 */
|
||||
0, /* 0xc5 */
|
||||
0, /* 0xc6 */
|
||||
0, /* 0xc7 */
|
||||
0, /* 0xc8 */
|
||||
0, /* 0xc9 */
|
||||
0, /* 0xca */
|
||||
0, /* 0xcb */
|
||||
0, /* 0xcc */
|
||||
0, /* 0xcd */
|
||||
0, /* 0xce */
|
||||
0, /* 0xcf */
|
||||
0, /* 0xd0 */
|
||||
0, /* 0xd1 */
|
||||
0, /* 0xd2 */
|
||||
0, /* 0xd3 */
|
||||
0, /* 0xd4 */
|
||||
0, /* 0xd5 */
|
||||
0, /* 0xd6 */
|
||||
0, /* 0xd7 */
|
||||
0, /* 0xd8 */
|
||||
0, /* 0xd9 */
|
||||
0, /* 0xda */
|
||||
0, /* 0xdb */
|
||||
0, /* 0xdc */
|
||||
0, /* 0xdd */
|
||||
0, /* 0xde */
|
||||
0, /* 0xdf */
|
||||
0, /* 0xe0 */
|
||||
0, /* 0xe1 */
|
||||
0, /* 0xe2 */
|
||||
0, /* 0xe3 */
|
||||
0, /* 0xe4 */
|
||||
0, /* 0xe5 */
|
||||
0, /* 0xe6 */
|
||||
0, /* 0xe7 */
|
||||
0, /* 0xe8 */
|
||||
0, /* 0xe9 */
|
||||
0, /* 0xea */
|
||||
0, /* 0xeb */
|
||||
0, /* 0xec */
|
||||
0, /* 0xed */
|
||||
0, /* 0xee */
|
||||
0, /* 0xef */
|
||||
0, /* 0xf0 */
|
||||
0, /* 0xf1 */
|
||||
0, /* 0xf2 */
|
||||
0, /* 0xf3 */
|
||||
0, /* 0xf4 */
|
||||
0, /* 0xf5 */
|
||||
0, /* 0xf6 */
|
||||
0, /* 0xf7 */
|
||||
0, /* 0xf8 */
|
||||
0, /* 0xf9 */
|
||||
0, /* 0xfa */
|
||||
0, /* 0xfb */
|
||||
0, /* 0xfc */
|
||||
0, /* 0xfd */
|
||||
0, /* 0xfe */
|
||||
0 /* 0xff */
|
||||
};
|
||||
|
||||
unsigned short *_pctype = _ctype + 1;
|
||||
unsigned short *_pwctype = _ctype + 1;
|
||||
|
||||
int _isctype (int c, int ctypeFlags)
|
||||
{
|
||||
return (_pctype[(unsigned char)(c & 0xFF)] & ctypeFlags);
|
||||
}
|
||||
|
||||
int iswctype(wint_t wc, wctype_t wctypeFlags)
|
||||
{
|
||||
return (_pwctype[(unsigned char)(wc & 0xFF)] & wctypeFlags);
|
||||
}
|
||||
|
||||
int isalpha(int c)
|
||||
{
|
||||
return(_isctype(c, _ALPHA));
|
||||
}
|
||||
|
||||
int isalnum(int c)
|
||||
{
|
||||
return(_isctype(c, _ALPHA | _DIGIT));
|
||||
}
|
||||
|
||||
int __isascii(int c)
|
||||
{
|
||||
return ((unsigned char)c <= 0x7f);
|
||||
}
|
||||
|
||||
int iscntrl(int c)
|
||||
{
|
||||
return(_isctype(c, _CONTROL));
|
||||
}
|
||||
|
||||
int __iscsym(int c)
|
||||
{
|
||||
return(isalnum(c)||(c == '_'));
|
||||
}
|
||||
|
||||
int __iscsymf(int c)
|
||||
{
|
||||
return(isalpha(c)||(c == '_'));
|
||||
}
|
||||
|
||||
|
||||
int isdigit(int c)
|
||||
{
|
||||
return(_isctype(c, _DIGIT));
|
||||
}
|
||||
|
||||
/*
|
||||
int isgraph(int c)
|
||||
{
|
||||
return (_isctype (c, _PUNCT | _ALPHA | _DIGIT));
|
||||
}
|
||||
*/
|
||||
|
||||
int islower(int c)
|
||||
{
|
||||
return (_isctype (c, _LOWER));
|
||||
}
|
||||
|
||||
int isprint(int c)
|
||||
{
|
||||
return (_isctype (c, _BLANK | _PUNCT | _ALPHA | _DIGIT));
|
||||
}
|
||||
|
||||
/*
|
||||
int ispunct(int c)
|
||||
{
|
||||
return (_isctype (c, _PUNCT));
|
||||
}
|
||||
*/
|
||||
|
||||
int isspace(int c)
|
||||
{
|
||||
return (_isctype (c, _SPACE));
|
||||
}
|
||||
|
||||
int isupper(int c)
|
||||
{
|
||||
return (_isctype (c, _UPPER));
|
||||
}
|
||||
|
||||
int isxdigit(int c)
|
||||
{
|
||||
return (_isctype (c, _HEX));
|
||||
}
|
||||
|
||||
/*
|
||||
int iswalpha(wint_t c)
|
||||
{
|
||||
return (iswctype (c, _ALPHA));
|
||||
}
|
||||
*/
|
||||
|
||||
int iswdigit(wint_t c)
|
||||
{
|
||||
return (iswctype (c, _DIGIT));
|
||||
}
|
||||
|
||||
int iswlower(wint_t c)
|
||||
{
|
||||
return (iswctype (c, _LOWER));
|
||||
}
|
||||
|
||||
int iswxdigit(wint_t c)
|
||||
{
|
||||
return (iswctype (c, _HEX));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
int __toascii(int c)
|
||||
{
|
||||
return((unsigned)(c) & 0x7f);
|
||||
}
|
||||
|
||||
int _tolower(int c)
|
||||
{
|
||||
if (_isctype (c, _UPPER))
|
||||
return (c - upalpha);
|
||||
return(c);
|
||||
}
|
||||
|
||||
int _toupper(int c)
|
||||
{
|
||||
if (_isctype (c, _LOWER))
|
||||
return (c + upalpha);
|
||||
return(c);
|
||||
}
|
||||
*/
|
||||
|
||||
int tolower(int c)
|
||||
{
|
||||
if (_isctype (c, _UPPER))
|
||||
return (c - upalpha);
|
||||
return(c);
|
||||
}
|
||||
|
||||
int toupper(int c)
|
||||
{
|
||||
if (_isctype (c, _LOWER))
|
||||
return (c + upalpha);
|
||||
return(c);
|
||||
}
|
||||
|
||||
wchar_t towlower(wchar_t c)
|
||||
{
|
||||
if (iswctype (c, _UPPER))
|
||||
return (c - upalpha);
|
||||
return(c);
|
||||
}
|
||||
|
||||
wchar_t towupper(wchar_t c)
|
||||
{
|
||||
if (iswctype (c, _LOWER))
|
||||
return (c + upalpha);
|
||||
return(c);
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
||||
int strcmp(const char *s1, const char *s2)
|
||||
{
|
||||
while (*s1 == *s2)
|
||||
{
|
||||
if (*s1 == 0)
|
||||
return 0;
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
|
||||
return *(unsigned const char *)s1 - *(unsigned const char *)(s2);
|
||||
}
|
||||
|
||||
int strncmp(const char *s1, const char *s2, size_t n)
|
||||
{
|
||||
if (n == 0)
|
||||
return 0;
|
||||
do
|
||||
{
|
||||
if (*s1 != *s2++)
|
||||
return *(unsigned const char *)s1 - *(unsigned const char *)--s2;
|
||||
if (*s1++ == 0)
|
||||
break;
|
||||
}
|
||||
while (--n != 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *strncpy(char *dst, const char *src, size_t n)
|
||||
{
|
||||
if (n != 0)
|
||||
{
|
||||
char *d = dst;
|
||||
const char *s = src;
|
||||
|
||||
do
|
||||
{
|
||||
if ((*d++ = *s++) == 0)
|
||||
{
|
||||
while (--n != 0)
|
||||
*d++ = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (--n != 0);
|
||||
}
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
void * memmove(void *dest,const void *src,size_t count)
|
||||
{
|
||||
char *char_dest = (char *)dest;
|
||||
char *char_src = (char *)src;
|
||||
|
||||
if ((char_dest <= char_src) || (char_dest >= (char_src+count)))
|
||||
{
|
||||
/* non-overlapping buffers */
|
||||
while(count > 0)
|
||||
{
|
||||
*char_dest = *char_src;
|
||||
char_dest++;
|
||||
char_src++;
|
||||
count--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* overlaping buffers */
|
||||
char_dest = (char *)dest + count - 1;
|
||||
char_src = (char *)src + count - 1;
|
||||
|
||||
while(count > 0)
|
||||
{
|
||||
*char_dest = *char_src;
|
||||
char_dest--;
|
||||
char_src--;
|
||||
count--;
|
||||
}
|
||||
}
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
/* FIXME: these types should be from the default includes */
|
||||
|
||||
typedef int (* _pfunccmp_t) (char *, char *);
|
||||
|
||||
#define min(a,b) ((a)<(b)?(a):(b))
|
||||
|
||||
/*
|
||||
* Qsort routine from Bentley & McIlroy's "Engineering a Sort Function".
|
||||
*/
|
||||
#define swapcode(TYPE, parmi, parmj, n) { \
|
||||
long i = (n) / sizeof (TYPE); \
|
||||
register TYPE *pi = (TYPE *) (parmi); \
|
||||
register TYPE *pj = (TYPE *) (parmj); \
|
||||
do { \
|
||||
register TYPE t = *pi; \
|
||||
*pi++ = *pj; \
|
||||
*pj++ = t; \
|
||||
} while (--i > 0); \
|
||||
}
|
||||
|
||||
#define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \
|
||||
es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1;
|
||||
|
||||
static inline void
|
||||
swapfunc (
|
||||
char * a,
|
||||
char * b,
|
||||
int n,
|
||||
int swaptype
|
||||
)
|
||||
{
|
||||
if(swaptype <= 1)
|
||||
swapcode(long, a, b, n)
|
||||
else
|
||||
swapcode(char, a, b, n)
|
||||
}
|
||||
|
||||
#define swap(a, b) \
|
||||
if (swaptype == 0) { \
|
||||
long t = *(long *)(a); \
|
||||
*(long *)(a) = *(long *)(b); \
|
||||
*(long *)(b) = t; \
|
||||
} else \
|
||||
swapfunc(a, b, es, swaptype)
|
||||
|
||||
#define vecswap(a, b, n) if ((n) > 0) swapfunc(a, b, n, swaptype)
|
||||
|
||||
static inline char *
|
||||
med3 (
|
||||
char * a,
|
||||
char * b,
|
||||
char * c,
|
||||
_pfunccmp_t cmp
|
||||
)
|
||||
{
|
||||
return cmp(a, b) < 0 ?
|
||||
(cmp(b, c) < 0 ? b : (cmp(a, c) < 0 ? c : a ))
|
||||
:(cmp(b, c) > 0 ? b : (cmp(a, c) < 0 ? a : c ));
|
||||
}
|
||||
|
||||
|
||||
/* EXPORTED */
|
||||
void
|
||||
qsort (
|
||||
void * a,
|
||||
size_t n,
|
||||
size_t es,
|
||||
_pfunccmp_t cmp
|
||||
)
|
||||
{
|
||||
char *pa, *pb, *pc, *pd, *pl, *pm, *pn;
|
||||
int d, r, swaptype, swap_cnt;
|
||||
|
||||
loop: SWAPINIT(a, es);
|
||||
swap_cnt = 0;
|
||||
if (n < 7)
|
||||
{
|
||||
for ( pm = (char *) a + es;
|
||||
pm < (char *) a + n * es;
|
||||
pm += es
|
||||
)
|
||||
{
|
||||
for ( pl = pm;
|
||||
pl > (char *) a && cmp(pl - es, pl) > 0;
|
||||
pl -= es
|
||||
)
|
||||
{
|
||||
swap(pl, pl - es);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
pm = (char *) a + (n / 2) * es;
|
||||
if (n > 7)
|
||||
{
|
||||
pl = (char *) a;
|
||||
pn = (char *) a + (n - 1) * es;
|
||||
if (n > 40)
|
||||
{
|
||||
d = (n / 8) * es;
|
||||
pl = med3(pl, pl + d, pl + 2 * d, cmp);
|
||||
pm = med3(pm - d, pm, pm + d, cmp);
|
||||
pn = med3(pn - 2 * d, pn - d, pn, cmp);
|
||||
}
|
||||
pm = med3(pl, pm, pn, cmp);
|
||||
}
|
||||
swap(a, pm);
|
||||
pa = pb = (char *) a + es;
|
||||
|
||||
pc = pd = (char *) a + (n - 1) * es;
|
||||
for (;;)
|
||||
{
|
||||
while (pb <= pc && (r = cmp(pb, a)) <= 0)
|
||||
{
|
||||
if (r == 0)
|
||||
{
|
||||
swap_cnt = 1;
|
||||
swap(pa, pb);
|
||||
pa += es;
|
||||
}
|
||||
pb += es;
|
||||
}
|
||||
while (pb <= pc && (r = cmp(pc, a)) >= 0)
|
||||
{
|
||||
if (r == 0)
|
||||
{
|
||||
swap_cnt = 1;
|
||||
swap(pc, pd);
|
||||
pd -= es;
|
||||
}
|
||||
pc -= es;
|
||||
}
|
||||
if (pb > pc)
|
||||
{
|
||||
break;
|
||||
}
|
||||
swap(pb, pc);
|
||||
swap_cnt = 1;
|
||||
pb += es;
|
||||
pc -= es;
|
||||
}
|
||||
if (swap_cnt == 0) /* Switch to insertion sort */
|
||||
{
|
||||
for ( pm = (char *) a + es;
|
||||
pm < (char *) a + n * es;
|
||||
pm += es
|
||||
)
|
||||
{
|
||||
for ( pl = pm;
|
||||
pl > (char *) a && cmp(pl - es, pl) > 0;
|
||||
pl -= es
|
||||
)
|
||||
{
|
||||
swap(pl, pl - es);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
pn = (char *) a + n * es;
|
||||
r = min(pa - (char *)a, pb - pa);
|
||||
vecswap(a, pb - r, r);
|
||||
r = min(pd - pc, pn - pd - es);
|
||||
vecswap(pb, pn - r, r);
|
||||
if ((r = pb - pa) > es)
|
||||
{
|
||||
qsort(a, r / es, es, cmp);
|
||||
}
|
||||
if ((r = pd - pc) > es)
|
||||
{
|
||||
/* Iterate rather than recurse to save stack space */
|
||||
a = pn - r;
|
||||
n = r / es;
|
||||
goto loop;
|
||||
}
|
||||
/* qsort(pn - r, r / es, es, cmp);*/
|
||||
}
|
||||
@@ -0,0 +1,264 @@
|
||||
FreeType 2 compilation how-to
|
||||
|
||||
|
||||
Introduction:
|
||||
|
||||
Welcome to this new beta of the FreeType 2 library. You'll find in this
|
||||
document instructions on how to compile the library on your favorite
|
||||
platform.
|
||||
|
||||
*** UNIX USERS : Even though the FT2 build system doesn't
|
||||
************** : use the Autoconf/Automake tools, these will
|
||||
************** : be introduced in the Unix-specific parts of
|
||||
************** : the build in our final release..
|
||||
|
||||
|
||||
I. QUICK COMMAND-LINE GUIDE:
|
||||
----------------------------
|
||||
|
||||
Install GNU Make, then try the following on Unix or any system with gcc:
|
||||
|
||||
make // this will setup the build
|
||||
make // this will build the library
|
||||
|
||||
On Win32+Visual C++:
|
||||
|
||||
make setup visualc // setup the build for VisualC++ on Win32
|
||||
make // build the library
|
||||
|
||||
Then, go to the "demos" directory and type
|
||||
|
||||
make
|
||||
|
||||
To compile the demo programs..
|
||||
|
||||
If this doesn't work, read the following..
|
||||
|
||||
|
||||
|
||||
II. COMMAND-LINE COMPILATION:
|
||||
-----------------------------
|
||||
|
||||
Note that if you do not want to compile FreeType 2 from a command line
|
||||
shell, please skip to section III below (DETAILED COMPILATION)
|
||||
|
||||
FreeType 2 includes a powerful and flexible build system that allows you
|
||||
to easily compile it on a great variety of platforms from the command
|
||||
line. To do so, just follow these simple instructions:
|
||||
|
||||
a/ Install GNU Make:
|
||||
|
||||
Because GNU Make is the only Make tool supported to compile FreeType 2,
|
||||
you should install it on your machine.
|
||||
|
||||
Because the FT2 build system relies on many important features of GNU
|
||||
Make, trying to build the library with any other Make tool will *fail*.
|
||||
|
||||
|
||||
b/ Invoke "make":
|
||||
|
||||
Go to the root FT2 directory, then simply invoke GNU Make from the
|
||||
command line, this will launch the FreeType 2 Host Platform detection
|
||||
routines. A summary will be displayed, for example, on Win32:
|
||||
|
||||
========================================================================
|
||||
FreeType build system -- automatic system detection
|
||||
|
||||
The following settings are used:
|
||||
|
||||
platform win32
|
||||
compiler gcc
|
||||
configuration directory ./builds/win32
|
||||
configuration rules ./builds/win32/w32-gcc.mk
|
||||
|
||||
If this does not correspond to your system or settings please remove
|
||||
the file 'config.mk' from this directory then read the INSTALL file
|
||||
for help.
|
||||
|
||||
Otherwise, simply type 'make' again to build the library.
|
||||
=========================================================================
|
||||
|
||||
If the detected settings correspond to your platform and compiler,
|
||||
skip to step e/. Note that if your platform is completely alien to
|
||||
the build system, the detected platform will be "ansi".
|
||||
|
||||
|
||||
c/ Configure the build system for a different compiler:
|
||||
|
||||
If the build system correctly detected your platform, but you want to
|
||||
use a different compiler than the one specified in the summary (for
|
||||
most platforms, gcc is the defaut compiler), simply invoke GNU Make
|
||||
like :
|
||||
|
||||
make setup <compiler>
|
||||
|
||||
For example:
|
||||
|
||||
to use Visual C++ on Win32, type: "make setup visualc"
|
||||
to use LCC-Win32 on Win32, type: "make setup lcc"
|
||||
|
||||
The <compiler> name to use is platform-dependent. The list of available
|
||||
compilers for your system is available in the file
|
||||
"builds/<system>/detect.mk" (note that we hope to make the list
|
||||
displayed at user demand in the final release)..
|
||||
|
||||
If you're satisfying by the new configuration summary, skip to step e/
|
||||
|
||||
|
||||
d/ Configure the build system for an unknown platform/compiler:
|
||||
|
||||
What the auto-detection/setup phase of the build system does is simply
|
||||
copy a file to the current directory under the name "config.mk".
|
||||
|
||||
For example, on OS/2+gcc, it would simply copy "builds/os2/os2-gcc.mk"
|
||||
to "./config.mk"
|
||||
|
||||
If for some reason your platform isn't correctly detected, simply copy
|
||||
manually the configuration sub-makefile to "./config.mk" and go to
|
||||
step e/.
|
||||
|
||||
Note that this file is a sub-Makefile used to specify Make variables
|
||||
used to invoke the compiler and linker during the build, you can easily
|
||||
create your own version from one of the existing configuration files,
|
||||
then copy it to the current directory under the name "./config.mk".
|
||||
|
||||
|
||||
e/ Build the library:
|
||||
|
||||
The auto-detection/setup phase should have copied a file in the current
|
||||
directory, called "./config.mk". This file contains definitions of various
|
||||
Make variables used to invoke the compiler and linker during the build.
|
||||
|
||||
To launch the build, simply invoke GNU Make again: the top Makefile will
|
||||
detect the configuration file and run the build with it..
|
||||
|
||||
|
||||
f/ Build the demonstration programs:
|
||||
|
||||
Once the library is compiled, go to "demos", then invoke GNU Make.
|
||||
|
||||
Note that the demonstration programs include a tiny graphics sub-system
|
||||
that includes "drivers" to display Windows on Win32, X11 and OS/2. The
|
||||
build system should automatically detect which driver to use based on
|
||||
the current platform.
|
||||
|
||||
UNIX USERS TAKE NOTE: XXXXXX
|
||||
|
||||
When building the demos, the build system tries to detect your X11 path
|
||||
by looking for the patterns "X11R5/bin", "X11R6/bin" or "X11/bin" in
|
||||
your current path. If no X11 path is found, the demo programs will not
|
||||
be able to display graphics and will fail. Change your current path
|
||||
if you encounter this problem.
|
||||
|
||||
Note that the release version will use Autoconf to detect everything
|
||||
on Unix, so this will not be necessary !!
|
||||
|
||||
|
||||
II. DETAILED COMPILATION PROCEDURE:
|
||||
-----------------------------------
|
||||
|
||||
If you don't want to compile FreeType 2 from the command-line (for example
|
||||
from a graphical IDE on a Mac or Windows), you'll need to understand how the
|
||||
FreeType files are organized.
|
||||
|
||||
FreeType 2 has a very module design, and it is made of several components.
|
||||
Each component must be compiled as a stand-alone object file, even when it
|
||||
is really made of several C source files. For example, the "base layer"
|
||||
component is made of the following C files:
|
||||
|
||||
src/
|
||||
base/
|
||||
ftcalc.c - computations
|
||||
ftobjs.c - object management
|
||||
ftstream.c - stream input
|
||||
ftlist.c - simple list management
|
||||
ftoutln.c - simple outline processing
|
||||
ftextend.c - extensions support
|
||||
|
||||
However, you can create a single object file by compiling the file
|
||||
"src/base/ftbase.c", whose content is basically:
|
||||
|
||||
#include <base/ftcalc.c>
|
||||
#include <base/ftobjs.c>
|
||||
#include <base/ftstream.c>
|
||||
#include <base/ftlist.c>
|
||||
#include <base/ftoutln.c>
|
||||
#include <base/ftextend.c>
|
||||
|
||||
Similarly, each component has a single "englobing" C file to compile it
|
||||
as a stand-alone object, i.e. :
|
||||
|
||||
src/base/ftbase.c - the base layer, high-level interface
|
||||
src/sfnt/sfnt.c - the "sfnt" module
|
||||
src/psnames/psnames.c - the Postscript Names module
|
||||
src/truetype/truetype.c - the TrueType font driver
|
||||
src/type1/type1.c - the Type 1 font driver
|
||||
|
||||
|
||||
To compile one component, do the following:
|
||||
|
||||
- add the top-level "include" directory to your compilation include path
|
||||
|
||||
- add the "src" directory to your compilation include path.
|
||||
|
||||
- compile the component "source" file (see list below), you don't need
|
||||
to be in the component's directory..
|
||||
|
||||
For example, the following line can be used to compile the truetype driver
|
||||
on Unix:
|
||||
|
||||
cd freetype2/
|
||||
cc -c -Iinclude -Isrc src/truetype/truetype.c
|
||||
|
||||
Alternatively:
|
||||
|
||||
cd freetype2/src/truetype
|
||||
cc -c -I../../include -I.. truetype.c
|
||||
|
||||
The complete list of files to compile for a feature-complete build of
|
||||
FreeType 2 is:
|
||||
|
||||
src/base/ftsystem.c - system-specific memory and i/o support
|
||||
src/base/ftinit.c - initialisation layer
|
||||
src/base/ftdebug.c - debugging component (empty in release build)
|
||||
src/base/ftbase.c - the "base layer" component
|
||||
src/base/ftglyph.c - optional convenience functions
|
||||
src/raster1/raster1.c - the monochrome bitmap renderer
|
||||
src/smooth/smooth.c - the anti-aliased bitmap renderer
|
||||
src/sfnt/sfnt.c - the "sfnt" module
|
||||
src/psnames/psnames.c - the "psnames" module
|
||||
src/truetype/truetype.c - the TrueType font driver
|
||||
src/type1/type1.c - the Type 1 font driver (incl. Multiple Masters)
|
||||
src/cid/type1cid.c - the Type 1 CID-keyed font driver
|
||||
src/cff/cff.c - the OpenType/CFF/CEF font driver
|
||||
src/winfonts/winfnt.c - the Windows FNT/FON font driver
|
||||
|
||||
All font drivers are optional. the "sfnt" and "psnames" modules are
|
||||
mandatory for certain drivers.
|
||||
|
||||
|
||||
III. Support for flat-directory compilation:
|
||||
----------------------------------------
|
||||
|
||||
It is now possible to put all FreeType 2 source files into a single
|
||||
directory, with the exception of the "include" hierarchy.
|
||||
|
||||
Note that you'll still need to only compile the 'wrapper' sources described
|
||||
above. Define the "FT_FLAT_COMPILE" macro when compiling. Here's an
|
||||
example:
|
||||
|
||||
1/ Copy all files in current directory:
|
||||
|
||||
cp freetype2/src/base/*.[hc] .
|
||||
cp freetype2/src/raster1/*.[hc] .
|
||||
cp freetype2/src/smooth/*.[hc] .
|
||||
etc...
|
||||
|
||||
2/ Compile sources:
|
||||
|
||||
cc -c -DFT_FLAT_COMPILE -Ifreetype/include ftsystem.c
|
||||
cc -c -DFT_FLAT_COMPILE -Ifreetype/include ftinit.c
|
||||
cc -c -DFT_FLAT_COMPILE -Ifreetype/include ftdebug.c
|
||||
cc -c -DFT_FLAT_COMPILE -Ifreetype/include ftbase.c
|
||||
etc...
|
||||
|
||||
@@ -0,0 +1,910 @@
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="Author" content="David Turner">
|
||||
<meta name="GENERATOR" content="Mozilla/4.5 [fr] (Win98; I) [Netscape]">
|
||||
<title>FreeType 2 Internals - I/O Frames</title>
|
||||
<basefont face="Georgia, Arial, Helvetica, Geneva">
|
||||
<style content="text/css">
|
||||
P { text-align=justify }
|
||||
H1 { text-align=center }
|
||||
H2 { text-align=center }
|
||||
LI { text-align=justify }
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body text="#000000"
|
||||
bgcolor="#FFFFFF"
|
||||
link="#0000EF"
|
||||
vlink="#51188E"
|
||||
alink="#FF0000">
|
||||
|
||||
<center>
|
||||
<h1>FreeType 2.0 Build System</h1></center>
|
||||
|
||||
<center>
|
||||
<h3>
|
||||
© 2000 David Turner (<a href="fichier :///[email protected]">[email protected]</a>)<br>
|
||||
© 2000 The FreeType Development Team
|
||||
(<a href="mailto:[email protected]">[email protected]</a>)
|
||||
</h3></center>
|
||||
|
||||
<center><table width=650><tr><td>
|
||||
|
||||
<p><hr WIDTH="100%"></p>
|
||||
|
||||
<h2>Table of Content</h2>
|
||||
|
||||
<center><table><tr><td>
|
||||
<p><font size="+1"><a href="#introduction">Introduction</a></font></p>
|
||||
<p><font size="+1"><a href="#features">I. Features & Background</a></font></p>
|
||||
<ul>
|
||||
<li><a href="#features-1">1. Convenience, not Requirement</a>
|
||||
<li><a href="#features-2">2. Compiler and platform independence</a>
|
||||
<li><a href="#features-3">3. Uses GNU Make</a>
|
||||
<li><a href="#features-4">4. Automatic host platform detection</a>
|
||||
<li><a href="#features-5">5. User-selectable builds</a>
|
||||
<li><a href="#features-6">6. Robustness</a>
|
||||
<li><a href="#features-7">7. Simple modules management</a>
|
||||
</ul>
|
||||
<p><font size="+1"><a href="#overview">II. Overview of the build process</a></font></p>
|
||||
<ul>
|
||||
<p><li><a href="#overview-1">1. Build setup</a>
|
||||
<ul>
|
||||
<li><a href="#overview-1-a">a. Default build setup</a>
|
||||
<li><a href="#overview-1-b">b. Selecting another build configuration</a>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<li><a href="#overview-2">2. Library compilation</a>
|
||||
</ul>
|
||||
<p><font size="+1"><a href="#setup">III. Build setup details</a></font></p>
|
||||
<p><font size="+1"><a href="#compilation">IV. Library compilation details</a></font></p>
|
||||
<ul>
|
||||
<li><a href="#compilation-1">a. Compiling the <tt>ftsystem</tt> component</a>
|
||||
<li><a href="#compilation-2">b. Compiling the base layer and optional components</a>
|
||||
<li><a href="#compilation-3">c. Compiling the modules</a>
|
||||
<li><a href="#compilation-4">d. Compiling the <tt>ftinit</tt> component</a>
|
||||
</ul>
|
||||
</ul>
|
||||
</td></tr></table></center>
|
||||
|
||||
<hr><a name="introduction">
|
||||
<h2>Introduction:</h2>
|
||||
|
||||
<p>This document describes the new build system that was introduced
|
||||
with FreeType 2.</p>
|
||||
|
||||
<p><hr></p>
|
||||
<a name="features">
|
||||
<h2>I. Features and Background:</h2>
|
||||
|
||||
<p>The FreeType 2 build system is a set of Makefiles and sub-Makefiles that
|
||||
are used to build the library on a very large variety of systems easily.
|
||||
One of its main features are the following:</p>
|
||||
|
||||
<a name="features-1">
|
||||
<h3>1. Convenience, not Requirement</h3>
|
||||
<ul>
|
||||
<p>Even though the build system is rather sophisticated, it simply is a
|
||||
convenience that was written simply to allow the compilation of the
|
||||
FreeType 2 library on as many platforms as possible, as easily as
|
||||
possible. However, it is not a requirement and the library can be
|
||||
compiled manually or in a graphical IDE without using it, with minimal
|
||||
efforts</p>
|
||||
|
||||
<p>(for more information on this topic, see the <tt>BUILD</tt>
|
||||
document that comes with your release of FreeType, in its <em>Detailed
|
||||
Compilation Guide</em> section).</p>
|
||||
</ul>
|
||||
|
||||
<a name="features-2">
|
||||
<h3>2. Compiler and platform independence</h3>
|
||||
<ul>
|
||||
<p>The FreeType 2 build system can be used with any compiler, on any platform.
|
||||
It is independent of object file suffix, executable file suffix, directory
|
||||
separator convention (i.e. "/" or "\"), and compiler flags for path
|
||||
inclusion, macro definition, output naming, ansi compliance, etc..</p>
|
||||
|
||||
<p>Supporting a new compiler is trivial and only requires writing a minimal
|
||||
configuration sub-makefile that contains several Makefile variables
|
||||
definitions that are later used by the rest of the build system. This is
|
||||
described in details later in the document.</p>
|
||||
</ul>
|
||||
|
||||
<a name="features-3">
|
||||
<h3>3. Uses GNU Make</h3>
|
||||
<ul>
|
||||
<p>The build system works <em>exclusively</em> with <b>GNU Make</b>. Reason
|
||||
is that it is the only make utility that has all the features required to
|
||||
implement the build system as described below. Moreover, it is already
|
||||
ported to hundreds of various distinct platforms and is widely and
|
||||
freely available.</p>
|
||||
|
||||
<p>It also uses the native command line shell. <em>You thus
|
||||
don't need a Unix-like shell on your platform</em>.
|
||||
For example, FreeType 2 already compiles on Unix, Dos, Windows
|
||||
and OS/2 right "out of the box" (assuming you have GNU Make
|
||||
installed).</p>
|
||||
|
||||
<p>Finally, note that the build system is <em>specifically</em> designed
|
||||
for gnu make and will <em>fail</em> with any other make tool. We have
|
||||
<em>no plans</em> to support a different tools, as you'll rapidly
|
||||
understand by reading this document or looking at the sub-makefiles
|
||||
themselves.</p>
|
||||
</ul>
|
||||
|
||||
<a name="features-4">
|
||||
<h3>4. Automatic host platform detection</h3>
|
||||
<ul>
|
||||
<p>When you launch the build system for the first time, by simply invoking
|
||||
GNU make in the top-level directory, it automatically tries to detect
|
||||
your current platform in order to choose the best configuration
|
||||
sub-makefile available. It then displays what it found. If everything
|
||||
is ok, you can then launch compilation of the library, by invoking make
|
||||
a second time.</p>
|
||||
|
||||
<p>The following platforms are currently automatically detected:</p>
|
||||
<ul>
|
||||
<li>Dos (plain-dos, windows in Dos mode, or Dos session under OS/2)
|
||||
<li>Windows 95, 98 + Windows NT (a.k.a win32)
|
||||
<li>OS/2
|
||||
<li>Unix (uses Autoconf/Automake)
|
||||
</ul>
|
||||
|
||||
<p>Note that adding support for a new platform requires writing a minimal
|
||||
number of very small files, and simply putting them in a new sub-directory
|
||||
of <tt>freetype2/config</tt>.</p>
|
||||
</ul>
|
||||
|
||||
<a name="features-5">
|
||||
<h3>5. User-selectable builds</h3>
|
||||
<ul>
|
||||
<p>The platform auto-detection rules try to setup the build for a default
|
||||
compiler (<em>gcc</em> for most platforms), with default build options
|
||||
for the library (which normally is
|
||||
<em>"all features enable, no debugging"</em>), as well as the default
|
||||
list of modules (which is <em>"all modules in <tt>freetype2/src</tt>"</em>)</p>
|
||||
|
||||
<p>There are cases where it is important to specify a different compiler,
|
||||
different build options or simply a different module list. The FreeType 2
|
||||
build system is designed in such a way that all of this is easily possible
|
||||
from the command line, <em>without having to touch a single file</em>.
|
||||
The latter is crucial when dealing with projects that need specific
|
||||
builds of the library without modifying a single file from the FreeType
|
||||
distribution.</p>
|
||||
|
||||
<p>The exact mechanism and implementation to do this is described later in
|
||||
this document. It allows, for example, to compile FreeType with any of
|
||||
the following compilers on Win32: gcc, Visual C++, Win32-LCC.</p>
|
||||
</ul>
|
||||
|
||||
<a name="features-6">
|
||||
<h3>6. Robustness</h3>
|
||||
<ul>
|
||||
<p>The build system uses a single top-level Makefile that includes
|
||||
one or more sub-makefiles to build the entire library (base layer
|
||||
plus all modules).
|
||||
|
||||
<font color="red">
|
||||
To understand why this is important, we <em>strongly</em> recommend
|
||||
the following article to all of our readers:</font></p>
|
||||
<p>
|
||||
<center>
|
||||
<font size="+2"><a href="http://www.pcug.org.au/~millerp/rmch/recu-make-cons-harm.html">
|
||||
Recursive Make Considered Dangerous
|
||||
</a>
|
||||
</font>
|
||||
</center>
|
||||
</p>
|
||||
|
||||
<p>As an example, here's a short list of files that make up the
|
||||
build system. Note that each sub-makefile contains rules corresponding
|
||||
to a very specific purpose, and that they all use the "<tt>.mk</tt>"
|
||||
suffix:</p>
|
||||
<ul>
|
||||
<li><tt>freetype2/Makefile</tt>
|
||||
<li><tt>freetype2/config/detect.mk</tt>
|
||||
<li><tt>freetype2/config/freetype.mk</tt>
|
||||
<li><tt>freetype2/config/<em><system></em>/detect.mk</tt>
|
||||
<li><tt>freetype2/src/<em><module></em>/rules.mk</tt>
|
||||
<li><tt>freetype2/src/<em><module></em>/module.mk</tt>
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
|
||||
<a name="features-7">
|
||||
<h3>7. Simple Module Management</h3>
|
||||
<ul>
|
||||
<p>FreeType 2 has a very modular design, and is made of a core
|
||||
<em>base layer</em> that provides its high-level API as well as
|
||||
generic services used by one or more <em>modules</em>.
|
||||
|
||||
Most modules are used to support a specific font format (like TrueType
|
||||
or Type 1), and they are called <em>font drivers</em>. However, some of
|
||||
them do not support font files directly, but rather provide helper
|
||||
services to the font drivers.</p>
|
||||
|
||||
<p>FreeType 2 is designed so that adding modules at run-time is possible
|
||||
and easy. Similarly, we expect many more modules to come in the near
|
||||
future and wanted a build system that makes such additions to the
|
||||
source package itself dead easy.
|
||||
|
||||
Indeed, all source code (base + modules) is located in the
|
||||
<tt>freetype2/src</tt> directory hierarchy. And the build system is
|
||||
capable of re-generating automatically the list of known modules
|
||||
from the contents of this directory. Hence, adding a new font driver
|
||||
to the FreeType sources simply requires to:</p>
|
||||
|
||||
<ul>
|
||||
<li><p>Add a new sub-directory to <tt>freetype2/src</tt>
|
||||
<li><p>Re-launch the build system</p>
|
||||
</ul>
|
||||
|
||||
<p>There is thus no need to edit a source file</p>
|
||||
</ul>
|
||||
|
||||
<p><hr><p>
|
||||
<a name="overview">
|
||||
<h2>II. Overview of the build process(es):</h2>
|
||||
|
||||
<p>Before describing in details how the build system works, it is essential
|
||||
to give a few examples of how it's used. This section presents
|
||||
what's the build process is to the typical developer:</p>
|
||||
|
||||
<p>Compiling the library is normally done in two steps: the first one
|
||||
configures the build according to the current platform and possible
|
||||
additional parameters, while the second simply compiles the library with
|
||||
the information gathered in the configuration step.</p>
|
||||
|
||||
<a name="overview-1">
|
||||
<h3>1. Build Setup</h3>
|
||||
|
||||
<a name="overview-1-a">
|
||||
<h4>a. Default build setup</h4>
|
||||
<ul>
|
||||
<p>To configure the build, simply invoke gnu make from the top-level FreeType
|
||||
directory. This will launch a series of rules that will detect your current
|
||||
host platform, and choose a configuration file for you. It will then display
|
||||
what it found. For example, here's the output of typing the command "make"
|
||||
on a win32 platform (assuming this calls GNU make):</p>
|
||||
|
||||
<pre><font color="blue">
|
||||
<font color="purple">C:\FreeType> make</font>
|
||||
|
||||
FreeType build system -- automatic system detection
|
||||
|
||||
The following settings are used:
|
||||
|
||||
platform win32
|
||||
compiler gcc
|
||||
configuration directory ./config/win32
|
||||
configuration rules ./config/win32/w32-gcc.mk
|
||||
|
||||
If this does not correspond to your system or settings please remove the file
|
||||
'config.mk' from this directory then read the INSTALL file for help.
|
||||
|
||||
Otherwise, simply type 'make' again to build the library.
|
||||
|
||||
<font color="purple">C:\FreeType></font>
|
||||
</font></pre>
|
||||
|
||||
<p>Note that this step copies the selected configuration file (here
|
||||
<tt>./config/win32/w32-gcc.mk</tt>) to <em>the current directory</em>, under
|
||||
the name <tt><b>config.mk</b></tt>. This file contains data that is used
|
||||
to drive the library compilation of the second step. It correspond to
|
||||
the platform and compiler selected by the auto-detection phase.</p>
|
||||
|
||||
<p>Note that you can re-generate the <tt><b>config.mk</b></tt> file anytime
|
||||
by invoking <tt>make setup</tt> whenever you need it, even when the file is
|
||||
already present in the current directory.</p>
|
||||
|
||||
<p>Finally, if your platform is not correctly detected, the build system will
|
||||
display and use configuration information for the virtual "ansi" platform.
|
||||
</p>
|
||||
</ul>
|
||||
<a name="overview-1-b">
|
||||
<h4>b. Selecting another build configuration</h4>
|
||||
<ul>
|
||||
<p>You may not be really satisfied by the configuration file selected by the
|
||||
auto-detection routines. Typically, you might be using a compiler that is
|
||||
not the default one for your platform. It is however possible to re-launch
|
||||
the build setup phase with an additional argument, used to specify a
|
||||
different compiler/config file. For example, you can type the following
|
||||
commands on Win32 systems:</p>
|
||||
|
||||
<p align=center><table width="80%" cellpadding=10><tr valign=top><td>
|
||||
<p><b><tt>make setup</tt></b></p>
|
||||
</td><td>
|
||||
<p>re-run the platform detection phase, and select the default compiler for it.
|
||||
On Win32, this is <em>gcc</em>.</p>
|
||||
</td></tr><tr valign=top><td>
|
||||
<p><b><tt>make setup visualc</tt></b></p>
|
||||
</td><td>
|
||||
<p>re-run the platform detection phase, and select a config file that
|
||||
corresponds to the <em>Visual C++</em> compiler</p>
|
||||
</td></tr><tr valign=top><td>
|
||||
<p><b><tt>make setup lcc</tt></b></p>
|
||||
</td><td>
|
||||
<p>re-run the platform detection phase, and select a config file that
|
||||
corresponds to the <em>Win32-LCC</em> compiler</p>
|
||||
</td></tr></table>
|
||||
</p>
|
||||
|
||||
<p>Note that a specific configuration is selected with a command that
|
||||
looks like : <tt><b>make setup <em>compiler</em></b></tt>,
|
||||
where the <em><tt>compiler</tt></em> keywords depends on the platform.
|
||||
Moreover, each one of them corresponds to a specific configuration
|
||||
sub-makefile that is copied as <b><tt>config.mk</tt></b> in the current
|
||||
directory.</p>
|
||||
</ul>
|
||||
|
||||
|
||||
<a name="overview-2">
|
||||
<h3>2. Library compilation</h3>
|
||||
|
||||
<p>Once you're satisfied with the version of <b><tt>config.mk</tt></b> that
|
||||
has been copied to your current directory, you can simply re-invoke
|
||||
gnu make <em>with no arguments</em>. The top-level Makefile will
|
||||
automatically detect the config sub-makefile in the current directory,
|
||||
and use it to drive the library compilation. The latter can be seen
|
||||
as a series of different steps decribed here:</p>
|
||||
|
||||
<ul>
|
||||
<li><p><b>Compiling the <tt>ftsystem</tt> component</b><br><ul>
|
||||
It encapsulates all low-level operations (memory management +
|
||||
i/o access) for the library. Its default version, located in
|
||||
<tt>./src/base/ftsystem.c</tt> uses the ANSI C library but
|
||||
system-specific implementations are also available to
|
||||
improve performance (e.g. memory-mapped files on Unix).
|
||||
</ul></p>
|
||||
|
||||
<li><p><b>Compiling the <em>base layer</em> and optional components</b><br><ul>
|
||||
They provide the library's high-level API as well as various useful
|
||||
routines for client applications. Many features of the base layer can
|
||||
be activated or not depending on a configuration file named
|
||||
<tt>ftoption.h</tt>
|
||||
</ul></p>
|
||||
|
||||
<li><p><b>Compiling the <em>modules</em></b><br><ul>
|
||||
Each module is used to support a specific font format (it is then
|
||||
called a <em>font driver</em>), or to provide helper services to
|
||||
the drivers (e.g. the auto-hinter). They are all located in
|
||||
sub-directories of <tt>./src</tt>, like <tt>./src/truetype</tt>,
|
||||
<tt>./src/type1</tt>.
|
||||
</ul></p>
|
||||
|
||||
<li><p><b>Compiling the <tt>ftinit</tt> component</b><br><ul>
|
||||
This one is in charge of implementing <tt>FT_Init_FreeType</tt>,
|
||||
the library initialisation routine. It also selects what modules
|
||||
are activated when a new library instance is created.
|
||||
</ul></p>
|
||||
</ul>
|
||||
<p><hr><p>
|
||||
<a name="setup">
|
||||
<h2>II. Details of the build setup.</h2>
|
||||
|
||||
<p>When the top-level <tt>Makefile</tt> is invoked, it looks for a
|
||||
file named <b><tt>config.mk</tt></b> in the <em>current directory</em>.
|
||||
If this file is found, it is used directly to build the library
|
||||
(skip to <a href="library">Section III</a> for details then).</p>
|
||||
|
||||
<p>Otherwise, the file <b><tt>./config/detect.mk</tt></b> is included
|
||||
by the top-level <tt>Makefile</tt> and parsed. Its purpose is to drive the
|
||||
platform-detection phase, by:</p>
|
||||
|
||||
<ul>
|
||||
<li><p>Defining the <tt>PLATFORM</tt> variable, which indicates
|
||||
what the currently detected platform is. It is initially
|
||||
set to the default value "<tt><b>ansi</b></tt>".
|
||||
</p>
|
||||
|
||||
<li><p>Searching for a <tt>detect.mk</tt> file in <em>all
|
||||
subdirectories</em> of <b><tt>./config</tt></b>.
|
||||
Each such file is included and parsed. Each of these files must
|
||||
try to detect if the host platform is a system it knows
|
||||
about. If so, it changes the value of the <tt>PLATFORM</tt> variable
|
||||
accordingly.</p>
|
||||
|
||||
<li><p>Copying the selected configuration submakefile to the current directory
|
||||
under the name <tt><b>config.mk</b></tt>.</p>
|
||||
</ul>
|
||||
<p>This is illustrated by the following graphics :</p>
|
||||
<p><center>
|
||||
<img src="platform-detection.png" border=0>
|
||||
</center></p>
|
||||
|
||||
<p>Each system-specific <b><tt>detect.mk</tt></b> works as follows:</p>
|
||||
<ul>
|
||||
<li><p>It checks that the value of <tt>PLATFORM</tt> is currently set
|
||||
to <b>ansi</b>, which indicates that no platform was detected
|
||||
for now. If this isn't true, it doesn't do anything</p>
|
||||
|
||||
<li><p>Otherwise, it runs a series of test to see wether it is on a
|
||||
system it knows about. Here are a few examples of tests:</p>
|
||||
|
||||
<p><center><table width="80%" cellpadding=5><tr valign=top><td>
|
||||
<em><b>Unix</b></em>
|
||||
</td><td>
|
||||
<p>checks for a file named <tt>/sbin/init</tt>, and runs, when it found
|
||||
it, a 'configure' script to generate the relevant config sub-makefile</p>
|
||||
</td></tr><tr valign=top><td>
|
||||
<em><b>Dos</b></em>
|
||||
</td><td>
|
||||
<p>checks for the <tt>COMSPEC</tt> environment variable, then tries to
|
||||
run the "<tt>ver</tt>" command on the current shell to check that there
|
||||
is a "Dos" substring in its output; if not, it tries to find the
|
||||
substring "<tt>MDOS\COMMAND</tt>" in <tt>COMSPEC</tt>, which indicates
|
||||
a Dos session under OS/2.</p>
|
||||
</td></tr><tr valign=top><td>
|
||||
<em><b>Win32</b></em>
|
||||
</td><td>
|
||||
<p>if the environment variable <tt>OS</tt> is defined and has the value
|
||||
<tt>Windows_NT</tt>, or if <tt>COMSPEC</tt> is defined and the
|
||||
"<tt>ver</tt>" returns a string that contains <tt>Windows</tt> in it,
|
||||
we're on a Win32 system.</p>
|
||||
</td></tr></table></center>
|
||||
</p>
|
||||
|
||||
<li><p>It sets the value of <tt>PLATFORM</tt> to a new value corresponding
|
||||
to its platform.</p>
|
||||
|
||||
<li><p>It then tries to select a configuration
|
||||
sub-makefile, depending on the current platform and any optional
|
||||
make target (like "visualc" or "devel", etc..). Note that it can
|
||||
even generate the file, as on Unix through Autoconf/Automake.</p>
|
||||
|
||||
<li><p>It copies the selected configuration sub-makefile to the current
|
||||
directory, under the name <tt><b>config.mk</b></tt>
|
||||
</ul>
|
||||
|
||||
<p>If one wants to support a new platform in the build system, it simply needs
|
||||
to provide:</p>
|
||||
|
||||
<ul>
|
||||
<li>A new subdirectory, in <tt>./config</tt>, with a file named
|
||||
<tt>detect.mk</tt> in it, containing relevant checks for the system.
|
||||
|
||||
<li>One or more configuration sub-makefiles that will get copied to
|
||||
<tt>config.mk</tt> at build setup time. You can use the one in
|
||||
<tt>./config/ansi/config.mk</tt> as a template.
|
||||
</ul>
|
||||
|
||||
<p>Similary, supporting a new compiler on an existing system simply means:</p>
|
||||
<ul>
|
||||
<li>Writing a new config sub-makefile that contains definitions used to
|
||||
specify the compiler and flags for the build.
|
||||
|
||||
<li>Change your <tt>./config/<em>system</em>/detect.mk</tt> to recognize
|
||||
a new optional build target that will copy your new config sub-makefile
|
||||
instead of the default one.
|
||||
</ul>
|
||||
|
||||
|
||||
<p><hr><p>
|
||||
<h2>III. Details of the library compilation.</h2>
|
||||
|
||||
<p>When the top-level Makefile is invoked, it looks for a file named
|
||||
<tt>config.mk</tt> in the current directory. If one is found, it
|
||||
defines the <tt>BUILD_FREETYPE</tt> variable, then includes and parses it.
|
||||
The structure of this file is the following:
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li><p>First, it defines a series of Make variables that describe
|
||||
the host environment, like the compiler, compilation flags,
|
||||
object file suffix, the directory where all object files are
|
||||
placed, etc..</p>
|
||||
|
||||
<li><p>If <tt>BUILD_FREETYPE</tt> is defined, it includes the file
|
||||
<tt><b>./config/freetype.mk</b></tt>, which is in charge of
|
||||
defining all the rules used to build the library object files.
|
||||
(The test is useful to use the <tt>config.mk</tt> file to
|
||||
compile other projects that rely on FreeType 2, like its
|
||||
demonstration programs).</p>
|
||||
|
||||
<li><p>Finally, it defines the rule(s) used to link FreeType 2 object files
|
||||
into a library file (e.g. <tt>libfreetype.a</tt>, <tt>freetype.lib</tt>,
|
||||
<tt>freetype.dll</tt>, ...). Unfortunately, the command line interface of link tools is
|
||||
a <em>lot less</em> standardized than those of compilers, which
|
||||
explains why this rule must be defined in the system-specific
|
||||
<tt>config.mk</tt>.</p>
|
||||
</ul>
|
||||
|
||||
<p>The following is an explanation of what <tt><b>./config/freetype.mk</b></tt>
|
||||
does to build the library objects:
|
||||
</p>
|
||||
|
||||
<h4>a. Include paths</h4>
|
||||
<ul>
|
||||
<p>To avoid namespace pollution, the <tt><em>freetype</em></tt> directory prefix
|
||||
is used to include all public header files of the library. This means
|
||||
that a client application will typically use lines like:</p>
|
||||
|
||||
<pre><font color="blue">
|
||||
#include <freetype/freetype.h>
|
||||
#include <freetype/ftglyph.h>
|
||||
</font></pre>
|
||||
|
||||
<p>to include one the FreeType 2 public header files. <tt>freetype.mk</tt>
|
||||
uses a variable named <tt><b>INCLUDES</b></tt> to hold the inclusion
|
||||
paths list, and thus starts by adding <tt>./include</tt> to it. However,
|
||||
nothing prevents
|
||||
|
||||
<p><tt>freetype.mk</tt> uses a variable named <tt><b>INCLUDES</b></tt>
|
||||
to hold directory inclusion-path to be used when compiling the library.
|
||||
It always add <tt>./include</tt> to this variable, which means
|
||||
|
||||
</ul>
|
||||
|
||||
<h4>b. Configuration header files:</h4>
|
||||
<ul>
|
||||
<p>Three header files used to configure the compilation of the
|
||||
FreeType 2 library. Their default versions are all located in the
|
||||
directory <tt><b>./include/freetype/config/</b></tt>, even though
|
||||
project specific versions can be provided on a given build, as
|
||||
described later:</p>
|
||||
|
||||
<ul>
|
||||
<p><b><tt>#include <freetype/config/ftoption.h></tt></b><br><ul>
|
||||
This file contains a set of configuration macro definitions that
|
||||
can be toggled to activate or deactivate certain features of the
|
||||
library. By changing one of these definitions, it is possible to
|
||||
compile <em>only the features that are needed</em> for a specific
|
||||
project. Note that by default, all options are enabled.
|
||||
<br><br>
|
||||
You might need to provide an alternative version of <tt>ftoption.h</tt>
|
||||
for one of your own projects.
|
||||
</ul></p>
|
||||
|
||||
<p><b><tt>#include <freetype/config/ftconfig.h></tt></b><br><ul>
|
||||
This file includes <tt>ftoption.h</tt> but also contains some automatic
|
||||
macro definitions used to indicate some important system-specific
|
||||
features (e.g: word size in bytes, DLL export prefix macros, etc..).
|
||||
<br><br>
|
||||
You shouldn't normally need to change or provide an alternative
|
||||
version of this file.
|
||||
</ul></p>
|
||||
|
||||
|
||||
<p><b><tt>#include <freetype/config/ftmodule.h></tt></b><br><ul>
|
||||
This file is very special, as it is normally machine-generated, and
|
||||
used by the <tt>ftinit</tt> component that is described below. To
|
||||
understand it, one must reminds that FreeType 2 has an extremely
|
||||
modular design and that it's possible to change, <em>at run-time</em>,
|
||||
the modules it's using. The <tt>ftmodule.h</tt> file simply contains
|
||||
the list of modules that are registered with each new instance of
|
||||
the library.
|
||||
<br><br>
|
||||
Note that the file can be re-generated automatically by invoking
|
||||
<tt>make setup</tt> from the top-level directory. The re-generated
|
||||
list contains all the modules that were found in subdirectories of
|
||||
<tt>./src</tt>.
|
||||
</ul></p>
|
||||
</ul>
|
||||
|
||||
<p>Note that we strongly advise you to avoid modifying the config files
|
||||
within the FreeType 2 source directory hierarchy. Rather, it's possible
|
||||
to specify alternative versions through the help of a build-specific
|
||||
include path that is include before <tt>./include</tt> in the inclusion
|
||||
path.</p>
|
||||
|
||||
<p>For example, imagine that your platform, named <em>foo</em>, needs a
|
||||
specific version of <tt>ftoption.h</tt>
|
||||
</ul>
|
||||
|
||||
<h4>a. Compiling the <b><tt>ftsystem</tt></b> component:</h4>
|
||||
<ul>
|
||||
<p>FreeType 2 encapsulates all low-level operations (i.e. memory management
|
||||
and i/o access) within a single component called <tt><b>ftsystem</b></tt>.
|
||||
Its default implementation uses the <em>ANSI C Library</em> and is located
|
||||
in <tt>./src/base/ftsystem.c</tt>.</p>
|
||||
|
||||
<p>However, some alternate, system-specific, implementations of
|
||||
<tt>ftsystem</tt> are provided with the library in order to support more
|
||||
efficient and advanced features. As an example, the file
|
||||
<tt>./config/unix/ftsystem.c</tt> is an implementation that
|
||||
uses memory-mapped files rather than the slow ANSI <tt>fopen</tt>,
|
||||
<tt>fread</tt> and <tt>fseek</tt>, boosting performance significantly.</p>
|
||||
|
||||
<p>The build system is thus capable of managing alternate implementations
|
||||
of <tt>ftsystem</tt></p>
|
||||
</ul>
|
||||
|
||||
<h4>b. Compiling the base layer and optional components:</h4>
|
||||
<ul>
|
||||
<p>The high-level API of the library is provided by a component called the
|
||||
<em>base layer</em>, whose source is located in <tt>./src/base</tt>. This
|
||||
directory also contains one or more components that are optional, i.e.
|
||||
that are not required by the library but provide valuable routines to
|
||||
client applications.</p>
|
||||
|
||||
<p>The features of the base library and other components are selected through
|
||||
a single configuration file named
|
||||
<tt><b>./include/freetype/config/ftoption.h</b></tt>. It contains a list
|
||||
of commented configuration macro definitions, that can be toggled to
|
||||
activate or de-activate a certain feature or component at build time.</p>
|
||||
|
||||
<p>For example, the code in <tt>./src/base/ftdebug.c</tt> will be compiled
|
||||
only if one of these two macros are defined in <tt>ftoption.h</tt>:
|
||||
<tt>FT_DEBUG_LEVEL_ERROR</tt> or <tt>FT_DEBUG_LEVEL_TRACE</tt></p>
|
||||
</ul>
|
||||
|
||||
<h4>c. Compiling the modules:</h4>
|
||||
<ul>
|
||||
<p>Once the base layer is completed, the build system starts to compile each
|
||||
additional module independently. These are simply defined as all source
|
||||
code located in a sub-directory of <tt>./src</tt> that contains a file
|
||||
named <tt><b>rules.</b></tt>, for example:
|
||||
<tt>src/sfnt</tt>, <tt>src/truetype</tt>, <tt>src/type1</tt>, ...</p>
|
||||
|
||||
<p>The <tt><b>rules.</b></tt> file simply contains directives used by the
|
||||
build system to compile the corresponding module into a single object
|
||||
file.</p>
|
||||
</ul>
|
||||
|
||||
<h4>d. Compiling the <b><tt>ftinit</tt></b> component:</h4>
|
||||
<ul>
|
||||
<p>The file <tt><b>./src/base/ftinit.c</b></tt> is special because it is used
|
||||
to implement the library initialisation function <tt>FT_Init_FreeType</tt>.
|
||||
</p>
|
||||
</ul>
|
||||
|
||||
<p>Typically, you will end up with all object files, as well as the
|
||||
corresponding library file, residing in the <tt>freetype2/obj</tt>
|
||||
directory.</p>
|
||||
|
||||
|
||||
<h3>1. Purpose of the configuration sub-makefile</h3>
|
||||
|
||||
<h3>2. Managing module dependencies</h3>
|
||||
|
||||
<h3>3. </h3>
|
||||
|
||||
<p><hr><p>
|
||||
<a name="modules">
|
||||
<h2>IV. Managing the modules list</h2>
|
||||
|
||||
<p><hr><p>
|
||||
The build system features some important points, which are all detailed
|
||||
in the following sections:<p>
|
||||
<ul>
|
||||
<li><b>Automatic host platform detection</b><br>
|
||||
The first time the top <tt>Makefile</tt> is invoked, it will
|
||||
run a series of rules to detect your platform. It will then
|
||||
create a system-specific configuration sub-Makefile in the
|
||||
current directory, called <b><tt>config.mk</tt></b>. You can now
|
||||
invoke the top <tt>Makefile</tt> a second time to compile the
|
||||
library directly.
|
||||
<p>
|
||||
The configuration sub-makefile can be regenerated any time
|
||||
by invoking "<tt>make setup</tt>", which will re-run the
|
||||
detection rules even if a <tt>config.mk</tt> is already present.
|
||||
<p>
|
||||
|
||||
|
||||
<li><b>User-selectable builds</b><br>
|
||||
<p>
|
||||
|
||||
|
||||
|
||||
<li><b>Automatic detection of font drivers</b><br>
|
||||
FreeType is made of a "base" layer that invokes several
|
||||
separately-compiled modules. Each module is a given
|
||||
font driver, in charge of supporting a given font format.
|
||||
<p>
|
||||
The list of font drivers is located in the file
|
||||
"<tt>freetype2/config/<em>system</em>/ftmodule.h</tt>", however
|
||||
it can be regenerated on-demand. Adding a new module to the
|
||||
FreeType source tree is thus as easy as:<p>
|
||||
<ul>
|
||||
<li>create a new directory in "<tt>freetype2/src</tt>" and
|
||||
put the new driver's source code and sub-makefiles there.
|
||||
<p>
|
||||
|
||||
<li>invoke the top <tt>Makefile</tt> with target
|
||||
"<tt>modules</tt>" (as in "<tt>make modules</tt>"),
|
||||
as this will automatically regenerate the list of
|
||||
available drivers by detecting the new directory and
|
||||
its content.
|
||||
</ul>
|
||||
<p>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
<p><hr><p>
|
||||
|
||||
<h2>II. Host Platform Detection</h2>
|
||||
<ul>
|
||||
When the top-level <tt>Makefile</tt> is invoked, it looks for a
|
||||
file named <tt>config.mk</tt> in the current directory. If this
|
||||
file is found, it is used to build the library
|
||||
(see <a href="library">Section III</a>).
|
||||
<p>
|
||||
Otherwise, the file <tt>freetype2/config/detect.mk</tt> is included
|
||||
and parsed. Its purpose is to:<p>
|
||||
<ul>
|
||||
<li>Define the <tt>PLATFORM</tt> variable, which indicates
|
||||
what is the currently detected platform. It is initially
|
||||
set to the default value "<tt>ansi</tt>".
|
||||
<p>
|
||||
|
||||
<li>It searches for a <tt>detect.mk</tt> file in all
|
||||
subdirectories of <tt>freetype2/config</tt>. Each such
|
||||
file is included and parsed. Each of these files must
|
||||
try to detect if the host platform is a system it knows
|
||||
about. If so, it changes the value of the <tt>PLATFORM</tt>
|
||||
accordingly.
|
||||
</ul>
|
||||
<p>
|
||||
This is illustrated by the following graphics :<p>
|
||||
<center>
|
||||
<img src="platform-detection.png" border=0>
|
||||
</center>
|
||||
<p>
|
||||
Note that each system-specific <tt>detect.mk</tt> is in charge
|
||||
of copying a valid configuration makefile to the current directory
|
||||
(i.e. the one where <tt>make</tt> was invoked), depending on the
|
||||
current targets. For example, the Win32 <tt>detect.mk</tt> will
|
||||
be able to detect a "<tt>visualc</tt>" or "<tt>lcc</tt>" target,
|
||||
as described in section I. Similarly, the OS/2 <tt>detect.mk</tt>
|
||||
can detect targets like "<tt>borlandc</tt>", "<tt>watcom</tt>"
|
||||
or "<tt>visualage</tt>", etc..
|
||||
</ul>
|
||||
|
||||
<p><hr><p>
|
||||
|
||||
<h2>III. Building the library</h2>
|
||||
<ul>
|
||||
When the top-level <tt>Makefile</tt> is invoked and that it finds
|
||||
a <tt>config.mk</tt> file in the current directory, it defines
|
||||
the variable <tt>BUILD_FREETYPE</tt>, then includes and parses the
|
||||
configuration sub-makefile.
|
||||
<p>
|
||||
The latter defines a number of important variables that describe
|
||||
the compilation process to the build system. Among other things:<p>
|
||||
<ul>
|
||||
<li>the extension to be used for object files and library files
|
||||
(i.e. <tt>.o</tt> and <tt>.a</tt> on Unix, <tt>.obj</tt>
|
||||
and <tt>.lib</tt> on Dos-Windows-OS/2, etc..).
|
||||
<p>
|
||||
|
||||
<li>the directory where all object files will be stored
|
||||
(usually <tt>freetype2/obj</tt>), as well as the one
|
||||
containing the library file (usually the same as for
|
||||
objects).
|
||||
<p>
|
||||
|
||||
<li>the command line compiler, and its compilation flags for
|
||||
indicating a new include path (usually "<tt>-I</tt>"),
|
||||
a new macro declaration (usually "<tt>-D</tt>") or
|
||||
the target object file (usually "<tt>-o </tt>")
|
||||
</ul>
|
||||
<p>
|
||||
Once these variable are defined, <tt>config.mk</tt> test for the
|
||||
definition of the <tt>BUILD_FREETYPE</tt> variable. If it exists,
|
||||
the makefile then includes "<tt>freetype2/config/freetype.mk</tt>"
|
||||
which contains the rules required to compile the library.
|
||||
<p>
|
||||
Note that <tt>freetype.mk</tt> also scans the subdirectories of
|
||||
"<tt>freetype2/src</tt>" for a file called "<tt>rules.mk</tt>".
|
||||
Each <tt>rules.mk</tt> contains, as it names suggests, the rules
|
||||
required to compile a given font driver or module.
|
||||
<p>
|
||||
Once all this parsing is done, the library can be compiled. Usually,
|
||||
each font driver is compiled as a standalone object file (e.g.
|
||||
<tt>sfnt.o</tt>, <tt>truetype.o</tt> and <tt>type1.o</tt>).
|
||||
<p>
|
||||
This process can be illustrated by the following graphics:<p>
|
||||
<center>
|
||||
<img src="library-compilation.png" border=0>
|
||||
</center>
|
||||
<p>
|
||||
</ul>
|
||||
|
||||
<p><hr><p>
|
||||
|
||||
<h2>IIV. Managing the list of modules</h2>
|
||||
<ul>
|
||||
The makefile <tt>freetype.mk</tt> only determines how to compile
|
||||
each one of the modules that are located in the sub-directories of
|
||||
<tt>freetype2/src</tt>.
|
||||
<p>
|
||||
However, when the function <tt>FT_Init_FreeType</tt> is invoked at
|
||||
the start of an application, it must create a new <tt>FT_Library</tt>
|
||||
object, and registers all <em>known</em> font drivers to it by
|
||||
repeatly calling <tt>FT_Add_Driver</tt>.
|
||||
<p>
|
||||
The list of <em>known</em> drivers is located in the file
|
||||
"<tt>freetype2/config/<em>system</em>/ftmodule.h</tt>", and is used
|
||||
exclusively by the internal function <tt>FT_Default_Drivers</tt>. The
|
||||
list in <tt>ftmodule.h</tt> must be re-generated each time you add
|
||||
or remove a module from <tt>freetype2/src</tt>.
|
||||
<p>
|
||||
This is normally performed by invoking the top-level <tt>Makefile</tt>
|
||||
with the <tt>modules</tt> target, as in:<p>
|
||||
<ul>
|
||||
<tt>make modules</tt>
|
||||
</ul>
|
||||
<p>
|
||||
This will trigger a special rule that will re-generate
|
||||
<tt>ftmodule.h</tt>. To do so, the Makefile will parse all module
|
||||
directories for a file called "<tt>module.mk</tt>". Each
|
||||
<tt>module.mk</tt> is a tiny sub-Makefile used to add a single
|
||||
module to the driver list.
|
||||
<p>
|
||||
This is illustrated by the following graphics:<p>
|
||||
<center>
|
||||
<img src="drivers-list.png" border=0>
|
||||
</center>
|
||||
<p>
|
||||
Note that the new list of modules is displayed in a very human-friendly
|
||||
way after a "<tt>make modules</tt>". Here's an example with the current
|
||||
source tree (on 11 Jan 2000):<p>
|
||||
<ul><pre>
|
||||
Regenerating the font drivers list in ./config/unix/ftmodule.h
|
||||
* driver: sfnt ( pseudo-driver for TrueType & OpenType formats )
|
||||
* driver: truetype ( Windows/Mac font files with extension *.ttf or *.ttc )
|
||||
* driver: type1 ( Postscript font files with extension *.pfa or *.pfb )
|
||||
-- done --
|
||||
</pre></ul>
|
||||
|
||||
</ul>
|
||||
|
||||
<p><hr><p>
|
||||
|
||||
<h2>V. Building the demonstration programs</h2>
|
||||
<ul>
|
||||
Several demonstration programs are located in the
|
||||
"<tt>freetype2/demos</tt>" directory hierarchy. This directory also
|
||||
includes a tiny graphics sub-system that is able to blit glyphs to
|
||||
a great variety of surfaces, as well as display these in various
|
||||
graphics libraries or windowed environments.
|
||||
<p>
|
||||
This section describes how the demonstration programs are compiled,
|
||||
using the configuration <tt>freetype2/config.mk</tt> and their own
|
||||
<tt>freetype2/demos/Makefile</tt>.
|
||||
<p>
|
||||
To compile the demonstration programs, <em>after the library</em>,
|
||||
simply go to <tt>freetype2/demos</tt> then invoke GNU make with no
|
||||
arguments.
|
||||
<p>
|
||||
The top-level Makefile will detect the <tt>config.mk</tt> in the
|
||||
<em>upper</em> directory and include it. Because it doesn't define
|
||||
the <tt>BUILD_FREETYPE</tt> variable, this will not force the
|
||||
inclusion of <tt>freetype2/config/freetype.mk</tt> as described in
|
||||
the previous section.
|
||||
<p>
|
||||
the <tt>Makefile</tt> will then include the makefile called
|
||||
"<tt>freetype2/demos/graph/rules.mk</tt>". The graphics <tt>rules.mk</tt>
|
||||
defines the rules required to compile the graphics sub-system.
|
||||
<p>
|
||||
Because the graphics syb-system is also designed modularly, it is able
|
||||
to use any number of "modules" to display surfaces on the screen.
|
||||
The graphics modules are located in the subdirectories of
|
||||
<tt>freetype2/demos/config</tt>. Each such directory contains a file
|
||||
named <tt>rules.mk</tt> which is in charge of:<p>
|
||||
<ul>
|
||||
<li>detecting wether the corresponding graphics library is
|
||||
available at the time of compilation.
|
||||
<p>
|
||||
<li>if it is, alter the compilation rules to include the graphics
|
||||
module in the build of the <tt>graph</tt> library.
|
||||
</ul>
|
||||
<p>
|
||||
When the <tt>graph</tt> library is built in <tt>demos/obj</tt>, the
|
||||
demonstration programs executables are generated by the top-level
|
||||
Makefile.
|
||||
<p>
|
||||
This is illustrated by the following graphics:<p>
|
||||
<center>
|
||||
<img src="demo-programs.png" border="0">
|
||||
</center>
|
||||
</ul>
|
||||
|
||||
<p><hr>
|
||||
</td></tr></table></center>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
‰PNG
|
||||
@@ -0,0 +1 @@
|
||||
‰PNG
|
||||
@@ -0,0 +1,791 @@
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="Author" content="David Turner">
|
||||
<meta name="GENERATOR" content="Mozilla/4.5 [fr] (Win98; I) [Netscape]">
|
||||
<title>FreeType 2 Internals</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<body text="#000000"
|
||||
bgcolor="#FFFFFF"
|
||||
link="#0000EF"
|
||||
vlink="#51188E"
|
||||
alink="#FF0000">
|
||||
|
||||
<center>
|
||||
<h1>
|
||||
FreeType 2.0 Internals</h1></center>
|
||||
|
||||
<center>
|
||||
<h2>
|
||||
Version 1.2</h2></center>
|
||||
|
||||
<center>
|
||||
<h3>
|
||||
© 1999-2000 David Turner (<a href="fichier :///[email protected]">[email protected]</a>)<br>
|
||||
© 1999-2000 The FreeType Development Team (<a href="fichier :///[email protected]">[email protected]</a>)</h3></center>
|
||||
|
||||
<p><br>
|
||||
<hr WIDTH="100%">
|
||||
<br>
|
||||
<h2>Introduction:</h2>
|
||||
|
||||
<p>This document describes in great deatils the internals of FreeType 2.
|
||||
It is a must read for porters and developers alike. Its purpose is to
|
||||
|
||||
present the
|
||||
<blockquote>This document describes in great details the internals of the
|
||||
FreeType 2.0 library. It is a must read for porters and developers alike.
|
||||
Its purpose is to present the engine's objects, their roles and interactions.
|
||||
It is assumed that the <b><i>FreeType Glyph Conventions</i></b> document
|
||||
has been read.
|
||||
<p>We advise porters to also read the <b><i>FreeType Porting Guide</i></b>
|
||||
after this document. Would-be hackers and maintainers are of course encouraged
|
||||
to read the <b><i>FreeType Coding Conventions</i></b> document too. The
|
||||
development of a new driver is described in more details in the <b><i>FreeType
|
||||
Driver HowTo</i></b> document.</blockquote>
|
||||
|
||||
<p><br>
|
||||
<hr WIDTH="100%">
|
||||
<h2>
|
||||
I. Overview :</h2>
|
||||
|
||||
<blockquote>
|
||||
<h3>
|
||||
1. Features (and what's new) :</h3>
|
||||
|
||||
<blockquote>FreeType 2.0 has a number of important new features that were
|
||||
not found in the 1.x releases :
|
||||
<br>
|
||||
<blockquote><b>font-format independent API</b>
|
||||
<br>FreeType 2.0 is able to support any kind of font format, be it fixed
|
||||
or scalable, through the use of pluggable "font drivers". These drivers
|
||||
can be added or replaced at run time, while applications use a new font
|
||||
format-independent API.
|
||||
<p><b>advanced stream caching</b>
|
||||
<br>2.0 is able to control the number of concurrently opened streams when
|
||||
using fonts. It is thus possible to open dozens or hundreds of font faces
|
||||
without running out of system resources.
|
||||
<p><b>real reentrancy support</b>
|
||||
<br>It is now possible to use FreeType as a shared library with no static
|
||||
data in a multi-threaded environment. The synchronization model has also
|
||||
been simplified in order to make font driver writing easier. Of course,
|
||||
you can build FreeType with no thread support to get a smaller library.
|
||||
<p><b>support for cubic beziers and 17-levels anti-aliasing</b>
|
||||
<br>The FreeType scan-line converter (a.k.a. raster) now supports cubic
|
||||
bezier arcs seamlessly. It also provides a new anti-aliasing mode which
|
||||
uses a palette of 17 levels of grays.
|
||||
<br> </blockquote>
|
||||
It also features the following :
|
||||
<blockquote><b>performance improvements :</b>
|
||||
<br>The FreeType raster has been optimized, and the generation of anti-aliased
|
||||
pixmaps is now 60% faster than in the 1.x release. Moreover, the TrueType
|
||||
bytecode interpreter has been profiled and greatly optimised.
|
||||
<p><b>easier portability</b>
|
||||
<br>Porting and configuring FreeType is now much easier. A single file
|
||||
must be provided for system-specific operations (like memory, i/o, thread
|
||||
management), and a single configuration header is used to select the build
|
||||
you need.
|
||||
<br> </blockquote>
|
||||
</blockquote>
|
||||
|
||||
<h3>
|
||||
2. Architecture :</h3>
|
||||
|
||||
<blockquote>The engine is now split in several parts, which are :
|
||||
<h4>
|
||||
a. The base layer :</h4>
|
||||
|
||||
<blockquote>This part contains all the font-format independent features
|
||||
of the engine which are :
|
||||
<ul>
|
||||
<li>
|
||||
computations/scaling</li>
|
||||
|
||||
<li>
|
||||
list processing</li>
|
||||
|
||||
<li>
|
||||
outline processing</li>
|
||||
|
||||
<li>
|
||||
scan-line converter</li>
|
||||
|
||||
<li>
|
||||
stream manager</li>
|
||||
|
||||
<li>
|
||||
base object classes</li>
|
||||
|
||||
<li>
|
||||
debugging & traces</li>
|
||||
|
||||
<li>
|
||||
high-level API functions</li>
|
||||
|
||||
<li>
|
||||
low-level system object (memory, i/o, threads)</li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
|
||||
<h4>
|
||||
b. The font drivers :</h4>
|
||||
|
||||
<blockquote>Each font format is managed with the use of a single font driver
|
||||
object. The base layer is able to manage several drivers, and these can
|
||||
be easily added, removed or upgraded at runtime. Each driver has the following
|
||||
features and functions :
|
||||
<ul>
|
||||
<li>
|
||||
auto-check font format when opening a font resource (i.e. file)</li>
|
||||
|
||||
<li>
|
||||
access, load and/or extract all tables and data from the font file</li>
|
||||
|
||||
<li>
|
||||
grid-fit/hint the glyph outlines (in the case of scalable formats like
|
||||
TrueType or Type1)</li>
|
||||
|
||||
<li>
|
||||
provide extensions to access font format-specific data and tables from
|
||||
the font file</li>
|
||||
</ul>
|
||||
Note that FreeType 2.0 is a font service. Its purpose is to provide a unified
|
||||
API for all kinds of fonts and extract individual glyph images and metrics.
|
||||
However, it does not render text itself, as this operation is left to the
|
||||
developer, or to higher-level libraries built on top of FreeType. Here
|
||||
are a few features that are thus not implemented :
|
||||
<blockquote>1) Text string rendering
|
||||
<br>2) Glyph bitmap/outline caching for improved performance
|
||||
<br>3) Synthetic fonts (i.e. italicising, emboldening, underlining)
|
||||
<br>4) Contextual glyph substitution and other advanced layout processes</blockquote>
|
||||
Note that features 1 through 3 should be provided by the SemTex library,
|
||||
which may soon become part of the standard FreeType distribution.</blockquote>
|
||||
</blockquote>
|
||||
</blockquote>
|
||||
|
||||
<p><br>
|
||||
<hr WIDTH="100%">
|
||||
<h2>
|
||||
II. Design :</h2>
|
||||
|
||||
<blockquote>
|
||||
<h3>
|
||||
1. Objects :</h3>
|
||||
|
||||
<blockquote>They are several kinds of objects in FreeType, which can be
|
||||
described as follows :
|
||||
<blockquote><b>Base objects</b>
|
||||
<br>These objects do not relate directly to font data, but to the way it
|
||||
is organised and managed. It is the basic core and provides functions that
|
||||
are heavily used by each font driver. Examples are the resource objects,
|
||||
used to describe font files, the system object used to manage low-level
|
||||
system operations, or the raster object, used to convert vector outlines
|
||||
into bitmaps or anti-aliased pixmaps. Most of the base objects are not
|
||||
directly visible for client applications of FreeType.
|
||||
<p><b>Font objects</b>
|
||||
<br>The font objects directly model the data as it is found in font files.
|
||||
The root classes implemented in the base layer like <tt>FT_Face</tt>, <tt>FT_Size</tt>,
|
||||
<tt>FT_GlyphSlot</tt>,
|
||||
must be derived in each font driver.</blockquote>
|
||||
Objects are defined in the files "<tt>base/freetype.h</tt>" and "<tt>base/ftobjs.h</tt>".
|
||||
The former contains all the public object definitions usable by client
|
||||
applications. The latter contains private definitions used by the rest
|
||||
of the base layer and each font driver.</blockquote>
|
||||
|
||||
<h3>
|
||||
2. List management</h3>
|
||||
|
||||
<blockquote>The "<tt>base/ftlist.c</tt>" component a very simple doubly-linked
|
||||
list facility which is used by the rest of the engine to create and process
|
||||
lists, including iteration and finalisation. The definition of the list
|
||||
node and functions are placed in the "<tt>base/freetype.h</tt>" to let
|
||||
client applications access listed objects as they like.
|
||||
<p>The base list type is <tt>FT_List</tt>, which links nodes of type <tt>FT_ListNode</tt>
|
||||
together.
|
||||
<br> </blockquote>
|
||||
|
||||
<h3>
|
||||
3. Limited encapsulation</h3>
|
||||
|
||||
<blockquote>Unlike what happened in the 1.x releases, the <tt>FT_Face</tt>,
|
||||
<tt>FT_Size</tt>,
|
||||
<tt>FT_GlyphSlot</tt> and <tt>FT_CharMap</tt> types are no longer blind
|
||||
pointers to opaque types. Rather, the corresponding structures are now
|
||||
public (and defined in "<tt>base/freetype.h</tt>", see <tt>FT_FaceRec</tt>,
|
||||
<tt>FT_SizeRec</tt>,
|
||||
etc..) in order to let client applications read directly the various object
|
||||
attributes they're interested in.
|
||||
<p>This breaks encapsulation of implementation, famed by OOP, but was chosen
|
||||
because:
|
||||
<br>
|
||||
<ul>
|
||||
<li>
|
||||
it simplifies a lot the work of client applications and libraries which
|
||||
don't need to perform a function call everytime they want to read one important
|
||||
object attribute (nor does it force them to cache these attributes in their
|
||||
own structures).</li>
|
||||
</ul>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
It reduces greatly the API, as many <tt>FT_Get_XXX</tt> functions are avoided.</li>
|
||||
</ul>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
Higher-level libraries are able to access data directly. When it
|
||||
is used frequently, they don't need to cache it in their own structures.</li>
|
||||
</ul>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
It is possible to tightly link FreeType objects with higher-level ones,
|
||||
in a clearer and more efficient way. This is very important when one wants
|
||||
to write a C++ wrapper or a text rendering library on top of FreeType (actually,
|
||||
both projects were performed in an earlier version of FreeType 2.0 which
|
||||
featured classic encapsulation through get/set methods. The resulting code
|
||||
was ugly and slow. Moving to a limited encapsulation approach simplified
|
||||
so many things that the compiled code size was reduced by a factor of two
|
||||
!).</li>
|
||||
</ul>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
Finally, the API and font object structures were designed after the creation
|
||||
of two scalable font drivers and one bitmap font driver. They are now very
|
||||
stable and the public (visible) attributes are not going to change.</li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
</blockquote>
|
||||
|
||||
<p><br>
|
||||
<hr WIDTH="100%">
|
||||
<h2>
|
||||
III. Base objects :</h2>
|
||||
|
||||
<blockquote>This section describes the FreeType base object classes :
|
||||
<br>
|
||||
<h3>
|
||||
1. System objects :</h3>
|
||||
|
||||
<blockquote>The system class is in charge of managing all low-level and
|
||||
system-specific operations. This means simply memory management, i/o access
|
||||
and thread synchronisation. It is implemented by the "<tt>ftsys.c</tt>"
|
||||
component, whose source must be located in the configuration directory
|
||||
when building FreeType. (e.g. "<tt>lib/arch/ansi/ftsys.c</tt>" for an ANSI
|
||||
build, "<tt>lib/arch/unix/ftsys.c</tt>" for a Unix one, etc..).
|
||||
<p>Porting FreeType 2.0 really means providing a new implementation of
|
||||
<tt>ftsys</tt>
|
||||
(along with a few configuration file changes). Note however that its interface
|
||||
is common to all ports, and located in "<tt>base/ftsys.h</tt>".</blockquote>
|
||||
|
||||
<h3>
|
||||
2. Resources and Streams:</h3>
|
||||
|
||||
<blockquote>The concepts of files as storages, and files as streams has
|
||||
been separated for FreeType 2.0. The "<b><i>resource</i></b>" concept was
|
||||
introduced while the "<b><i>stream</i></b>" one has been redefined. Here
|
||||
is how they work together :
|
||||
<ul>
|
||||
<li>
|
||||
a "<b>resource</b>" is an object which models a file, seen as a storage.
|
||||
There are several classes of resources, which differ usually in two ways
|
||||
: the way their data is accessed by applications, and the way they're named
|
||||
within the system.</li>
|
||||
</ul>
|
||||
|
||||
<ul>For example, when parsing files with the ANSI C library, data has to
|
||||
be read (through fseek/fread) into intermediate buffers before it can be
|
||||
decoded. This scheme is highly portable, but rather inefficient; when using
|
||||
it, we'll describe the file as a disk-based resource.
|
||||
<p>As most modern operating systems now provide memory-mapped files, which
|
||||
allow direct access while improving performance and reducing memory usage.
|
||||
Because data can be read directly in memory, we'll speak of a memory-based
|
||||
resource in this case. For embedded systems (like printers, PDAs, etc..),
|
||||
ROM-fonts fit into this category as well.
|
||||
<p>Regarding naming, most systems use a string to name files in their storage
|
||||
hierarchy. Though a typical pathname is an ASCII string (<tt>'c:\windows\fonts\times.ttf'</tt>
|
||||
on Windows, <tt>'/home/fonts/times.ttf'</tt> on Unix), some OSes use different
|
||||
schemes, varying from Unicode character strings to file i-node numbers.
|
||||
These details are platform-specific and must be hidden to the rest of the
|
||||
library in resource objects.
|
||||
<p>A resource encapsulates the lowest details regarding a file, though
|
||||
it should have NO STATE. Note that the nature or type of a resource (i.e.
|
||||
disk or memory based) is important to the "stream" component only. The
|
||||
rest of the library and font drivers work transparently from their implementation.
|
||||
<p>Note also that it is perfectly possible to mix resources of distinct
|
||||
natures in a single build</ul>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
a "<b>stream</b>" is an object which is used to extract bytes from a resource.
|
||||
Only resource objects can create streams, through its <i><tt>Open_Stream()</tt></i>
|
||||
method. A stream has state, which typically consist of a file "cursor",
|
||||
some intermediate buffers, a "current frame" and, of course, methods used
|
||||
to extract the data from streams, resolving endianess and alignement issues.</li>
|
||||
</ul>
|
||||
Data can be extracted from streams through direct reads, or through the
|
||||
use of <b>frames</b>. A frame models <i>a run of contiguous bytes</i> starting
|
||||
from the current stream position, and of liberal size.
|
||||
<p>Methods exist to extract successive integers of any sizes, while resolving
|
||||
endianess and alignement issues. Rather than a long rethorical explanation,
|
||||
here's how frames are typically used :
|
||||
<blockquote><tt>{</tt>
|
||||
<br><tt> …</tt>
|
||||
<br><tt> FT_Error error;</tt>
|
||||
<p><tt> error = FT_Access_Frame( stream, 14 );</tt>
|
||||
<br><tt> if (error) goto Fail;</tt>
|
||||
<p><tt> val1 = FT_Get_Short(stream);</tt>
|
||||
<br><tt> val2 = FT_Get_Long(stream);</tt>
|
||||
<br><tt> val3 = FT_Get_Long(stream);</tt>
|
||||
<br><tt> val4 = FT_Get_Long(stream);</tt>
|
||||
<p><tt> FT_Forget_Frame(stream);</tt>
|
||||
<br><tt> …</tt>
|
||||
<br><tt>}</tt></blockquote>
|
||||
This code does the following :
|
||||
<blockquote>
|
||||
<ol>
|
||||
<li>
|
||||
first, it "loads" the next 14 bytes from the current cursor position
|
||||
into the stream's frame, using the <tt>FT_Access_Frame</tt> API. An error
|
||||
is returned if, for example, less than 14 bytes are left in the stream
|
||||
when the call occurs..</li>
|
||||
</ol>
|
||||
|
||||
<ol>
|
||||
<li>
|
||||
it extract four integers (one 16-bit short, three 32-bit longs) from
|
||||
the frame using <tt>FT_Get_Short</tt> and <tt>FT_Get_Long</tt>. These function
|
||||
increment the frame's cursor finally, it "releases" the stream's frame.</li>
|
||||
</ol>
|
||||
|
||||
<ol>
|
||||
<li>
|
||||
Each stream has its own frame which can be accessed independently,
|
||||
however, nested frame accesses are not allowed. Note also that the bytes
|
||||
are effectively read from the stream on the call to <tt>FT_Access_Frame</tt>.
|
||||
Any subsequent read will occur after these 14 bytes, even if less are extracted
|
||||
through <tt>FT_Get_xxxx</tt> functions.</li>
|
||||
</ol>
|
||||
</blockquote>
|
||||
The implementation of the resource class is located in the system component
|
||||
(i.e. "<tt>arch/<i><system></i>/ftsys.c</tt>") and can thus be tailored
|
||||
for a specific port of the engine.
|
||||
<p>A resource can be created through the <tt>FT_New_Resource</tt> API;
|
||||
however this function only accepts an 8-bit pathname to name the target
|
||||
font file, which may be inappropriate for systems using a different naming
|
||||
scheme (e.g. UTF-16 pathname, i-node number, etc..). It's up to the porter
|
||||
then to provide its own resource creation function (like. <tt>FT_New_UTF16_Resource</tt>,
|
||||
for example) in its version of "<tt>ftsys.c</tt>".
|
||||
<p>Note that <tt>FT_New_Resource</tt> will fail and return an error code
|
||||
if the font file cannot be found, or when its font format isn't recognized
|
||||
by one of the drivers installed in the library. The list or resources created
|
||||
for a given library instance is thus the list of "installed font files".
|
||||
<br> </blockquote>
|
||||
|
||||
<h3>
|
||||
3. Stream Manager :</h3>
|
||||
|
||||
<blockquote>As said before, resources do not bear states, while streams
|
||||
do. Stream creation is also a very lengthy process, depending on the target
|
||||
operating system (e.g. "<tt>fopen</tt>" is usually very slow).
|
||||
<p>Because a typical font driver will want to use a new stream on each
|
||||
access to individual glyphs, being able to cache the most recently used
|
||||
streams is a requirement in order to avoid considerable performance penalties.
|
||||
<p>Stream caching is thus implemented in the "<tt>ftstream</tt>" component.
|
||||
It maintains a simple LRU list of the least recently used streams. Each
|
||||
stream in the cache is still opened and available for immediate processing.
|
||||
When a resource is destroyed, the stream cache is parsed to remove all
|
||||
related cached streams.
|
||||
<p>Stream caching can also be disabled with a configuration macro when
|
||||
using only ROM based resources (where stream opening is really quick).
|
||||
It is implemented through a Stream Manager object (see <tt>ftstream.c</tt>).
|
||||
<br> </blockquote>
|
||||
|
||||
<h3>
|
||||
4. Raster :</h3>
|
||||
|
||||
<blockquote>The raster is the component is charge of generating bitmaps
|
||||
and anti-aliased pixmaps from vectorial outline definitions. It is also
|
||||
sometimes called the scan-line converter. It has been completely rewritten
|
||||
for FreeType 2.0 in order to support third-order bezier arcs, 17-levels
|
||||
anti-aliasing (through 4x4 sub-sampling), improved performance, as well
|
||||
as stand-alone compilation (in order to include it in other graphics package
|
||||
without requiring the rest of the FreeType engine).
|
||||
<p>Because it was designed for easy re-use and embedded systems, the raster
|
||||
is a rtaher 'unusual' piece of code, because it doesn't perform a single
|
||||
memory allocation, nor contain any static or global variable. Rather, it
|
||||
is up to client applications to allocate a raster object in their own heap
|
||||
or memory space.
|
||||
<p>Each raster object also needs a rather large block of memory called
|
||||
its render pool. The pool is used during rendering (and only during it)
|
||||
in order to perform the scan-line conversion. Because it accesses and manages
|
||||
data directly within the pool, the raster yelds impressive performance
|
||||
as well as bounded memory consumption. It can also automatically decompose
|
||||
large requests into smaller individual sub-tasks.
|
||||
<p>Finally, it never creates bitmaps or pixmaps, but simply renders into
|
||||
them (providing clipping too). These must be described to the raster with
|
||||
the help of a <tt>FT_Raster_Map</tt> structure (a very simple bitmap/pixmap
|
||||
descriptor).
|
||||
<p>Note that when rendering anti-aliased pixmaps, the raster doesn't use
|
||||
an intermediate bitmap buffer, as filtering is part of the scan-line conversion
|
||||
process.
|
||||
<br> </blockquote>
|
||||
|
||||
<h3>
|
||||
5. Library objects :</h3>
|
||||
|
||||
<blockquote>A library object models a single instance of the FreeType engine.
|
||||
This is useful when FreeType is compiled as a shared object (DLL), as it
|
||||
can then be used by several applications, each with its own resources and
|
||||
objects.
|
||||
<p>The <tt>FT_Library</tt> type is an opaque handle to a library object.
|
||||
Such an object is created through a call to <tt>FT_Init_FreeType</tt>.
|
||||
Once you don't need it anymore, one can destroy a library object through
|
||||
<tt>FT_Done_FreeType</tt>.
|
||||
<p>Note that in reentrant builds, several threads can access a single library
|
||||
object concurrently. Such a build can be chosen by switching one configuration
|
||||
macro in the file '<tt>arch/<i><system></i>/ftconfig.h</tt>'</blockquote>
|
||||
|
||||
<h3>
|
||||
6. Driver objects :</h3>
|
||||
|
||||
<blockquote>A driver object models an instance of a given font driver,
|
||||
i.e. an element of FreeType code in charge of handling a given font format,
|
||||
like TrueType, Type1, FNT, PCF, etc..
|
||||
<p>Each library object contains a given set of driver objects when it is
|
||||
created through FT_Init_FreeType, this set being determined at compile
|
||||
time (see the file 'base/ftapi.c'). However, removing or adding drivers
|
||||
is possible at run-time, in order to make upgrades easy.</blockquote>
|
||||
|
||||
<h3>
|
||||
7. Diagram</h3>
|
||||
|
||||
<blockquote>This diagram show the object relationships for the sole base
|
||||
layer. The library object is the root of the object graph :
|
||||
<center>
|
||||
<p><img SRC="objects_diagram.png" height=300 width=562></center>
|
||||
|
||||
<p>It can be read as follows :
|
||||
<br>
|
||||
<ul>
|
||||
<li>
|
||||
Each library object has one system, one raster and one stream manager objects.
|
||||
These objects can only belong to one given library.</li>
|
||||
</ul>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
Each library contains one list of 0 or more resources, as well as one list
|
||||
of 0 or more driver objects.</li>
|
||||
</ul>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
Each stream manager holds a bounded list ("0..n" where 'n' is the stream
|
||||
cache's size) of stream objects. Each stream is related to one given resource
|
||||
object. Each resource may be related to zero or one stream.</li>
|
||||
</ul>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
Each resource is related to one driver object. A driver is related to 0
|
||||
or more resources.</li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
</blockquote>
|
||||
|
||||
<p><br>
|
||||
<hr WIDTH="100%">
|
||||
<h2>
|
||||
IV. Font objects :</h2>
|
||||
|
||||
<blockquote>Font objects are used to directly map the information found
|
||||
in font files into several categories :
|
||||
<br>
|
||||
<h3>
|
||||
1. Face objects :</h3>
|
||||
|
||||
<blockquote>Face objects are used to model individual font faces. They
|
||||
encapsulate data which isn't related to a specific character size, or a
|
||||
specific glyph or glyph set. Usually, this means :
|
||||
<ul>
|
||||
<li>
|
||||
the font face's family and style names (e.g. "Palatino" + "Regular")</li>
|
||||
|
||||
<li>
|
||||
some flags indicating which kind of font this is (scalable or fixed ? fixed-width
|
||||
or proportional ? horizontal or vertical ? etc…)</li>
|
||||
|
||||
<li>
|
||||
the number of glyphs, charmaps and eventually fixed character sizes (for
|
||||
bitmap formats) found in the font face.</li>
|
||||
|
||||
<li>
|
||||
for scalable formats, some important metrics like the ascender, descender,
|
||||
global font bounding box, maximum advance width, etc.. expressed in notional
|
||||
font/grid units (as well as the number of units on the EM grid).</li>
|
||||
</ul>
|
||||
A face is created from a resource object, with the <tt>FT_New_Face</tt>
|
||||
API. Each driver contains a list of opened face objects for the resources
|
||||
it manages. When a driver is removed or destroyed, all its child faces
|
||||
are discarded automatically with it.</blockquote>
|
||||
|
||||
<h3>
|
||||
2. Size objects :</h3>
|
||||
|
||||
<blockquote>Size objects are used to model a given character dimension
|
||||
for a given device resolution (which really means a given character pixel
|
||||
dimensions).
|
||||
<p>Each size object is created from a parent face object. The object can
|
||||
be reset to new dimensions at any time. Each face object holds a list of
|
||||
all its child sizes, these are destroyed automatically when the face object
|
||||
is discarded.
|
||||
<p>The metrics contains metrics, expressed in pixels, for the ascender,
|
||||
descender, maximum advance width, etc..
|
||||
<br> </blockquote>
|
||||
|
||||
<h3>
|
||||
3. Glyph Slot objects :</h3>
|
||||
|
||||
<blockquote>A glyph slot is a container where one can load individual glyphs,
|
||||
be they in vector of bitmap format. Each slot also contains metrics for
|
||||
the glyph it contains.
|
||||
<p>Each face object contains one or more glyph slot object : the first
|
||||
glyph slot is created automatically with its parent face, and it is possible
|
||||
to add new glyph slots (this is rarely used outside of debugging purposes).
|
||||
<br> </blockquote>
|
||||
|
||||
<h3>
|
||||
4. CharMap objects :</h3>
|
||||
|
||||
<blockquote>A charmap object is a sort of dictionary whose task is to translate
|
||||
character codes in a given character encoding (like ShiftJIS, Unicode,
|
||||
ANSI, etc..) into glyph indexes in a given font face.
|
||||
<p>A face object contains one or more charmap objects. All charmap objects
|
||||
are created when the parent face is created, though they're not directly
|
||||
visible to client applications (rather, they can be enumerated through
|
||||
FT_Get_First_CharMap and FT_Get_Next_CharMap, or more simply picked adequately
|
||||
with FT_Find_CharMap for a set of given encodings).
|
||||
<br> </blockquote>
|
||||
|
||||
<h3>
|
||||
5. Diagram</h3>
|
||||
|
||||
<blockquote>The following diagram illustrates the relationships between
|
||||
font objects :
|
||||
<center>
|
||||
<p><img SRC="objects_diagram2.png" height=327 width=561></center>
|
||||
|
||||
<p>Which can be read as :
|
||||
<br>
|
||||
<ul>
|
||||
<li>
|
||||
each resource may have zero or more child face objects "opened" for it.
|
||||
The number of faces is bounded by the number of font faces within the font
|
||||
resource.</li>
|
||||
</ul>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
each driver holds a list of all the faces opened for the resources it manages.
|
||||
When the driver is removed, its child faces are discarded automatically.</li>
|
||||
</ul>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
each face object has one single parent resource, and one single driver.</li>
|
||||
</ul>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
each face has one or more charmaps, and one or more glyph slots</li>
|
||||
</ul>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
each face holds a list of zero or more child size objects</li>
|
||||
</ul>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
each charmap, glyph slot and size is related to one given parent face.
|
||||
These objects are destroyed automatically when the parent face is discarded.</li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
</blockquote>
|
||||
|
||||
<p><br>
|
||||
<hr WIDTH="100%">
|
||||
<h2>
|
||||
V. Driver Interface :</h2>
|
||||
|
||||
<blockquote>A font driver is added to a given library object through the
|
||||
<tt>FT_Add_Driver</tt>
|
||||
API. This function receives a structure known as a <tt>FT_DriverInterface</tt>,
|
||||
which describes the driver's basic properties.
|
||||
<p>The <tt>FT_DriverInterface</tt> contains a set of function pointers
|
||||
used for the base FreeType functionalities. However, each driver can also
|
||||
provide a font-format-specific extended interface to allow client applications
|
||||
to use more advanced features.
|
||||
<br>
|
||||
<h3>
|
||||
1. Common Interface</h3>
|
||||
|
||||
<blockquote>The structure of <tt>FT_DriverInterface</tt> is rather simple,
|
||||
and defined in "<tt>base/ftdriver.h</tt>". It must be well known by any
|
||||
developer who wants to write a new driver for the engine. We advise reading
|
||||
the <b><i>FreeType Driver HowTo</i></b> as well as the source code of existing
|
||||
drivers. Source comments.</blockquote>
|
||||
|
||||
<h3>
|
||||
2. Driver-specific extensions</h3>
|
||||
|
||||
<blockquote>The field of the <tt>FT_DriverInterface</tt> structure is a
|
||||
typeless pointer to a format-specific interface. This extended interface
|
||||
is usually a structure containing function pointers as well as other kind
|
||||
of information related to the driver.
|
||||
<p>It is assumed that client applications that wish to use the driver-specific
|
||||
extensions are able to <tt>#include</tt> the relevant header files to understand
|
||||
the format-specific interface structure.</blockquote>
|
||||
</blockquote>
|
||||
|
||||
<hr WIDTH="100%">
|
||||
<h2>
|
||||
VI. Configuration:</h2>
|
||||
|
||||
<blockquote>This section relates to the configuration of the FreeType library.
|
||||
By configuration, we mean selection of build options as well as the choice
|
||||
of font drivers to be used for each new library object.
|
||||
<br>
|
||||
<h3>
|
||||
1. Configuration files :</h3>
|
||||
|
||||
<blockquote>A single file is used to configure the FreeType base engine.
|
||||
As it is considered system-specific, it is located in the architecture
|
||||
directories of the library, under the name "arch/<system>/ftconfig.h".
|
||||
Note that the same directory should also contain a platform-specific implementation
|
||||
of "ftsys.c".
|
||||
<p>The configuration files is a simple C header which is included by the
|
||||
engine's sources during compilation. It is not included in "freetype.h",
|
||||
and hence doesn't need to be copied when installing the FreeType headers
|
||||
on your system.
|
||||
<p>It is made of a series of #define or #undef statements, which are used
|
||||
to select or turn off a specific option. Each option is documented with
|
||||
heavy comments, and some of them are explained below.</blockquote>
|
||||
|
||||
<h3>
|
||||
2. Building and Makefiles :</h3>
|
||||
|
||||
<blockquote>FreeType 2.0 is more complex than its 1.x release. In order
|
||||
to facilitate maintenance, as well as ease considerably the writing of
|
||||
new font drivers, <b><i>only GNU Make is supported with FreeType 2.0</i></b>.
|
||||
However, it is possible to use any compiler, as well as any object or library
|
||||
prefix (<tt>.o, .obj, .a, .lib</tt> etc..) with them.
|
||||
<p>To build FreeType 2.0, one has to be in the library directory, then
|
||||
invoke its platform-specific makefile. For a Unix system, this would be
|
||||
:
|
||||
<blockquote>
|
||||
<blockquote><tt>% cd freetype2/lib</tt>
|
||||
<br><tt>% make -f arch/unix/Makefile</tt>
|
||||
<p>where '<tt>make</tt>' is really GNU Make !</blockquote>
|
||||
</blockquote>
|
||||
The system-specific <tt>Makefile</tt> located in '<tt>arch/<i><system></i></tt>'
|
||||
is a tiny file used to define several variables. It then includes the file
|
||||
<tt>freetype2/lib/Makefile.lib</tt>,
|
||||
which contains all the gory details about library compilation. The system-specific
|
||||
<tt>Makefile</tt> can be very easily modified to accomodate a new compiler/platform
|
||||
(see the comments within one of these files).
|
||||
<p>Each font driver is located in a directory like "<tt>freetype2/lib/drivers/<i><formatdir></i></tt>".
|
||||
For example, the TrueType driver is located in "<tt>drivers/truetype</tt>".
|
||||
Each driver directory must contain a <tt>Makefile</tt> which will be included
|
||||
by <tt>Makefile.lib</tt>. The former is used to define and build driver
|
||||
object files.
|
||||
<br>
|
||||
<p><br>
|
||||
<center>
|
||||
<p><img SRC="build_diagram.png" height=284 width=559></center>
|
||||
</blockquote>
|
||||
|
||||
<h3>
|
||||
3. Make options :</h3>
|
||||
|
||||
<blockquote>The base layer, as well as each font driver, are made up of
|
||||
several C sources. Traditionally, one compiles each source (i.e. '<tt>.c</tt>'
|
||||
file) into an object ('<tt>.o</tt>' or '<tt>.obj</tt>') file, and all of
|
||||
them are grouped into a library file (i.e. '<tt>.a</tt>' or '<tt>.lib</tt>').
|
||||
<p>By default, FreeType takes a slightly different approach when it comes
|
||||
to compiling each part of the engine. Usually, a single tiny source is
|
||||
compiled, which includes all other component sources. This results in a
|
||||
single object files, with the benefits or reduced code size, usually better
|
||||
compilation as well as a drastic reduction of the number of symbols exported
|
||||
by the library. Of course, it is made possible through the use of specific
|
||||
declaration macros in the FreeType source (see the definition of <tt>LOCAL_DEF</tt>
|
||||
and <tt>LOCAL_FUNC</tt> in <tt>ftconfig.h</tt> for details).
|
||||
<p>For a concrete example, see the source code in "<tt>base/ftbase.c</tt>"
|
||||
which generates the whole base layer in a single object file. The same
|
||||
build process is applied to font drivers, in order to generate one single
|
||||
object file per given font format (e.g. <tt>truetype.o</tt>, <tt>type1.o</tt>,
|
||||
etc..).
|
||||
<p>Compiling the library and drivers in "normal" mode is possible, through
|
||||
the use of the '<tt>multi</tt>' target (which really means « multiple
|
||||
objects »). For example, calling :
|
||||
<blockquote><tt>% make -f arch/ansi/Makefile multi</tt></blockquote>
|
||||
Will build the FreeType library by compiling each source file to an individual
|
||||
object, then linking them together. You'll notice that the library is significantly
|
||||
bigger in this case. Creating a shared dll from a 'multi' build is certainly
|
||||
a very poor idea, as this will export a huge quantity of symbols that aren't
|
||||
useful to any client application.</blockquote>
|
||||
|
||||
<h3>
|
||||
4. Adding a driver at compile time</h3>
|
||||
|
||||
<blockquote>A driver can be included very easily in the build process by
|
||||
including its <tt>Makefile</tt> in <tt>Makefile.lib</tt>. For example,
|
||||
the TrueType driver is simply included with the following lines (see <tt>Makefile.lib</tt>):
|
||||
<blockquote><tt># TrueType driver rules</tt>
|
||||
<br><tt>#</tt>
|
||||
<br><tt>include $(DRIVERS_DIR)/truetype/Makefile</tt></blockquote>
|
||||
|
||||
<p><br>Where <tt>DRIVERS_DIR</tt> really is "<tt>freetype2/lib/drivers</tt>",
|
||||
though this can be redefined. You can, of course specify a different path
|
||||
if you want to place your driver sources in another location.
|
||||
<p>Note that this only adds the driver's object files to the generated
|
||||
library file. A few more steps are needed to make your <tt>FT_Library</tt>
|
||||
objects use the driver. They consist in modifying the file "<tt>base/ftinit.c</tt>",
|
||||
whose sole purpose is to define the set of driver objects that are to be
|
||||
created with each new library object.
|
||||
<br> </blockquote>
|
||||
|
||||
<h3>
|
||||
5. Adding a driver at run time</h3>
|
||||
|
||||
<blockquote>New driver objects can be added at run-time through the <tt>FT_Add_Driver</tt>
|
||||
API. This function takes a handle to an existing library object, as well
|
||||
as a pointer to a given driver interface. This interface is used to create
|
||||
a new driver object and register it within the library.
|
||||
<p>Similarly, a single driver can be removed from a library anytime through
|
||||
<tt>FT_Remove_Driver</tt>.
|
||||
This will automatically discard the resources and face objects managed
|
||||
by the driver.</blockquote>
|
||||
|
||||
<h3>
|
||||
6. Custom library objects :</h3>
|
||||
|
||||
<blockquote>Finally, it is possible to build custom library objects. You
|
||||
need to pass a handle to a valid <tt>FT_System</tt> object to the <tt>FT_Build_Library</tt>
|
||||
API. The function will return a handle to the new fresh library object.
|
||||
Note that the library has no registered drivers after the call, developers
|
||||
have to add them by hand with <tt>FT_Add_Driver</tt>.
|
||||
<p>It is thus possible to create two distinct library objects with distinct
|
||||
<tt>FT_System</tt>
|
||||
implementations in the same session, which can be useful for debugging
|
||||
purpose.</blockquote>
|
||||
|
||||
<br> </blockquote>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,343 @@
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=iso-8859-1">
|
||||
<meta name="Author"
|
||||
content="David Turner">
|
||||
<title>FreeType 2 Internals - I/O Frames</title>
|
||||
</head>
|
||||
|
||||
<body text="#000000"
|
||||
bgcolor="#FFFFFF"
|
||||
link="#0000EF"
|
||||
vlink="#51188E"
|
||||
alink="#FF0000">
|
||||
|
||||
<h1 align=center>
|
||||
FreeType 2.0 I/O Frames
|
||||
</h1>
|
||||
|
||||
<h3 align=center>
|
||||
© 2000 David Turner
|
||||
(<a href="mailto:[email protected]">[email protected]</a>)<br>
|
||||
© 2000 The FreeType Development Team
|
||||
(<a href="http://www.freetype.org">www.freetype.org</a>)
|
||||
</h3>
|
||||
|
||||
<center>
|
||||
<table width="70%">
|
||||
<tr><td>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2>
|
||||
Introduction
|
||||
</h2>
|
||||
|
||||
<p>This document explains the concept of I/O <b>frames</b> as used in the
|
||||
FreeType 2 source code. It also enumerates the various functions and
|
||||
macros that can be used to read them.</p>
|
||||
|
||||
<p>It is targeted to FreeType hackers, or more simply to developers who
|
||||
would like a better understanding of the library's source code.</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2>
|
||||
I. What frames are
|
||||
</h2>
|
||||
|
||||
<p>Simply speaking, a frame is an array of bytes in a font file that is
|
||||
`preloaded' into memory in order to be rapidly parsed. Frames are useful
|
||||
to ensure that every `load' is checked against end-of-file overruns, and
|
||||
provides nice functions to extract data in a variety of distinct
|
||||
formats.</p>
|
||||
|
||||
<p>But an example is certainly more meaningful than anything else. The
|
||||
following code</p>
|
||||
|
||||
<font color="blue">
|
||||
<pre>
|
||||
error = read_short( stream, &str.value1 );
|
||||
if ( error ) goto ...
|
||||
|
||||
error = read_ulong( stream, &str.value2 );
|
||||
if ( error ) goto ...
|
||||
|
||||
error = read_ulong( stream, &str.value3 );
|
||||
if ( error ) goto ...</pre>
|
||||
</font>
|
||||
|
||||
<p>can easily be replaced with</p>
|
||||
|
||||
<font color="blue">
|
||||
<pre>
|
||||
error = FT_Access_Frame( stream, 2 + 4 + 4 );
|
||||
if ( error ) goto ...
|
||||
|
||||
str.value1 = FT_Get_Short( stream );
|
||||
str.value2 = FT_Get_ULong( stream );
|
||||
str.value3 = FT_Get_ULong( stream );
|
||||
|
||||
FT_Forget_Frame( stream );</pre>
|
||||
</font>
|
||||
|
||||
<p>Here, the call to <code>FT_Access_Frame()</code> will</p>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<p>Ensure that there are at least 2+4+4=10 bytes left in the
|
||||
stream.</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>`Preload' (for disk-based streams) 10 bytes from the current
|
||||
stream position.</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>Set the frame `cursor' to the first byte in the frame.</p>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p>Each <code>FT_Get_Short()</code> or <code>FT_Get_ULong()</code> call
|
||||
will read a big-endian integer from the stream (2 bytes for
|
||||
<code>FT_Get_Short()</code>, 4 bytes for <code>FT_Get_ULong</code>)
|
||||
and advance the frame cursor accordingly.</p>
|
||||
|
||||
<p><code>FT_Forget_Frame()</code> `releases' the frame from memory.</p>
|
||||
|
||||
<p>There are several advantages to using frames:</p>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<p>Single-check when loading tables.</p>
|
||||
</li>
|
||||
<li>
|
||||
<p><em>Making code clearer</em> by providing simple parsing functions
|
||||
<em>while keeping code safe</em> from file over-runs and invalid
|
||||
offsets.</p>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2>
|
||||
II. Accessing and reading a frame with macros
|
||||
</h2>
|
||||
|
||||
<p>By convention in the FreeType source code, macros are able to use two
|
||||
implicit variables named <var>error</var> and <var>stream</var>. This is
|
||||
useful because these two variables are extremely often used in the
|
||||
library, and doing this only reduces our typing requirements and make the
|
||||
source code much clearer.</p>
|
||||
|
||||
<p>Note that <var>error</var> must be a local variable of type
|
||||
<code>FT_Error</code>, while <var>stream</var> must be a local variable or
|
||||
argument of type <code>FT_Stream</code>.</p>
|
||||
|
||||
<p>The macro used to access a frame is <font
|
||||
color="purple"><code><b>ACCESS_Frame(_size_)</b></code></font>, it will
|
||||
translate to</p>
|
||||
|
||||
<font color="blue">
|
||||
<pre>
|
||||
( error = FT_Access_Frame( stream, _size_ ) )
|
||||
!= FT_Err_Ok</pre>
|
||||
</font>
|
||||
|
||||
<p>Similarly, the macro <font
|
||||
color="purple"><b><code>FORGET_Frame()</code></b></font> translates to</p>
|
||||
|
||||
<font color="blue">
|
||||
<pre>
|
||||
FT_Forget_Frame( stream )</pre>
|
||||
</font>
|
||||
|
||||
<p>Extracting integers can be performed with the <code>GET_xxx()</code>
|
||||
macros, like</p>
|
||||
|
||||
<table align=center
|
||||
cellpadding=5>
|
||||
<tr valign="top">
|
||||
<th>
|
||||
Macro name
|
||||
</th>
|
||||
<th>
|
||||
Translation
|
||||
</th>
|
||||
<th>
|
||||
Description
|
||||
</th>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<font color="purple"><code><b>GET_Byte()</b></code></font>
|
||||
</td>
|
||||
<td>
|
||||
<font color="blue"><code>FT_Get_Byte(stream)</code></font>
|
||||
</td>
|
||||
<td>
|
||||
<p>Reads an 8-bit unsigned byte.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<font color="purple"><code><b>GET_Char()</b></code></font>
|
||||
</td>
|
||||
<td>
|
||||
<font color="blue"><code>(FT_Char)<br>
|
||||
FT_Get_Byte(stream)</code></font>
|
||||
</td>
|
||||
<td>
|
||||
<p>Reads an 8-bit <em>signed</em> byte.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<font color="purple"><code><b>GET_Short()</b></code></font>
|
||||
</td>
|
||||
<td>
|
||||
<font color="blue"><code>FT_Get_Short(stream)</code></font>
|
||||
</td>
|
||||
<td>
|
||||
Reads a 16-bit signed big-endian integer.
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<font color="purple"><code><b>GET_UShort()</b></code></font>
|
||||
</td>
|
||||
<td>
|
||||
<font color="blue"><code>(FT_UShort)<br>
|
||||
FT_Get_Short(stream)</code></font>
|
||||
</td>
|
||||
<td>
|
||||
Reads a 16-bit unsigned big-endian integer.
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<font color="purple"><code><b>GET_Offset()</b></code></font>
|
||||
</td>
|
||||
<td>
|
||||
<font color="blue"><code>FT_Get_Offset(stream)</code></font>
|
||||
</td>
|
||||
<td>
|
||||
Reads a 24-bit signed big-endian integer.
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<font color="purple"><code><b>GET_UOffset()</b></code></font>
|
||||
</td>
|
||||
<td>
|
||||
<font color="blue"><code>(FT_UOffset)<br>
|
||||
FT_Get_Offset(stream)</code></font>
|
||||
</td>
|
||||
<td>
|
||||
Reads a 24-bit unsigned big-endian integer.
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<font color="purple"><code><b>GET_Long()</b></code></font>
|
||||
</td>
|
||||
<td>
|
||||
<font color="blue"><code>FT_Get_Long(stream)</code></font>
|
||||
</td>
|
||||
<td>
|
||||
Reads a 32-bit signed big-endian integer.
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<font color="purple"><code><b>GET_ULong()</b></code></font>
|
||||
</td>
|
||||
<td>
|
||||
<font color="blue"><code>(FT_ULong)<br>
|
||||
FT_Get_Long(stream)</code></font>
|
||||
</td>
|
||||
<td>
|
||||
Reads a 32-bit unsigned big-endian integer.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>(Note that an <b>Offset</b> is an integer stored with 3 bytes on
|
||||
the file.)</p>
|
||||
|
||||
<p>All this means that the following code</p>
|
||||
|
||||
<font color="blue">
|
||||
<pre>
|
||||
error = FT_Access_Frame( stream, 2 + 4 + 4 );
|
||||
if ( error ) goto ...
|
||||
|
||||
str.value1 = FT_Get_Short( stream );
|
||||
str.value2 = FT_Get_ULong( stream );
|
||||
str.value3 = FT_Get_ULong( stream );
|
||||
|
||||
FT_Forget_Frame( stream );</pre>
|
||||
</font>
|
||||
|
||||
<p>can be simplified with macros:</p>
|
||||
|
||||
<font color="blue">
|
||||
<pre>
|
||||
if ( ACCESS_Frame( 2 +4 + 4 ) ) goto ...
|
||||
|
||||
str.value1 = GET_Short();
|
||||
str.value2 = GET_ULong();
|
||||
str.value3 = GET_ULong();
|
||||
|
||||
FORGET_Frame();</pre>
|
||||
</font>
|
||||
|
||||
<p>Which is clearer. Notice that <var>error</var> and <var>stream</var>
|
||||
must be defined locally though for this code to work!</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2>
|
||||
III. Alternatives
|
||||
</h2>
|
||||
|
||||
<p>It is sometimes useful to read small integers from a font file without
|
||||
using a frame. Some functions have been introduced in FreeType 2 to
|
||||
do just that, and they are of the form <font
|
||||
color="blue"><code>FT_Read_xxxx</code></font>.</p>
|
||||
|
||||
<p>For example, <font color="blue"><code>FT_Read_Short(stream,
|
||||
&error)</code></font> reads and returns a 2-byte big-endian integer from a
|
||||
<var>stream</var>, and places an error code in the <var>error</var>
|
||||
variable.</p>
|
||||
|
||||
<p>Thus, reading a single big-endian integer is shorter than using a frame
|
||||
for it.</p>
|
||||
|
||||
<p>Note that there are also macros <font
|
||||
color="purple"><code>READ_xxx()</code></font> which translate to</p>
|
||||
|
||||
<font color="blue">
|
||||
<pre>
|
||||
FT_Read_xxx( stream, &error ), error != FT_Err_Ok</pre>
|
||||
</font>
|
||||
|
||||
<p>and can be used as in</p>
|
||||
|
||||
<font color="blue">
|
||||
<pre>
|
||||
if ( READ_UShort( variable1 ) ||
|
||||
READ_ULong ( variable2 ) )
|
||||
goto Fail;</pre>
|
||||
</font>
|
||||
|
||||
<p>if <var>error</var> and <var>stream</var> are already defined
|
||||
locally.</p>
|
||||
|
||||
</td></tr>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1 @@
|
||||
‰PNG
|
||||
@@ -0,0 +1 @@
|
||||
‰PNG
|
||||
@@ -0,0 +1 @@
|
||||
‰PNG
|
||||
@@ -0,0 +1 @@
|
||||
‰PNG
|
||||
@@ -0,0 +1 @@
|
||||
‰PNG
|
||||
@@ -0,0 +1,258 @@
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="Author" content="David Turner">
|
||||
<meta name="GENERATOR" content="Mozilla/4.5 [fr] (Win98; I) [Netscape]">
|
||||
<title>FreeType 2 Internals</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<body text="#000000"
|
||||
bgcolor="#FFFFFF"
|
||||
link="#0000EF"
|
||||
vlink="#51188E"
|
||||
alink="#FF0000">
|
||||
|
||||
<center>
|
||||
<h1>
|
||||
FreeType 2.0 System Interface</h1></center>
|
||||
|
||||
<center>
|
||||
<h3>
|
||||
© 2000 David Turner (<a href="fichier :///[email protected]">[email protected]</a>)<br>
|
||||
© 2000 The FreeType Development Team (<a href="fichier :///[email protected]">[email protected]</a>)</h3></center>
|
||||
|
||||
<p><br>
|
||||
<hr WIDTH="100%">
|
||||
<br>
|
||||
<h2>Introduction:</h2>
|
||||
<ul>
|
||||
This document explains how the FreeType 2 library performs the low-level and
|
||||
system-specific operations of memory management and i/o access. It is targetted
|
||||
to FreeType hackers, porters and "advanced" developers who want special
|
||||
features like providing their own memory manager or streams.
|
||||
<p>
|
||||
Note that the only system-specific part of the library is a file
|
||||
named "<tt>ftsystem.c</tt>", normally located in the directory
|
||||
"<tt>freetype2/config/<system></tt>" where <tt><system></tt> designates
|
||||
your platform (e.g. "<tt>config/ansi/ftsystem.c</tt>" or
|
||||
"<tt>config/unix/ftsystem.c</tt>").
|
||||
<p>
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
<hr>
|
||||
<p>
|
||||
|
||||
<h2>I. Memory Management</h2>
|
||||
<ul>
|
||||
Memory allocation and releases are performed through a <tt>FT_Memory</tt> object in
|
||||
FreeType. A <tt>FT_Memory</tt> is nothing more than a table of functions plus
|
||||
an arbitrary user data field. It is defined in the file
|
||||
"<tt>freetype2/include/ftsystem.h</tt>" and has the following structure:
|
||||
<p>
|
||||
<ul>
|
||||
<tt>typedef struct</tt><br>
|
||||
<tt>{</tt>
|
||||
<ul>
|
||||
<table>
|
||||
<tr><td><tt><b>void* user</b></tt> <td> // a user-defined pointer. This is zero by default
|
||||
<tr><td><tt><b>void* (*alloc)( FT_System, int)</b></tt> <td> // a function used to allocate a new block
|
||||
<tr><td><tt><b>void* (*realloc)( FT_System, int, int, void* )</b></tt><td> // a function used to reallocate a given block
|
||||
<tr><td><tt><b>void (*free)( FT_System, void*)</b></tt> <td> // a function used to release a given block
|
||||
</table>
|
||||
</ul>
|
||||
<tt>} FT_MemoryRec, *FT_Memory;</tt><br>
|
||||
</ul>
|
||||
<p>
|
||||
You'll notice that:<p>
|
||||
<ul>
|
||||
<li>The <tt>FT_Memory</tt> type is really a pointer to a <tt>FT_MemoryRec</tt>.
|
||||
This is a normal convention for the FreeType code.
|
||||
<li>The <tt>realloc</tt> takes two integer arguments. The first one is the
|
||||
current block size, the second one its new size.
|
||||
</ul>
|
||||
<p>
|
||||
|
||||
All current implementations of "<tt>ftsystem.c</tt>" provide a very simple
|
||||
implementation of the <tt>FT_Memory</tt> interface by calling directly the
|
||||
standard C <tt>alloc</tt>, <tt>realloc</tt> and <tt>free</tt>.
|
||||
<p>
|
||||
The FreeType source code never invokes directly the function pointers. Rather,
|
||||
it calls <tt>FT_Alloc</tt>, <tt>FT_Realloc</tt> and <tt>FT_Free</tt> functions
|
||||
which are defined in "<tt>freetype2/src/base/ftobjs.c</tt>". These will not be
|
||||
discussed here.
|
||||
<p>
|
||||
<b>If you want to use your own memory allocator</b> rather than the one provided
|
||||
by your build of FreeType, follow these simple steps:<p>
|
||||
<ol>
|
||||
<li>Create your own <tt>FT_Memory</tt> object, with pointers that map to
|
||||
your own memory management routines (beware function signatures though).
|
||||
<p>
|
||||
<li>Call <tt>FT_Build_Library(memory,&library)</tt>. This will create a new
|
||||
<tt>FT_Library</tt> object that uses your own <tt>FT_Memory</tt> exclusively.
|
||||
Note however that this library has no font drivers loaded in !!
|
||||
<p>
|
||||
<li>Load the default font drivers into the new library, either by
|
||||
calling <tt>FT_Default_Drivers(library)</tt>, or by adding them manually
|
||||
through repeated calls to <tt>FT_Add_Driver(library,&driver_interface)</tt>
|
||||
<p>
|
||||
</ol>
|
||||
This will replace the <tt>FT_Init_FreeType(&library)</tt> call that an application
|
||||
must do to initialise one library instance.
|
||||
<p>
|
||||
Notice that you <em>don't need to recompile FreeType 2 to use your own memory
|
||||
manager !!</em>.
|
||||
<p>
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
<hr>
|
||||
<p>
|
||||
|
||||
<h2>II. Streams</h2>
|
||||
<ul>
|
||||
<h3>1. Basic Stream Structure</h3>
|
||||
<p>
|
||||
A stream models the array of bytes found in a font file. FreeType 2 separates
|
||||
streams into two families :<p>
|
||||
<ul>
|
||||
<li><b>memory-based streams:</b><br>
|
||||
when the stream's content is entirely found in memory. This is the
|
||||
case for ROM font files, or memory-mapped files.
|
||||
<p>
|
||||
<li><b>disk-based streams:</b><br>
|
||||
when the stream isn't directly accessible in memory. This is the
|
||||
case for local or remote files.
|
||||
<p>
|
||||
</ul>
|
||||
<p>
|
||||
Note that a stream's nature only determines how FreeType accesses its content, not
|
||||
the way it is effectively stored. For example, in the case of a compressed font file,
|
||||
one implementation may choose to uncompress the font in memory, then provide a memory
|
||||
based stream to access it. Another one might chose a disk based stream to perform
|
||||
on-the-fly decompression of the font data. Similarly, the font file can be stored
|
||||
on a local disk, or obtained from a network. This will be completely transparent to
|
||||
FreeType.
|
||||
<p>
|
||||
The stream structure is:
|
||||
<p>
|
||||
<ul>
|
||||
<tt>typedef struct</tt><br>
|
||||
<tt>{</tt><br>
|
||||
<ul><table>
|
||||
<tr><td><tt><b>char* base</b></tt> <td> for memory-based streams, the address
|
||||
of its first byte.
|
||||
|
||||
<tr><td><tt><b>ulong size</b></tt> <td> the stream's size in bytes.
|
||||
|
||||
<tr><td><tt><b>ulong pos</b></tt> <td> the current stream position in the file
|
||||
|
||||
<tr><td><tt><b>descriptor</b></tt><td> a union field used to hold either an
|
||||
integer file descriptor or pointer.
|
||||
This field is not used by FreeType
|
||||
itself, but is left to implementations
|
||||
of "<tt>ftsystem</tt>"
|
||||
<tr><td><tt><b>pathname</b></tt> <td> a union field that can hold either an
|
||||
integer or pointer. It is not used by
|
||||
FreeType itself, but is left to
|
||||
implementations. These can put the
|
||||
file pathname's during debugging for
|
||||
example.
|
||||
|
||||
<tr><td><tt><b>read</b></tt> <td> a pointer to a function used to seek the
|
||||
stream and/or read a run of bytes from it.
|
||||
|
||||
<tr><td><tt><b>close</b></tt><td> a pointer to a function called when the
|
||||
stream is closed.
|
||||
|
||||
<tr><td><tt><b>memory</b></tt> <td> a <tt>FT_Memory</tt> object, which is used
|
||||
to allocate frames for disk-based streams.
|
||||
This field is set and used by FreeType.
|
||||
|
||||
<tr><td><tt><b>cursor</b></tt> <td> a pointer in memory used when accessing
|
||||
frames. This is set and used by FreeType.
|
||||
|
||||
<tr><td><tt><b>limit</b></tt> <td> a pointer in memory used when accessing
|
||||
frames. This is set and used by FreeType.
|
||||
</table></ul>
|
||||
<tt>} FT_StreamRec, *FT_Stream</tt>
|
||||
</ul>
|
||||
<p>
|
||||
|
||||
The following important things must be noticed here:<p>
|
||||
<ul>
|
||||
<li>The <tt>FT_Stream</tt> type is really a pointer to a <tt>FT_StreamRec</tt>.
|
||||
This is a normal convention for the FreeType source.
|
||||
<p>
|
||||
|
||||
<li>When the <tt>read</tt> field is non NULL, the stream is considered to be
|
||||
disk-based. Otherwise, the stream is memory-based, and the <tt>base</tt>
|
||||
field <em>must</em> be set by "<tt>ftsystem.c</tt>" when the stream is
|
||||
created.
|
||||
<p>
|
||||
|
||||
<li>The <tt>base</tt> field must be set to 0 when a disk-based stream is created.
|
||||
However, this field will later be set and used by the FreeType library when
|
||||
accessing frames of bytes within the font file (of course, this doesn't
|
||||
happen with memory-based streams).
|
||||
</ul>
|
||||
|
||||
<h3>2. Stream lifecyles</h3>
|
||||
<p>
|
||||
Each <tt>FT_Face</tt> needs its own stream to access font data. The most common
|
||||
way to create a new <tt>FT_Stream</tt> object is to call the function
|
||||
<tt>FT_New_Face</tt>. This function takes a <em>file pathname</em> argument that
|
||||
is used to create a new stream object.
|
||||
<p>
|
||||
This is possible because each implementation of "<tt>ftsystem.c</tt>" provides
|
||||
a function called <tt>FT_New_Stream</tt> which takes a file pathname and a
|
||||
<tt>FT_Stream</tt> pointer as an argument. The function simply opens the file
|
||||
and initialises the stream structure accordingly. It is called by <tt>FT_New_Face</tt>
|
||||
to create the face's stream object.
|
||||
<p>
|
||||
A stream is only closed when the face is destroyed through <tt>FT_Done_Face</tt>.
|
||||
Its <tt>close</tt> field function will then be called. Note that the function should
|
||||
<em>never</em> destroy the <tt>FT_Stream</tt>.
|
||||
<p>
|
||||
|
||||
|
||||
<h3>3. Using your own streams</h3>
|
||||
<p>
|
||||
There are cases where it is interesting to provide your own stream to create
|
||||
a new face object, rather than rely on the default implementation. For example,
|
||||
a filepathname, which is a C string, might not be useful on a system where files
|
||||
are named with a UTF-16 string or via an i-node number of memory address (for ROM files).
|
||||
<p>
|
||||
For this purpose, the <tt>FT_Open_Face</tt> is defined. It simply takes a
|
||||
<tt>FT_Stream</tt> pointer as its second argument, instead of a file pathname (the
|
||||
stream must be allocated and initialised by you, so be careful).
|
||||
<p>
|
||||
Actually, the only thing that <tt>FT_New_Face</tt> does is create a new stream
|
||||
through <tt>FT_New_Stream</tt>, then call <tt>FT_Open_Face</tt> to create the
|
||||
face with it.
|
||||
<p>
|
||||
Note also that you can use the function <tt>FT_New_Memory_Face</tt> to create
|
||||
a new font face for a memory-based font file, whose address and size can be passed
|
||||
as arguments. The function automatically creates the corresponding memory-based
|
||||
stream and use it to create the face.
|
||||
<p>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
<p>
|
||||
<hr>
|
||||
<p>
|
||||
|
||||
<h2>III. Thread synchronisation</h2>
|
||||
<ul>
|
||||
The FreeType library uses no static data. It can be used concurrently by two
|
||||
thread as long as each one uses its own <tt>FT_Library</tt> instance. Otherwise,
|
||||
one can very simply synchronize access to a single library instance by using a
|
||||
mutex to protect each call to one of FreeType's API functions.
|
||||
<p>
|
||||
</ul>
|
||||
|
||||
|
||||
@@ -0,0 +1,516 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# DocMaker is a very simple program used to generate HTML documentation
|
||||
# from the source files of the FreeType packages.
|
||||
#
|
||||
|
||||
import fileinput, sys, string
|
||||
|
||||
# This function is used to parse a source file, and extract comment blocks
|
||||
# from it. The following comment block formats are recognized :
|
||||
#
|
||||
# /**************************
|
||||
# *
|
||||
# * FORMAT1
|
||||
# *
|
||||
# *
|
||||
# *
|
||||
# *
|
||||
# *************************/
|
||||
#
|
||||
# /**************************/
|
||||
# /* */
|
||||
# /* FORMAT2 */
|
||||
# /* */
|
||||
# /* */
|
||||
# /* */
|
||||
# /* */
|
||||
#
|
||||
# /**************************/
|
||||
# /* */
|
||||
# /* FORMAT3 */
|
||||
# /* */
|
||||
# /* */
|
||||
# /* */
|
||||
# /* */
|
||||
# /**************************/
|
||||
#
|
||||
# Each block is modeled as a simple list of text strings
|
||||
# The function returns a list of blocks, i.e. a list of strings lists
|
||||
#
|
||||
|
||||
def make_block_list():
|
||||
"""parse a file and extract comments blocks from it"""
|
||||
|
||||
list = []
|
||||
block = []
|
||||
format = 0
|
||||
|
||||
for line in fileinput.input():
|
||||
|
||||
line = string.strip(line)
|
||||
l = len(line)
|
||||
|
||||
if format == 0:
|
||||
if l > 3 and line[0:3] == '/**':
|
||||
i = 3
|
||||
while (i < l) and (line[i] == '*'):
|
||||
i = i+1
|
||||
|
||||
if i == l:
|
||||
# this is '/**' followed by any number of '*', the
|
||||
# beginning of a Format 1 block
|
||||
#
|
||||
block = [];
|
||||
format = 1;
|
||||
|
||||
elif (i == l-1) and (line[i] == '/'):
|
||||
# this is '/**' followed by any number of '*', followed
|
||||
# by a '/', i.e. the beginning of a Format 2 or 3 block
|
||||
#
|
||||
block = [];
|
||||
format = 2;
|
||||
|
||||
##############################################################
|
||||
#
|
||||
# FORMAT 1
|
||||
#
|
||||
elif format == 1:
|
||||
|
||||
# if the line doesn't begin with a "*", something went
|
||||
# wrong, and we must exit, and forget the current block..
|
||||
if (l == 0) or (line[0] != '*'):
|
||||
block = []
|
||||
format = 0
|
||||
|
||||
# otherwise, we test for an end of block, which is an
|
||||
# arbitrary number of '*', followed by '/'
|
||||
else:
|
||||
i = 1
|
||||
while (i < l) and (line[i] == '*'):
|
||||
i = i+1
|
||||
|
||||
# test for the end of the block
|
||||
if (i < l) and (line[i] == '/'):
|
||||
if block != []: list.append( block )
|
||||
format = 0
|
||||
block = []
|
||||
|
||||
else:
|
||||
block.append( line[1:] )
|
||||
|
||||
##############################################################
|
||||
#
|
||||
# FORMAT 2
|
||||
#
|
||||
elif format == 2:
|
||||
|
||||
# if the line doesn't begin with '/*' and end with '*/',
|
||||
# this is the end of the format 2 format..
|
||||
if (l < 4 ) or (line[:2] != '/*') or (line[-2:] != '*/'):
|
||||
if block != []: list.append(block)
|
||||
block = []
|
||||
format = 0
|
||||
continue
|
||||
|
||||
# remove the start and end comment delimiters, then right-strip
|
||||
# the line
|
||||
line = string.rstrip(line[2:-2])
|
||||
|
||||
# check for end of a format2 block, i.e. a run of '*'
|
||||
if string.count(line,'*') == l-4:
|
||||
if block != []: list.append(block)
|
||||
block = []
|
||||
format = 0
|
||||
else:
|
||||
# otherwise, add the line to the current block
|
||||
block.append(line)
|
||||
|
||||
return list
|
||||
|
||||
|
||||
# This function is only used for debugging
|
||||
#
|
||||
def dump_block_list( list ):
|
||||
"""dump a comment block list"""
|
||||
for block in list:
|
||||
print "----------------------------------------"
|
||||
for line in block:
|
||||
print line
|
||||
print "---------the end-----------------------"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
######################################################################################
|
||||
#
|
||||
#
|
||||
# The DocParagraph is used to store either simple text paragraph or
|
||||
# source code lines
|
||||
#
|
||||
#
|
||||
# If the paragraph contains source code (use code=1 when initializing the
|
||||
# object), self.lines is a list of source code strings
|
||||
#
|
||||
# Otherwise, self.lines is simply a list of words for the paragraph
|
||||
#
|
||||
class DocParagraph:
|
||||
|
||||
def __init__(self,code=0,margin=0):
|
||||
self.lines = []
|
||||
self.code = code
|
||||
self.margin = margin
|
||||
|
||||
def add(self,line):
|
||||
|
||||
if self.code==0:
|
||||
# get rid of unwanted spaces in the paragraph
|
||||
self.lines.extend( string.split(line) )
|
||||
|
||||
else:
|
||||
# remove margin whitespace
|
||||
if string.strip( line[:self.margin] ) == "": line = line[self.margin:]
|
||||
self.lines.append(line)
|
||||
|
||||
|
||||
def dump(self):
|
||||
|
||||
max_width = 50
|
||||
|
||||
if self.code == 0:
|
||||
cursor = 0
|
||||
line = ""
|
||||
|
||||
for word in self.lines:
|
||||
|
||||
if cursor+len(word)+1 > max_width:
|
||||
print line
|
||||
cursor = 0
|
||||
line = ""
|
||||
|
||||
line = line + word + " "
|
||||
cursor = cursor + len(word) + 1
|
||||
|
||||
if cursor > 0:
|
||||
print line
|
||||
|
||||
else:
|
||||
for line in self.lines:
|
||||
print "--" + line
|
||||
|
||||
print ""
|
||||
|
||||
|
||||
######################################################################################
|
||||
#
|
||||
#
|
||||
# The DocContent class is used to store the content of a given marker
|
||||
# Each DocContent can have its own text, plus a list of fields. Each field
|
||||
# has its own text too
|
||||
#
|
||||
# Hence, the following lines :
|
||||
#
|
||||
# """
|
||||
# Some arbitraty text:
|
||||
#
|
||||
# fieldone :: some arbitraty text for this field,
|
||||
# note that the text stretches to several lines
|
||||
#
|
||||
# fieldtwo :: some other text
|
||||
#
|
||||
# """
|
||||
#
|
||||
# will be stored as (each text is a list of string:
|
||||
#
|
||||
# self.fields = [ "", "fieldone", "fieldtwo" ]
|
||||
# self.texts = [
|
||||
# [ "some arbitraty text for this field," ,
|
||||
# "note that the text stretches to several lines" ],
|
||||
#
|
||||
# [ "some other text" ]
|
||||
# ]
|
||||
#
|
||||
#
|
||||
class DocContent:
|
||||
|
||||
def __init__(self, paragraph_lines=[]):
|
||||
|
||||
self.fields = []
|
||||
self.texts = []
|
||||
|
||||
code_mode = 0
|
||||
code_margin = 0
|
||||
|
||||
field = ""
|
||||
text = []
|
||||
paragraph = None
|
||||
|
||||
for aline in paragraph_lines:
|
||||
|
||||
if code_mode == 0:
|
||||
line = string.lstrip(aline)
|
||||
l = len(line)
|
||||
margin = len(aline) - l
|
||||
|
||||
# if the line is empty, this is the end of the current
|
||||
# paragraph
|
||||
if line == "":
|
||||
if paragraph:
|
||||
text.append(paragraph)
|
||||
paragraph = None
|
||||
continue
|
||||
|
||||
# test for the beginning of a code block, i.e.'{' is the first
|
||||
# and only character on the line..
|
||||
#
|
||||
if line == '{':
|
||||
code_mode = 1
|
||||
code_margin = margin
|
||||
if paragraph:
|
||||
text.append(paragraph)
|
||||
paragraph = DocParagraph( 1, margin )
|
||||
continue
|
||||
|
||||
words = string.split(line)
|
||||
|
||||
# test for a field delimiter on the start of the line, i.e.
|
||||
# the oken `::'
|
||||
#
|
||||
if len(words) >= 2 and words[1] == "::":
|
||||
if paragraph:
|
||||
text.append(paragraph)
|
||||
paragraph = None
|
||||
|
||||
self.fields.append(field)
|
||||
self.texts.append(text)
|
||||
|
||||
field = words[0]
|
||||
text = []
|
||||
words = words[2:]
|
||||
|
||||
if len(words) > 0:
|
||||
line = string.join(words)
|
||||
if not paragraph:
|
||||
paragraph = DocParagraph()
|
||||
paragraph.add( line )
|
||||
|
||||
else:
|
||||
line = aline
|
||||
|
||||
# the code block ends with a line that has a single '}' on it
|
||||
if line == " "*code_margin+'}':
|
||||
text.append(paragraph)
|
||||
paragraph = None
|
||||
code_mode = 0
|
||||
code_margin = 0
|
||||
|
||||
# otherwise, add the line to the current paragraph
|
||||
else:
|
||||
paragraph.add(line)
|
||||
|
||||
if paragraph:
|
||||
text.append(paragraph)
|
||||
|
||||
self.fields.append( field )
|
||||
self.texts.append( text )
|
||||
|
||||
|
||||
|
||||
def dump(self):
|
||||
for i in range(len(self.fields)):
|
||||
field = self.fields[i]
|
||||
if field: print "<field "+field+">"
|
||||
|
||||
for paras in self.texts[i]:
|
||||
paras.dump()
|
||||
|
||||
if field: print "</field> "
|
||||
|
||||
def dump_html(self):
|
||||
n = len(self.fields)
|
||||
for i in range(n):
|
||||
field = self.fields[i]
|
||||
if field==[]:
|
||||
print "<p>"
|
||||
for paras in self.texts[i]:
|
||||
print "<p>"
|
||||
paras.dump()
|
||||
print "</p>"
|
||||
else:
|
||||
if i==1:
|
||||
print "<table cellpadding=4><tr valign=top><td>"
|
||||
else:
|
||||
print "</td></tr><tr valign=top><td>"
|
||||
|
||||
print "<b>"+field+"</b></td><td>"
|
||||
|
||||
for paras in self.texts[i]:
|
||||
print "<p>"
|
||||
paras.dump()
|
||||
print "</p>"
|
||||
|
||||
print "</td></tr>"
|
||||
if n > 1:
|
||||
print "</table>"
|
||||
|
||||
|
||||
######################################################################################
|
||||
#
|
||||
#
|
||||
# The DocBlock class is used to store a given comment block. It contains
|
||||
# a list of markers, as well as a list of contents for each marker.
|
||||
#
|
||||
#
|
||||
class DocBlock:
|
||||
|
||||
def __init__(self, block_line_list=[]):
|
||||
self.markers = []
|
||||
self.contents = []
|
||||
|
||||
marker = ""
|
||||
content = []
|
||||
alphanum = string.letters + string.digits + "_"
|
||||
|
||||
for line in block_line_list:
|
||||
line2 = string.lstrip(line)
|
||||
l = len(line2)
|
||||
margin = len(line) - l
|
||||
|
||||
if l > 3 and line2[0] == '<':
|
||||
i = 1
|
||||
while i < l and line2[i] in alphanum: i = i+1
|
||||
if i < l and line2[i] == '>':
|
||||
if marker or content:
|
||||
self.add( marker, content )
|
||||
marker = line2[1:i]
|
||||
content = []
|
||||
line2 = string.lstrip(line2[i+1:])
|
||||
l = len(line2)
|
||||
line = " "*margin + line2
|
||||
|
||||
content.append(line)
|
||||
|
||||
if marker or content:
|
||||
self.add( marker, content )
|
||||
|
||||
|
||||
def add( self, marker, lines ):
|
||||
|
||||
# remove the first and last empty lines from the content list
|
||||
l = len(lines)
|
||||
if l > 0:
|
||||
i = 0
|
||||
while l > 0 and string.strip(lines[l-1]) == "": l = l-1
|
||||
while i < l and string.strip(lines[i]) == "": i = i+1
|
||||
lines = lines[i:l]
|
||||
l = len(lines)
|
||||
|
||||
# add a new marker only if its marker and its content list aren't empty
|
||||
if l > 0 and marker:
|
||||
self.markers.append(marker)
|
||||
self.contents.append(lines)
|
||||
|
||||
def dump( self ):
|
||||
for i in range( len(self.markers) ):
|
||||
print "["+self.markers[i]+"]"
|
||||
for line in self.contents[i]:
|
||||
print "-- "+line
|
||||
|
||||
def doc_contents(self):
|
||||
contents = []
|
||||
for item in self.contents:
|
||||
contents.append( DocContent(item) )
|
||||
return contents
|
||||
|
||||
|
||||
def dump_doc_blocks( block_list ):
|
||||
for block in block_list:
|
||||
docblock = DocBlock(block)
|
||||
docblock.dump()
|
||||
print "<<------------------->>"
|
||||
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
def dump_single_content( block_list ):
|
||||
|
||||
block = block_list[0]
|
||||
docblock = DocBlock(block)
|
||||
|
||||
print "<block>"
|
||||
for i in range(len(docblock.markers)):
|
||||
marker = docblock.markers[i]
|
||||
contents = docblock.contents[i]
|
||||
|
||||
print "<marker "+marker+">"
|
||||
doccontent = DocContent( contents )
|
||||
|
||||
doccontent.dump()
|
||||
|
||||
print "</marker>"
|
||||
|
||||
print "</block>"
|
||||
|
||||
def dump_doc_contents( block_list ):
|
||||
|
||||
for block in block_list:
|
||||
docblock = DocBlock(block)
|
||||
print "<block>"
|
||||
|
||||
for i in range(len(docblock.markers)):
|
||||
print "<marker "+docblock.markers[i]+">"
|
||||
content = DocContent( docblock.contents[i] )
|
||||
content.dump()
|
||||
print "</marker>"
|
||||
print "</block>"
|
||||
|
||||
def dump_html_1( block_list ):
|
||||
|
||||
print "<html><body>"
|
||||
types = [ 'Type', 'Struct', 'FuncType', 'Function', 'Constant', 'Enumeration' ]
|
||||
for block in block_list:
|
||||
docblock = DocBlock(block)
|
||||
print "<hr>"
|
||||
for i in range(len(docblock.markers)):
|
||||
marker = docblock.markers[i]
|
||||
content = docblock.contents[i]
|
||||
dcontent = DocContent( content )
|
||||
|
||||
if marker=="Description":
|
||||
print "<ul><p>"
|
||||
dcontent.dump()
|
||||
print "</p></ul>"
|
||||
|
||||
elif marker in types:
|
||||
print "<h3><font color=blue>"+content[0]+"</font></h3>"
|
||||
else:
|
||||
print "<h4>"+marker+"</h4>"
|
||||
print "<ul><p>"
|
||||
dcontent.dump_html()
|
||||
print "</p></ul>"
|
||||
|
||||
print ""
|
||||
|
||||
print "<hr></body></html>"
|
||||
|
||||
|
||||
def main(argv):
|
||||
"""main program loop"""
|
||||
print "extracting comment blocks from sources .."
|
||||
list = make_block_list()
|
||||
|
||||
# dump_block_list( list )
|
||||
|
||||
# dump_doc_blocks( list )
|
||||
|
||||
# print "dumping block contents .."
|
||||
# dump_doc_contents(list)
|
||||
|
||||
dump_html_1(list)
|
||||
|
||||
# dump_single_content(list)
|
||||
|
||||
# If called from the command line
|
||||
if __name__=='__main__': main(sys.argv)
|
||||
@@ -0,0 +1,352 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>FreeType 2 Introduction</title>
|
||||
<basefont face="Georgia, Arial, Helvetica, Geneva">
|
||||
<style content="text/css">
|
||||
P { text-align=justify }
|
||||
H1 { text-align=center }
|
||||
H2 { text-align=center }
|
||||
LI { text-align=justify }
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body text="#000000"
|
||||
bgcolor="#FFFFFF"
|
||||
link="#0000EF"
|
||||
vlink="#51188E"
|
||||
alink="#FF0000">
|
||||
|
||||
|
||||
<font size=1>http://www.freetype.org</font><p>
|
||||
|
||||
<center>
|
||||
<a href="freetype.html">
|
||||
<img src="image/freetype.jpg" width=550 height=105 alt="The FreeType Project" border=0></a>
|
||||
<h1>An Introduction to FreeType 2</h1>
|
||||
</center>
|
||||
|
||||
<center><table width=750 cellspacing=10 cellpadding=30><tr><td>
|
||||
<hr><p>
|
||||
|
||||
DOCUMENT INDEX:<br>
|
||||
<ul>
|
||||
<li><a href="#what">What is FreeType 2 ?</a>
|
||||
<li><a href="#features">Features</a>
|
||||
<li><a href="#requirements">Requirements</a>
|
||||
<li><a href="#patents">Patents issues</a>
|
||||
</ul><p>
|
||||
|
||||
|
||||
<hr><p>
|
||||
|
||||
<table width="100%" cellspacing=5><tr bgcolor="#CCCCEE"><td>
|
||||
<h2 align=center><a name="what">What is FreeType 2 ?</h2>
|
||||
</td></tr><tr><td>
|
||||
|
||||
<p>The FreeType project is a team of volunteers who develop free, portable
|
||||
and high-quality software solutions for digital typography. We specifically
|
||||
target embedded systems and focus on bringing small, efficient and
|
||||
ubiquitous products.</p>
|
||||
|
||||
<p>the FreeType 2 library is our new software font engine. It has been
|
||||
designed to provide the following important features:</p>
|
||||
|
||||
<ul>
|
||||
<li><p>
|
||||
<b>A universal and simple API to manage font files:</b><br>
|
||||
<ul>
|
||||
<p>The FreeType 2 API is simple and easy to use. It supports both
|
||||
bitmapped and scalable fonts and is well-suited to manage font
|
||||
files of all formats. Unlike other font libraries, FreeType 2
|
||||
returns and manages outline font data (images & metrics).</p>
|
||||
</ul>
|
||||
</p></li>
|
||||
|
||||
<li><p>
|
||||
<b>Support for several font formats through loadable modules:</b><br>
|
||||
<ul>
|
||||
<p>FreeType 2 uses <em>"font drivers"</em>. Each driver is a loadable
|
||||
module used to support one specific font format. Each driver can also
|
||||
provide specific extensions used to access format-specific features of
|
||||
the font.</p>
|
||||
</ul>
|
||||
</p></li>
|
||||
|
||||
|
||||
<li><p>
|
||||
<b>High-quality anti-aliasing:</b><br>
|
||||
<ul>
|
||||
<p>FreeType 2 produces etremely smooth outlines at small sizes, with its new
|
||||
anti-aliasing renderer, which produces bitmaps with 256-levels of gray.
|
||||
It uses a new algorithm that has been specifically designed to render
|
||||
small complex shapes (like glyphs) at high speed. Indeed, it's even
|
||||
faster than the monochrome renderer for small character sizes (under
|
||||
20 pixels) !!
|
||||
</p>
|
||||
</ul>
|
||||
|
||||
|
||||
<li><b>High portability & performance:</b><br>
|
||||
<ul>
|
||||
<p>The FreeType 2 source code is written in ANSI C and runs on any
|
||||
platform with a compliant compiler. Client applications can
|
||||
provide their own memory manager or input stream to the library
|
||||
(which means that font files can come from any place: disk,
|
||||
memory, compressed file, network, etc..).
|
||||
</p>
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
|
||||
<p>Note that <em>the beta of FreeType 2 is available <b>now</b></em>. For more
|
||||
info, check our <a href="download.html">Download page</a> or see the source
|
||||
and its diffs through our <a href="cgi-bin/cvsweb.cgi">CVS Web interface</a>.
|
||||
</p>
|
||||
</ul>
|
||||
|
||||
</td></tr></table>
|
||||
|
||||
<table width="100%" cellspacing=5><tr bgcolor="#CCCCEE"><td>
|
||||
<h2 align=center><a name="features">Features</h2>
|
||||
</td></tr><tr><td>
|
||||
|
||||
<h3>Supported font formats</h3>
|
||||
|
||||
<p>FreeType 2 readily supports the following font formats:</p>
|
||||
|
||||
<ul>
|
||||
<li>TrueType files (.ttf) and collections (.ttc)</li>
|
||||
<li>Type 1 font files both in ASCII (.pfa) or binary (.pfb) format</li>
|
||||
<li>Type 1 Multiple Master fonts. The FreeType 2 API also provides
|
||||
routines to manage design instances easily</li>
|
||||
<li>Type 1 CID-keyed fonts</li>
|
||||
<li>OpenType/CFF (.otf) fonts</li>
|
||||
<li>CFF/Type 2 fonts</li>
|
||||
<li>Adobe CEF fonts (.cef), used to embed fonts in SVG documents
|
||||
with the Adobe SVG viewer plugin.</li>
|
||||
<li>Windows FNT/FON bitmap fonts</li>
|
||||
</ul>
|
||||
|
||||
<p>Note that Apple's TrueType GX fonts are supported as normal TTFs,
|
||||
(the advanced tables are ignored).</p>
|
||||
|
||||
<p>Besides, it's possible to add support for new font formats by providing
|
||||
a specific <em>font driver</em> module. Modules can be added either at
|
||||
build time (when recompiling the library), or at <em>run-time</em>;
|
||||
this allows, for example, applications to register their own
|
||||
font driver to support program-specific formats.</p>
|
||||
|
||||
|
||||
<h3>Patent-free automatic hinter</h3>
|
||||
|
||||
<p>TrueType fonts are normally renderered (hinted) with the help of a
|
||||
specific bytecode where the behaviour of a few opcodes is patented by
|
||||
Apple. We're currently in contact with Apple to discuss the importance
|
||||
of such patents and their use in open source projects like FreeType.
|
||||
</p>
|
||||
|
||||
<p>In the meantime, we have developped our own alternative technology that
|
||||
is capable of automatically hinting scalable glyph images. It is
|
||||
now part of the FreeType 2 source tree as the "autohint" module,
|
||||
and is used to hint glyphs when the bytecode interpreter is disabled
|
||||
(through a configuration macro when building the engine). Note that
|
||||
the auto-hinter is also used to handle glyphs in other formats like
|
||||
CFF and Type 1.</p>
|
||||
|
||||
<p>The auto-hinter provides pretty good results (in some cases, it even
|
||||
significantly improves the output of poorly hinted fonts) but we'll
|
||||
continue to improve it with each new release of FreeType to achieve
|
||||
the highest possible quality.</p>
|
||||
|
||||
|
||||
<h3>Modular design:</h3>
|
||||
|
||||
<p>The design of FreeType 2 is extremely modular as most features are
|
||||
supported through optional modules. This means it's easily possible to
|
||||
only compile the features you need. As each module is between
|
||||
10 and 20 Kb in size, it's possible to build a bare-bones
|
||||
font engine that supports anti-aliasing in about 30 Kb !!</p>
|
||||
|
||||
<p>Configuration is performed by modifications of only two header
|
||||
files (one to select global features, another one to select modules)
|
||||
and don't need tweaking of source code. Note that it is however
|
||||
possible to provide your own implementation of certain components.</p>
|
||||
|
||||
<p>For example, when building on Unix, the engine will automatically
|
||||
use memory-mapped files when available on the target platform,
|
||||
thus significantly increasing font file i/o.</p>
|
||||
|
||||
|
||||
<p>Due to its very flexible design, it is possible to add, remove and
|
||||
upgrade modules at run-time.</p>
|
||||
|
||||
|
||||
|
||||
<h3>Advanced glyph management</h3>
|
||||
|
||||
<p>The API comes with a standard extension used to extract individual
|
||||
glyph images from font files. These images can be bitmaps, scalable
|
||||
bezier outlines or even anything else. (e.g. bi-color or metafont
|
||||
glyphs, as long as they're supported by a module).</p>
|
||||
|
||||
<p>Each scalable glyph image can be transformed, measured and
|
||||
rendered into a monochrome or anti-aliased bitmaps easily
|
||||
through a uniform interface.
|
||||
|
||||
This allows client applications to easily cache glyphs or
|
||||
perform text rendering effects with minimal difficulty
|
||||
(look at the FreeType 2 Tutorial to see how to render
|
||||
rotated text with very few lines of code).
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
<h3>Advanced font access</h3>
|
||||
|
||||
<p>The FreeType 2 API is useful to retrieve advanced information from
|
||||
various fonts:</p>
|
||||
|
||||
<ul>
|
||||
<li>vertical metrics are available whenever found in the font file</li>
|
||||
|
||||
<li>kerning distances are available when found in the font file. It
|
||||
is also possible to "attach" a given additional file to a given
|
||||
font face. This is useful to load kerning distances from an
|
||||
.afm file into a Type 1 face for example.</li>
|
||||
|
||||
<li>provides ASCII glyph names whenever available in the font
|
||||
(TrueType, OpenType, Type1, etc..)</li>
|
||||
|
||||
<li>provides access to important tables for SFNT-based font formats
|
||||
(i.e. TrueType, OpenType, CEF, etc..), like the name table,
|
||||
font header, maximum profile, etc...</li>
|
||||
|
||||
<li>automatic synthesis of Unicode-based character maps for
|
||||
those fonts or formats that do not provide one. This is
|
||||
extremely useful with Type 1 fonts which are normally
|
||||
limited to a stupid 256-characters encoding.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>Simple & clean API</h3>
|
||||
|
||||
<p>The FreeType 2 high-level API is simple and straightforward, as it
|
||||
has been specifically designed to make the most commmon font operations
|
||||
easy</p>
|
||||
|
||||
<p>As a comparison, the number of function calls needed to perform a
|
||||
the tasks of font face creation/opening and glyph loading/rendering
|
||||
has been reduced by a factor of 4 !!</p>
|
||||
|
||||
<p>The API is also independent of any font-format specific issue, though
|
||||
it provides standard extensions to access format-specific tables and
|
||||
information. More extensions can also be easily added through new
|
||||
modules</p>
|
||||
|
||||
|
||||
<h3>Robust & Portable code</h3>
|
||||
|
||||
<p>Because it is written in industry-standard ANSI C, FreeType 2 compiles
|
||||
on all platforms with a compliant compiler. Because the default build
|
||||
only relies on the C library, it is free of any system-specific
|
||||
dependencies, even if it is possible to "enhance" certain components
|
||||
by providing a specific implementation.</p>
|
||||
|
||||
<p>The code doesn't use global or static variables. Client applications
|
||||
can provide their own memory manager. Font files can be read from
|
||||
a disk file, memory, or through a client-provided input stream. This
|
||||
allows to support compressed font files, remote fonts, fonts embedded
|
||||
in other streams (e.g. Type42 fonts), etc..</p>
|
||||
|
||||
<p>An advanced i/o sub-system is used to optimise file access, as well
|
||||
as reduce memory usage of the library when the file is memory-based
|
||||
( ROM, RAM, memory-mapped ).</p>
|
||||
|
||||
|
||||
<h3>Open Source & Vendor Independence</h3>
|
||||
|
||||
<p>Finally, FreeType 2 is released under its own BSD-like open source
|
||||
license, one of the less restricting licenses available, and this
|
||||
means that:</p>
|
||||
|
||||
<ul>
|
||||
<li><p>
|
||||
It can be included in all kinds of products, be they proprietary
|
||||
or not.
|
||||
</p></li>
|
||||
|
||||
<li><p>
|
||||
As any module can be added or replaced anytime, any third party
|
||||
vendor has the ability to provide its own set of modules (under
|
||||
its own license) in order to support proprietary font formats or
|
||||
more advanced features (e.g. a new auto-hinter, or a new
|
||||
anti-aliasing renderer for LCDs or TV screens).
|
||||
</p></li>
|
||||
</ul>
|
||||
|
||||
<p>One could even imagine an application using the FreeType 2 API with
|
||||
a "wrapper" module used to access system-specific fonts (like through
|
||||
the Windows GDI). This would mean native font support with more portable
|
||||
application code (as simply changing the wrapper module would be required
|
||||
to port the application to another system).</p>
|
||||
|
||||
</td></tr></table>
|
||||
|
||||
<table width="100%" cellspacing=5><tr bgcolor="#CCCCEE"><td>
|
||||
<h2 align=center><a name="requirements">Requirements</h2>
|
||||
</td></tr><tr><td>
|
||||
|
||||
<p>FreeType 2 is written in ANSI C and should compile with no problems
|
||||
on a great variety of platforms. We have taken care of removing all
|
||||
compilation warnings from major compliant compilers. Detailed compilation
|
||||
instructions are provided in the software archive.</p>
|
||||
|
||||
<p>This version of the library has been succesfully compiled and run
|
||||
under the following systems: Dos, OS/2, Windows, Macintosh, Unix
|
||||
(including the 64-bits DEC Unix, a.k.a. "True64"). You should not
|
||||
encounter major problems compiling it on any other kind of platform.
|
||||
In all cases, contact us if you do.</p>
|
||||
|
||||
<p>Note that a small set of demonstration programs is also separately
|
||||
available. They include a tiny graphics sub-system that is used to
|
||||
display and show-off the library's capabilities on the following
|
||||
platforms: X11, MacOS, OS/2 & Windows.</p>
|
||||
|
||||
<p>Please visit our <a href="http://www.freetype.org/download.html">
|
||||
Download section</a> to access the software archives.</p>
|
||||
|
||||
</ul>
|
||||
|
||||
</td></tr></table>
|
||||
|
||||
<table width="100%" cellspacing=5><tr bgcolor="#CCCCEE"><td>
|
||||
<h2 align=center><a name="patents">Patents issues</h2>
|
||||
</td></tr><tr><td>
|
||||
|
||||
<p>The FreeType 2 source code includes a TrueType bytecode interpreter that
|
||||
is covered by the Apple patents. However, this piece of code is never
|
||||
compiled by default in this release (unlike in previous betas) making
|
||||
a default build of the library <em>entirely patent-free !!</em></p>
|
||||
|
||||
<p>Note that in order to compile the interpreter, one needs to define
|
||||
the configuration macro <tt><b>TT_CONFIG_OPTION_BYTECODE_INTERPRETER</b></tt> configuration
|
||||
macro in the file "<tt>ftoption.h</tt>". More details are available in
|
||||
the software archive. Note that the use of the interpreter is normally
|
||||
protected by US, UK and French patents. In the event you'd absolutely
|
||||
need it, you may have to <a href="mailto:[email protected]">contact
|
||||
Apple legal department</a> for licensing conditions, depending on your
|
||||
location and the places you distribute/sell your products.</p>
|
||||
|
||||
<p>Please do not ask us any detailed information regarding licensing, as
|
||||
we're still discussing with Apple this issue, we're unable to inform
|
||||
the public of what's currently going on..</p>
|
||||
|
||||
</td></tr></table>
|
||||
|
||||
<hr>
|
||||
<p>
|
||||
<a href="index.html">Back to FreeType homepage</a><p>
|
||||
|
||||
</td></tr></table>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,502 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>FreeType 2 FAQ</title>
|
||||
<basefont face="Georgia, Arial, Helvetica, Geneva">
|
||||
<style content="text/css">
|
||||
P { text-align=justify }
|
||||
H1 { text-align=center }
|
||||
H2 { text-align=center }
|
||||
LI { text-align=justify }
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body text="#000000"
|
||||
bgcolor="#FFFFFF"
|
||||
link="#0000EF"
|
||||
vlink="#51188E"
|
||||
alink="#FF0000">
|
||||
|
||||
|
||||
<font size=1>http://www.freetype.org</font><p>
|
||||
|
||||
<center>
|
||||
<a href="freetype.html">
|
||||
<img src="image/freetype.jpg" width=550 height=105 alt="The FreeType Project" border=0></a>
|
||||
<h1>The FreeType 2 FAQ</h1>
|
||||
</center>
|
||||
|
||||
<center><table width=750 cellspacing=10 cellpadding=30><tr><td>
|
||||
<hr><p>
|
||||
|
||||
DOCUMENT INDEX:<br>
|
||||
<ul>
|
||||
<li><p><a href="#general">General</a>
|
||||
<ul>
|
||||
<li><a href="#general-dead">I thought the FreeType project was dead. It this true?</a></li>
|
||||
<li><a href="#general-long">Why did it take so long to release FreeType 2?</a></li>
|
||||
<li><a href="#general-unix">Is FreeType 2 a Unix-only project?</a></li>
|
||||
<li><a href="#general-x11">When will X11 support anti-aliased glyphs?</a></li>
|
||||
<li><a href="#general-ft1">Is FreeType 2 backwards compatible with 1.x?</a></li>
|
||||
<li><a href="#general-edit">Can I use FreeType 2 to edit fonts or create new ones?</a></li>
|
||||
</ul></p>
|
||||
</li>
|
||||
<li><p><a href="#builds">Compilation & Configuration</a>
|
||||
<ul>
|
||||
<li><a href="#builds-compile">How do I compile the FreeType 2 library?</a></li>
|
||||
<li><a href="#builds-config">How do I configure my library build?</a></li>
|
||||
<li><a href="#builds-modules">How do I select the modules I need?</a></li>
|
||||
<li><a href="#builds-flat">How do I compile all FreeType 2 files in a single directory?</a></li>
|
||||
</ul>
|
||||
</p></li>
|
||||
<li><p><a href="#library">Using the FreeType 2 library</a></p></li>
|
||||
<li><p><a href="#autohint">The FreeType 2 Autohinter</a>
|
||||
<ul>
|
||||
<li><a href="#autohint-license">Under which license is the auto-hinter released ?</a></li>
|
||||
<li><a href="#autohint-work">How does auto-hinting work in FreeType 2 ?</a></li>
|
||||
<li><a href="#autohint-cjk">Why doesn't the auto-hinter work well with CJK fonts ?</a></li>
|
||||
</ul>
|
||||
</p></li>
|
||||
<li><p><a href="#other">Other questions</a>
|
||||
<ul>
|
||||
<li><a href="#other-antialias">What is the anti-aliasing algorithm used in the FreeType 2 renderer?</a></li>
|
||||
<li><a href="#other-opentype">When will FreeType 2 support OpenType ?</a></li>
|
||||
</ul></p>
|
||||
</li>
|
||||
</ul><p>
|
||||
|
||||
|
||||
<hr><p>
|
||||
|
||||
<table width="100%" cellspacing=5><tr bgcolor="#CCCCEE"><td>
|
||||
<h2 align=center><a name="general">General questions & answers</h2>
|
||||
</td></tr><tr><td>
|
||||
|
||||
<a name="general-dead">
|
||||
<h3>I.1. I though the FreeType project was dead. Is this true?</h3>
|
||||
<ul>
|
||||
<p>Well, not exactly :-) It's true that the TrueType patents issues
|
||||
have been less than a graceful event to handle but it didn't not
|
||||
really killed the project per se, as Apple hasn't made an official
|
||||
statement yet regarding the use of the patented "technology" in
|
||||
open source projects (or other products).</p>
|
||||
|
||||
<p>We have thus continued updating FreeType 1.x, and started developping
|
||||
FreeType 2 with the idea of providing this time a completely patent
|
||||
free font engine. However, we largely preferred not to broadly
|
||||
communicate about it until we've got a satisfying implementation
|
||||
to show.</p>
|
||||
</ul>
|
||||
|
||||
|
||||
<a name="general-long">
|
||||
<h3>I.2. Why did it take so long to release FreeType 2?</h3>
|
||||
<ul>
|
||||
<p>Several factors come to mind. The first one is that FreeType 2 is
|
||||
a much more complex and dense project that was mostly developed
|
||||
on non-working hours. And surely some important changes in the
|
||||
life (like marriage, new jobs and kids) of some the FreeType
|
||||
developers cannot be ignored :-)</p>
|
||||
|
||||
<p>A second one is that a first version of the library was designed
|
||||
one year ago (and already worked with a multitude of font drivers),
|
||||
though with a design that was judged by its authors as well as
|
||||
beta testers as not enough flexible or consistent. In short, it worked
|
||||
well but we were not exactly proud of it (call us perfectionists).
|
||||
It has then be significantly reworked to become what we're now
|
||||
distributing as FreeType 2</p>
|
||||
|
||||
<p>Finally, it would have been hard to distribute such a library without
|
||||
an alternative technology to replace the patented bytecode interpreter.
|
||||
This involved significant research work that could only be performed
|
||||
correctly full-time, and we had to found a company to fund such a
|
||||
development and still make it available under a BSD-like license.
|
||||
Huge thanks to <a href="http://www.catharon.com">Catharon Productions, Inc.</a>
|
||||
for their commitment to this project.</p>
|
||||
|
||||
<p>And of course, we added support for more font files, and we'll
|
||||
continue to as long as the specs are available and that we find an
|
||||
interest in it. For example, FreeType 2 is to date the only
|
||||
software library available on the market that supports the new
|
||||
Adobe "CEF" font format.</p>
|
||||
</ul>
|
||||
|
||||
<a name="general-unix">
|
||||
<h3>I.3. Is FreeType 2 a Unix-only project?</h3>
|
||||
<ul>
|
||||
<p>Absolutely not, even though many people still seem to think so :-)
|
||||
FreeType 2, just like version 1.x, can be compiled on any platform with
|
||||
an ANSI compiler. Some beta versions of the library are even heavily
|
||||
used in brand new OSes (see the <a href="http://www.atheos.cx">AtheOS
|
||||
</a> screenshots for examples).</p>
|
||||
|
||||
<p>The library is itself mainly developped on several platforms
|
||||
(Windows & Linux, though a great deal has also been achieved on OS/2)
|
||||
and the code is highly generic and modular to adapt even the most
|
||||
strict environments like low-memory embedded systems.</p>
|
||||
|
||||
</ul>
|
||||
|
||||
<a name="general-x11">
|
||||
<h3>I.4. When will X11/XFree support anti-aliased text?</h3>
|
||||
<ul>
|
||||
<p>This question isn't exactly related to FreeType as we have no direct
|
||||
connection to the XFree people, but we've been asked so frequently
|
||||
about it that it deserves a prominent place in this FAQ :-)</p>
|
||||
|
||||
<p>FreeType has been capable of anti-aliasing since version 1.0. The
|
||||
reason why XFree doesn't support it is directly related to the
|
||||
limitations of the design and specification of X11. More specifically:</p>
|
||||
|
||||
<ul>
|
||||
<li><p>
|
||||
X11 assumes that all glyph images are monochrome bitmaps,
|
||||
hence the X font library and server are unable to send anything
|
||||
else to the X server.
|
||||
</p></li>
|
||||
|
||||
<li><p>
|
||||
Even if the X font library/server was able to generate anti-aliased
|
||||
bitmaps (and this has been already done through extensions), the X
|
||||
rendering model doesn't allow translucent composition of "gray" pixmaps
|
||||
onto an arbitrary drawable.
|
||||
</p></li>
|
||||
</ul>
|
||||
|
||||
<p>As both the font and rendering models of X11 are limited, it's basically
|
||||
impossible to draw anti-aliased glyphs without performing <em>huge</em>
|
||||
hacks within the server.</p>
|
||||
|
||||
<p>Note that Keith Packard, from XFree fame, has recently started working
|
||||
on a new rendering model for X11 in order to support new features
|
||||
(mainly transparency and anti-aliased fonts). This will be provided
|
||||
through protocol extensions. The question of knowing wether legacy X
|
||||
applications will be able to display anti-aliased text is still very
|
||||
uncertain.
|
||||
</p>
|
||||
</ul>
|
||||
|
||||
<a name="general-ft1">
|
||||
<h3>I.5. Is FreeType 2 backwards compatible with FreeType 1.x?</h3>
|
||||
<ul>
|
||||
<p>Not directly, though we had the project to provide an optional binary
|
||||
compatibility layer on top of it in order to easily re-link applications
|
||||
with the new version. However, this idea has been dropped as it is
|
||||
possible to install and use the two versions independtly on any
|
||||
system (read: no namespace conflicts).</p>
|
||||
|
||||
<p>The FreeType 2 API is a lot simpler than the one in 1.x while being
|
||||
much more powerful. We thus encourage you to adapt your source code
|
||||
to it as this should not involve much work.</p>
|
||||
|
||||
</ul>
|
||||
|
||||
<a name="general-edit">
|
||||
<h3>I.6. Can I use FreeType 2 to edit fonts or create new ones?</h3>
|
||||
<ul>
|
||||
<p>The answer is a definitive NO, because the library was specifically
|
||||
designed to <em>read</em> font files with small code size and very
|
||||
low memory usage.</p>
|
||||
|
||||
<p>We thus do not plan to support editing or creation in the font
|
||||
engine in any way, as this would imply a complete rewrite. This
|
||||
doesn't mean that we won't introduce a font editing/creation library
|
||||
in the future, as this really depends on how many people are asking
|
||||
for it (or how much they would be willing to pay for it), as well as
|
||||
the time of the FreeType developers.</p>
|
||||
|
||||
<p>Do not expect anything in this direction until we officially announce
|
||||
something though. There are other axis of development for this project
|
||||
(like text-layout capabilities, glyph caching, etc..) that may be more
|
||||
important to us at the moment..</p>
|
||||
</ul>
|
||||
|
||||
</td></tr></table>
|
||||
|
||||
<table width="100%" cellspacing=5><tr bgcolor="#CCCCEE"><td>
|
||||
<h2 align=center><a name="builds">Compilation & Configuration</h2>
|
||||
</td></tr><tr><td>
|
||||
|
||||
<a name="builds-compile">
|
||||
<h3>II.1. How do I compile the FreeType 2 library?</h3>
|
||||
<ul>
|
||||
<p>The library can be compiled in various ways, and a detailed documentation
|
||||
is available in the file "<tt>freetype2/docs/BUILD</tt>". However, we'll
|
||||
summarize the process to a few cases:</p>
|
||||
|
||||
<h3>a. by using the command-line 2 build system</h3>
|
||||
|
||||
<p>The engine comes with a sophisticated build system that is used
|
||||
to configure and compile a build of the library. You'll need
|
||||
<em>GNU Make</em> installed on your platform (NOTE: It will <b>not</b>
|
||||
work with other Make tools).</p>
|
||||
|
||||
<p>Basically, you'll need to invoke <tt>make</tt> a first time in the
|
||||
top-level FreeType 2 directory in order to setup the build. This will
|
||||
detect your current platform and choose a configuration sub-makefile to
|
||||
drive the build. A specific compiler can be selected on some platforms
|
||||
by providing an additional target. For example, on Win32:</p>
|
||||
|
||||
<ul>
|
||||
<li><b><tt>make visualc</tt></b> will select the Visual C++ compiler</li>
|
||||
<li><b><tt>make lcc</tt></b> will select the Win32-lcc compiler</li>
|
||||
</ul>
|
||||
|
||||
<p>Note that on Unix, the first time make is called, a configure script
|
||||
located in "<tt>freetype2/builds/unix</tt>" will be run in order to
|
||||
automatically detect the platform & compiler.</p>
|
||||
|
||||
<p>A summary will be displayed showing the detected platform and compiler
|
||||
selected. You'll then be able to start the build by invoking <tt>make</tt>
|
||||
a second time. In case of problem, consult the <tt>BUILD</tt> document.</p>
|
||||
|
||||
|
||||
<h3>b. by direct compilation</h3>
|
||||
|
||||
<p>You can also directly compile the library from the command line by
|
||||
using these simple rules:</p>
|
||||
|
||||
<ul>
|
||||
<li><p>
|
||||
You should place the directories "<tt>freetype2/include</tt>" and
|
||||
"<tt>freetype2/src</tt>" in your include path in order to compile
|
||||
any component of the library. You can also add the system-specific
|
||||
build directory (i.e. "<tt>builds/<em>system</em>/</tt>") in the
|
||||
case where an alternate implementation of some of the components
|
||||
is available there (e.g. the memory-mapped i/o implementation
|
||||
on some Unix systems).
|
||||
</p></li>
|
||||
|
||||
<li><p>
|
||||
The components of the library are located in sub-directories of
|
||||
"<tt>src</tt>", for example: "<tt>src/base</tt>",
|
||||
"<tt>src/truetype</tt>", etc..
|
||||
</p></li>
|
||||
|
||||
<li><p>
|
||||
Each component is normally compiled through a single C file that
|
||||
"wraps" other sources in the component's directory. For example,
|
||||
your should compile the TrueType font driver by compiling the
|
||||
file "<tt>src/truetype/truetype.c</tt>". The list of C files to
|
||||
compile for a feature-complete build of the library is given in
|
||||
the <tt>BUILD</tt> document.
|
||||
</p></li>
|
||||
</ul>
|
||||
|
||||
<h3>c. in a graphical IDE</h3>
|
||||
<ul>
|
||||
<p>Well, the process is vastly similar to the one described in b.,
|
||||
except that you need to set the include paths, source code paths,
|
||||
etc.. in dialog boxes before running the compilation.
|
||||
</p>
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
|
||||
<a name="builds-config">
|
||||
<h3>II.2. How do I configure my build of the library?</h3>
|
||||
<ul>
|
||||
<p>Each build of the library is configured through two header files
|
||||
located in "<tt>include/freetype/config</tt>":</p>
|
||||
|
||||
<ul>
|
||||
<li><p><b><tt>ftoption.h</tt></b><br>
|
||||
This file contains various configuration macros whose definition
|
||||
can be toggled on a per-build basis. Each macro is heavily
|
||||
commented in this file's comment, and we invite you to refer
|
||||
to it directly.</p></li>
|
||||
|
||||
<li><p><b><tt>ftmodule.h</tt></b><br>
|
||||
This file contains the list of all the modules that are initially
|
||||
registered (added) when the function <b><tt>FT_Init_FreeType</tt></b>
|
||||
is called. See the next answer to know how to change it and
|
||||
why it may be important.</p></li>
|
||||
</ul>
|
||||
|
||||
<p>Alternatively, some specific implementations of some FT2 components
|
||||
can be provided in a "<tt>builds/<em>system</em>/</tt>" directory
|
||||
(e.g. the Unix-specific <tt>ftsystem.c</tt> that uses memory-mapped
|
||||
file for i/o).</p>
|
||||
</ul>
|
||||
|
||||
<a name="builds-modules">
|
||||
<h3>II.3. How do I select the modules I need in my build?</h3>
|
||||
<ul>
|
||||
<p>The function <tt><b>FT_Init_FreeType</b></tt> creates a new instance
|
||||
of the FT2 library and registers a set of "default" modules before
|
||||
returning to the calling application. Its default implementation
|
||||
is in the file "<tt>src/base/ftinit.c</tt>".</p>
|
||||
|
||||
<p>The list of default modules used by <tt>ftinit.c</tt> is located in
|
||||
the configuration file "<tt>include/freetype/config/ftmodule.h</tt>".
|
||||
It is normally automatically generated by the build system by
|
||||
invoking the "<tt><b>make modules</b></tt>" command in the top
|
||||
level FT2 directory (note: only works with GNU Make, you can
|
||||
edit the file by hand otherwise). It does so by parsing all
|
||||
sub-directories of "<tt>src</tt>" that contain a file named
|
||||
<tt>module.mk</tt>.</p>
|
||||
|
||||
<p>Note that a specific port or project is free to provide its own
|
||||
implementation of <tt>ftinit.c</tt> in order to ensure a different
|
||||
initialisation sequence. For example, one could do something like:</p>
|
||||
|
||||
<ul>
|
||||
<li><p>compile each module as a shared library (DLL or .so) with
|
||||
a common "entry point" to retrieve a pointer to its
|
||||
module class (there is already some code that allows this
|
||||
when compiling each module).</p></li>
|
||||
|
||||
<li><p>place these modules in a directory like
|
||||
"<tt>/usr/lib/freetype2/modules/</tt>"</p></li>
|
||||
|
||||
<li><p>provide an implementation of <tt>ftinit.c</tt> that would
|
||||
scan the directory for valid modules.</p></li>
|
||||
</ul>
|
||||
|
||||
<p>This example only emphasize the flexibility that is left to
|
||||
developers when building the library.</p>
|
||||
|
||||
</ul>
|
||||
|
||||
<a name="builds-flat">
|
||||
<h3>II.4. How do I compile all FreeType 2 files in a single directory?</h3>
|
||||
<ul>
|
||||
<p>Some projects may need, for the sake of simplicity or ease of
|
||||
building, to compile the FT2 library with all source files
|
||||
copied to a single directory. This is possible.</p>
|
||||
|
||||
<p>To do so, you'll need to copy all source files located under
|
||||
"<tt>src</tt>" to your own directory (you must retain the
|
||||
include files in a distinct hierarchy though), then compile
|
||||
each of the FreeType 2 component with the macro
|
||||
<tt><b>FT_FLAT_COMPILE</b></tt>. This will change the way
|
||||
<tt><b>#include</b></tt> works during the build.</p>
|
||||
</ul>
|
||||
|
||||
</td></tr></table>
|
||||
|
||||
<table width="100%" cellspacing=5><tr bgcolor="#CCCCEE"><td>
|
||||
<h2 align=center><a name="library">Using the FreeType 2 library</h2>
|
||||
</td></tr><tr><td>
|
||||
|
||||
</td></tr></table>
|
||||
|
||||
<table width="100%" cellspacing=5><tr bgcolor="#CCCCEE"><td>
|
||||
<h2 align=center><a name="autohint">The FreeType 2 auto-hinter</h2>
|
||||
</td></tr><tr><td>
|
||||
|
||||
<a name="autohint-license">
|
||||
<h3>IV.1. Under which license is the FreeType 2 auto-hinter released</h3>
|
||||
<ul>
|
||||
<p>The auto-hinter was initially designed and implemented under contract
|
||||
for <a href="http://www.catharon.com">Catharon Productions, Inc</a>
|
||||
which gladly accepted to released it under an open-source license
|
||||
compatible with the FreeType one.</p>
|
||||
|
||||
<p>This license can be found in "<tt>src/autohint/CatharonLicense.txt</tt>"
|
||||
and requires that you cite Catharon Productions in your documentation
|
||||
(just like you do with FreeType) when using the auto-hinting module.</p>
|
||||
|
||||
<p>Other than that, you still have the same freedom than with the good old
|
||||
FreeType license. Enjoy !</p>
|
||||
</ul>
|
||||
|
||||
<a name="autohint-work">
|
||||
<h3>IV.2. How does the auto-hinter works ?</h3>
|
||||
<ul>
|
||||
<p>Well, a complete description would be difficult. Have a look at the
|
||||
dedicated <a href="autohinting/index.html">auto-hinter pages</a> on the FreeType
|
||||
site, as they describe most of its details with graphics and explanations.
|
||||
You could also look at the source code if you want to :-)</p>
|
||||
|
||||
<p>To give a few details, the auto-hinter is used to perform grid-fitting
|
||||
on scalable font formats that use bezier outlines as their primary glyph
|
||||
image format (this means nearly all scalable font formats today). When
|
||||
a given font driver doesn't provide its own hinter, the auto-hinter is
|
||||
used by default. When a format-specific hinter is provided, it is still
|
||||
possible to use the auto-hinter using the
|
||||
<tt><b>FT_LOAD_FORCE_AUTOHINT</b></tt> bit flag when calling
|
||||
<tt>FT_Load_Glyph</tt>.</p>
|
||||
|
||||
<p>The auto-hinter currently doesn't use external hints to do its job,
|
||||
as it automatically computes global metrics (when it "opens" a font
|
||||
for the first time) and glyph "hints" from their outline. Note that
|
||||
we plan the ability to specify external hints, given that it is based
|
||||
on a constraint system. That could be used to support native hints
|
||||
in Type 1/Type 2 fonts, for example.</p>
|
||||
</ul>
|
||||
|
||||
<a name="autohint-cjk">
|
||||
<h3>IV.3. Why does the auto-hinter doesn't work correctly with CJK fonts ?</h3>
|
||||
<ul>
|
||||
<p>The auto-hinter was first designed to manage and hint latin-based fonts,
|
||||
as they consist of most of the fonts available today. It doesn't hint
|
||||
asian fonts, as well as a few other complex scripts, because we didn't
|
||||
put enough research on the topic yet. Hinting CJK isn't really more
|
||||
difficult than latin, just different with a set of different constraints
|
||||
(basically, more distortion of glyphs is acceptable as long as certain
|
||||
features like triple-stem positions are respected more strictly..).</p>
|
||||
|
||||
<p>We thus plan to handle such a case rather rapidly.. Please be patient.</p>
|
||||
</ul>
|
||||
|
||||
|
||||
</td></tr></table>
|
||||
|
||||
<table width="100%" cellspacing=5><tr bgcolor="#CCCCEE"><td>
|
||||
<h2 align=center><a name="other">Other questions</h2>
|
||||
</td></tr><tr><td>
|
||||
|
||||
<a name="other-antialias">
|
||||
<h3>V.1. What is the anti-aliasing algorithm used by FreeType 2 ?</h3>
|
||||
<ul>
|
||||
<p>The algorithm has been specifically designed for FreeType. It is
|
||||
based on ideas that were originally found in the implementation
|
||||
of the <a href="http://www.levien.com/libart">libArt</a> graphics
|
||||
library to compute the <em>exact pixel coverage</em> of a vector
|
||||
image with absolutely now sub-sampling/filtering.
|
||||
</p>
|
||||
|
||||
<p>However, these two implementations are radically distinct and use
|
||||
vastly different models. The FreeType 2 renderer is optimized
|
||||
specifically for rendering small complex shapes, like glyphs, at
|
||||
very high speed while using very few memory; while libArt shines
|
||||
at general shape/polygon processing, especially large ones.</p>
|
||||
|
||||
<p>The FT2 anti-aliasing renderer is indeed <em>faster</em> than the
|
||||
monochrome renderer for small character sizes (typically < 20 pixels).
|
||||
This is explained because the monochrome renderer must perform two
|
||||
passes on the outline in order to perform drop-out control according
|
||||
to the TrueType spec (we could drop this requirement later though).</p>
|
||||
|
||||
<p>We'll try to document its design in a later document, though this is
|
||||
not a priority for now.</p>
|
||||
</ul>
|
||||
|
||||
<a name="other-opentype">
|
||||
<h3>V.2. When will FreeType 2 support OpenType ?</h3>
|
||||
<ul>
|
||||
<p>Well, the engine already reads OpenType/CFF files perfectly. What it
|
||||
doesn't do is handle "OpenType Layout" tables yet.</p>
|
||||
|
||||
<p>FreeType 1 comes with a set of extensions that are used to load
|
||||
and manage OpenType Layout tables. It even has a demonstration program
|
||||
named "<tt>ftstrtto</tt>" used to demonstrate its capabilities that
|
||||
runs pretty smooth.</p>
|
||||
|
||||
<p>For FreeType 2, we have decided that the layout operations provided
|
||||
through these tables is better placed in a specific text-layout library,
|
||||
(many people having asked for such a thing). This new engine would not
|
||||
depend on FT2 explicitely and will be developed as a separate project.
|
||||
We plan to announce it in a few weeks with all gory details,
|
||||
once the definitive 2.0 release of FreeType has been made.</p>
|
||||
</ul>
|
||||
|
||||
</td></tr></table>
|
||||
|
||||
<hr>
|
||||
<p>
|
||||
<a href="index.html">Back to FreeType homepage</a><p>
|
||||
|
||||
</td></tr></table>
|
||||
</body>
|
||||
</html>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
||||
‰PNG
|
||||
@@ -0,0 +1 @@
|
||||
‰PNG
|
||||
@@ -0,0 +1 @@
|
||||
‰PNG
|
||||
@@ -0,0 +1 @@
|
||||
‰PNG
|
||||
@@ -0,0 +1 @@
|
||||
‰PNG
|
||||
@@ -0,0 +1 @@
|
||||
‰PNG
|
||||
@@ -0,0 +1 @@
|
||||
‰PNG
|
||||
@@ -0,0 +1 @@
|
||||
‰PNG
|
||||
@@ -0,0 +1 @@
|
||||
‰PNG
|
||||
@@ -0,0 +1 @@
|
||||
‰PNG
|
||||
@@ -0,0 +1 @@
|
||||
‰PNG
|
||||
@@ -0,0 +1 @@
|
||||
‰PNG
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
||||
‰PNG
|
||||
@@ -0,0 +1 @@
|
||||
‰PNG
|
||||
@@ -0,0 +1 @@
|
||||
‰PNG
|
||||
@@ -0,0 +1 @@
|
||||
‰PNG
|
||||
@@ -0,0 +1 @@
|
||||
‰PNG
|
||||
@@ -0,0 +1 @@
|
||||
‰PNG
|
||||
@@ -0,0 +1 @@
|
||||
‰PNG
|
||||
@@ -0,0 +1,871 @@
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=iso-8859-1">
|
||||
<meta name="Author"
|
||||
content="David Turner">
|
||||
<title>FreeType 2 Tutorial</title>
|
||||
</head>
|
||||
|
||||
<body text="#000000"
|
||||
bgcolor="#FFFFFF"
|
||||
link="#0000EF"
|
||||
vlink="#51188E"
|
||||
alink="#FF0000">
|
||||
|
||||
<h1 align=center>
|
||||
FreeType 2.0 Tutorial
|
||||
</h1>
|
||||
|
||||
<h3 align=center>
|
||||
© 2000 David Turner
|
||||
(<a href="mailto:[email protected]">[email protected]</a>)<br>
|
||||
© 2000 The FreeType Development Team
|
||||
(<a href="http://www.freetype.org">www.freetype.org</a>)
|
||||
</h3>
|
||||
|
||||
<center>
|
||||
<table width="70%">
|
||||
<tr><td>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2>
|
||||
Introduction
|
||||
</h2>
|
||||
|
||||
<p>This short tutorial will teach you how to use the FreeType 2
|
||||
library in your own applications.</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<h3>
|
||||
1. Header files
|
||||
</h3>
|
||||
|
||||
<p>To include the main FreeType header file, simply say</p>
|
||||
|
||||
<font color="blue">
|
||||
<pre>
|
||||
#include <freetype/freetype.h></pre>
|
||||
</font>
|
||||
|
||||
<p>in your application code. Note that other files are available in the
|
||||
FreeType include directory, most of them being included by
|
||||
<tt>"freetype.h"</tt>. They will be described later in this
|
||||
tutorial.</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<h3>
|
||||
2. Initialize the library
|
||||
</h3>
|
||||
|
||||
<p>Simply create a variable of type <tt>FT_Library</tt> named, for
|
||||
example, <tt>library</tt>, and call the function
|
||||
<tt>FT_Init_FreeType()</tt> as in</p>
|
||||
|
||||
<font color="blue">
|
||||
<pre>
|
||||
#include <freetype/freetype.h>
|
||||
|
||||
FT_Library library;
|
||||
|
||||
...
|
||||
|
||||
{
|
||||
...
|
||||
error = FT_Init_FreeType( &library );
|
||||
if ( error )
|
||||
{
|
||||
... an error occurred during library initialization ...
|
||||
}
|
||||
}</pre>
|
||||
</font>
|
||||
|
||||
<p>This function is in charge of the following:</p>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<p>Creating a new instance of the FreeType 2 library, and set
|
||||
the handle <tt>library</tt> to it.</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>Load each modules that FreeType knows about in the library.
|
||||
This means that by default, your new <tt>library</tt> object is able
|
||||
to handle TrueType, Type 1, CID-keyed & OpenType/CFF fonts
|
||||
gracefully.</p>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p>As you can see, the function returns an error code, like most others
|
||||
in the FreeType API. An error code of 0 <em>always</em> means that
|
||||
the operation was successful; otherwise, the value describes the error,
|
||||
and <tt>library</tt> is set to NULL.</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<h3>
|
||||
3. Load a font face
|
||||
</h3>
|
||||
|
||||
<h4>
|
||||
a. From a font file
|
||||
</h4>
|
||||
|
||||
<p>Create a new <em>face</em> object by calling <tt>FT_New_Face</tt>.
|
||||
A <em>face</em> describes a given typeface and style. For example,
|
||||
"Times New Roman Regular" and "Times New Roman Italic" correspond to
|
||||
two different faces.</p>
|
||||
|
||||
<font color="blue">
|
||||
<pre>
|
||||
FT_Library library; /* handle to library */
|
||||
FT_Face face; /* handle to face object */
|
||||
|
||||
error = FT_Init_FreeType( &library );
|
||||
if ( error ) { ... }
|
||||
|
||||
error = FT_New_Face( library,
|
||||
"/usr/share/fonts/truetype/arial.ttf",
|
||||
0,
|
||||
&face );
|
||||
if ( error == FT_Err_Unknown_File_Format )
|
||||
{
|
||||
... the font file could be opened and read, but it appears
|
||||
... that its font format is unsupported
|
||||
}
|
||||
else if ( error )
|
||||
{
|
||||
... another error code means that the font file could not
|
||||
... be opened or read, or simply that it is broken...
|
||||
}</pre>
|
||||
</font>
|
||||
|
||||
<p>As you can certainly imagine, <tt>FT_New_Face</tt> opens a font
|
||||
file, then tries to extract one face from it. Its parameters are</p>
|
||||
|
||||
<table cellpadding=5>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<tt><b>library</b></tt>
|
||||
</td>
|
||||
<td>
|
||||
<p>handle to the FreeType library instance where the face object
|
||||
is created</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<tt><b>filepathname</b></tt>
|
||||
</td>
|
||||
<td>
|
||||
<p>the font file pathname (standard C string).</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<tt><b>face_index</b></tt>
|
||||
</td>
|
||||
<td>
|
||||
<p>Certain font formats allow several font faces to be embedded
|
||||
in a single file.</p>
|
||||
|
||||
<p>This index tells which face you want to load. An error will
|
||||
be returned if its value is too large.</p>
|
||||
|
||||
<p>Index 0 always work though.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<tt><b>face</b></tt>
|
||||
</td>
|
||||
<td>
|
||||
<p>A <em>pointer</em> to the handle that will be set to describe
|
||||
the new face object.</p>
|
||||
|
||||
<p>It is set to NULL in case of error.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>To know how many faces a given font file contains, simply load its
|
||||
first face (use <tt>face_index</tt>=0), then see the value of
|
||||
<tt>face->num_faces</tt> which indicates how many faces are embedded
|
||||
in the font file.</p>
|
||||
|
||||
<h4>
|
||||
b. From memory
|
||||
</h4>
|
||||
|
||||
<p>In the case where you have already loaded the font file in memory,
|
||||
you can similarly create a new face object for it by calling
|
||||
<tt>FT_New_Memory_Face</tt> as in</p>
|
||||
|
||||
<font color="blue">
|
||||
<pre>
|
||||
FT_Library library; /* handle to library */
|
||||
FT_Face face; /* handle to face object */
|
||||
|
||||
error = FT_Init_FreeType( &library );
|
||||
if ( error ) { ... }
|
||||
|
||||
error = FT_New_Memory_Face( library,
|
||||
buffer, /* first byte in memory */
|
||||
size, /* size in bytes */
|
||||
0, /* face_index */
|
||||
&face );
|
||||
if ( error ) { ... }</pre>
|
||||
</font>
|
||||
|
||||
<p>As you can see, <tt>FT_New_Memory_Face()</tt> simply takes a
|
||||
pointer to the font file buffer and its size in bytes instead of a
|
||||
file pathname. Other than that, it has exactly the same semantics as
|
||||
<tt>FT_New_Face()</tt>.</p>
|
||||
|
||||
<h4>
|
||||
c. From other sources (compressed files, network, etc.)
|
||||
</h4>
|
||||
|
||||
<p>There are cases where using a file pathname or preloading the file
|
||||
in memory is simply not enough. With FreeType 2, it is possible
|
||||
to provide your own implementation of i/o routines.</p>
|
||||
|
||||
<p>This is done through the <tt>FT_Open_Face()</tt> function, which
|
||||
can be used to open a new font face with a custom input stream, select
|
||||
a specific driver for opening, or even pass extra parameters to the
|
||||
font driver when creating the object. We advise you to refer to the
|
||||
FreeType 2 reference manual in order to learn how to use it.</p>
|
||||
|
||||
<p>Note that providing a custom stream might also be used to access a
|
||||
TrueType font embedded in a Postscript Type 42 wrapper.</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<h3>
|
||||
4. Accessing face content
|
||||
</h3>
|
||||
|
||||
<p>A <em>face object</em> models all information that globally describes
|
||||
the face. Usually, this data can be accessed directly by dereferencing
|
||||
a handle, like</p>
|
||||
|
||||
<table cellpadding=5>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<tt><b>face->num_glyphs</b></tt>
|
||||
</td>
|
||||
<td>
|
||||
<p>Gives the number of <em>glyphs</em> available in the font face.
|
||||
A glyph is simply a character image. It doesn't necessarily
|
||||
correspond to a <em>character code</em> though.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<tt><b>face->flags</b></tt>
|
||||
</td>
|
||||
<td>
|
||||
<p>A 32-bit integer containing bit flags used to describe some
|
||||
face properties. For example, the flag
|
||||
<tt>FT_FACE_FLAG_SCALABLE</tt> is used to indicate that the face's
|
||||
font format is scalable and that glyph images can be rendered for
|
||||
all character pixel sizes. For more information on face flags,
|
||||
please read the <a href="#">FreeType 2 API Reference</a>.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<tt><b>face->units_per_EM</b></tt>
|
||||
</td>
|
||||
<td>
|
||||
<p>This field is only valid for scalable formats (it is set to 0
|
||||
otherwise). It indicates the number of font units covered by the
|
||||
EM.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<tt><b>face->num_fixed_sizes</b></tt>
|
||||
</td>
|
||||
<td>
|
||||
<p>This field gives the number of embedded bitmap <em>strikes</em>
|
||||
in the current face. A <em>strike</em> is simply a series of
|
||||
glyph images for a given character pixel size. For example, a
|
||||
font face could include strikes for pixel sizes 10, 12
|
||||
and 14. Note that even scalable font formats can have
|
||||
embedded bitmap strikes!</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<tt><b>face->fixed_sizes</b></tt>
|
||||
</td>
|
||||
<td>
|
||||
<p>this is a pointer to an array of <tt>FT_Bitmap_Size</tt>
|
||||
elements. Each <tt>FT_Bitmap_Size</tt> indicates the horizontal
|
||||
and vertical <em>pixel sizes</em> for each of the strikes that are
|
||||
present in the face.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>For a complete listing of all face properties and fields, please read
|
||||
the <a href="#">FreeType 2 API Reference</a>.<p>
|
||||
|
||||
<hr>
|
||||
|
||||
<h3>
|
||||
5. Setting the current pixel size
|
||||
</h3>
|
||||
|
||||
<p>FreeType 2 uses "<em>size objects</em>" to model all
|
||||
information related to a given character size for a given face.
|
||||
For example, a size object will hold the value of certain metrics
|
||||
like the ascender or text height, expressed in 1/64th of a pixel,
|
||||
for a character size of 12 points.</p>
|
||||
|
||||
<p>When the <tt>FT_New_Face</tt> function is called (or one of its
|
||||
cousins), it <b>automatically</b> creates a new size object for
|
||||
the returned face. This size object is directly accessible as
|
||||
<b><tt>face->size</tt></b>.</p>
|
||||
|
||||
<p><em>NOTA BENE: a single face object can deal with one or more size
|
||||
objects at a time, however, this is something that few programmers
|
||||
really need to do. We have thus have decided to simplify the API for
|
||||
the most common use (i.e. one size per face), while keeping this
|
||||
feature available through additional fuctions.</em></p>
|
||||
|
||||
<p>When a new face object is created, its size object defaults to the
|
||||
character size of 10 pixels (both horizontally and vertically) for
|
||||
scalable formats. For fixed-sizes formats, the size is more or less
|
||||
undefined, which is why you must set it before trying to load a
|
||||
glyph.</p>
|
||||
|
||||
<p>To do that, simply call <tt>FT_Set_Char_Size()</tt>. Here is an
|
||||
example where the character size is set to 16pt for a 300x300 dpi
|
||||
device:</p>
|
||||
|
||||
<font color="blue">
|
||||
<pre>
|
||||
error = FT_Set_Char_Size(
|
||||
face, /* handle to face object */
|
||||
0, /* char_width in 1/64th of points */
|
||||
16*64, /* char_height in 1/64th of points */
|
||||
300, /* horizontal device resolution */
|
||||
300 ); /* vertical device resolution */</pre>
|
||||
</font>
|
||||
|
||||
<p>You will notice that:</p>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<p>The character width and heights are specified in 1/64th of
|
||||
points. A point is a <em>physical</em> distance, equaling 1/72th
|
||||
of an inch, it's not a pixel..<p>
|
||||
</li>
|
||||
<li>
|
||||
<p>The horizontal and vertical device resolutions are expressed in
|
||||
<em>dots-per-inch</em>, or <em>dpi</em>. You can use 72 or
|
||||
96 dpi for display devices like the screen. The resolution
|
||||
is used to compute the character pixel size from the character
|
||||
point size.</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>A value of 0 for the character width means "<em>same as
|
||||
character height</em>", a value of 0 for the character height
|
||||
means "<em>same as character width</em>". Otherwise, it is possible
|
||||
to specify different char widths and heights.</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>Using a value of 0 for the horizontal or vertical resolution means
|
||||
72 dpi, which is the default.</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>The first argument is a handle to a face object, not a size
|
||||
object. That's normal, and must be seen as a convenience.</p>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p>This function computes the character pixel size that corresponds to
|
||||
the character width and height and device resolutions. However, if you
|
||||
want to specify the pixel sizes yourself, you can simply call
|
||||
<tt>FT_Set_Pixel_Sizes()</tt>, as in</p>
|
||||
|
||||
<font color="blue">
|
||||
<pre>
|
||||
error = FT_Set_Pixel_Sizes(
|
||||
face, /* handle to face object */
|
||||
0, /* pixel_width */
|
||||
16 ); /* pixel_height */</pre>
|
||||
</font>
|
||||
|
||||
<p>This example will set the character pixel sizes to 16x16 pixels.
|
||||
As previously, a value of 0 for one of the dimensions means
|
||||
"<em>same as the other</em>".</p>
|
||||
|
||||
<p>Note that both functions return an error code. Usually, an error
|
||||
occurs with a fixed-size font format (like FNT or PCF) when trying to
|
||||
set the pixel size to a value that is not listed in the
|
||||
<tt><b>face->fixed_sizes</b></tt> array.</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<h3>
|
||||
6. Loading a glyph image
|
||||
</h3>
|
||||
|
||||
<h4>
|
||||
a. Converting a character code into a glyph index
|
||||
</h4>
|
||||
|
||||
<p>Usually, an application wants to load a glyph image based on its
|
||||
<em>character code</em>, which is a unique value that defines the
|
||||
character for a given <em>encoding</em>. For example, the character
|
||||
code 65 represents the `A' in ASCII encoding.</p>
|
||||
|
||||
<p>A face object contains one or more tables, called
|
||||
<em>charmaps</em>, that are used to convert character codes to glyph
|
||||
indices. For example, most TrueType fonts contain two charmaps. One
|
||||
is used to convert Unicode character codes to glyph indices, the other
|
||||
is used to convert Apple Roman encoding into glyph indices. Such
|
||||
fonts can then be used either on Windows (which uses Unicode) and
|
||||
Macintosh (which uses Apple Roman, bwerk). Note also that a given
|
||||
charmap might not map to all the glyphs present in the font.</p>
|
||||
|
||||
<p>By default, when a new face object is created, it lists all the
|
||||
charmaps contained in the font face and selects the one that supports
|
||||
Unicode character codes if it finds one. Otherwise, it tries to find
|
||||
support for Latin-1, then ASCII.</p>
|
||||
|
||||
<p>We will describe later how to look for specific charmaps in a face.
|
||||
For now, we will assume that the face contains at least a Unicode
|
||||
charmap that was selected during <tt>FT_New_Face()</tt>. To convert a
|
||||
Unicode character code to a font glyph index, we use
|
||||
<tt>FT_Get_Char_Index()</tt> as in</p>
|
||||
|
||||
<font color="blue">
|
||||
<pre>
|
||||
glyph_index = FT_Get_Char_Index( face, charcode );</pre>
|
||||
</font>
|
||||
|
||||
<p>This will look the glyph index corresponding to the given
|
||||
<tt>charcode</tt> in the charmap that is currently selected for the
|
||||
face. If charmap is selected, the function simply returns the
|
||||
charcode.</p>
|
||||
|
||||
<p>Note that this is one of the rare FreeType functions that do not
|
||||
return an error code. However, when a given character code has no
|
||||
glyph image in the face, the value 0 is returned. By convention,
|
||||
it always correspond to a special glyph image called the <b>missing
|
||||
glyph</b>, which usually is represented as a box or a space.</p>
|
||||
|
||||
<h4>
|
||||
b. Loading a glyph from the face
|
||||
</h4>
|
||||
|
||||
<p>Once you have a glyph index, you can load the corresponding glyph
|
||||
image. Note that the glyph image can be in several formats. For
|
||||
example, it will be a bitmap for fixed-size formats like FNT, FON, or
|
||||
PCF. It will also be a scalable vector outline for formats like
|
||||
TrueType or Type 1. The glyph image can also be stored in an
|
||||
alternate way that is not known at the time of writing this
|
||||
documentation.</p>
|
||||
|
||||
<p>The glyph image is always stored in a special object called a
|
||||
<em>glyph slot</em>. As its name suggests, a glyph slot is simply a
|
||||
container that is able to hold one glyph image at a time, be it a
|
||||
bitmap, an outline, or something else. Each face object has a single
|
||||
glyph slot object that can be accessed as
|
||||
<b><tt>face->glyph</tt></b>.</p>
|
||||
|
||||
<p>Loading a glyph image into the slot is performed by calling
|
||||
<tt>FT_Load_Glyph()</tt> as in</p>
|
||||
|
||||
<font color="blue">
|
||||
<pre>
|
||||
error = FT_Load_Glyph(
|
||||
face, /* handle to face object */
|
||||
glyph_index, /* glyph index */
|
||||
load_flags ); /* load flags, see below */</pre>
|
||||
</font>
|
||||
|
||||
<p>The <tt>load_flags</tt> value is a set of bit flags used to
|
||||
indicate some special operations. The default value
|
||||
<tt>FT_LOAD_DEFAULT</tt> is 0.</p>
|
||||
|
||||
<p>This function will try to load the corresponding glyph image
|
||||
from the face. Basically, this means that:</p>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<p>If a bitmap is found for the corresponding glyph and pixel
|
||||
size, it will in the slot (embedded bitmaps are always
|
||||
favored over native image formats, because we assume that
|
||||
they are higher-quality versions of the same image. This
|
||||
can be ignored by using the FT_LOAD_NO_BITMAP flag)</p>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<p>Otherwise, a native image for the glyph will be loaded.
|
||||
It will also be scaled to the current pixel size, as
|
||||
well as hinted for certain formats like TrueType and
|
||||
Type1.</p>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p>The field <tt><b>glyph->format</b></tt> describe the format
|
||||
used to store the glyph image in the slot. If it is not
|
||||
<tt>ft_glyph_format_bitmap</tt>, one can immediately
|
||||
convert it to a bitmap through <tt>FT_Render_Glyph</tt>,
|
||||
as in:</p>
|
||||
|
||||
<font color="blue">
|
||||
<pre>
|
||||
error = FT_Render_Glyph(
|
||||
face->glyph, /* glyph slot */
|
||||
render_mode ); /* render mode */
|
||||
</pre>
|
||||
</font>
|
||||
|
||||
<p>The parameter <tt>render_mode</tt> is a set of bit flags used
|
||||
to specify how to render the glyph image. Set it to 0 to render
|
||||
a monochrome bitmap, or to <tt>ft_render_mode_antialias</tt> to
|
||||
generate a high-quality (256 gray levels) anti-aliased bitmap
|
||||
from the glyph image.</p>
|
||||
|
||||
<p>Once you have a bitmap glyph image, you can access it directly
|
||||
through <tt><b>glyph->bitmap</b></tt> (a simple bitmap descriptor),
|
||||
and position it through <tt><b>glyph->bitmap_left</b></tt> and
|
||||
<tt><b>glyph->bitmap_top</b></tt>.</p>
|
||||
|
||||
<p>Note that <tt>bitmap_left</tt> is the horizontal distance from the
|
||||
current pen position to the left-most border of the glyph bitmap,
|
||||
while <tt>bitmap_top</tt> is the vertical distance from the
|
||||
pen position (on the baseline) to the top-most border of the
|
||||
glyph bitmap. <em>It is positive to indicate an upwards
|
||||
distance</em>.</p>
|
||||
|
||||
<p>The next section will detail the content of a glyph slot and
|
||||
how to access specific glyph information (including metrics).</p>
|
||||
|
||||
<h4>
|
||||
c. Using other charmaps
|
||||
</h4>
|
||||
|
||||
<p>As said before, when a new face object is created, it will look for
|
||||
a Unicode, Latin-1, or ASCII charmap and select it. The currently
|
||||
selected charmap is accessed via <b><tt>face->charmap</tt></b>. This
|
||||
field is NULL when no charmap is selected, which typically happens
|
||||
when you create a new <tt>FT_Face</tt> object from a font file that
|
||||
doesn't contain an ASCII, Latin-1, or Unicode charmap (rare
|
||||
stuff).</p>
|
||||
|
||||
<p>There are two ways to select a different charmap with FreeType 2.
|
||||
The easiest is when the encoding you need already has a corresponding
|
||||
enumeration defined in <tt><freetype/freetype.h></tt>, as
|
||||
<tt>ft_encoding_big5</tt>. In this case, you can simply call
|
||||
<tt>FT_Select_CharMap</tt> as in:</p>
|
||||
|
||||
<font color="blue"><pre>
|
||||
error = FT_Select_CharMap(
|
||||
face, /* target face object */
|
||||
ft_encoding_big5 ); /* encoding.. */
|
||||
</pre></font>
|
||||
|
||||
<p>Another way is to manually parse the list of charmaps for the
|
||||
face, this is accessible through the fields
|
||||
<tt><b>num_charmaps</b></tt> and <tt><b>charmaps</b></tt>
|
||||
(notice the 's') of the face object. As you could expect,
|
||||
the first is the number of charmaps in the face, while the
|
||||
second is <em>a table of pointers to the charmaps</em>
|
||||
embedded in the face.</p>
|
||||
|
||||
<p>Each charmap has a few visible fields used to describe it more
|
||||
precisely. Mainly, one will look at
|
||||
<tt><b>charmap->platform_id</b></tt> and
|
||||
<tt><b>charmap->encoding_id</b></tt> that define a pair of
|
||||
values that can be used to describe the charmap in a rather
|
||||
generic way.</p>
|
||||
|
||||
<p>Each value pair corresponds to a given encoding. For example,
|
||||
the pair (3,1) corresponds to Unicode. Their list is
|
||||
defined in the TrueType specification but you can also use the
|
||||
file <tt><freetype/ftnameid.h></tt> which defines several
|
||||
helpful constants to deal with them..</p>
|
||||
|
||||
<p>To look for a specific encoding, you need to find a corresponding
|
||||
value pair in the specification, then look for it in the charmaps
|
||||
list. Don't forget that some encoding correspond to several
|
||||
values pair (yes it's a real mess, but blame Apple and Microsoft
|
||||
on such stupidity..). Here's some code to do it:</p>
|
||||
|
||||
<font color="blue">
|
||||
<pre>
|
||||
FT_CharMap found = 0;
|
||||
FT_CharMap charmap;
|
||||
int n;
|
||||
|
||||
for ( n = 0; n < face->num_charmaps; n++ )
|
||||
{
|
||||
charmap = face->charmaps[n];
|
||||
if ( charmap->platform_id == my_platform_id &&
|
||||
charmap->encoding_id == my_encoding_id )
|
||||
{
|
||||
found = charmap;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !found ) { ... }
|
||||
|
||||
/* now, select the charmap for the face object */
|
||||
error = FT_Set_CharMap( face, found );
|
||||
if ( error ) { ... }</pre>
|
||||
</font>
|
||||
|
||||
<p>Once a charmap has been selected, either through
|
||||
<tt>FT_Select_CharMap</tt> or <tt>FT_Set_CharMap</tt>,
|
||||
it is used by all subsequent calls to
|
||||
<tt>FT_Get_Char_Index()</tt>.</p>
|
||||
|
||||
|
||||
<h4>
|
||||
d. Glyph Transforms:
|
||||
</h4>
|
||||
|
||||
<p>It is possible to specify an affine transformation to be applied
|
||||
to glyph images when they're loaded. Of course, this will only
|
||||
work for scalable (vectorial) font formats.</p>
|
||||
|
||||
<p>To do that, simply call <tt>FT_Set_Transform</tt>, as in:</p>
|
||||
|
||||
<font color="blue"><pre>
|
||||
error = FT_Set_Transform(
|
||||
face, /* target face object */
|
||||
&matrix, /* pointer to 2x2 matrix */
|
||||
&delta ); /* pointer to 2d vector */
|
||||
</pre></font>
|
||||
|
||||
<p>This function will set the current transform for a given face
|
||||
object. Its second parameter is a pointer to a simple
|
||||
<tt>FT_Matrix</tt> structure that describes a 2x2 affine matrix.
|
||||
The third parameter is a pointer to a <tt>FT_Vector</tt> structure
|
||||
that describe a simple 2d vector.</p>
|
||||
|
||||
<p>Note that the matrix pointer can be set to NULL, (in which case
|
||||
the identity transform will be used). Coefficients of the matrix
|
||||
are in 16.16 fixed float units.</p>
|
||||
|
||||
<p>The vector pointer can also be set to NULL (in which case a delta
|
||||
of (0,0) will be used). The vector coordinates are expressed in
|
||||
1/64th of a pixel (also known as 26.6 fixed floats).</p>
|
||||
|
||||
<p><em>NOTA BENE: The transform is applied every glyph that is loaded
|
||||
through <tt>FT_Load_Glyph</tt>. Note that loading a glyph bitmap
|
||||
with a non-trivial transform will produce an error..</em></p>
|
||||
|
||||
<hr>
|
||||
|
||||
<h3>
|
||||
7. Accessing glyph image data
|
||||
</h3>
|
||||
|
||||
<p>Glyph image data is accessible through <tt><b>face->glyph</b></tt>.
|
||||
See the definition of the <tt>FT_GlyphSlot</tt> type for more details.
|
||||
As stated previously, each face has a single glyph slot, where
|
||||
<em>one</em> glyph image <em>at a time</em> can be loaded. Each time
|
||||
you call <tt>FT_Load_Glyph()</tt>, you erase the content of the glyph
|
||||
slot with a new glyph image.</p>
|
||||
|
||||
<p>Note however that the glyph slot object itself doesn't change, only
|
||||
its content, which means that you can perfectly create a "shortcut" to
|
||||
access it as in</p>
|
||||
|
||||
<font color="blue">
|
||||
<pre>
|
||||
{
|
||||
/* shortcut to glyph slot */
|
||||
FT_GlyphSlot glyph = face->glyph;
|
||||
|
||||
for ( n = 0; n < face->num_glyphs; n++ )
|
||||
{
|
||||
... load glyph n ...
|
||||
... access glyph data as glyph->xxxx
|
||||
}
|
||||
}</pre>
|
||||
</font>
|
||||
|
||||
<p>The <tt>glyph</tt> variable will be valid until its parent
|
||||
<tt>face</tt> is destroyed. Here are a few important fields of the
|
||||
glyph slot:<p>
|
||||
|
||||
<table cellpadding=5>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<tt><b>glyph->format</b></tt>
|
||||
</td>
|
||||
<td>
|
||||
<p>Indicates the type of the loaded glyph image. Can be either
|
||||
<tt>ft_glyph_format_bitmap</tt>, <tt>ft_glyph_format_outline</tt>,
|
||||
or other values.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<tt><b>glyph->metrics</b></tt>
|
||||
</td>
|
||||
<td>
|
||||
<p>A simple structure used to hold the glyph image's metrics.
|
||||
Note that <em>most distances are expressed in 1/64th of
|
||||
pixels!</em> See the API reference or the user guide for a
|
||||
description of the <tt>FT_Glyph_Metrics</tt> structure.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<tt><b>glyph->bitmap</b></tt>
|
||||
</td>
|
||||
<td>
|
||||
<p>If the glyph slot contains a bitmap, a simple
|
||||
<tt>FT_Bitmap</tt> that describes it. See the API reference or
|
||||
user guide for a description of the <tt>FT_Bitmap</tt>
|
||||
structure.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<tt><b>glyph->outline</b></tt>
|
||||
</td>
|
||||
<td>
|
||||
<p>When the glyph slot contains a scalable outline, this structure
|
||||
describes it. See the definition of the <tt>FT_Outline</tt>
|
||||
structure.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h3>
|
||||
8. Rendering glyph outlines into bitmaps
|
||||
</h3>
|
||||
|
||||
<p>You can easily test the format of the glyph image by inspecting the
|
||||
<tt>face->glyph->format</tt> variable. If its value is
|
||||
<tt>ft_glyph_format_bitmap</tt>, the glyph image that was loaded is a
|
||||
bitmap that can be directly blit to your own surfaces through your
|
||||
favorite graphics library (FreeType 2 doesn't provide bitmap
|
||||
blitting routines, as you may imagine :-)</p>
|
||||
|
||||
<p>If the format is <tt>ft_glyph_format_outline</tt> or something else,
|
||||
the library provides a means to convert such glyph images to bitmaps
|
||||
through what are called <b>rasters</b>.</p>
|
||||
|
||||
<p>On the other hand, if the image is a scalable outline or something
|
||||
else, FreeType provides a function to convert the glyph image into a
|
||||
pre-existing bitmap that you will handle to it, named
|
||||
<tt>FT_Get_Glyph_Bitmap</tt>. Here's a <em>simple</em> example code
|
||||
that renders an outline into a <b>monochrome</b> bitmap:</p>
|
||||
|
||||
<font color="blue">
|
||||
<pre>
|
||||
{
|
||||
FT_GlyphSlot glyph;
|
||||
|
||||
... load glyph ...
|
||||
|
||||
glyph = face->glyph; /* shortcut to glyph data */
|
||||
if ( glyph->format == ft_glyph_format_outline )
|
||||
{
|
||||
FT_Bitmap bit;
|
||||
|
||||
/* set-up a bitmap descriptor for our target bitmap */
|
||||
bit.rows = bitmap_height;
|
||||
bit.width = bitmap_width;
|
||||
bit.pitch = bitmap_row_bytes;
|
||||
/* render into a mono bitmap */
|
||||
bit.pixel_mode = ft_pixel_mode_mono;
|
||||
bit.buffer = bitmap_buffer;
|
||||
|
||||
/* render the outline directly into the bitmap */
|
||||
error = FT_Get_Glyph_Bitmap( face, &bit );
|
||||
if ( error ) { ... }
|
||||
}
|
||||
}</pre>
|
||||
</font>
|
||||
|
||||
<p>You should note that <b><em><tt>FT_Get_Glyph_Bitmap()</tt> doesn't
|
||||
create the bitmap</em></b>. It only needs a descriptor, of type
|
||||
<tt>FT_Bitmap</tt>, and writes directly into it.</p>
|
||||
|
||||
<p>Note that the FreeType scan-converter for outlines can also generate
|
||||
anti-aliased glyph bitmaps with 128 level of grays. For now, it is
|
||||
restricted to rendering to 8-bit gray-level bitmaps, though this may
|
||||
change in the future. Here is some code to do just that:</p>
|
||||
|
||||
<font color="blue">
|
||||
<pre>
|
||||
{
|
||||
FT_GlyphSlot glyph;
|
||||
|
||||
... load glyph ...
|
||||
|
||||
glyph = face->glyph; /* shortcut to glyph data */
|
||||
if ( glyph->format == ft_glyph_format_outline )
|
||||
{
|
||||
FT_Bitmap bit;
|
||||
|
||||
/* set-up a bitmap descriptor for our target bitmap */
|
||||
bit.rows = bitmap_height;
|
||||
bit.width = bitmap_width;
|
||||
bit.pitch = bitmap_row_bytes;
|
||||
/* 8-bit gray-level bitmap */
|
||||
bit.pixel_mode = ft_pixel_mode_gray;
|
||||
/* MUST be 128 for now */
|
||||
bit.grays = 128;
|
||||
bit.buffer = bitmap_buffer;
|
||||
|
||||
/* clean the bitmap - IMPORTANT */
|
||||
memset( bit.buffer, 0, bit.rows*bit.pitch );
|
||||
|
||||
/* render the outline directly into the bitmap */
|
||||
error = FT_Get_Glyph_Bitmap( face, &bit );
|
||||
if ( error ) { ... }
|
||||
}
|
||||
}</pre>
|
||||
</font>
|
||||
|
||||
<p>You will notice that</p>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<p>As previously, <tt>FT_Get_Glyph_Bitmap()</tt> doesn't generate
|
||||
the bitmap, it simply renders to it.</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>The target bitmap must be cleaned before calling the function.
|
||||
This is a limitation of our current anti-aliasing algorithm and is
|
||||
EXTREMELY important.</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>The anti-aliaser uses 128 levels of grays exclusively for
|
||||
now (this will probably change in a near future). This means that
|
||||
you <b>must</b> set <tt>bit.grays</tt> to 128. The generated
|
||||
image uses values from 0 (back color) to 127 (foreground color).</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>It is <b>not</b> possible to render directly an anti-aliased
|
||||
outline into a pre-existing gray-level bitmap, or even any
|
||||
colored-format one (like RGB16 or paletted 8-bits). We will not
|
||||
discuss this issue in great details here, but the reason is that we
|
||||
do not want to deal with graphics composition (or alpha-blending)
|
||||
within FreeType.<p/>
|
||||
</li>
|
||||
</ul>
|
||||
</td></tr>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,956 @@
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=iso-8859-1">
|
||||
<meta name="Author"
|
||||
content="David Turner">
|
||||
<title>FreeType 2 Tutorial</title>
|
||||
</head>
|
||||
|
||||
<body text="#000000"
|
||||
bgcolor="#FFFFFF"
|
||||
link="#0000EF"
|
||||
vlink="#51188E"
|
||||
alink="#FF0000">
|
||||
|
||||
<h1 align=center>
|
||||
FreeType 2.0 Tutorial<br>
|
||||
Step 1 - simple glyph loading
|
||||
</h1>
|
||||
|
||||
<h3 align=center>
|
||||
© 2000 David Turner
|
||||
(<a href="mailto:[email protected]">[email protected]</a>)<br>
|
||||
© 2000 The FreeType Development Team
|
||||
(<a href="http://www.freetype.org">www.freetype.org</a>)
|
||||
</h3>
|
||||
|
||||
<center>
|
||||
<table width="70%">
|
||||
<tr><td>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2>
|
||||
Introduction
|
||||
</h2>
|
||||
|
||||
<p>This is the first section of the FreeType 2 tutorial. It will teach
|
||||
you to do the following:</p>
|
||||
|
||||
<ul>
|
||||
<li>initialise the library</li>
|
||||
<li>open a font file by creating a new face object</li>
|
||||
<li>select a character size in points or in pixels</li>
|
||||
<li>load a single glyph image and convert it to a bitmap</li>
|
||||
<li>render a very simple string of text</li>
|
||||
<li>render a rotated string of text easily</li>
|
||||
</ul>
|
||||
|
||||
<hr>
|
||||
|
||||
<h3>
|
||||
1. Header files
|
||||
</h3>
|
||||
|
||||
<p>To include the main FreeType header file, simply say</p>
|
||||
|
||||
<font color="blue">
|
||||
<pre>
|
||||
#include <freetype/freetype.h></pre>
|
||||
</font>
|
||||
|
||||
<p>in your application code. Note that other files are available in the
|
||||
FreeType include directory, most of them being included by
|
||||
<tt>"freetype.h"</tt>. They will be described later in this
|
||||
tutorial.</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<h3>
|
||||
2. Initialize the library
|
||||
</h3>
|
||||
|
||||
<p>Simply create a variable of type <tt>FT_Library</tt> named, for
|
||||
example, <tt>library</tt>, and call the function
|
||||
<tt>FT_Init_FreeType()</tt> as in</p>
|
||||
|
||||
<font color="blue">
|
||||
<pre>
|
||||
#include <freetype/freetype.h>
|
||||
|
||||
FT_Library library;
|
||||
|
||||
...
|
||||
|
||||
{
|
||||
...
|
||||
error = FT_Init_FreeType( &library );
|
||||
if ( error )
|
||||
{
|
||||
... an error occurred during library initialization ...
|
||||
}
|
||||
}</pre>
|
||||
</font>
|
||||
|
||||
<p>This function is in charge of the following:</p>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<p>Creating a new instance of the FreeType 2 library, and set
|
||||
the handle <tt>library</tt> to it.</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>Load each modules that FreeType knows about in the library.
|
||||
This means that by default, your new <tt>library</tt> object is able
|
||||
to handle TrueType, Type 1, CID-keyed & OpenType/CFF fonts
|
||||
gracefully.</p>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p>As you can see, the function returns an error code, like most others
|
||||
in the FreeType API. An error code of 0 <em>always</em> means that
|
||||
the operation was successful; otherwise, the value describes the error,
|
||||
and <tt>library</tt> is set to NULL.</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<h3>
|
||||
3. Load a font face
|
||||
</h3>
|
||||
|
||||
<h4>
|
||||
a. From a font file
|
||||
</h4>
|
||||
|
||||
<p>Create a new <em>face</em> object by calling <tt>FT_New_Face</tt>.
|
||||
A <em>face</em> describes a given typeface and style. For example,
|
||||
"Times New Roman Regular" and "Times New Roman Italic" correspond to
|
||||
two different faces.</p>
|
||||
|
||||
<font color="blue">
|
||||
<pre>
|
||||
FT_Library library; /* handle to library */
|
||||
FT_Face face; /* handle to face object */
|
||||
|
||||
error = FT_Init_FreeType( &library );
|
||||
if ( error ) { ... }
|
||||
|
||||
error = FT_New_Face( library,
|
||||
"/usr/share/fonts/truetype/arial.ttf",
|
||||
0,
|
||||
&face );
|
||||
if ( error == FT_Err_Unknown_File_Format )
|
||||
{
|
||||
... the font file could be opened and read, but it appears
|
||||
... that its font format is unsupported
|
||||
}
|
||||
else if ( error )
|
||||
{
|
||||
... another error code means that the font file could not
|
||||
... be opened or read, or simply that it is broken...
|
||||
}</pre>
|
||||
</font>
|
||||
|
||||
<p>As you can certainly imagine, <tt>FT_New_Face</tt> opens a font
|
||||
file, then tries to extract one face from it. Its parameters are</p>
|
||||
|
||||
<table cellpadding=5>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<tt><b>library</b></tt>
|
||||
</td>
|
||||
<td>
|
||||
<p>handle to the FreeType library instance where the face object
|
||||
is created</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<tt><b>filepathname</b></tt>
|
||||
</td>
|
||||
<td>
|
||||
<p>the font file pathname (standard C string).</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<tt><b>face_index</b></tt>
|
||||
</td>
|
||||
<td>
|
||||
<p>Certain font formats allow several font faces to be embedded
|
||||
in a single file.</p>
|
||||
|
||||
<p>This index tells which face you want to load. An error will
|
||||
be returned if its value is too large.</p>
|
||||
|
||||
<p>Index 0 always work though.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<tt><b>face</b></tt>
|
||||
</td>
|
||||
<td>
|
||||
<p>A <em>pointer</em> to the handle that will be set to describe
|
||||
the new face object.</p>
|
||||
|
||||
<p>It is set to NULL in case of error.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>To know how many faces a given font file contains, simply load its
|
||||
first face (use <tt>face_index</tt>=0), then see the value of
|
||||
<tt>face->num_faces</tt> which indicates how many faces are embedded
|
||||
in the font file.</p>
|
||||
|
||||
<h4>
|
||||
b. From memory
|
||||
</h4>
|
||||
|
||||
<p>In the case where you have already loaded the font file in memory,
|
||||
you can similarly create a new face object for it by calling
|
||||
<tt>FT_New_Memory_Face</tt> as in</p>
|
||||
|
||||
<font color="blue">
|
||||
<pre>
|
||||
FT_Library library; /* handle to library */
|
||||
FT_Face face; /* handle to face object */
|
||||
|
||||
error = FT_Init_FreeType( &library );
|
||||
if ( error ) { ... }
|
||||
|
||||
error = FT_New_Memory_Face( library,
|
||||
buffer, /* first byte in memory */
|
||||
size, /* size in bytes */
|
||||
0, /* face_index */
|
||||
&face );
|
||||
if ( error ) { ... }</pre>
|
||||
</font>
|
||||
|
||||
<p>As you can see, <tt>FT_New_Memory_Face()</tt> simply takes a
|
||||
pointer to the font file buffer and its size in bytes instead of a
|
||||
file pathname. Other than that, it has exactly the same semantics as
|
||||
<tt>FT_New_Face()</tt>.</p>
|
||||
|
||||
<h4>
|
||||
c. From other sources (compressed files, network, etc.)
|
||||
</h4>
|
||||
|
||||
<p>There are cases where using a file pathname or preloading the file
|
||||
in memory is simply not enough. With FreeType 2, it is possible
|
||||
to provide your own implementation of i/o routines.</p>
|
||||
|
||||
<p>This is done through the <tt>FT_Open_Face()</tt> function, which
|
||||
can be used to open a new font face with a custom input stream, select
|
||||
a specific driver for opening, or even pass extra parameters to the
|
||||
font driver when creating the object. We advise you to refer to the
|
||||
FreeType 2 reference manual in order to learn how to use it.</p>
|
||||
|
||||
<p>Note that providing a custom stream might also be used to access a
|
||||
TrueType font embedded in a Postscript Type 42 wrapper.</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<h3>
|
||||
4. Accessing face content
|
||||
</h3>
|
||||
|
||||
<p>A <em>face object</em> models all information that globally describes
|
||||
the face. Usually, this data can be accessed directly by dereferencing
|
||||
a handle, like</p>
|
||||
|
||||
<table cellpadding=5>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<tt><b>face->num_glyphs</b></tt>
|
||||
</td>
|
||||
<td>
|
||||
<p>Gives the number of <em>glyphs</em> available in the font face.
|
||||
A glyph is simply a character image. It doesn't necessarily
|
||||
correspond to a <em>character code</em> though.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<tt><b>face->flags</b></tt>
|
||||
</td>
|
||||
<td>
|
||||
<p>A 32-bit integer containing bit flags used to describe some
|
||||
face properties. For example, the flag
|
||||
<tt>FT_FACE_FLAG_SCALABLE</tt> is used to indicate that the face's
|
||||
font format is scalable and that glyph images can be rendered for
|
||||
all character pixel sizes. For more information on face flags,
|
||||
please read the <a href="#">FreeType 2 API Reference</a>.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<tt><b>face->units_per_EM</b></tt>
|
||||
</td>
|
||||
<td>
|
||||
<p>This field is only valid for scalable formats (it is set to 0
|
||||
otherwise). It indicates the number of font units covered by the
|
||||
EM.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<tt><b>face->num_fixed_sizes</b></tt>
|
||||
</td>
|
||||
<td>
|
||||
<p>This field gives the number of embedded bitmap <em>strikes</em>
|
||||
in the current face. A <em>strike</em> is simply a series of
|
||||
glyph images for a given character pixel size. For example, a
|
||||
font face could include strikes for pixel sizes 10, 12
|
||||
and 14. Note that even scalable font formats can have
|
||||
embedded bitmap strikes!</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<tt><b>face->fixed_sizes</b></tt>
|
||||
</td>
|
||||
<td>
|
||||
<p>this is a pointer to an array of <tt>FT_Bitmap_Size</tt>
|
||||
elements. Each <tt>FT_Bitmap_Size</tt> indicates the horizontal
|
||||
and vertical <em>pixel sizes</em> for each of the strikes that are
|
||||
present in the face.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>For a complete listing of all face properties and fields, please read
|
||||
the <a href="#">FreeType 2 API Reference</a>.<p>
|
||||
|
||||
<hr>
|
||||
|
||||
<h3>
|
||||
5. Setting the current pixel size
|
||||
</h3>
|
||||
|
||||
<p>FreeType 2 uses "<em>size objects</em>" to model all
|
||||
information related to a given character size for a given face.
|
||||
For example, a size object will hold the value of certain metrics
|
||||
like the ascender or text height, expressed in 1/64th of a pixel,
|
||||
for a character size of 12 points.</p>
|
||||
|
||||
<p>When the <tt>FT_New_Face</tt> function is called (or one of its
|
||||
cousins), it <b>automatically</b> creates a new size object for
|
||||
the returned face. This size object is directly accessible as
|
||||
<b><tt>face->size</tt></b>.</p>
|
||||
|
||||
<p><em>NOTA BENE: a single face object can deal with one or more size
|
||||
objects at a time, however, this is something that few programmers
|
||||
really need to do. We have thus have decided to simplify the API for
|
||||
the most common use (i.e. one size per face), while keeping this
|
||||
feature available through additional fuctions.</em></p>
|
||||
|
||||
<p>When a new face object is created, its size object defaults to the
|
||||
character size of 10 pixels (both horizontally and vertically) for
|
||||
scalable formats. For fixed-sizes formats, the size is more or less
|
||||
undefined, which is why you must set it before trying to load a
|
||||
glyph.</p>
|
||||
|
||||
<p>To do that, simply call <tt>FT_Set_Char_Size()</tt>. Here is an
|
||||
example where the character size is set to 16pt for a 300x300 dpi
|
||||
device:</p>
|
||||
|
||||
<font color="blue">
|
||||
<pre>
|
||||
error = FT_Set_Char_Size(
|
||||
face, /* handle to face object */
|
||||
0, /* char_width in 1/64th of points */
|
||||
16*64, /* char_height in 1/64th of points */
|
||||
300, /* horizontal device resolution */
|
||||
300 ); /* vertical device resolution */</pre>
|
||||
</font>
|
||||
|
||||
<p>You will notice that:</p>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<p>The character width and heights are specified in 1/64th of
|
||||
points. A point is a <em>physical</em> distance, equaling 1/72th
|
||||
of an inch, it's not a pixel..<p>
|
||||
</li>
|
||||
<li>
|
||||
<p>The horizontal and vertical device resolutions are expressed in
|
||||
<em>dots-per-inch</em>, or <em>dpi</em>. You can use 72 or
|
||||
96 dpi for display devices like the screen. The resolution
|
||||
is used to compute the character pixel size from the character
|
||||
point size.</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>A value of 0 for the character width means "<em>same as
|
||||
character height</em>", a value of 0 for the character height
|
||||
means "<em>same as character width</em>". Otherwise, it is possible
|
||||
to specify different char widths and heights.</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>Using a value of 0 for the horizontal or vertical resolution means
|
||||
72 dpi, which is the default.</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>The first argument is a handle to a face object, not a size
|
||||
object. That's normal, and must be seen as a convenience.</p>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p>This function computes the character pixel size that corresponds to
|
||||
the character width and height and device resolutions. However, if you
|
||||
want to specify the pixel sizes yourself, you can simply call
|
||||
<tt>FT_Set_Pixel_Sizes()</tt>, as in</p>
|
||||
|
||||
<font color="blue">
|
||||
<pre>
|
||||
error = FT_Set_Pixel_Sizes(
|
||||
face, /* handle to face object */
|
||||
0, /* pixel_width */
|
||||
16 ); /* pixel_height */</pre>
|
||||
</font>
|
||||
|
||||
<p>This example will set the character pixel sizes to 16x16 pixels.
|
||||
As previously, a value of 0 for one of the dimensions means
|
||||
"<em>same as the other</em>".</p>
|
||||
|
||||
<p>Note that both functions return an error code. Usually, an error
|
||||
occurs with a fixed-size font format (like FNT or PCF) when trying to
|
||||
set the pixel size to a value that is not listed in the
|
||||
<tt><b>face->fixed_sizes</b></tt> array.</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<h3>
|
||||
6. Loading a glyph image
|
||||
</h3>
|
||||
|
||||
<h4>
|
||||
a. Converting a character code into a glyph index
|
||||
</h4>
|
||||
|
||||
<p>Usually, an application wants to load a glyph image based on its
|
||||
<em>character code</em>, which is a unique value that defines the
|
||||
character for a given <em>encoding</em>. For example, the character
|
||||
code 65 represents the `A' in ASCII encoding.</p>
|
||||
|
||||
<p>A face object contains one or more tables, called
|
||||
<em>charmaps</em>, that are used to convert character codes to glyph
|
||||
indices. For example, most TrueType fonts contain two charmaps. One
|
||||
is used to convert Unicode character codes to glyph indices, the other
|
||||
is used to convert Apple Roman encoding into glyph indices. Such
|
||||
fonts can then be used either on Windows (which uses Unicode) and
|
||||
Macintosh (which uses Apple Roman, bwerk). Note also that a given
|
||||
charmap might not map to all the glyphs present in the font.</p>
|
||||
|
||||
<p>By default, when a new face object is created, it lists all the
|
||||
charmaps contained in the font face and selects the one that supports
|
||||
Unicode character codes if it finds one. Otherwise, it tries to find
|
||||
support for Latin-1, then ASCII.</p>
|
||||
|
||||
<p>We will describe later how to look for specific charmaps in a face.
|
||||
For now, we will assume that the face contains at least a Unicode
|
||||
charmap that was selected during <tt>FT_New_Face()</tt>. To convert a
|
||||
Unicode character code to a font glyph index, we use
|
||||
<tt>FT_Get_Char_Index()</tt> as in</p>
|
||||
|
||||
<font color="blue">
|
||||
<pre>
|
||||
glyph_index = FT_Get_Char_Index( face, charcode );</pre>
|
||||
</font>
|
||||
|
||||
<p>This will look the glyph index corresponding to the given
|
||||
<tt>charcode</tt> in the charmap that is currently selected for the
|
||||
face. If charmap is selected, the function simply returns the
|
||||
charcode.</p>
|
||||
|
||||
<p>Note that this is one of the rare FreeType functions that do not
|
||||
return an error code. However, when a given character code has no
|
||||
glyph image in the face, the value 0 is returned. By convention,
|
||||
it always correspond to a special glyph image called the <b>missing
|
||||
glyph</b>, which usually is represented as a box or a space.</p>
|
||||
|
||||
<h4>
|
||||
b. Loading a glyph from the face
|
||||
</h4>
|
||||
|
||||
<p>Once you have a glyph index, you can load the corresponding glyph
|
||||
image. The latter can be stored in various formats within the font file.
|
||||
For fixed-size formats like FNT or PCF, each image is a bitmap. Scalable
|
||||
formats like TrueType or Type 1 use vectorial shapes, named "outlines"
|
||||
to describe each glyph. Some formats may have even more exotic ways
|
||||
of representing glyph (e.g. MetaFont). Fortunately, FreeType 2 is
|
||||
flexible enough to support any kind of glyph format through
|
||||
a simple API.</p>
|
||||
|
||||
<p>The glyph image is always stored in a special object called a
|
||||
<em>glyph slot</em>. As its name suggests, a glyph slot is simply a
|
||||
container that is able to hold one glyph image at a time, be it a
|
||||
bitmap, an outline, or something else. Each face object has a single
|
||||
glyph slot object that can be accessed as
|
||||
<b><tt>face->glyph</tt></b>.</p>
|
||||
|
||||
<p>Loading a glyph image into the slot is performed by calling
|
||||
<tt>FT_Load_Glyph()</tt> as in</p>
|
||||
|
||||
<font color="blue">
|
||||
<pre>
|
||||
error = FT_Load_Glyph(
|
||||
face, /* handle to face object */
|
||||
glyph_index, /* glyph index */
|
||||
load_flags ); /* load flags, see below */</pre>
|
||||
</font>
|
||||
|
||||
<p>The <tt>load_flags</tt> value is a set of bit flags used to
|
||||
indicate some special operations. The default value
|
||||
<tt>FT_LOAD_DEFAULT</tt> is 0.</p>
|
||||
|
||||
<p>This function will try to load the corresponding glyph image
|
||||
from the face. Basically, this means that:</p>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<p>If a bitmap is found for the corresponding glyph and pixel
|
||||
size, it will be loaded into the slot (embedded bitmaps are always
|
||||
favored over native image formats, because we assume that
|
||||
they are higher-quality versions of the same glyph. This
|
||||
can be ignored by using the FT_LOAD_NO_BITMAP flag)</p>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<p>Otherwise, a native image for the glyph will be loaded.
|
||||
It will also be scaled to the current pixel size, as
|
||||
well as hinted for certain formats like TrueType and
|
||||
Type1.</p>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p>The field <tt><b>glyph->format</b></tt> describe the format
|
||||
used to store the glyph image in the slot. If it is not
|
||||
<tt>ft_glyph_format_bitmap</tt>, one can immediately
|
||||
convert it to a bitmap through <tt>FT_Render_Glyph</tt>,
|
||||
as in:</p>
|
||||
|
||||
<font color="blue">
|
||||
<pre>
|
||||
error = FT_Render_Glyph(
|
||||
face->glyph, /* glyph slot */
|
||||
render_mode ); /* render mode */
|
||||
</pre>
|
||||
</font>
|
||||
|
||||
<p>The parameter <tt>render_mode</tt> is a set of bit flags used
|
||||
to specify how to render the glyph image. Set it to 0, or the
|
||||
equivalent <tt>ft_render_mode_normal</tt> to render a high-quality
|
||||
anti-aliased (256 gray levels) bitmap, as this is the default.
|
||||
You can alternatively use <tt>ft_render_mode_mono</tt> if you
|
||||
want to generate a 1-bit monochrome bitmap.</p>
|
||||
|
||||
<p>Once you have a bitmapped glyph image, you can access it directly
|
||||
through <tt><b>glyph->bitmap</b></tt> (a simple bitmap descriptor),
|
||||
and position it through <tt><b>glyph->bitmap_left</b></tt> and
|
||||
<tt><b>glyph->bitmap_top</b></tt>.</p>
|
||||
|
||||
<p>Note that <tt>bitmap_left</tt> is the horizontal distance from the
|
||||
current pen position to the left-most border of the glyph bitmap,
|
||||
while <tt>bitmap_top</tt> is the vertical distance from the
|
||||
pen position (on the baseline) to the top-most border of the
|
||||
glyph bitmap. <em>It is positive to indicate an upwards
|
||||
distance</em>.</p>
|
||||
|
||||
<p>The next section will detail the content of a glyph slot and
|
||||
how to access specific glyph information (including metrics).</p>
|
||||
|
||||
<h4>
|
||||
c. Using other charmaps
|
||||
</h4>
|
||||
|
||||
<p>As said before, when a new face object is created, it will look for
|
||||
a Unicode, Latin-1, or ASCII charmap and select it. The currently
|
||||
selected charmap is accessed via <b><tt>face->charmap</tt></b>. This
|
||||
field is NULL when no charmap is selected, which typically happens
|
||||
when you create a new <tt>FT_Face</tt> object from a font file that
|
||||
doesn't contain an ASCII, Latin-1, or Unicode charmap (rare
|
||||
stuff).</p>
|
||||
|
||||
<p>There are two ways to select a different charmap with FreeType 2.
|
||||
The easiest is when the encoding you need already has a corresponding
|
||||
enumeration defined in <tt><freetype/freetype.h></tt>, as
|
||||
<tt>ft_encoding_big5</tt>. In this case, you can simply call
|
||||
<tt>FT_Select_CharMap</tt> as in:</p>
|
||||
|
||||
<font color="blue"><pre>
|
||||
error = FT_Select_CharMap(
|
||||
face, /* target face object */
|
||||
ft_encoding_big5 ); /* encoding.. */
|
||||
</pre></font>
|
||||
|
||||
<p>Another way is to manually parse the list of charmaps for the
|
||||
face, this is accessible through the fields
|
||||
<tt><b>num_charmaps</b></tt> and <tt><b>charmaps</b></tt>
|
||||
(notice the 's') of the face object. As you could expect,
|
||||
the first is the number of charmaps in the face, while the
|
||||
second is <em>a table of pointers to the charmaps</em>
|
||||
embedded in the face.</p>
|
||||
|
||||
<p>Each charmap has a few visible fields used to describe it more
|
||||
precisely. Mainly, one will look at
|
||||
<tt><b>charmap->platform_id</b></tt> and
|
||||
<tt><b>charmap->encoding_id</b></tt> that define a pair of
|
||||
values that can be used to describe the charmap in a rather
|
||||
generic way.</p>
|
||||
|
||||
<p>Each value pair corresponds to a given encoding. For example,
|
||||
the pair (3,1) corresponds to Unicode. Their list is
|
||||
defined in the TrueType specification but you can also use the
|
||||
file <tt><freetype/ftnameid.h></tt> which defines several
|
||||
helpful constants to deal with them..</p>
|
||||
|
||||
<p>To look for a specific encoding, you need to find a corresponding
|
||||
value pair in the specification, then look for it in the charmaps
|
||||
list. Don't forget that some encoding correspond to several
|
||||
values pair (yes it's a real mess, but blame Apple and Microsoft
|
||||
on such stupidity..). Here's some code to do it:</p>
|
||||
|
||||
<font color="blue">
|
||||
<pre>
|
||||
FT_CharMap found = 0;
|
||||
FT_CharMap charmap;
|
||||
int n;
|
||||
|
||||
for ( n = 0; n < face->num_charmaps; n++ )
|
||||
{
|
||||
charmap = face->charmaps[n];
|
||||
if ( charmap->platform_id == my_platform_id &&
|
||||
charmap->encoding_id == my_encoding_id )
|
||||
{
|
||||
found = charmap;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !found ) { ... }
|
||||
|
||||
/* now, select the charmap for the face object */
|
||||
error = FT_Set_CharMap( face, found );
|
||||
if ( error ) { ... }</pre>
|
||||
</font>
|
||||
|
||||
<p>Once a charmap has been selected, either through
|
||||
<tt>FT_Select_CharMap</tt> or <tt>FT_Set_CharMap</tt>,
|
||||
it is used by all subsequent calls to
|
||||
<tt>FT_Get_Char_Index()</tt>.</p>
|
||||
|
||||
|
||||
<h4>
|
||||
d. Glyph Transforms:
|
||||
</h4>
|
||||
|
||||
<p>It is possible to specify an affine transformation to be applied
|
||||
to glyph images when they're loaded. Of course, this will only
|
||||
work for scalable (vectorial) font formats.</p>
|
||||
|
||||
<p>To do that, simply call <tt>FT_Set_Transform</tt>, as in:</p>
|
||||
|
||||
<font color="blue"><pre>
|
||||
error = FT_Set_Transform(
|
||||
face, /* target face object */
|
||||
&matrix, /* pointer to 2x2 matrix */
|
||||
&delta ); /* pointer to 2d vector */
|
||||
</pre></font>
|
||||
|
||||
<p>This function will set the current transform for a given face
|
||||
object. Its second parameter is a pointer to a simple
|
||||
<tt>FT_Matrix</tt> structure that describes a 2x2 affine matrix.
|
||||
The third parameter is a pointer to a <tt>FT_Vector</tt> structure
|
||||
that describe a simple 2d vector that is used to translate the
|
||||
glyph image <em>after</em> the 2x2 transform.</p>
|
||||
|
||||
<p>Note that the matrix pointer can be set to NULL, (in which case
|
||||
the identity transform will be used). Coefficients of the matrix
|
||||
are otherwise in 16.16 fixed float units.</p>
|
||||
|
||||
<p>The vector pointer can also be set to NULL (in which case a delta
|
||||
of (0,0) will be used). The vector coordinates are expressed in
|
||||
1/64th of a pixel (also known as 26.6 fixed floats).</p>
|
||||
|
||||
<font color="red">
|
||||
<p>NOTA BENE: The transform is applied to every glyph that is loaded
|
||||
through <tt>FT_Load_Glyph</tt> and is <b>completely independent
|
||||
of any hinting process.</b> This means that you won't get the same
|
||||
results if you load a glyph at the size of 24 pixels, or a glyph at
|
||||
the size at 12 pixels scaled by 2 through a transform, because the
|
||||
hints will have been computed differently (unless, of course you
|
||||
disabled hints).</em></p></font>
|
||||
|
||||
<p>If you ever need to use a non-orthogonal transform with optimal
|
||||
hints, you first need to decompose your transform into a scaling part
|
||||
and a rotation/shearing part. Use the scaling part to compute a new
|
||||
character pixel size, then the other one to call FT_Set_Transform.
|
||||
This is explained in details in a later section of this tutorial.</p>
|
||||
|
||||
<p>Note also that loading a glyph bitmap with a non-identity transform
|
||||
will produce an error..</p>
|
||||
<hr>
|
||||
|
||||
<h3>
|
||||
7. Simple Text Rendering:
|
||||
</h3>
|
||||
|
||||
<p>We will now present you with a very simple example used to render
|
||||
a string of 8-bit Latin-1 text, assuming a face that contains a
|
||||
Unicode charmap</p>
|
||||
|
||||
<p>The idea is to create a loop that will, on each iteration, load one
|
||||
glyph image, convert it to an anti-aliased bitmap, draw it on the
|
||||
target surface, then increment the current pen position</p>
|
||||
|
||||
<h4>a. basic code :</h4>
|
||||
|
||||
<p>The following code performs our simple text rendering with the
|
||||
functions previously described.</p>
|
||||
|
||||
<font color="blue"><pre>
|
||||
FT_GlyphSlot slot = face->glyph; // a small shortcut
|
||||
int pen_x, pen_y, n;
|
||||
|
||||
.. initialise library ..
|
||||
.. create face object ..
|
||||
.. set character size ..
|
||||
|
||||
pen_x = 300;
|
||||
pen_y = 200;
|
||||
|
||||
for ( n = 0; n < num_chars; n++ )
|
||||
{
|
||||
FT_UInt glyph_index;
|
||||
|
||||
// retrieve glyph index from character code
|
||||
glyph_index = FT_Get_Char_Index( face, text[n] );
|
||||
|
||||
// load glyph image into the slot (erase previous one)
|
||||
error = FT_Load_Glyph( face, glyph_index, FT_LOAD_DEFAULT );
|
||||
if (error) continue; // ignore errors
|
||||
|
||||
// convert to an anti-aliased bitmap
|
||||
error = FT_Render_Glyph( face->glyph, ft_render_mode_normal );
|
||||
if (error) continue;
|
||||
|
||||
// now, draw to our target surface
|
||||
my_draw_bitmap( &slot->bitmap,
|
||||
pen_x + slot->bitmap_left,
|
||||
pen_y - slot->bitmap_top );
|
||||
|
||||
// increment pen position
|
||||
pen_x += slot->advance.x >> 6;
|
||||
pen_y += slot->advance.y >> 6; // unuseful for now..
|
||||
}
|
||||
</pre></font>
|
||||
|
||||
<p>This code needs a few explanations:</p>
|
||||
<ul>
|
||||
<li><p>
|
||||
we define a handle named <tt>slot</tt> that points to the
|
||||
face object's glyph slot. (the type <tt>FT_GlyphSlot</tt> is
|
||||
a pointer). That's a convenience to avoid using
|
||||
<tt>face->glyph->XXX</tt> every time.
|
||||
</p></li>
|
||||
|
||||
<li><p>
|
||||
we increment the pen position with the vector <tt>slot->advance</tt>,
|
||||
which correspond to the glyph's <em>advance width</em> (also known
|
||||
as its <em>escapement</em>). The advance vector is expressed in
|
||||
64/th of pixels, and is truncated to integer pixels on each
|
||||
iteration.</p>
|
||||
</p></li>
|
||||
|
||||
<li><p>
|
||||
The function <tt>my_draw_bitmap</tt> is not part of FreeType, but
|
||||
must be provided by the application to draw the bitmap to the target
|
||||
surface. In this example, it takes a pointer to a FT_Bitmap descriptor
|
||||
and the position of its top-left corner as arguments.
|
||||
</p></li>
|
||||
|
||||
<li><p>
|
||||
The value of <tt>slot->bitmap_top</tt> is positive for an
|
||||
<em>upwards</em> vertical distance. Assuming that the coordinates
|
||||
taken by <tt>my_draw_bitmap</tt> use the opposite convention
|
||||
(increasing Y corresponds to downwards scanlines), we substract
|
||||
it to <tt>pen_y</tt>, instead of adding it..
|
||||
</p></li>
|
||||
|
||||
</ul>
|
||||
|
||||
<h4>b. refined code:</h4>
|
||||
|
||||
<p>The following code is a refined version of the example above. It
|
||||
uses features and functions of FreeType 2 that have not yet been
|
||||
introduced, and they'll be explained below:</p>
|
||||
|
||||
<font color="blue"><pre>
|
||||
FT_GlyphSlot slot = face->glyph; // a small shortcut
|
||||
FT_UInt glyph_index;
|
||||
int pen_x, pen_y, n;
|
||||
|
||||
.. initialise library ..
|
||||
.. create face object ..
|
||||
.. set character size ..
|
||||
|
||||
pen_x = 300;
|
||||
pen_y = 200;
|
||||
|
||||
for ( n = 0; n < num_chars; n++ )
|
||||
{
|
||||
// load glyph image into the slot (erase previous one)
|
||||
error = FT_Load_Char( face, text[n], FT_LOAD_RENDER );
|
||||
if (error) continue; // ignore errors
|
||||
|
||||
// now, draw to our target surface
|
||||
my_draw_bitmap( &slot->bitmap,
|
||||
pen_x + slot->bitmap_left,
|
||||
pen_y - slot->bitmap_top );
|
||||
|
||||
// increment pen position
|
||||
pen_x += slot->advance.x >> 6;
|
||||
}
|
||||
</pre></font>
|
||||
|
||||
<p>We've reduced the size of our code, but it does exactly the same thing,
|
||||
as:</p>
|
||||
|
||||
<ul>
|
||||
<li><p>
|
||||
We use the function <tt><b>FT_Load_Char</b></tt> instead of
|
||||
<tt>FT_Load_Glyph</tt>. As you probably imagine, it's equivalent
|
||||
to calling <tt>FT_Get_Char_Index</tt> then <tt>FT_Get_Load_Glyph</tt>.
|
||||
</p></li>
|
||||
|
||||
<li><p>
|
||||
We do not use <tt>FT_LOAD_DEFAULT</tt> for the loading mode, but
|
||||
the bit flag <tt><b>FT_LOAD_RENDER</b></tt>. It indicates that
|
||||
the glyph image must be immediately converted to an anti-aliased
|
||||
bitmap. This is of course a shortcut that avoids calling
|
||||
<tt>FT_Render_Glyph</tt> explicitely but is strictly equivalent.</p>
|
||||
|
||||
<p>
|
||||
Note that you can also specify that you want a monochrome bitmap
|
||||
instead by using the addition <tt><b>FT_LOAD_MONOCHROME</b></tt>
|
||||
load flag.
|
||||
</p></li>
|
||||
</ul>
|
||||
|
||||
<h4>c. more advanced rendering:</h4>
|
||||
|
||||
<p>Let's try to render transformed text now (for example through a
|
||||
rotation). We can do this using <tt>FT_Set_Transform</tt>. Here's
|
||||
how to do it:</p>
|
||||
|
||||
<font color="blue"><pre>
|
||||
FT_GlyphSlot slot = face->glyph; // a small shortcut
|
||||
FT_Matrix matrix; // transformation matrix
|
||||
FT_UInt glyph_index;
|
||||
FT_Vector pen; // untransformed origin
|
||||
int pen_x, pen_y, n;
|
||||
|
||||
.. initialise library ..
|
||||
.. create face object ..
|
||||
.. set character size ..
|
||||
|
||||
// set up matrix
|
||||
matrix.xx = (FT_Fixed)( cos(angle)*0x10000);
|
||||
matrix.xy = (FT_Fixed)(-sin(angle)*0x10000);
|
||||
matrix.yx = (FT_Fixed)( sin(angle)*0x10000);
|
||||
matrix.yy = (FT_Fixed)( cos(angle)*0x10000);
|
||||
|
||||
// the pen position in 26.6 cartesian space coordinates
|
||||
pen.x = 300 * 64;
|
||||
pen.y = ( my_target_height - 200 ) * 64;
|
||||
|
||||
for ( n = 0; n < num_chars; n++ )
|
||||
{
|
||||
// set transform
|
||||
FT_Set_Transform( face, &matrix, &pen );
|
||||
|
||||
// load glyph image into the slot (erase previous one)
|
||||
error = FT_Load_Char( face, text[n], FT_LOAD_RENDER );
|
||||
if (error) continue; // ignore errors
|
||||
|
||||
// now, draw to our target surface (convert position)
|
||||
my_draw_bitmap( &slot->bitmap,
|
||||
slot->bitmap_left,
|
||||
my_target_height - slot->bitmap_top );
|
||||
|
||||
// increment pen position
|
||||
pen.x += slot->advance.x;
|
||||
pen.y += slot->advance.y;
|
||||
}
|
||||
</pre></font>
|
||||
|
||||
<p>You'll notice that:</p>
|
||||
|
||||
<ul>
|
||||
<li><p>
|
||||
we now use a vector, of type <tt>FT_Vector</tt> to store the pen
|
||||
position, with coordinates expressed as 1/64th of pixels, hence
|
||||
a multiplication. The position is expressed in cartesian space.
|
||||
</p></li>
|
||||
|
||||
<li><p>
|
||||
glyph images are always loaded, transformed and described in the
|
||||
cartesian coordinate system in FreeType (which means that
|
||||
increasing Y corresponds to upper scanlines), unlike the system
|
||||
typically used for bitmaps (where the top-most scanline has
|
||||
coordinate 0). We must thus convert between the two systems
|
||||
when we define the pen position, and when we compute the top-left
|
||||
position of the bitmap.
|
||||
</p></li>
|
||||
|
||||
<li><p>
|
||||
we set the transform on each glyph, to indicate the rotation
|
||||
matrix, as well as a delta that will move the transformed image
|
||||
to the current pen position (in cartesian space, not bitmap space).
|
||||
</p></li>
|
||||
|
||||
<li><p>
|
||||
the advance is always returned transformed, which is why it can
|
||||
be directly added to the current pen position. Note that it is
|
||||
<b>not</b> rounded this time.
|
||||
</p></li>
|
||||
|
||||
</ul>
|
||||
|
||||
<p>It is important to note that, while this example is a bit more
|
||||
complex than the previous one, it is strictly equivalent
|
||||
for the case where the transform is the identity.. Hence it can
|
||||
be used as a replacement (but a more powerful one).</p>
|
||||
|
||||
<p>It has however a few short comings that we will explain, and solve,
|
||||
in the next part of this tutorial.</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<h3>
|
||||
Conclusion
|
||||
</h3>
|
||||
|
||||
<p>In this first section, you have learned the basics of FreeType 2,
|
||||
as well as sufficient knowledge to know how to render rotated text.
|
||||
Woww ! Congratulations..</p>
|
||||
|
||||
<p>The next section will dive into more details of the API in order
|
||||
to let you access glyph metrics and images directly, as well as
|
||||
how to deal with scaling, hinting, kerning, etc..</p>
|
||||
|
||||
<p>The third section will discuss issues like modules, caching and a
|
||||
few other advanced topics like how to use multiple size objects
|
||||
with a single face.
|
||||
</p>
|
||||
|
||||
</td></tr>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user