David Turner | d2b1f35 | 1999-12-16 23:11:37 +0000 | [diff] [blame] | 1 | This file summarizes the changes that occured since the last "beta" of FreeType 2. |
| 2 | Because the list is important, it has been divided into separate sections: |
| 3 | |
David Turner | 5951ce9 | 1999-12-29 00:53:44 +0000 | [diff] [blame^] | 4 | Table Of Contents: |
| 5 | |
| 6 | I High-Level Interface (easier !) |
| 7 | II Directory Structure |
| 8 | III Glyph Image Formats |
| 9 | IV Build System |
| 10 | V Portability |
| 11 | VI Font Drivers |
David Turner | d2b1f35 | 1999-12-16 23:11:37 +0000 | [diff] [blame] | 12 | |
| 13 | ----------------------------------------------------------------------------------------- |
| 14 | High-Level Interface : |
| 15 | |
| 16 | The high-level API has been considerably simplified. Here is how : |
| 17 | |
David Turner | 5951ce9 | 1999-12-29 00:53:44 +0000 | [diff] [blame^] | 18 | - resource objects have disappeared. this means that face objects can |
| 19 | now be created with a single function call (see FT_New_Face and |
David Turner | d2b1f35 | 1999-12-16 23:11:37 +0000 | [diff] [blame] | 20 | FT_Open_Face) |
| 21 | |
| 22 | - when calling either FT_New_Face & FT_Open_Face, a size object and a |
| 23 | glyph slot object are automatically created for the face, and can be |
| 24 | accessed through "face->glyph" and "face->size" if one really needs to. |
| 25 | In most cases, there's no need to call FT_New_Size or FT_New_Glyph. |
| 26 | |
| 27 | - similarly, FT_Load_Glyph now only takes a "face" argument (instead of |
| 28 | a glyph slot and a size). Also, it's "result" parameter is gone, as |
| 29 | the glyph image type is returned in the field "face->glyph.format" |
| 30 | |
| 31 | - the list of available charmaps is directly accessible through |
| 32 | "face->charmaps", counting "face->num_charmaps" elements. Each |
| 33 | charmap has an 'encoding' field which specifies which known encoding |
| 34 | it deals with. Valid values are, for example : |
| 35 | |
| 36 | ft_encoding_unicode (for ASCII, Latin-1 and Unicode) |
| 37 | ft_encoding_apple_roman |
| 38 | ft_encoding_sjis |
| 39 | ft_encoding_adobe_standard |
David Turner | 5951ce9 | 1999-12-29 00:53:44 +0000 | [diff] [blame^] | 40 | ft_encoding_adobe_expert |
David Turner | d2b1f35 | 1999-12-16 23:11:37 +0000 | [diff] [blame] | 41 | |
| 42 | other values may be added in the future. Each charmap still holds its |
| 43 | "platform_id" and "encoding_id" values in case the encoding is too |
| 44 | exotic for the current library |
| 45 | |
| 46 | |
| 47 | ----------------------------------------------------------------------------------------- |
| 48 | Directory Structure: |
| 49 | |
| 50 | Should seem obvious to most of you: |
| 51 | |
| 52 | freetype/ |
| 53 | config/ -- configuration sub-makefiles |
| 54 | ansi/ |
David Turner | 5951ce9 | 1999-12-29 00:53:44 +0000 | [diff] [blame^] | 55 | unix/ -- platform-specific configuration files |
David Turner | d2b1f35 | 1999-12-16 23:11:37 +0000 | [diff] [blame] | 56 | win32/ |
| 57 | os2/ |
| 58 | msdos/ |
| 59 | |
| 60 | include/ -- public header files, those to be included directly |
| 61 | by client apps |
| 62 | |
| 63 | src/ -- sources of the library |
| 64 | base/ -- the base layer |
| 65 | sfnt/ -- the sfnt "driver" (see the drivers section below) |
| 66 | truetype/ -- the truetype driver |
| 67 | type1/ -- the type1 driver |
| 68 | shared/ -- some header files shared between drivers |
| 69 | |
| 70 | demos/ -- demos/tools |
| 71 | |
| 72 | docs/ -- documentation (a bit empty for now) |
| 73 | |
| 74 | ----------------------------------------------------------------------------------------- |
| 75 | Glyph Image Formats : |
| 76 | |
| 77 | Drivers are now able to register new glyph image formats within the library. |
| 78 | For now, the base layer supports of course bitmaps and vector outlines, but |
| 79 | one could imagine something different like colored bitmaps, bi-color |
| 80 | vectors or wathever else (Metafonts anyone ??). |
| 81 | |
| 82 | See the file `include/ftimage.h'. Note also that the type FT_Raster_Map is |
| 83 | gone, and is now replaced by FT_Bitmap, which should encompass all known |
| 84 | bitmap types. |
| 85 | |
| 86 | Each new image format must provide at least one "raster", i.e. a module |
David Turner | 5951ce9 | 1999-12-29 00:53:44 +0000 | [diff] [blame^] | 87 | capable of transforming the glyph image into a bitmap. It's also possible |
David Turner | d2b1f35 | 1999-12-16 23:11:37 +0000 | [diff] [blame] | 88 | to change the default raster used for a given glyph image format. |
| 89 | |
| 90 | The default outline scan-converter now uses 128 levels of grays by default, |
| 91 | which tends to smooth many things. Note that the demo programs have been |
David Turner | 5951ce9 | 1999-12-29 00:53:44 +0000 | [diff] [blame^] | 92 | updated significantly in order to display these.. |
David Turner | d2b1f35 | 1999-12-16 23:11:37 +0000 | [diff] [blame] | 93 | |
| 94 | |
| 95 | ----------------------------------------------------------------------------------------- |
| 96 | Build system : |
| 97 | |
| 98 | You still need GNU Make to build the library. The build system has been |
| 99 | very seriously re-vamped in order to provide things like : |
| 100 | |
| 101 | - automatic host platform detection (reverting to 'config/ansi' |
| 102 | if it is not detected, with pseudo-standard compilation flags) |
| 103 | |
| 104 | - the ability to compile from the Makefiles with very different and |
| 105 | exotic compilers. Note that linking the library can be difficult for |
| 106 | some platforms. |
| 107 | |
| 108 | For example, the file `config/win32/lcclib.bat' is invoked by the |
| 109 | build system to create the ".lib" file with LCC-Win32 because its |
| 110 | librarian has too many flaws to be invoked directly from the Makefile. |
| 111 | |
| 112 | Here's how it works : |
| 113 | |
| 114 | - the first time you type `make', the build system runs a series of |
| 115 | sub-makefiles in order to detect your host platform. It then dumps |
| 116 | what it found, and creates a file called `config.mk' in the current |
| 117 | directory. This is a sub-Makefile used to define many important Make |
| 118 | variables used to build the library. |
| 119 | |
| 120 | - the second time, the build system detects the `config.mk' then use it |
| 121 | to build the library. All object files go into 'obj' by default, as |
| 122 | well as the library file, but this can easily be changed. |
| 123 | |
| 124 | Note that you can run "make setup" to force another host platform detection |
| 125 | even if a `config.mk' is present in the current directory. Another solution |
| 126 | is simply to delete the file, then re-run make. |
| 127 | |
| 128 | Finally, the default compiler for all platforms is gcc (for now, this will |
| 129 | hopefully changed in the future). You can however specify a different |
| 130 | compiler by specifying it after the 'setup' target as in : |
| 131 | |
| 132 | gnumake setup lcc on Win32 to use the LCC compiler |
| 133 | gnumake setup visualc on Win32 to use Visual C++ |
| 134 | |
| 135 | See the file `config/<system>/detect.mk' for a list of supported compilers |
| 136 | for your platforms. |
| 137 | |
| 138 | It should be relatively easy to write new detection rules files and |
| 139 | config.mk.. |
| 140 | |
| 141 | Finally, to build the demo programs, go to `demos' and launch GNU Make, |
| 142 | it will use the `config.mk' in the top directory to build the test |
| 143 | programs.. |
| 144 | |
| 145 | ----------------------------------------------------------------------------------------- |
| 146 | Portability : |
| 147 | |
| 148 | In the previous beta, a single FT_System object was used to encompass |
| 149 | all low-level operations like thread synchronisation, memory management |
| 150 | and i/o access. This has been greatly simplified : |
| 151 | |
| 152 | - thread synchronisation has been dropped, for the simple reason that |
| 153 | the library is already re-entrant, and that if you really need two |
| 154 | threads accessing the same FT_Library, you should really synchronize |
| 155 | access to it yourself with a simple mutex. |
| 156 | |
| 157 | - memory management is performed through a very simple object called |
| 158 | "FT_Memory", which really is a table containing a table of pointers |
| 159 | to functions like malloc, realloc and free as well as some user data |
| 160 | (closure). |
| 161 | |
| 162 | - resources have disappeared (they created more problems than they |
| 163 | solved), and i/o management have been simplified greatly as a |
| 164 | result. Streams are defined through FT_Stream objects, which can |
| 165 | be either memory-based or disk-based. |
| 166 | |
| 167 | Note that each face has its own stream, which is closed only when |
| 168 | the face object is destroyed. Hence, a function like TT_Flush_Face |
| 169 | in 1.x cannot be directly supported. However, if you really need |
| 170 | something like this, you can easily tailor your own streams to achieve |
| 171 | the same feature at a lower level (and use FT_Open_Face instead of |
| 172 | FT_New_Face to create the face). |
| 173 | |
| 174 | See the file "include/ftsystem.h" for more details, as well as the |
| 175 | implementations found in "config/unix" and "config/ansi". |
| 176 | |
| 177 | |
| 178 | ----------------------------------------------------------------------------------------- |
David Turner | 5951ce9 | 1999-12-29 00:53:44 +0000 | [diff] [blame^] | 179 | Font Drivers : |
| 180 | |
| 181 | |
| 182 | The Font Driver interface has been modified in order to support |
| 183 | extensions & versioning. |
| 184 | |
| 185 | |
| 186 | The list of the font drivers that are statically linked to the |
| 187 | library at compile time is managed through a new configuration file |
| 188 | called `config/<platform>/ftmodule.h'. |
| 189 | |
| 190 | This file is autogenerated when invoking `make modules'. This target |
| 191 | will parse all sub-directories of 'src', looking for a "module.mk" |
| 192 | rules file, used to describe the driver to the build system. |
| 193 | |
| 194 | Hence, one should call `make modules' each time a font driver is added |
| 195 | or removed from the `src' directory. |
| 196 | |
| 197 | |
| 198 | Finally, this version provides a "pseudo-driver" in `src/sfnt'. This |
| 199 | driver doesn't support font files directly, but provides services used |
| 200 | by all TrueType-like font drivers. Hence, its code is shared between |
| 201 | the TrueType & OpenType font formats, and possibly more formats to |
| 202 | come if we're lucky.. |
David Turner | d2b1f35 | 1999-12-16 23:11:37 +0000 | [diff] [blame] | 203 | |
| 204 | ----------------------------------------------------------------------------------------- |
| 205 | Extensions support : |
David Turner | 5951ce9 | 1999-12-29 00:53:44 +0000 | [diff] [blame^] | 206 | |
| 207 | The extensions support is inspired by the one found in 1.x. |
| 208 | |
| 209 | Now, each font driver has its own "extension registry", which lists |
| 210 | which extensions are available for the font faces managed by the driver. |
| 211 | |
| 212 | Extension ids are now strings, rather than 4-byte tags, as this is |
| 213 | usually more readable.. |
| 214 | |
| 215 | Each extension has: |
| 216 | - some data, associated to each face object |
| 217 | - an interface (table of function pointers) |
| 218 | |
| 219 | An extension that is format-specific should simply register itself |
| 220 | to the correct font driver. Here is some example code: |
| 221 | |
| 222 | // Registering an extensions |
| 223 | // |
| 224 | FT_Error FT_Init_XXXX_Extension( FT_Library library ) |
| 225 | { |
| 226 | FT_DriverInterface* tt_driver; |
| 227 | |
| 228 | driver = FT_Get_Driver( library, "truetype" ); |
| 229 | if (!driver) return FT_Err_Unimplemented_Feature; |
| 230 | |
| 231 | return FT_Register_Extension( driver, &extension_class ); |
| 232 | } |
| 233 | |
| 234 | |
| 235 | // Implementing the extensions |
| 236 | // |
| 237 | FT_Error FT_Proceed_Extension_XXX( FT_Face face ) |
| 238 | { |
| 239 | FT_XXX_Extension ext; |
| 240 | FT_XXX_Extension_Interface ext_interface; |
| 241 | |
| 242 | ext = FT_Get_Extension( face, "extensionid", &ext_interface ); |
| 243 | if (!ext) return error; |
| 244 | |
| 245 | return ext_interface->do_it(ext); |
| 246 | } |
David Turner | d2b1f35 | 1999-12-16 23:11:37 +0000 | [diff] [blame] | 247 | |