From 7d2e40ca923194278cfd4571c692bfa53935ccfc Mon Sep 17 00:00:00 2001
From: Werner Lemberg
No directly, as FreeType is a font library, not a general purpose
- graphics library or text rendering service. However, note that the
+ Not directly, as FreeType is a font library, not a general purpose
+ graphics library or text rendering service. However, note that the
anti-aliased renderer allows you to convert a vectorial glyph outline
- into a list of "spans" (i.e. horizontal pixel segments with same coverage)
- that can be rendered through user-provided callbacks.
- IV.1 Can I use FreeType to draw text on a pixmap with arbitratry depth ?
+ IV.1 Can I use FreeType to draw text on a pixmap with arbitratry depth?
-
By providing the appropriate span callback, you can render anti-aliased - text to any kind of surface. You can also use any color or fill - pattern/image if you want to. This process is called - direct rendering. For more information, please read the - documentation contained in the following files:
+By providing the appropriate span callback, you can render + anti-aliased text to any kind of surface. You can also use any color or + fill pattern/image if you want to. This process is called direct + rendering. For more information, please read the documentation + contained in the following files:
-- <freetype/ftimage.h> contains the definition - of the FT_Raster_Params type used with direct rendering. -
- <freetype/ftoutln.h> contains the definition - of the FT_Outline_Render function that can be used to - convert vectorial outlines to span lists. -
<freetype/ftimage.h> contains the definition of + the FT_Raster_Params type used with direct rendering.
+<freetype/ftoutln.h> contains the definition of + the FT_Outline_Render() function that can be used to + convert vectorial outlines to span lists.
+Here's some code that uses them:
-+- -Here's some code that uses them:
+ ++ FT_Raster_Params params; + FT_Outline outline; + + + ... load vectorial glyph in "outline" ... + + params.flags = ft_raster_flag_aa | ft_raster_flag_direct; + params.gray_spans = (FT_Raster_Span_Func)your_own_span_function_here; + params.user = your_own_data_pointer; + + error = FT_Outline_Render( library, &outline, ¶ms );+ - FT_Raster_Params params; - FT_Outline outline; - - .. load vectorial glyph in "outline" - - params.flags = ft_raster_flag_aa | ft_raster_flag_direct; - params.gray_spans = (FT_Raster_Span_Func)your_own_span_function_here; - params.user = your_own_data_pointer; - - error = FT_Outline_Render( library, &outline, ¶ms ); -
Note that direct rendering is not available with monochrome - output, as the current renderer uses a two-pass algorithm to generate - glyphs with correct drop-out control.
+Note that direct rendering is not available with monochrome + output, as the current renderer uses a two-pass algorithm to generate + glyphs with correct drop-out control.
Basically, you can't do that, because FreeType is simply a font - library. In general, you'll need to use your favorite graphics library - to draw the FreeType glyphs with the appropriate color.
+ library. In general, you will need to use your favorite graphics + library to draw the FreeType glyphs with the appropriate color.Note that for anti-aliased glyphs, you can "set the color" by using direct rendering as described in this - answer
- + answer.A lot of people have a hard time understanding this topic, because - they think of glyphs as fixed-width/height "cells", like those of - fonts used in terminals/consoles. This assumption is simply not valid - with most "modern" font formats, even bitmapped-based ones like - PCF or BDF.
+A lot of people have difficulties to understand this topic, because + they think of glyphs as fixed-width resp. fixed-height "cells", like + those of fonts used in terminals/consoles. This assumption is simply + not valid with most "modern" font formats, even bitmapped-based ones + like PCF or BDF.
Be aware that the character size that is set either through - FT_Set_Char_Size or FT_Set_Pixel_Sizes isn't directly - related to the dimension of the glyph bitmaps generated.
+ FT_Set_Char_Size() or FT_Set_Pixel_Sizes() isn't + directly related to the dimension of the glyph bitmaps generated. -Rather, the character size is indeed the size of - an abstract square, called the EM, used by typographers - to design fonts. Scaling two distinct fonts to the same character size, be - it expressed in points or pixels, will generally result in bitmaps with - distinct dimensions !
+Rather, the character size is indeed the size of an abstract + square, called the EM, used by typographers to design + fonts. Scaling two distinct fonts to the same character size, be it + expressed in points or pixels, will generally result in bitmaps with + distinct dimensions!
Note that historically, the EM corresponded to the width of a capital - "M" in Latin typefaces. However, later improvements in typography led to - the designs that greatly detract from this rule. Today, it is not possible - to connect the EM size to a specific font "feature" in a reliable way.
+ "M" in Latin typefaces. However, later improvements in typography led + to designs that greatly detract from this rule. Today, it is not + possible to connect the EM size to a specific font "feature" in a + reliable way.A lot of people want to be able to compute the size in pixels of a simple - string of text with minimal overhead. For example, that can be useful to - draw centered text within a button.
- - +A lot of people want to be able to compute the size in pixels of a + simple string of text with minimal overhead. For example, that can be + useful to draw centered text within a button. (to be continued...)
+ +The algorithm has been specifically designed for FreeType. It is based on ideas that were originally found in the implementation of the @@ -699,7 +698,7 @@
Well, the engine already reads OpenType/CFF files perfectly. What it @@ -707,7 +706,7 @@
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 "ftstrtto" to show its capabilities.
+ named ftstrtto to show its capabilities.For FreeType 2, we have decided that the layout operations provided through these tables are better placed in a specific