The FreeType engine is a free and portable TrueType font rendering engine. It has been developed to provide TT support to a great variety of platforms and environments. FreeType 2.4.0 has been released (2010-Jul-12) This is the first release of the 2.4 series. In addition to many bugfixes, the TrueType bytecode interpreter is now enabled by default. I'm having troubles with linking freetype 2 under linux using cmake when building a C11 project with an extern C library. With cmake and freetype 2 I basically have 2 options: use the utility freetype-config like freetype-config -libs; use the FindFreetype cmake module. By using the FreeType library we can create anti-aliased text that looks better than text made using bitmap fonts (as in Lesson 13). Our text will also have some other advantages over bitmap fonts - it will be easy to rotate and works well with OpenGL's picking functions. Jul 04, 2010 The design of FreeType 2 is based on modules that can be either linked statically to the library at compile time, or loaded on demand at runtime. Modules are used to support specific font formats, or even new glyph image formats! FreeType 2 was written with embedded systems in mind.
0.8
(perhaps pronounced oh'ghoul-foot)
Table of Contents
Introduction
This C++ library supplies an interface between the fonts on your system and an OpenGL or Mesa application. It uses the excellent FreeType library to read font faces from their files and renders text strings as OpenGL primitives.
OGLFT is hosted on SourceForge. If you have questions or comments, try out the OLGFT mailing list.
Important Note
Versions 2.0.9 through 2.1.2 of the FreeType library contain a bug which prevents rotated text from being displayed properly. OGLFT makes no attempt to work around this.
Freetype Library Not Found
Features
Here is an overview of the features of this library: Lam usb devices driver download.
- Characters can be rendered in several ways:
- Outlines extracted directly from vector font face data (the lines and curves in TrueType and Type1 formats)
- Tessellated, filled polygons
- Extruded solids (through the GLE Tubing and Extrusion library)
- Monochrome bitmaps
- Solid grayscale, antialiased pixmaps
- Translucent antialiased pixmaps
- As texture maps
- Glyphs can be drawn individually or as a string.
- If OGLFT is compiled with Qt support, glyphs can be rendered using UNICODE characters via the QString class.
- You can also combine several fonts together in one OGLFT Face in order to increase the coverage of UNICODE points or for other special effects.
- Strings can be rotated through any angle. Additionally each character in a string can be rotated through a given angle. Alternatively, each rendered string or individual character can have its own transformation matrix (or any other set of OpenGL operations which can be compiled into a display list).
- PHIGS-like capability to draw right, centered or left justified strings.
- Each rendered glyph is available as an OpenGL display list (although the application does not normally need to deal with this information). In the case of defining the glyphs as texture maps, a texture object is stored for each glyph.
- A face (i.e., all the glyphs in a face) can map a coloration and/or texture function to the coordinates of the glyphs.
- You can draw formatted numbers using the usual printf-style formats. There is also a special format (%p) which will draw the number as a fraction.
Examples
You draw text by creating a instance of a style object and then calling the draw()
function with the string to render.
This table describes the various possible styles in which text can be rendered.
Style | Description | Example |
Outline | The outline of the characters is rendered as a set of polylines. | |
Filled | The characters are rendered as tessellated polygons. | |
Solid | The characters are rendered as extruded solids using the GLE Extrusion and Tubing library. | |
Monochrome | The characters are rasterized in monochrome format by the FreeType library and drawn using glBitmap . | |
Grayscale | The characters are rasterized in antialiased format by the FreeType library and drawn with a solid background using glDrawPixels . | |
Translucent | The characters are rasterized in antialiased format by the FreeType library and drawn using glDrawPixels . The difference from Grayscale is that the antialiased grayscale levels are used as an alpha-mask so that glyphs can be properly blended into the background. | |
Texture | Each character is rasterized by the FreeType library. The raster image is then converted to alpha-masked texture map. You can pick either monochrome, grayscale or translucent textures. |
Each style has its advantages and disadvantages. This table tries to give you some guidance about which mode to pick.
Style | Advantages | Disadvantages | Typical Frame Rates (FPS) | |||||||||||||||||||||||||||||||||||||||
Outline | Relatively quick to draw. Easily manipulated by modeling transformations. | I can't really think of any particular use for it. Maybe for limning Filled characters? Doesn't work well at small sizes due to lack of drop-out control. |
| |||||||||||||||||||||||||||||||||||||||
Filled | Useful mostly for capping the solid. Easily manipulated by modeling transformations. Can make interesting use of texture maps. I also use this for printing. | Doesn't work well at small sizes due to lack of drop-out control. |
| |||||||||||||||||||||||||||||||||||||||
Solid | Make very fancy demonstrations of animated text! Easily manipulated by modeling transformations. | Lots of drawing involved, can be slow. Again, looks best at larger sizes. |
| |||||||||||||||||||||||||||||||||||||||
Monochrome | Fast. Looks best at small sizes. Works over any background pattern. | Limited to a single color. Limited transformations. |
| |||||||||||||||||||||||||||||||||||||||
Grayscale | Standard way to draw text which looks good independent of size. Only slightly slower than monochrome (unaccelerated, anyway). | Limited to single foreground and background color. Limited transformations. |
| |||||||||||||||||||||||||||||||||||||||
Translucent | Looks good at all sizes. Works over any background pattern. | Generally requires a reasonably accelerated alpha blending capability in OpenGL. Limited transformations. |
| |||||||||||||||||||||||||||||||||||||||
Texture | Combines the speed of a raster font with most of the modeling transformation capabilities of the vector styles. Looks better at small sizes than vector styles. | Generally requires a reasonably accelerated texture mapping capability in OpenGL. Maximum point size may be limited by texture map implementation. |
|
Freetype Library Download
Frame Rate Notes: FPS is Frames Per Second. These results were generated with the speedtest
program. The string 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' was drawn in each style in each of three modes:
- immediate drawing, which includes the FreeType rasterization and any OpenGL processing each time the glyph is rendered,
- with the glyph images cached as display lists as they are first encountered (the default drawing mode),
- with the whole string stored as a display list.
The most important result shown by the table (other than it helps to buy faster hardware) is that there is very little to be gained from compiling drawn strings into display lists. If it is convenient to do so, however, it won't reduce performance. Also, it appears that the textured drawing modes have the best all-around performance.
Demos
OGLFT currently comes with three demo programs. demo
draws a string in each of the supported styles. You can use the a/A, s/S, d/D keys to rotate the glyphs clockwise/counter-clockwise around each axis. f/F rotates the entire string. r resets all the faces back to their default orientation. Note that glyphs drawn in the raster styles are not rotated around the X and Y axes.
demo2
shows how to use a FreeType FT_Face structure that is already open. The demo requires a Multiple Master Type 1 font in order to work. A couple of multiple master fonts are available in Adobe's Acrobat Reader distribution if you want to check this out.
demo3
is a 1 minute animation showing most of the features in OGLFT. This demo requires the Qt toolkit.
Tutorial
One of the goals of this library is ease of use, so hopefully the tutorial will not have to be very long!
Basic Rendering
Here are the pieces of a complete GLUT application which renders a well-known string in the center of the window. (See the tutorial1.c
file.)
Note that no OpenGL calls are made when a face is constructed, so the initialization of monochrome
could have been done in main()
as well.
Drawing a string is very simple. Here is a typical GLUT display
routine.
Table of Contents
Introduction
This C++ library supplies an interface between the fonts on your system and an OpenGL or Mesa application. It uses the excellent FreeType library to read font faces from their files and renders text strings as OpenGL primitives.
OGLFT is hosted on SourceForge. If you have questions or comments, try out the OLGFT mailing list.
Important Note
Versions 2.0.9 through 2.1.2 of the FreeType library contain a bug which prevents rotated text from being displayed properly. OGLFT makes no attempt to work around this.
Freetype Library Not Found
Features
Here is an overview of the features of this library: Lam usb devices driver download.
- Characters can be rendered in several ways:
- Outlines extracted directly from vector font face data (the lines and curves in TrueType and Type1 formats)
- Tessellated, filled polygons
- Extruded solids (through the GLE Tubing and Extrusion library)
- Monochrome bitmaps
- Solid grayscale, antialiased pixmaps
- Translucent antialiased pixmaps
- As texture maps
- Glyphs can be drawn individually or as a string.
- If OGLFT is compiled with Qt support, glyphs can be rendered using UNICODE characters via the QString class.
- You can also combine several fonts together in one OGLFT Face in order to increase the coverage of UNICODE points or for other special effects.
- Strings can be rotated through any angle. Additionally each character in a string can be rotated through a given angle. Alternatively, each rendered string or individual character can have its own transformation matrix (or any other set of OpenGL operations which can be compiled into a display list).
- PHIGS-like capability to draw right, centered or left justified strings.
- Each rendered glyph is available as an OpenGL display list (although the application does not normally need to deal with this information). In the case of defining the glyphs as texture maps, a texture object is stored for each glyph.
- A face (i.e., all the glyphs in a face) can map a coloration and/or texture function to the coordinates of the glyphs.
- You can draw formatted numbers using the usual printf-style formats. There is also a special format (%p) which will draw the number as a fraction.
Examples
You draw text by creating a instance of a style object and then calling the draw()
function with the string to render.
This table describes the various possible styles in which text can be rendered.
Style | Description | Example |
Outline | The outline of the characters is rendered as a set of polylines. | |
Filled | The characters are rendered as tessellated polygons. | |
Solid | The characters are rendered as extruded solids using the GLE Extrusion and Tubing library. | |
Monochrome | The characters are rasterized in monochrome format by the FreeType library and drawn using glBitmap . | |
Grayscale | The characters are rasterized in antialiased format by the FreeType library and drawn with a solid background using glDrawPixels . | |
Translucent | The characters are rasterized in antialiased format by the FreeType library and drawn using glDrawPixels . The difference from Grayscale is that the antialiased grayscale levels are used as an alpha-mask so that glyphs can be properly blended into the background. | |
Texture | Each character is rasterized by the FreeType library. The raster image is then converted to alpha-masked texture map. You can pick either monochrome, grayscale or translucent textures. |
Each style has its advantages and disadvantages. This table tries to give you some guidance about which mode to pick.
Style | Advantages | Disadvantages | Typical Frame Rates (FPS) | |||||||||||||||||||||||||||||||||||||||
Outline | Relatively quick to draw. Easily manipulated by modeling transformations. | I can't really think of any particular use for it. Maybe for limning Filled characters? Doesn't work well at small sizes due to lack of drop-out control. |
| |||||||||||||||||||||||||||||||||||||||
Filled | Useful mostly for capping the solid. Easily manipulated by modeling transformations. Can make interesting use of texture maps. I also use this for printing. | Doesn't work well at small sizes due to lack of drop-out control. |
| |||||||||||||||||||||||||||||||||||||||
Solid | Make very fancy demonstrations of animated text! Easily manipulated by modeling transformations. | Lots of drawing involved, can be slow. Again, looks best at larger sizes. |
| |||||||||||||||||||||||||||||||||||||||
Monochrome | Fast. Looks best at small sizes. Works over any background pattern. | Limited to a single color. Limited transformations. |
| |||||||||||||||||||||||||||||||||||||||
Grayscale | Standard way to draw text which looks good independent of size. Only slightly slower than monochrome (unaccelerated, anyway). | Limited to single foreground and background color. Limited transformations. |
| |||||||||||||||||||||||||||||||||||||||
Translucent | Looks good at all sizes. Works over any background pattern. | Generally requires a reasonably accelerated alpha blending capability in OpenGL. Limited transformations. |
| |||||||||||||||||||||||||||||||||||||||
Texture | Combines the speed of a raster font with most of the modeling transformation capabilities of the vector styles. Looks better at small sizes than vector styles. | Generally requires a reasonably accelerated texture mapping capability in OpenGL. Maximum point size may be limited by texture map implementation. |
|
Freetype Library Download
Frame Rate Notes: FPS is Frames Per Second. These results were generated with the speedtest
program. The string 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' was drawn in each style in each of three modes:
- immediate drawing, which includes the FreeType rasterization and any OpenGL processing each time the glyph is rendered,
- with the glyph images cached as display lists as they are first encountered (the default drawing mode),
- with the whole string stored as a display list.
The most important result shown by the table (other than it helps to buy faster hardware) is that there is very little to be gained from compiling drawn strings into display lists. If it is convenient to do so, however, it won't reduce performance. Also, it appears that the textured drawing modes have the best all-around performance.
Demos
OGLFT currently comes with three demo programs. demo
draws a string in each of the supported styles. You can use the a/A, s/S, d/D keys to rotate the glyphs clockwise/counter-clockwise around each axis. f/F rotates the entire string. r resets all the faces back to their default orientation. Note that glyphs drawn in the raster styles are not rotated around the X and Y axes.
demo2
shows how to use a FreeType FT_Face structure that is already open. The demo requires a Multiple Master Type 1 font in order to work. A couple of multiple master fonts are available in Adobe's Acrobat Reader distribution if you want to check this out.
demo3
is a 1 minute animation showing most of the features in OGLFT. This demo requires the Qt toolkit.
Tutorial
One of the goals of this library is ease of use, so hopefully the tutorial will not have to be very long!
Basic Rendering
Here are the pieces of a complete GLUT application which renders a well-known string in the center of the window. (See the tutorial1.c
file.)
Note that no OpenGL calls are made when a face is constructed, so the initialization of monochrome
could have been done in main()
as well.
Drawing a string is very simple. Here is a typical GLUT display
routine.
This will display the string 'Hello, World!' in red about half way up the left side of the window.
Here is the remaining infrastructure of the GLUT program.
Simple Animation
Now let's make something with a little more life to it. We'll animate the text spinning around in the center of the window. The first modification is to add a periodic callback to the GLUT event loop. This is called the idle
routine. Change the last four lines of main()
to be (see tutorial2.c
):
The idle()
function does two things: it updates the angle that the text is rotated through and it tells GLUT to redraw the screen after idle()
exits.
Next we need to add a line to init()
to tell the Face to render the text with center justification; that way, the text will rotate about it's own center point.
Finally, it would look best of the text itself was centered in the window; so, we change the draw()
command to draw at the center of the window.
Fancy Animation
If you use the polygonal styles (Outline, Filled or Solid), you can supply the Face with your own OpenGL display list to execute before each glyph is rendered. To demonstrate this, we're going to set 'Hello, World!' adrift at sea by varying its baseline with a traveling sine function.
First, we need to construct a Solid face and develop the sequence of transformations to apply. Note that the Solid style looks best when it is lighted. Also, it will not look correct unless the depth test is enabled. So, both of these features are enabled in init()
as well. (See tutorial3.c
)
The redisplay routine first draws the string, which is relatively straight-forward. Then it draws the ocean; it uses the bounding box information to figure out the width of the text.
The reshape()
function is modified slightly to rotate the string out of the XY plane. Otherwise, it would look two-dimensional!
The animation routine does three things: it rotates the display lists in the face so the characters appear to move up and down, it tells GLUT to redraw the scene when the routine returns and it pauses briefly in order to slow down the animation.
Assignments
N-trig others driver download. Try out these modifications to the tutorial programs.
- Modify
tutorial3.cpp
so that it takes the string to display as a command line argument and appropriately computes the displacement transformations and the ocean size. - Modify the per character display lists so that the glyphs are simultaneously rotated such that they are always normal to the surface of the ocean.
To Do..
Here is a list of the things OGLFT doesn't do currently, sorted roughly in order of importance. Feel free to recommend additional functionality.
- Color and texture coordinate callback objects for Outline, Filled and Solid styles. (As of version 0.5, Outline has a color callback and Solid has color and texture coordinate callback objects.)
- OGLFT's use of GLE is very primitive, amounting to nothing more than block extrusion. In order to improve it, the library needs to know which contours of a glyph are interior and which are exterior. This information is not directly available from FreeType, but it can be computed. This would allow for making solid glyphs with bevels and rounds.
- A C interface.
- Implement rendering of bitmap faces.
- Spline trajectories for glyph baselines. Spline trajectories for glyph toplines.
Miscellaneous Programming Notes
Freetype Library Centos
If you feel so inclined as to look at the code, here are a few notes it might be helpful to know about in advance.
Style
Class member variables are suffixed with an _ to distinguish them from automatic variables and method arguments.
Glyph Decomposition
When FreeType decomposes (i.e., traverses) a vector face's glyph's outline, it does so as a series of callbacks to functions of the form moveTo, lineTo, conicTo, and cubicTo. Each of these functions is passed a single point in space and, if necessary, additional control point information. As the glyph's outline is traversed, the call to moveTo signals the start of an independent contour. Otherwise, there is no way to predict when a contour is going to terminate.
In generating the outline, filled and solid glyphs, the points on the contour are collected and passed to the various routines which generated OpenGL drawing commands (directly to glVertex3, to the GLU tessellation routines, and gleExtrusion, respectively). The GLU tessellation routines in particular are more efficient if the first and last points on the contours are not repeated. In the code, this is handled by buffering the point supplied to moveTo and only adding points for the lineTo and {arc}To calls.
Other Software
Miray scsi & raid devices driver download. Here are a couple of packages which you might find faster, easier to use or more robust.
- GLF: works with an internal format for vector fonts or with BMF formatted bitmap fonts. Lots of functionality.
Freetype Library In Linux
- GLTT: uses FreeType 1 to draw TrueType fonts with much the same functionality as this library.