freetype2/src/smooth/ftsmooth.c

464 lines
13 KiB
C
Raw Normal View History

/***************************************************************************/
/* */
/* ftsmooth.c */
/* */
/* Anti-aliasing renderer interface (body). */
/* */
2018-01-02 09:33:57 +01:00
/* Copyright 2000-2018 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. */
/* */
/***************************************************************************/
2000-12-08 17:17:16 +01:00
#include <ft2build.h>
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_OBJECTS_H
#include FT_OUTLINE_H
#include "ftsmooth.h"
#include "ftgrays.h"
Complete redesign of error codes. Please check ftmoderr.h for more details. * include/freetype/internal/cfferrs.h, include/freetype/internal/tterrors.h, include/freetype/internal/t1errors.h: Removed. Replaced with files local to the module. All extra error codes have been moved to `fterrors.h'. * src/sfnt/ttpost.h: Move error codes to `fterrors.h'. * src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h, src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h, src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h, src/smooth/ftsmerrs.h, src/truetype/tterrors.h, src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the error names for the module it belongs to. * include/freetype/ftmoderr.h: New file, defining the module error offsets. Its structure is similar to `fterrors.h'. * include/freetype/fterrors.h (FT_NOERRORDEF): New macro. (FT_ERRORDEF): Redefined to use module error offsets. All internal error codes are now public; unused error codes have been removed, some are new. * include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New macro. * include/freetype/config/ftoption.h (FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro. All other source files have been updated to use the new error codes; some already existing (internal) error codes local to a module have been renamed to give them the same name as in the base module. All make files have been updated to include the local error files. * src/cid/cidtokens.h: Replaced with... * src/cid/cidtoken.h: This file for 8+3 consistency. * src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
#include "ftsmerrs.h"
2000-12-08 17:17:16 +01:00
/* initialize renderer -- init its raster */
2001-06-28 01:25:46 +02:00
static FT_Error
ft_smooth_init( FT_Renderer render )
2000-06-28 01:18:39 +02:00
{
render->clazz->raster_class->raster_reset( render->raster, NULL, 0 );
2000-06-28 01:18:39 +02:00
return 0;
}
2000-06-28 01:18:39 +02:00
/* sets render-specific mode */
2001-06-28 01:25:46 +02:00
static FT_Error
ft_smooth_set_mode( FT_Renderer render,
FT_ULong mode_tag,
FT_Pointer data )
2000-06-28 01:18:39 +02:00
{
/* we simply pass it to the raster */
return render->clazz->raster_class->raster_set_mode( render->raster,
mode_tag,
data );
}
2000-06-28 01:18:39 +02:00
/* transform a given glyph image */
2001-06-28 01:25:46 +02:00
static FT_Error
ft_smooth_transform( FT_Renderer render,
FT_GlyphSlot slot,
const FT_Matrix* matrix,
const FT_Vector* delta )
2000-06-28 01:18:39 +02:00
{
FT_Error error = FT_Err_Ok;
if ( slot->format != render->glyph_format )
2000-06-28 01:18:39 +02:00
{
error = FT_THROW( Invalid_Argument );
2000-06-28 01:18:39 +02:00
goto Exit;
}
if ( matrix )
2000-06-28 01:18:39 +02:00
FT_Outline_Transform( &slot->outline, matrix );
if ( delta )
2000-06-28 01:18:39 +02:00
FT_Outline_Translate( &slot->outline, delta->x, delta->y );
2000-06-28 01:18:39 +02:00
Exit:
return error;
}
/* return the glyph's control box */
2001-06-28 01:25:46 +02:00
static void
ft_smooth_get_cbox( FT_Renderer render,
FT_GlyphSlot slot,
FT_BBox* cbox )
2000-06-28 01:18:39 +02:00
{
FT_ZERO( cbox );
2000-06-28 01:18:39 +02:00
if ( slot->format == render->glyph_format )
2000-06-28 01:18:39 +02:00
FT_Outline_Get_CBox( &slot->outline, cbox );
}
2000-06-28 01:18:39 +02:00
/* convert a slot's glyph image into a bitmap */
2001-06-28 01:25:46 +02:00
static FT_Error
ft_smooth_render_generic( FT_Renderer render,
FT_GlyphSlot slot,
FT_Render_Mode mode,
const FT_Vector* origin,
FT_Render_Mode required_mode )
2000-06-28 01:18:39 +02:00
{
FT_Error error = FT_Err_Ok;
FT_Outline* outline = &slot->outline;
FT_Bitmap* bitmap = &slot->bitmap;
FT_Memory memory = render->root.memory;
FT_Pos x_shift = 0;
FT_Pos y_shift = 0;
2016-12-25 22:55:25 +01:00
FT_Int hmul = ( mode == FT_RENDER_MODE_LCD );
FT_Int vmul = ( mode == FT_RENDER_MODE_LCD_V );
2000-06-28 01:18:39 +02:00
FT_Raster_Params params;
2000-06-28 01:18:39 +02:00
/* check glyph image format */
if ( slot->format != render->glyph_format )
2000-06-28 01:18:39 +02:00
{
error = FT_THROW( Invalid_Argument );
2000-06-28 01:18:39 +02:00
goto Exit;
}
2000-06-28 01:18:39 +02:00
/* check mode */
if ( mode != required_mode )
{
error = FT_THROW( Cannot_Render_Glyph );
goto Exit;
}
/* release old bitmap buffer */
if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
{
FT_FREE( bitmap->buffer );
slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
}
ft_glyphslot_preset_bitmap( slot, mode, origin );
/* allocate new one */
if ( FT_ALLOC_MULT( bitmap->buffer, bitmap->rows, bitmap->pitch ) )
2000-06-28 01:18:39 +02:00
goto Exit;
slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
x_shift = 64 * -slot->bitmap_left;
y_shift = 64 * -slot->bitmap_top;
if ( bitmap->pixel_mode == FT_PIXEL_MODE_LCD_V )
y_shift += 64 * (FT_Int)bitmap->rows / 3;
else
y_shift += 64 * (FT_Int)bitmap->rows;
if ( origin )
{
x_shift += origin->x;
y_shift += origin->y;
}
/* translate outline to render it into the bitmap */
if ( x_shift || y_shift )
FT_Outline_Translate( outline, x_shift, y_shift );
2000-06-28 01:18:39 +02:00
/* set up parameters */
params.target = bitmap;
params.source = outline;
params.flags = FT_RASTER_FLAG_AA;
CHANGES BETWEEN 2.2.1 and 2.2.2 I. IMPORTANT BUG FIXES - Various integer overflows have been fixed. - PFB fonts with MacOS resource fork weren't handled correctly on non-MacOS platforms. - The PCF font loarder has been seriously hardened against malformed font files. II. IMPORTANT CHANGES - the unpatented hinter is now part of the default build of the library, and we added code to automatically support "tricky" fonts that need it. what this means is that FreeType should "just work" with certain Asian fonts, like MingLiu, which cannot properly load without a bytecode interpreter, but fortunately do not use any of the patented bytecode opcodes. Note that the API didn't change, so you can still force unpatented hinting with a special parameter to FT_Open_Face as well. if you're an embedded systems developer, you might want to *disable* the feature to save code space by undefining TT_CONFIG_OPTION_UNPATENTED_HINTING in ftoption.h. - LCD-optimized rendering is now disabled in all default builds of the library, mainly due to patent reasons. For more information see: http://lists.gnu.org/archive/html/freetype/2006-09/msg00064.html a new configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING has been introduced in ftoption.h; manually define it in this file if you want to re-enable the feature. the change only affects the implementation, not the FreeType API. This means that clients don't need to be modified, because the library still generates LCD decimated bitmaps, but with the added constraint that R=G=B on each triplet. - Some computation bugs in the TrueType bytecode interpreter were found, which allow us to get rid of very subtle and rare differences we had with the Windows renderer. III. MISCELLANEOUS - TrueType glyph loading is now about 25% faster. - the anti-aliased rasterizer has been optimized and is now 15% to 25% percent faster than the previous one, depending on content - the Type 1 loader has been improved; as an example, it now skips over top-level dictionaries properly ======================================================================
2006-09-26 18:58:21 +02:00
#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
2006-09-26 23:55:44 +02:00
/* implode outline if needed */
{
FT_Vector* points = outline->points;
FT_Vector* points_end = points + outline->n_points;
FT_Vector* vec;
if ( hmul )
for ( vec = points; vec < points_end; vec++ )
vec->x *= 3;
if ( vmul )
for ( vec = points; vec < points_end; vec++ )
vec->y *= 3;
}
2000-06-28 01:18:39 +02:00
/* render outline into the bitmap */
error = render->raster_render( render->raster, &params );
/* deflate outline if needed */
{
FT_Vector* points = outline->points;
FT_Vector* points_end = points + outline->n_points;
FT_Vector* vec;
if ( hmul )
for ( vec = points; vec < points_end; vec++ )
vec->x /= 3;
if ( vmul )
for ( vec = points; vec < points_end; vec++ )
vec->y /= 3;
}
2006-09-26 23:55:44 +02:00
if ( error )
goto Exit;
/* finally apply filtering */
if ( hmul || vmul )
{
FT_Byte* lcd_weights;
FT_Bitmap_LcdFilterFunc lcd_filter_func;
/* Per-face LCD filtering takes priority if set up. */
if ( slot->face && slot->face->internal->lcd_filter_func )
{
lcd_weights = slot->face->internal->lcd_weights;
lcd_filter_func = slot->face->internal->lcd_filter_func;
}
else
{
lcd_weights = slot->library->lcd_weights;
lcd_filter_func = slot->library->lcd_filter_func;
}
if ( lcd_filter_func )
lcd_filter_func( bitmap, mode, lcd_weights );
}
CHANGES BETWEEN 2.2.1 and 2.2.2 I. IMPORTANT BUG FIXES - Various integer overflows have been fixed. - PFB fonts with MacOS resource fork weren't handled correctly on non-MacOS platforms. - The PCF font loarder has been seriously hardened against malformed font files. II. IMPORTANT CHANGES - the unpatented hinter is now part of the default build of the library, and we added code to automatically support "tricky" fonts that need it. what this means is that FreeType should "just work" with certain Asian fonts, like MingLiu, which cannot properly load without a bytecode interpreter, but fortunately do not use any of the patented bytecode opcodes. Note that the API didn't change, so you can still force unpatented hinting with a special parameter to FT_Open_Face as well. if you're an embedded systems developer, you might want to *disable* the feature to save code space by undefining TT_CONFIG_OPTION_UNPATENTED_HINTING in ftoption.h. - LCD-optimized rendering is now disabled in all default builds of the library, mainly due to patent reasons. For more information see: http://lists.gnu.org/archive/html/freetype/2006-09/msg00064.html a new configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING has been introduced in ftoption.h; manually define it in this file if you want to re-enable the feature. the change only affects the implementation, not the FreeType API. This means that clients don't need to be modified, because the library still generates LCD decimated bitmaps, but with the added constraint that R=G=B on each triplet. - Some computation bugs in the TrueType bytecode interpreter were found, which allow us to get rid of very subtle and rare differences we had with the Windows renderer. III. MISCELLANEOUS - TrueType glyph loading is now about 25% faster. - the anti-aliased rasterizer has been optimized and is now 15% to 25% percent faster than the previous one, depending on content - the Type 1 loader has been improved; as an example, it now skips over top-level dictionaries properly ======================================================================
2006-09-26 18:58:21 +02:00
#else /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
2006-09-26 23:55:44 +02:00
if ( hmul ) /* lcd */
CHANGES BETWEEN 2.2.1 and 2.2.2 I. IMPORTANT BUG FIXES - Various integer overflows have been fixed. - PFB fonts with MacOS resource fork weren't handled correctly on non-MacOS platforms. - The PCF font loarder has been seriously hardened against malformed font files. II. IMPORTANT CHANGES - the unpatented hinter is now part of the default build of the library, and we added code to automatically support "tricky" fonts that need it. what this means is that FreeType should "just work" with certain Asian fonts, like MingLiu, which cannot properly load without a bytecode interpreter, but fortunately do not use any of the patented bytecode opcodes. Note that the API didn't change, so you can still force unpatented hinting with a special parameter to FT_Open_Face as well. if you're an embedded systems developer, you might want to *disable* the feature to save code space by undefining TT_CONFIG_OPTION_UNPATENTED_HINTING in ftoption.h. - LCD-optimized rendering is now disabled in all default builds of the library, mainly due to patent reasons. For more information see: http://lists.gnu.org/archive/html/freetype/2006-09/msg00064.html a new configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING has been introduced in ftoption.h; manually define it in this file if you want to re-enable the feature. the change only affects the implementation, not the FreeType API. This means that clients don't need to be modified, because the library still generates LCD decimated bitmaps, but with the added constraint that R=G=B on each triplet. - Some computation bugs in the TrueType bytecode interpreter were found, which allow us to get rid of very subtle and rare differences we had with the Windows renderer. III. MISCELLANEOUS - TrueType glyph loading is now about 25% faster. - the anti-aliased rasterizer has been optimized and is now 15% to 25% percent faster than the previous one, depending on content - the Type 1 loader has been improved; as an example, it now skips over top-level dictionaries properly ======================================================================
2006-09-26 18:58:21 +02:00
{
FT_Byte* line;
FT_Byte* temp = NULL;
FT_UInt i, j;
CHANGES BETWEEN 2.2.1 and 2.2.2 I. IMPORTANT BUG FIXES - Various integer overflows have been fixed. - PFB fonts with MacOS resource fork weren't handled correctly on non-MacOS platforms. - The PCF font loarder has been seriously hardened against malformed font files. II. IMPORTANT CHANGES - the unpatented hinter is now part of the default build of the library, and we added code to automatically support "tricky" fonts that need it. what this means is that FreeType should "just work" with certain Asian fonts, like MingLiu, which cannot properly load without a bytecode interpreter, but fortunately do not use any of the patented bytecode opcodes. Note that the API didn't change, so you can still force unpatented hinting with a special parameter to FT_Open_Face as well. if you're an embedded systems developer, you might want to *disable* the feature to save code space by undefining TT_CONFIG_OPTION_UNPATENTED_HINTING in ftoption.h. - LCD-optimized rendering is now disabled in all default builds of the library, mainly due to patent reasons. For more information see: http://lists.gnu.org/archive/html/freetype/2006-09/msg00064.html a new configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING has been introduced in ftoption.h; manually define it in this file if you want to re-enable the feature. the change only affects the implementation, not the FreeType API. This means that clients don't need to be modified, because the library still generates LCD decimated bitmaps, but with the added constraint that R=G=B on each triplet. - Some computation bugs in the TrueType bytecode interpreter were found, which allow us to get rid of very subtle and rare differences we had with the Windows renderer. III. MISCELLANEOUS - TrueType glyph loading is now about 25% faster. - the anti-aliased rasterizer has been optimized and is now 15% to 25% percent faster than the previous one, depending on content - the Type 1 loader has been improved; as an example, it now skips over top-level dictionaries properly ======================================================================
2006-09-26 18:58:21 +02:00
2017-10-01 09:23:42 +02:00
unsigned int height = bitmap->rows;
unsigned int width = bitmap->width;
int pitch = bitmap->pitch;
/* Render 3 separate monochrome bitmaps, shifting the outline */
/* by 1/3 pixel. */
width /= 3;
2006-09-26 23:55:44 +02:00
bitmap->buffer += width;
CHANGES BETWEEN 2.2.1 and 2.2.2 I. IMPORTANT BUG FIXES - Various integer overflows have been fixed. - PFB fonts with MacOS resource fork weren't handled correctly on non-MacOS platforms. - The PCF font loarder has been seriously hardened against malformed font files. II. IMPORTANT CHANGES - the unpatented hinter is now part of the default build of the library, and we added code to automatically support "tricky" fonts that need it. what this means is that FreeType should "just work" with certain Asian fonts, like MingLiu, which cannot properly load without a bytecode interpreter, but fortunately do not use any of the patented bytecode opcodes. Note that the API didn't change, so you can still force unpatented hinting with a special parameter to FT_Open_Face as well. if you're an embedded systems developer, you might want to *disable* the feature to save code space by undefining TT_CONFIG_OPTION_UNPATENTED_HINTING in ftoption.h. - LCD-optimized rendering is now disabled in all default builds of the library, mainly due to patent reasons. For more information see: http://lists.gnu.org/archive/html/freetype/2006-09/msg00064.html a new configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING has been introduced in ftoption.h; manually define it in this file if you want to re-enable the feature. the change only affects the implementation, not the FreeType API. This means that clients don't need to be modified, because the library still generates LCD decimated bitmaps, but with the added constraint that R=G=B on each triplet. - Some computation bugs in the TrueType bytecode interpreter were found, which allow us to get rid of very subtle and rare differences we had with the Windows renderer. III. MISCELLANEOUS - TrueType glyph loading is now about 25% faster. - the anti-aliased rasterizer has been optimized and is now 15% to 25% percent faster than the previous one, depending on content - the Type 1 loader has been improved; as an example, it now skips over top-level dictionaries properly ======================================================================
2006-09-26 18:58:21 +02:00
error = render->raster_render( render->raster, &params );
if ( error )
goto Exit;
2006-09-26 23:55:44 +02:00
FT_Outline_Translate( outline, -21, 0 );
2017-10-01 09:23:42 +02:00
x_shift -= 21;
bitmap->buffer += width;
2006-09-26 23:55:44 +02:00
error = render->raster_render( render->raster, &params );
if ( error )
goto Exit;
CHANGES BETWEEN 2.2.1 and 2.2.2 I. IMPORTANT BUG FIXES - Various integer overflows have been fixed. - PFB fonts with MacOS resource fork weren't handled correctly on non-MacOS platforms. - The PCF font loarder has been seriously hardened against malformed font files. II. IMPORTANT CHANGES - the unpatented hinter is now part of the default build of the library, and we added code to automatically support "tricky" fonts that need it. what this means is that FreeType should "just work" with certain Asian fonts, like MingLiu, which cannot properly load without a bytecode interpreter, but fortunately do not use any of the patented bytecode opcodes. Note that the API didn't change, so you can still force unpatented hinting with a special parameter to FT_Open_Face as well. if you're an embedded systems developer, you might want to *disable* the feature to save code space by undefining TT_CONFIG_OPTION_UNPATENTED_HINTING in ftoption.h. - LCD-optimized rendering is now disabled in all default builds of the library, mainly due to patent reasons. For more information see: http://lists.gnu.org/archive/html/freetype/2006-09/msg00064.html a new configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING has been introduced in ftoption.h; manually define it in this file if you want to re-enable the feature. the change only affects the implementation, not the FreeType API. This means that clients don't need to be modified, because the library still generates LCD decimated bitmaps, but with the added constraint that R=G=B on each triplet. - Some computation bugs in the TrueType bytecode interpreter were found, which allow us to get rid of very subtle and rare differences we had with the Windows renderer. III. MISCELLANEOUS - TrueType glyph loading is now about 25% faster. - the anti-aliased rasterizer has been optimized and is now 15% to 25% percent faster than the previous one, depending on content - the Type 1 loader has been improved; as an example, it now skips over top-level dictionaries properly ======================================================================
2006-09-26 18:58:21 +02:00
FT_Outline_Translate( outline, 42, 0 );
2017-10-01 09:23:42 +02:00
x_shift += 42;
bitmap->buffer -= 2 * width;
error = render->raster_render( render->raster, &params );
if ( error )
goto Exit;
/* XXX: Rearrange the bytes according to FT_PIXEL_MODE_LCD. */
/* XXX: It is more efficient to render every third byte above. */
if ( FT_ALLOC( temp, (FT_ULong)pitch ) )
goto Exit;
for ( i = 0; i < height; i++ )
{
line = bitmap->buffer + i * (FT_ULong)pitch;
for ( j = 0; j < width; j++ )
{
temp[3 * j ] = line[j];
temp[3 * j + 1] = line[j + width];
temp[3 * j + 2] = line[j + width + width];
CHANGES BETWEEN 2.2.1 and 2.2.2 I. IMPORTANT BUG FIXES - Various integer overflows have been fixed. - PFB fonts with MacOS resource fork weren't handled correctly on non-MacOS platforms. - The PCF font loarder has been seriously hardened against malformed font files. II. IMPORTANT CHANGES - the unpatented hinter is now part of the default build of the library, and we added code to automatically support "tricky" fonts that need it. what this means is that FreeType should "just work" with certain Asian fonts, like MingLiu, which cannot properly load without a bytecode interpreter, but fortunately do not use any of the patented bytecode opcodes. Note that the API didn't change, so you can still force unpatented hinting with a special parameter to FT_Open_Face as well. if you're an embedded systems developer, you might want to *disable* the feature to save code space by undefining TT_CONFIG_OPTION_UNPATENTED_HINTING in ftoption.h. - LCD-optimized rendering is now disabled in all default builds of the library, mainly due to patent reasons. For more information see: http://lists.gnu.org/archive/html/freetype/2006-09/msg00064.html a new configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING has been introduced in ftoption.h; manually define it in this file if you want to re-enable the feature. the change only affects the implementation, not the FreeType API. This means that clients don't need to be modified, because the library still generates LCD decimated bitmaps, but with the added constraint that R=G=B on each triplet. - Some computation bugs in the TrueType bytecode interpreter were found, which allow us to get rid of very subtle and rare differences we had with the Windows renderer. III. MISCELLANEOUS - TrueType glyph loading is now about 25% faster. - the anti-aliased rasterizer has been optimized and is now 15% to 25% percent faster than the previous one, depending on content - the Type 1 loader has been improved; as an example, it now skips over top-level dictionaries properly ======================================================================
2006-09-26 18:58:21 +02:00
}
FT_MEM_COPY( line, temp, pitch );
CHANGES BETWEEN 2.2.1 and 2.2.2 I. IMPORTANT BUG FIXES - Various integer overflows have been fixed. - PFB fonts with MacOS resource fork weren't handled correctly on non-MacOS platforms. - The PCF font loarder has been seriously hardened against malformed font files. II. IMPORTANT CHANGES - the unpatented hinter is now part of the default build of the library, and we added code to automatically support "tricky" fonts that need it. what this means is that FreeType should "just work" with certain Asian fonts, like MingLiu, which cannot properly load without a bytecode interpreter, but fortunately do not use any of the patented bytecode opcodes. Note that the API didn't change, so you can still force unpatented hinting with a special parameter to FT_Open_Face as well. if you're an embedded systems developer, you might want to *disable* the feature to save code space by undefining TT_CONFIG_OPTION_UNPATENTED_HINTING in ftoption.h. - LCD-optimized rendering is now disabled in all default builds of the library, mainly due to patent reasons. For more information see: http://lists.gnu.org/archive/html/freetype/2006-09/msg00064.html a new configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING has been introduced in ftoption.h; manually define it in this file if you want to re-enable the feature. the change only affects the implementation, not the FreeType API. This means that clients don't need to be modified, because the library still generates LCD decimated bitmaps, but with the added constraint that R=G=B on each triplet. - Some computation bugs in the TrueType bytecode interpreter were found, which allow us to get rid of very subtle and rare differences we had with the Windows renderer. III. MISCELLANEOUS - TrueType glyph loading is now about 25% faster. - the anti-aliased rasterizer has been optimized and is now 15% to 25% percent faster than the previous one, depending on content - the Type 1 loader has been improved; as an example, it now skips over top-level dictionaries properly ======================================================================
2006-09-26 18:58:21 +02:00
}
FT_FREE( temp );
}
else if ( vmul ) /* lcd_v */
CHANGES BETWEEN 2.2.1 and 2.2.2 I. IMPORTANT BUG FIXES - Various integer overflows have been fixed. - PFB fonts with MacOS resource fork weren't handled correctly on non-MacOS platforms. - The PCF font loarder has been seriously hardened against malformed font files. II. IMPORTANT CHANGES - the unpatented hinter is now part of the default build of the library, and we added code to automatically support "tricky" fonts that need it. what this means is that FreeType should "just work" with certain Asian fonts, like MingLiu, which cannot properly load without a bytecode interpreter, but fortunately do not use any of the patented bytecode opcodes. Note that the API didn't change, so you can still force unpatented hinting with a special parameter to FT_Open_Face as well. if you're an embedded systems developer, you might want to *disable* the feature to save code space by undefining TT_CONFIG_OPTION_UNPATENTED_HINTING in ftoption.h. - LCD-optimized rendering is now disabled in all default builds of the library, mainly due to patent reasons. For more information see: http://lists.gnu.org/archive/html/freetype/2006-09/msg00064.html a new configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING has been introduced in ftoption.h; manually define it in this file if you want to re-enable the feature. the change only affects the implementation, not the FreeType API. This means that clients don't need to be modified, because the library still generates LCD decimated bitmaps, but with the added constraint that R=G=B on each triplet. - Some computation bugs in the TrueType bytecode interpreter were found, which allow us to get rid of very subtle and rare differences we had with the Windows renderer. III. MISCELLANEOUS - TrueType glyph loading is now about 25% faster. - the anti-aliased rasterizer has been optimized and is now 15% to 25% percent faster than the previous one, depending on content - the Type 1 loader has been improved; as an example, it now skips over top-level dictionaries properly ======================================================================
2006-09-26 18:58:21 +02:00
{
2017-10-01 09:23:42 +02:00
int pitch = bitmap->pitch;
/* Render 3 separate monochrome bitmaps, shifting the outline */
/* by 1/3 pixel. Triple the pitch to render on each third row. */
bitmap->pitch *= 3;
bitmap->rows /= 3;
2006-09-26 23:55:44 +02:00
bitmap->buffer += pitch;
CHANGES BETWEEN 2.2.1 and 2.2.2 I. IMPORTANT BUG FIXES - Various integer overflows have been fixed. - PFB fonts with MacOS resource fork weren't handled correctly on non-MacOS platforms. - The PCF font loarder has been seriously hardened against malformed font files. II. IMPORTANT CHANGES - the unpatented hinter is now part of the default build of the library, and we added code to automatically support "tricky" fonts that need it. what this means is that FreeType should "just work" with certain Asian fonts, like MingLiu, which cannot properly load without a bytecode interpreter, but fortunately do not use any of the patented bytecode opcodes. Note that the API didn't change, so you can still force unpatented hinting with a special parameter to FT_Open_Face as well. if you're an embedded systems developer, you might want to *disable* the feature to save code space by undefining TT_CONFIG_OPTION_UNPATENTED_HINTING in ftoption.h. - LCD-optimized rendering is now disabled in all default builds of the library, mainly due to patent reasons. For more information see: http://lists.gnu.org/archive/html/freetype/2006-09/msg00064.html a new configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING has been introduced in ftoption.h; manually define it in this file if you want to re-enable the feature. the change only affects the implementation, not the FreeType API. This means that clients don't need to be modified, because the library still generates LCD decimated bitmaps, but with the added constraint that R=G=B on each triplet. - Some computation bugs in the TrueType bytecode interpreter were found, which allow us to get rid of very subtle and rare differences we had with the Windows renderer. III. MISCELLANEOUS - TrueType glyph loading is now about 25% faster. - the anti-aliased rasterizer has been optimized and is now 15% to 25% percent faster than the previous one, depending on content - the Type 1 loader has been improved; as an example, it now skips over top-level dictionaries properly ======================================================================
2006-09-26 18:58:21 +02:00
error = render->raster_render( render->raster, &params );
if ( error )
goto Exit;
CHANGES BETWEEN 2.2.1 and 2.2.2 I. IMPORTANT BUG FIXES - Various integer overflows have been fixed. - PFB fonts with MacOS resource fork weren't handled correctly on non-MacOS platforms. - The PCF font loarder has been seriously hardened against malformed font files. II. IMPORTANT CHANGES - the unpatented hinter is now part of the default build of the library, and we added code to automatically support "tricky" fonts that need it. what this means is that FreeType should "just work" with certain Asian fonts, like MingLiu, which cannot properly load without a bytecode interpreter, but fortunately do not use any of the patented bytecode opcodes. Note that the API didn't change, so you can still force unpatented hinting with a special parameter to FT_Open_Face as well. if you're an embedded systems developer, you might want to *disable* the feature to save code space by undefining TT_CONFIG_OPTION_UNPATENTED_HINTING in ftoption.h. - LCD-optimized rendering is now disabled in all default builds of the library, mainly due to patent reasons. For more information see: http://lists.gnu.org/archive/html/freetype/2006-09/msg00064.html a new configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING has been introduced in ftoption.h; manually define it in this file if you want to re-enable the feature. the change only affects the implementation, not the FreeType API. This means that clients don't need to be modified, because the library still generates LCD decimated bitmaps, but with the added constraint that R=G=B on each triplet. - Some computation bugs in the TrueType bytecode interpreter were found, which allow us to get rid of very subtle and rare differences we had with the Windows renderer. III. MISCELLANEOUS - TrueType glyph loading is now about 25% faster. - the anti-aliased rasterizer has been optimized and is now 15% to 25% percent faster than the previous one, depending on content - the Type 1 loader has been improved; as an example, it now skips over top-level dictionaries properly ======================================================================
2006-09-26 18:58:21 +02:00
FT_Outline_Translate( outline, 0, 21 );
2017-10-01 09:23:42 +02:00
y_shift += 21;
bitmap->buffer += pitch;
2006-09-26 23:55:44 +02:00
error = render->raster_render( render->raster, &params );
if ( error )
goto Exit;
FT_Outline_Translate( outline, 0, -42 );
2017-10-01 09:23:42 +02:00
y_shift -= 42;
bitmap->buffer -= 2 * pitch;
error = render->raster_render( render->raster, &params );
if ( error )
goto Exit;
bitmap->pitch /= 3;
bitmap->rows *= 3;
}
else /* grayscale */
error = render->raster_render( render->raster, &params );
CHANGES BETWEEN 2.2.1 and 2.2.2 I. IMPORTANT BUG FIXES - Various integer overflows have been fixed. - PFB fonts with MacOS resource fork weren't handled correctly on non-MacOS platforms. - The PCF font loarder has been seriously hardened against malformed font files. II. IMPORTANT CHANGES - the unpatented hinter is now part of the default build of the library, and we added code to automatically support "tricky" fonts that need it. what this means is that FreeType should "just work" with certain Asian fonts, like MingLiu, which cannot properly load without a bytecode interpreter, but fortunately do not use any of the patented bytecode opcodes. Note that the API didn't change, so you can still force unpatented hinting with a special parameter to FT_Open_Face as well. if you're an embedded systems developer, you might want to *disable* the feature to save code space by undefining TT_CONFIG_OPTION_UNPATENTED_HINTING in ftoption.h. - LCD-optimized rendering is now disabled in all default builds of the library, mainly due to patent reasons. For more information see: http://lists.gnu.org/archive/html/freetype/2006-09/msg00064.html a new configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING has been introduced in ftoption.h; manually define it in this file if you want to re-enable the feature. the change only affects the implementation, not the FreeType API. This means that clients don't need to be modified, because the library still generates LCD decimated bitmaps, but with the added constraint that R=G=B on each triplet. - Some computation bugs in the TrueType bytecode interpreter were found, which allow us to get rid of very subtle and rare differences we had with the Windows renderer. III. MISCELLANEOUS - TrueType glyph loading is now about 25% faster. - the anti-aliased rasterizer has been optimized and is now 15% to 25% percent faster than the previous one, depending on content - the Type 1 loader has been improved; as an example, it now skips over top-level dictionaries properly ======================================================================
2006-09-26 18:58:21 +02:00
#endif /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
2000-06-28 01:18:39 +02:00
Exit:
if ( !error )
2017-10-01 09:23:42 +02:00
{
/* everything is fine; the glyph is now officially a bitmap */
slot->format = FT_GLYPH_FORMAT_BITMAP;
2017-10-01 09:23:42 +02:00
}
else if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
{
FT_FREE( bitmap->buffer );
slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
}
if ( x_shift || y_shift )
FT_Outline_Translate( outline, -x_shift, -y_shift );
2000-06-28 01:18:39 +02:00
return error;
}
/* convert a slot's glyph image into a bitmap */
static FT_Error
ft_smooth_render( FT_Renderer render,
FT_GlyphSlot slot,
FT_Render_Mode mode,
const FT_Vector* origin )
{
if ( mode == FT_RENDER_MODE_LIGHT )
mode = FT_RENDER_MODE_NORMAL;
return ft_smooth_render_generic( render, slot, mode, origin,
FT_RENDER_MODE_NORMAL );
}
/* convert a slot's glyph image into a horizontal LCD bitmap */
static FT_Error
ft_smooth_render_lcd( FT_Renderer render,
FT_GlyphSlot slot,
FT_Render_Mode mode,
const FT_Vector* origin )
{
return ft_smooth_render_generic( render, slot, mode, origin,
FT_RENDER_MODE_LCD );
}
/* convert a slot's glyph image into a vertical LCD bitmap */
static FT_Error
ft_smooth_render_lcd_v( FT_Renderer render,
FT_GlyphSlot slot,
FT_Render_Mode mode,
const FT_Vector* origin )
{
return ft_smooth_render_generic( render, slot, mode, origin,
FT_RENDER_MODE_LCD_V );
}
FT_DEFINE_RENDERER(
ft_smooth_renderer_class,
2009-04-05 17:14:04 +02:00
FT_MODULE_RENDERER,
2011-11-30 10:46:53 +01:00
sizeof ( FT_RendererRec ),
2000-06-28 01:18:39 +02:00
"smooth",
0x10000L,
0x20000L,
NULL, /* module specific interface */
(FT_Module_Constructor)ft_smooth_init, /* module_init */
(FT_Module_Destructor) NULL, /* module_done */
(FT_Module_Requester) NULL, /* get_interface */
2000-06-28 01:18:39 +02:00
FT_GLYPH_FORMAT_OUTLINE,
(FT_Renderer_RenderFunc) ft_smooth_render, /* render_glyph */
(FT_Renderer_TransformFunc)ft_smooth_transform, /* transform_glyph */
(FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox, /* get_glyph_cbox */
(FT_Renderer_SetModeFunc) ft_smooth_set_mode, /* set_mode */
(FT_Raster_Funcs*)&ft_grays_raster /* raster_class */
2009-04-05 17:14:04 +02:00
)
FT_DEFINE_RENDERER(
ft_smooth_lcd_renderer_class,
2012-01-16 18:00:24 +01:00
FT_MODULE_RENDERER,
2011-11-30 10:46:53 +01:00
sizeof ( FT_RendererRec ),
"smooth-lcd",
0x10000L,
0x20000L,
NULL, /* module specific interface */
(FT_Module_Constructor)ft_smooth_init, /* module_init */
(FT_Module_Destructor) NULL, /* module_done */
(FT_Module_Requester) NULL, /* get_interface */
FT_GLYPH_FORMAT_OUTLINE,
(FT_Renderer_RenderFunc) ft_smooth_render_lcd, /* render_glyph */
(FT_Renderer_TransformFunc)ft_smooth_transform, /* transform_glyph */
(FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox, /* get_glyph_cbox */
(FT_Renderer_SetModeFunc) ft_smooth_set_mode, /* set_mode */
(FT_Raster_Funcs*)&ft_grays_raster /* raster_class */
2009-04-05 17:14:04 +02:00
)
FT_DEFINE_RENDERER(
ft_smooth_lcdv_renderer_class,
FT_MODULE_RENDERER,
2011-11-30 10:46:53 +01:00
sizeof ( FT_RendererRec ),
"smooth-lcdv",
0x10000L,
0x20000L,
NULL, /* module specific interface */
(FT_Module_Constructor)ft_smooth_init, /* module_init */
(FT_Module_Destructor) NULL, /* module_done */
(FT_Module_Requester) NULL, /* get_interface */
FT_GLYPH_FORMAT_OUTLINE,
(FT_Renderer_RenderFunc) ft_smooth_render_lcd_v, /* render_glyph */
(FT_Renderer_TransformFunc)ft_smooth_transform, /* transform_glyph */
(FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox, /* get_glyph_cbox */
(FT_Renderer_SetModeFunc) ft_smooth_set_mode, /* set_mode */
(FT_Raster_Funcs*)&ft_grays_raster /* raster_class */
2009-04-05 17:14:04 +02:00
)
2000-06-28 01:18:39 +02:00
/* END */