freetype2/src/smooth/ftsmooth.c

535 lines
14 KiB
C
Raw Normal View History

/***************************************************************************/
/* */
/* ftsmooth.c */
/* */
/* Anti-aliasing renderer interface (body). */
/* */
/* Copyright 2000-2006, 2009-2013 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"
2009-04-05 17:14:04 +02:00
#include "ftspic.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
{
FT_Library library = FT_MODULE_LIBRARY( render );
2000-06-28 01:18:39 +02:00
render->clazz->raster_class->raster_reset( render->raster,
library->raster_pool,
library->raster_pool_size );
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_MEM_ZERO( cbox, sizeof ( *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_Outline* outline = NULL;
2000-06-28 01:18:39 +02:00
FT_BBox cbox;
FT_Pos width, height, pitch;
#ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
FT_Pos height_org, width_org;
#endif
FT_Bitmap* bitmap = &slot->bitmap;
FT_Memory memory = render->root.memory;
FT_Int hmul = mode == FT_RENDER_MODE_LCD;
FT_Int vmul = mode == FT_RENDER_MODE_LCD_V;
FT_Pos x_shift = 0;
FT_Pos y_shift = 0;
FT_Pos x_left, y_top;
2000-06-28 01:18:39 +02:00
FT_Raster_Params params;
FT_Bool have_translated_origin = FALSE;
FT_Bool have_outline_shifted = FALSE;
FT_Bool have_buffer = FALSE;
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;
}
2000-06-28 01:18:39 +02:00
outline = &slot->outline;
2000-06-28 01:18:39 +02:00
/* translate the outline to the new origin if needed */
if ( origin )
{
2000-06-28 01:18:39 +02:00
FT_Outline_Translate( outline, origin->x, origin->y );
have_translated_origin = TRUE;
}
2000-06-28 01:18:39 +02:00
/* compute the control box, and grid fit it */
FT_Outline_Get_CBox( outline, &cbox );
cbox.xMin = FT_PIX_FLOOR( cbox.xMin );
cbox.yMin = FT_PIX_FLOOR( cbox.yMin );
cbox.xMax = FT_PIX_CEIL( cbox.xMax );
cbox.yMax = FT_PIX_CEIL( cbox.yMax );
2000-06-28 01:18:39 +02:00
if ( cbox.xMin < 0 && cbox.xMax > FT_INT_MAX + cbox.xMin )
{
FT_ERROR(( "ft_smooth_render_generic: glyph too large:"
" xMin = %d, xMax = %d\n",
cbox.xMin >> 6, cbox.xMax >> 6 ));
error = FT_THROW( Raster_Overflow );
goto Exit;
}
else
width = ( cbox.xMax - cbox.xMin ) >> 6;
if ( cbox.yMin < 0 && cbox.yMax > FT_INT_MAX + cbox.yMin )
{
FT_ERROR(( "ft_smooth_render_generic: glyph too large:"
" yMin = %d, yMax = %d\n",
cbox.yMin >> 6, cbox.yMax >> 6 ));
error = FT_THROW( Raster_Overflow );
goto Exit;
}
else
height = ( cbox.yMax - cbox.yMin ) >> 6;
#ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
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
width_org = width;
height_org = height;
#endif
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
2000-06-28 01:18:39 +02:00
/* release old bitmap buffer */
if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
2000-06-28 01:18:39 +02:00
{
FT_FREE( bitmap->buffer );
slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
2000-06-28 01:18:39 +02:00
}
/* allocate new one */
2000-06-28 01:18:39 +02:00
pitch = width;
if ( hmul )
{
width = width * 3;
pitch = FT_PAD_CEIL( width, 4 );
}
if ( vmul )
height *= 3;
x_shift = (FT_Int) cbox.xMin;
y_shift = (FT_Int) cbox.yMin;
x_left = (FT_Int)( cbox.xMin >> 6 );
y_top = (FT_Int)( cbox.yMax >> 6 );
#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
2006-09-29 23:31:53 +02:00
if ( slot->library->lcd_filter_func )
{
FT_Int extra = slot->library->lcd_extra;
2006-11-14 11:37:10 +01:00
if ( hmul )
{
2006-11-14 11:37:10 +01:00
x_shift -= 64 * ( extra >> 1 );
width += 3 * extra;
pitch = FT_PAD_CEIL( width, 4 );
2006-11-14 11:37:10 +01:00
x_left -= extra >> 1;
}
2006-11-14 11:37:10 +01:00
if ( vmul )
{
2006-11-14 11:37:10 +01:00
y_shift -= 64 * ( extra >> 1 );
height += 3 * extra;
y_top += extra >> 1;
}
}
2006-09-29 23:31:53 +02:00
#endif
#if FT_UINT_MAX > 0xFFFFU
/* Required check is (pitch * height < FT_ULONG_MAX), */
/* but we care realistic cases only. Always pitch <= width. */
if ( width > 0x7FFF || height > 0x7FFF )
{
FT_ERROR(( "ft_smooth_render_generic: glyph too large: %u x %u\n",
width, height ));
error = FT_THROW( Raster_Overflow );
goto Exit;
}
#endif
bitmap->pixel_mode = FT_PIXEL_MODE_GRAY;
2000-06-28 01:18:39 +02:00
bitmap->num_grays = 256;
bitmap->width = width;
bitmap->rows = height;
bitmap->pitch = pitch;
/* translate outline to render it into the bitmap */
FT_Outline_Translate( outline, -x_shift, -y_shift );
have_outline_shifted = TRUE;
if ( FT_ALLOC( bitmap->buffer, (FT_ULong)pitch * height ) )
2000-06-28 01:18:39 +02:00
goto Exit;
else
have_buffer = TRUE;
2000-06-28 01:18:39 +02:00
slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
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;
if ( slot->library->lcd_filter_func )
slot->library->lcd_filter_func( bitmap, mode, slot->library );
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
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
/* render outline into bitmap */
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
/* expand it horizontally */
if ( hmul )
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 = bitmap->buffer;
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_UInt hh;
2006-09-26 23:55:44 +02:00
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
for ( hh = height_org; hh > 0; hh--, line += pitch )
{
FT_UInt xx;
FT_Byte* end = line + width;
2006-09-26 23:55:44 +02:00
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
for ( xx = width_org; xx > 0; xx-- )
{
FT_UInt pixel = line[xx-1];
2006-09-26 23:55:44 +02:00
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
end[-3] = (FT_Byte)pixel;
end[-2] = (FT_Byte)pixel;
end[-1] = (FT_Byte)pixel;
end -= 3;
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
}
}
}
/* expand it vertically */
if ( vmul )
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
{
2006-09-26 23:55:44 +02:00
FT_Byte* read = bitmap->buffer + ( height - height_org ) * pitch;
FT_Byte* write = bitmap->buffer;
FT_UInt hh;
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
for ( hh = height_org; hh > 0; hh-- )
{
ft_memcpy( write, read, pitch );
write += 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_memcpy( write, read, pitch );
write += pitch;
2006-09-26 23:55:44 +02:00
ft_memcpy( write, read, pitch );
write += pitch;
read += 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
}
}
#endif /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
/*
* XXX: on 16bit system, we return an error for huge bitmap
* to prevent an overflow.
*/
if ( x_left > FT_INT_MAX || y_top > FT_INT_MAX )
{
error = FT_THROW( Invalid_Pixel_Size );
goto Exit;
}
slot->format = FT_GLYPH_FORMAT_BITMAP;
slot->bitmap_left = (FT_Int)x_left;
slot->bitmap_top = (FT_Int)y_top;
2000-06-28 01:18:39 +02:00
/* everything is fine; don't deallocate buffer */
have_buffer = FALSE;
error = FT_Err_Ok;
2000-06-28 01:18:39 +02:00
Exit:
if ( have_outline_shifted )
FT_Outline_Translate( outline, x_shift, y_shift );
if ( have_translated_origin )
FT_Outline_Translate( outline, -origin->x, -origin->y );
if ( have_buffer )
{
FT_FREE( bitmap->buffer );
slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
}
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 )
{
FT_Error error;
error = ft_smooth_render_generic( render, slot, mode, origin,
FT_RENDER_MODE_LCD );
if ( !error )
slot->bitmap.pixel_mode = FT_PIXEL_MODE_LCD;
return error;
}
/* 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 )
{
FT_Error error;
error = ft_smooth_render_generic( render, slot, mode, origin,
FT_RENDER_MODE_LCD_V );
if ( !error )
slot->bitmap.pixel_mode = FT_PIXEL_MODE_LCD_V;
return error;
}
2011-11-30 10:46:53 +01:00
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,
2000-06-28 01:18:39 +02:00
0, /* module specific interface */
(FT_Module_Constructor)ft_smooth_init,
(FT_Module_Destructor) 0,
(FT_Module_Requester) 0
2009-04-05 17:14:04 +02:00
,
2000-06-28 01:18:39 +02:00
FT_GLYPH_FORMAT_OUTLINE,
(FT_Renderer_RenderFunc) ft_smooth_render,
(FT_Renderer_TransformFunc)ft_smooth_transform,
(FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox,
(FT_Renderer_SetModeFunc) ft_smooth_set_mode,
2009-04-05 17:14:04 +02:00
(FT_Raster_Funcs*) &FT_GRAYS_RASTER_GET
)
2011-11-30 10:46:53 +01: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,
0, /* module specific interface */
(FT_Module_Constructor)ft_smooth_init,
(FT_Module_Destructor) 0,
(FT_Module_Requester) 0
2009-04-05 17:14:04 +02:00
,
FT_GLYPH_FORMAT_OUTLINE,
(FT_Renderer_RenderFunc) ft_smooth_render_lcd,
(FT_Renderer_TransformFunc)ft_smooth_transform,
(FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox,
(FT_Renderer_SetModeFunc) ft_smooth_set_mode,
2009-04-05 17:14:04 +02:00
(FT_Raster_Funcs*) &FT_GRAYS_RASTER_GET
)
2011-11-30 10:46:53 +01: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,
0, /* module specific interface */
(FT_Module_Constructor)ft_smooth_init,
(FT_Module_Destructor) 0,
(FT_Module_Requester) 0
2009-04-05 17:14:04 +02:00
,
FT_GLYPH_FORMAT_OUTLINE,
(FT_Renderer_RenderFunc) ft_smooth_render_lcd_v,
(FT_Renderer_TransformFunc)ft_smooth_transform,
(FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox,
(FT_Renderer_SetModeFunc) ft_smooth_set_mode,
2009-04-05 17:14:04 +02:00
(FT_Raster_Funcs*) &FT_GRAYS_RASTER_GET
)
2000-06-28 01:18:39 +02:00
/* END */