< prev index next >

src/java.desktop/share/native/libfreetype/src/base/ftobjs.c

Print this page

        

*** 1,21 **** ! /***************************************************************************/ ! /* */ ! /* ftobjs.c */ ! /* */ ! /* The FreeType private base classes (body). */ ! /* */ ! /* Copyright 1996-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. */ ! /* */ ! /***************************************************************************/ #include <ft2build.h> #include FT_LIST_H #include FT_OUTLINE_H --- 1,21 ---- ! /**************************************************************************** ! * ! * ftobjs.c ! * ! * The FreeType private base classes (body). ! * ! * Copyright (C) 1996-2019 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. ! * ! */ #include <ft2build.h> #include FT_LIST_H #include FT_OUTLINE_H
*** 77,86 **** --- 77,98 ---- #if defined( _MSC_VER ) #pragma warning( pop ) #endif + static const char* const pixel_modes[] = + { + "none", + "monochrome bitmap", + "gray 8-bit bitmap", + "gray 2-bit bitmap", + "gray 4-bit bitmap", + "LCD 8-bit bitmap", + "vertical LCD 8-bit bitmap", + "BGRA 32-bit color image bitmap" + }; + #endif /* FT_DEBUG_LEVEL_TRACE */ #define GRID_FIT_METRICS
*** 257,274 **** FT_FREE( stream ); } } ! /*************************************************************************/ ! /* */ ! /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ ! /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ ! /* messages during execution. */ ! /* */ #undef FT_COMPONENT ! #define FT_COMPONENT trace_objs /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ --- 269,286 ---- FT_FREE( stream ); } } ! /************************************************************************** ! * ! * The macro FT_COMPONENT is used in trace mode. It is an implicit ! * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log ! * messages during execution. ! */ #undef FT_COMPONENT ! #define FT_COMPONENT objs /*************************************************************************/ /*************************************************************************/ /*************************************************************************/
*** 328,356 **** slot->bitmap.buffer = NULL; } } ! FT_BASE_DEF( void ) ft_glyphslot_preset_bitmap( FT_GlyphSlot slot, FT_Render_Mode mode, const FT_Vector* origin ) { FT_Outline* outline = &slot->outline; FT_Bitmap* bitmap = &slot->bitmap; FT_Pixel_Mode pixel_mode; ! FT_BBox cbox; FT_Pos x_shift = 0; FT_Pos y_shift = 0; FT_Pos x_left, y_top; FT_Pos width, height, pitch; ! if ( slot->internal && ( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) ) ! return; if ( origin ) { x_shift = origin->x; y_shift = origin->y; --- 340,370 ---- slot->bitmap.buffer = NULL; } } ! /* overflow-resistant presetting of bitmap position and dimensions; */ ! /* also check whether the size is too large for rendering */ ! FT_BASE_DEF( FT_Bool ) ft_glyphslot_preset_bitmap( FT_GlyphSlot slot, FT_Render_Mode mode, const FT_Vector* origin ) { FT_Outline* outline = &slot->outline; FT_Bitmap* bitmap = &slot->bitmap; FT_Pixel_Mode pixel_mode; ! FT_BBox cbox, pbox; FT_Pos x_shift = 0; FT_Pos y_shift = 0; FT_Pos x_left, y_top; FT_Pos width, height, pitch; ! if ( slot->format != FT_GLYPH_FORMAT_OUTLINE ) ! return 1; if ( origin ) { x_shift = origin->x; y_shift = origin->y;
*** 358,437 **** /* compute the control box, and grid-fit it, */ /* taking into account the origin shift */ FT_Outline_Get_CBox( outline, &cbox ); ! cbox.xMin += x_shift; ! cbox.yMin += y_shift; ! cbox.xMax += x_shift; ! cbox.yMax += y_shift; switch ( mode ) { case FT_RENDER_MODE_MONO: pixel_mode = FT_PIXEL_MODE_MONO; #if 1 ! /* undocumented but confirmed: bbox values get rounded */ ! /* unless the rounded box can collapse for a narrow glyph */ ! if ( cbox.xMax - cbox.xMin < 64 ) { ! cbox.xMin = FT_PIX_FLOOR( cbox.xMin ); ! cbox.xMax = FT_PIX_CEIL_LONG( cbox.xMax ); ! } else ! { ! cbox.xMin = FT_PIX_ROUND_LONG( cbox.xMin ); ! cbox.xMax = FT_PIX_ROUND_LONG( cbox.xMax ); } ! if ( cbox.yMax - cbox.yMin < 64 ) { ! cbox.yMin = FT_PIX_FLOOR( cbox.yMin ); ! cbox.yMax = FT_PIX_CEIL_LONG( cbox.yMax ); ! } else ! { ! cbox.yMin = FT_PIX_ROUND_LONG( cbox.yMin ); ! cbox.yMax = FT_PIX_ROUND_LONG( cbox.yMax ); } #else ! cbox.xMin = FT_PIX_FLOOR( cbox.xMin ); ! cbox.yMin = FT_PIX_FLOOR( cbox.yMin ); ! cbox.xMax = FT_PIX_CEIL_LONG( cbox.xMax ); ! cbox.yMax = FT_PIX_CEIL_LONG( cbox.yMax ); #endif - break; case FT_RENDER_MODE_LCD: pixel_mode = FT_PIXEL_MODE_LCD; ! ft_lcd_padding( &cbox.xMin, &cbox.xMax, slot ); ! goto Round; case FT_RENDER_MODE_LCD_V: pixel_mode = FT_PIXEL_MODE_LCD_V; ! ft_lcd_padding( &cbox.yMin, &cbox.yMax, slot ); ! goto Round; case FT_RENDER_MODE_NORMAL: case FT_RENDER_MODE_LIGHT: default: pixel_mode = FT_PIXEL_MODE_GRAY; ! Round: ! cbox.xMin = FT_PIX_FLOOR( cbox.xMin ); ! cbox.yMin = FT_PIX_FLOOR( cbox.yMin ); ! cbox.xMax = FT_PIX_CEIL_LONG( cbox.xMax ); ! cbox.yMax = FT_PIX_CEIL_LONG( cbox.yMax ); } ! x_shift = SUB_LONG( x_shift, cbox.xMin ); ! y_shift = SUB_LONG( y_shift, cbox.yMin ); ! ! x_left = cbox.xMin >> 6; ! y_top = cbox.yMax >> 6; ! width = ( (FT_ULong)cbox.xMax - (FT_ULong)cbox.xMin ) >> 6; ! height = ( (FT_ULong)cbox.yMax - (FT_ULong)cbox.yMin ) >> 6; switch ( pixel_mode ) { case FT_PIXEL_MODE_MONO: pitch = ( ( width + 15 ) >> 4 ) << 1; --- 372,464 ---- /* compute the control box, and grid-fit it, */ /* taking into account the origin shift */ FT_Outline_Get_CBox( outline, &cbox ); ! /* rough estimate of pixel box */ ! pbox.xMin = ( cbox.xMin >> 6 ) + ( x_shift >> 6 ); ! pbox.yMin = ( cbox.yMin >> 6 ) + ( y_shift >> 6 ); ! pbox.xMax = ( cbox.xMax >> 6 ) + ( x_shift >> 6 ); ! pbox.yMax = ( cbox.yMax >> 6 ) + ( y_shift >> 6 ); ! ! /* tiny remainder box */ ! cbox.xMin = ( cbox.xMin & 63 ) + ( x_shift & 63 ); ! cbox.yMin = ( cbox.yMin & 63 ) + ( y_shift & 63 ); ! cbox.xMax = ( cbox.xMax & 63 ) + ( x_shift & 63 ); ! cbox.yMax = ( cbox.yMax & 63 ) + ( y_shift & 63 ); switch ( mode ) { case FT_RENDER_MODE_MONO: pixel_mode = FT_PIXEL_MODE_MONO; #if 1 ! /* x */ ! ! /* undocumented but confirmed: bbox values get rounded; */ ! /* we do asymmetric rounding so that the center of a pixel */ ! /* gets always included */ ! ! pbox.xMin += ( cbox.xMin + 31 ) >> 6; ! pbox.xMax += ( cbox.xMax + 32 ) >> 6; ! ! /* if the bbox collapsed, we add a pixel based on the total */ ! /* rounding remainder to cover most of the original cbox */ ! ! if ( pbox.xMin == pbox.xMax ) { ! if ( ( ( cbox.xMin + 31 ) & 63 ) - 31 + ! ( ( cbox.xMax + 32 ) & 63 ) - 32 < 0 ) ! pbox.xMin -= 1; else ! pbox.xMax += 1; } ! /* y */ ! ! pbox.yMin += ( cbox.yMin + 31 ) >> 6; ! pbox.yMax += ( cbox.yMax + 32 ) >> 6; ! ! if ( pbox.yMin == pbox.yMax ) { ! if ( ( ( cbox.yMin + 31 ) & 63 ) - 31 + ! ( ( cbox.yMax + 32 ) & 63 ) - 32 < 0 ) ! pbox.yMin -= 1; else ! pbox.yMax += 1; } + + break; #else ! goto Adjust; #endif case FT_RENDER_MODE_LCD: pixel_mode = FT_PIXEL_MODE_LCD; ! ft_lcd_padding( &cbox, slot, mode ); ! goto Adjust; case FT_RENDER_MODE_LCD_V: pixel_mode = FT_PIXEL_MODE_LCD_V; ! ft_lcd_padding( &cbox, slot, mode ); ! goto Adjust; case FT_RENDER_MODE_NORMAL: case FT_RENDER_MODE_LIGHT: default: pixel_mode = FT_PIXEL_MODE_GRAY; ! Adjust: ! pbox.xMin += cbox.xMin >> 6; ! pbox.yMin += cbox.yMin >> 6; ! pbox.xMax += ( cbox.xMax + 63 ) >> 6; ! pbox.yMax += ( cbox.yMax + 63 ) >> 6; } ! x_left = pbox.xMin; ! y_top = pbox.yMax; ! width = pbox.xMax - pbox.xMin; ! height = pbox.yMax - pbox.yMin; switch ( pixel_mode ) { case FT_PIXEL_MODE_MONO: pitch = ( ( width + 15 ) >> 4 ) << 1;
*** 457,466 **** --- 484,503 ---- bitmap->pixel_mode = (unsigned char)pixel_mode; bitmap->num_grays = 256; bitmap->width = (unsigned int)width; bitmap->rows = (unsigned int)height; bitmap->pitch = pitch; + + if ( pbox.xMin < -0x8000 || pbox.xMax > 0x7FFF || + pbox.yMin < -0x8000 || pbox.yMax > 0x7FFF ) + { + FT_TRACE3(( "ft_glyphslot_preset_bitmap: [%ld %ld %ld %ld]\n", + pbox.xMin, pbox.yMin, pbox.xMax, pbox.yMax )); + return 1; + } + + return 0; } FT_BASE_DEF( void ) ft_glyphslot_set_bitmap( FT_GlyphSlot slot,
*** 805,815 **** * The general rules are: * * - Do only auto-hinting if we have * * - a hinter module, ! * - a scalable font format dealing with outlines, * - not a tricky font, and * - no transforms except simple slants and/or rotations by * integer multiples of 90 degrees. * * - Then, auto-hint if FT_LOAD_FORCE_AUTOHINT is set or if we don't --- 842,852 ---- * The general rules are: * * - Do only auto-hinting if we have * * - a hinter module, ! * - a scalable font, * - not a tricky font, and * - no transforms except simple slants and/or rotations by * integer multiples of 90 degrees. * * - Then, auto-hint if FT_LOAD_FORCE_AUTOHINT is set or if we don't
*** 823,834 **** */ if ( hinter && !( load_flags & FT_LOAD_NO_HINTING ) && !( load_flags & FT_LOAD_NO_AUTOHINT ) && ! FT_DRIVER_IS_SCALABLE( driver ) && ! FT_DRIVER_USES_OUTLINES( driver ) && !FT_IS_TRICKY( face ) && ( ( load_flags & FT_LOAD_IGNORE_TRANSFORM ) || ( face->internal->transform_matrix.yx == 0 && face->internal->transform_matrix.xx != 0 ) || ( face->internal->transform_matrix.xx == 0 && --- 860,870 ---- */ if ( hinter && !( load_flags & FT_LOAD_NO_HINTING ) && !( load_flags & FT_LOAD_NO_AUTOHINT ) && ! FT_IS_SCALABLE( face ) && !FT_IS_TRICKY( face ) && ( ( load_flags & FT_LOAD_IGNORE_TRANSFORM ) || ( face->internal->transform_matrix.yx == 0 && face->internal->transform_matrix.xx != 0 ) || ( face->internal->transform_matrix.xx == 0 &&
*** 924,934 **** if ( error ) goto Exit; #ifdef GRID_FIT_METRICS if ( !( load_flags & FT_LOAD_NO_HINTING ) ) ! ft_glyphslot_grid_fit_metrics( slot, FT_BOOL( load_flags & FT_LOAD_VERTICAL_LAYOUT ) ); #endif } } --- 960,971 ---- if ( error ) goto Exit; #ifdef GRID_FIT_METRICS if ( !( load_flags & FT_LOAD_NO_HINTING ) ) ! ft_glyphslot_grid_fit_metrics( ! slot, FT_BOOL( load_flags & FT_LOAD_VERTICAL_LAYOUT ) ); #endif } }
*** 993,1002 **** --- 1030,1042 ---- /* transform advance */ FT_Vector_Transform( &slot->advance, &internal->transform_matrix ); } } + slot->glyph_index = glyph_index; + slot->internal->load_flags = load_flags; + /* do we need to render the image or preset the bitmap now? */ if ( !error && ( load_flags & FT_LOAD_NO_SCALE ) == 0 && slot->format != FT_GLYPH_FORMAT_BITMAP && slot->format != FT_GLYPH_FORMAT_COMPOSITE )
*** 1012,1032 **** error = FT_Render_Glyph( slot, mode ); else ft_glyphslot_preset_bitmap( slot, mode, NULL ); } ! FT_TRACE5(( "FT_Load_Glyph: index %d, flags %x\n", glyph_index, load_flags )); FT_TRACE5(( " x advance: %f\n", slot->advance.x / 64.0 )); FT_TRACE5(( " y advance: %f\n", slot->advance.y / 64.0 )); FT_TRACE5(( " linear x advance: %f\n", slot->linearHoriAdvance / 65536.0 )); FT_TRACE5(( " linear y advance: %f\n", slot->linearVertAdvance / 65536.0 )); ! FT_TRACE5(( " bitmap %dx%d, mode %d\n", ! slot->bitmap.width, slot->bitmap.rows, slot->bitmap.pixel_mode )); Exit: return error; } --- 1052,1076 ---- error = FT_Render_Glyph( slot, mode ); else ft_glyphslot_preset_bitmap( slot, mode, NULL ); } ! #ifdef FT_DEBUG_LEVEL_TRACE ! FT_TRACE5(( "FT_Load_Glyph: index %d, flags 0x%x\n", glyph_index, load_flags )); FT_TRACE5(( " x advance: %f\n", slot->advance.x / 64.0 )); FT_TRACE5(( " y advance: %f\n", slot->advance.y / 64.0 )); FT_TRACE5(( " linear x advance: %f\n", slot->linearHoriAdvance / 65536.0 )); FT_TRACE5(( " linear y advance: %f\n", slot->linearVertAdvance / 65536.0 )); ! FT_TRACE5(( " bitmap %dx%d, %s (mode %d)\n", ! slot->bitmap.width, ! slot->bitmap.rows, ! pixel_modes[slot->bitmap.pixel_mode], slot->bitmap.pixel_mode )); + #endif Exit: return error; }
*** 1160,1183 **** driver->root.memory, driver ); } ! /*************************************************************************/ ! /* */ ! /* <Function> */ ! /* find_unicode_charmap */ ! /* */ ! /* <Description> */ ! /* This function finds a Unicode charmap, if there is one. */ ! /* And if there is more than one, it tries to favour the more */ ! /* extensive one, i.e., one that supports UCS-4 against those which */ ! /* are limited to the BMP (said UCS-2 encoding.) */ ! /* */ ! /* This function is called from open_face() (just below), and also */ ! /* from FT_Select_Charmap( ..., FT_ENCODING_UNICODE ). */ ! /* */ static FT_Error find_unicode_charmap( FT_Face face ) { FT_CharMap* first; FT_CharMap* cur; --- 1204,1227 ---- driver->root.memory, driver ); } ! /************************************************************************** ! * ! * @Function: ! * find_unicode_charmap ! * ! * @Description: ! * This function finds a Unicode charmap, if there is one. ! * And if there is more than one, it tries to favour the more ! * extensive one, i.e., one that supports UCS-4 against those which ! * are limited to the BMP (said UCS-2 encoding.) ! * ! * This function is called from open_face() (just below), and also ! * from FT_Select_Charmap( ..., FT_ENCODING_UNICODE ). ! */ static FT_Error find_unicode_charmap( FT_Face face ) { FT_CharMap* first; FT_CharMap* cur;
*** 1253,1271 **** return FT_THROW( Invalid_CharMap_Handle ); } ! /*************************************************************************/ ! /* */ ! /* <Function> */ ! /* find_variant_selector_charmap */ ! /* */ ! /* <Description> */ ! /* This function finds the variant selector charmap, if there is one. */ ! /* There can only be one (platform=0, specific=5, format=14). */ ! /* */ static FT_CharMap find_variant_selector_charmap( FT_Face face ) { FT_CharMap* first; FT_CharMap* end; --- 1297,1315 ---- return FT_THROW( Invalid_CharMap_Handle ); } ! /************************************************************************** ! * ! * @Function: ! * find_variant_selector_charmap ! * ! * @Description: ! * This function finds the variant selector charmap, if there is one. ! * There can only be one (platform=0, specific=5, format=14). ! */ static FT_CharMap find_variant_selector_charmap( FT_Face face ) { FT_CharMap* first; FT_CharMap* end;
*** 1292,1309 **** return NULL; } ! /*************************************************************************/ ! /* */ ! /* <Function> */ ! /* open_face */ ! /* */ ! /* <Description> */ ! /* This function does some work for FT_Open_Face(). */ ! /* */ static FT_Error open_face( FT_Driver driver, FT_Stream *astream, FT_Bool external_stream, FT_Long face_index, --- 1336,1353 ---- return NULL; } ! /************************************************************************** ! * ! * @Function: ! * open_face ! * ! * @Description: ! * This function does some work for FT_Open_Face(). ! */ static FT_Error open_face( FT_Driver driver, FT_Stream *astream, FT_Bool external_stream, FT_Long face_index,
*** 2174,2190 **** FT_Face *aface, const FT_Open_Args *args ) { #undef FT_COMPONENT ! #define FT_COMPONENT trace_raccess FT_Memory memory = library->memory; FT_Error error = FT_ERR( Unknown_File_Format ); FT_UInt i; ! char * file_names[FT_RACCESS_N_RULES]; FT_Long offsets[FT_RACCESS_N_RULES]; FT_Error errors[FT_RACCESS_N_RULES]; FT_Bool is_darwin_vfs, vfs_rfork_has_no_font = FALSE; /* not tested */ FT_Open_Args args2; --- 2218,2234 ---- FT_Face *aface, const FT_Open_Args *args ) { #undef FT_COMPONENT ! #define FT_COMPONENT raccess FT_Memory memory = library->memory; FT_Error error = FT_ERR( Unknown_File_Format ); FT_UInt i; ! char* file_names[FT_RACCESS_N_RULES]; FT_Long offsets[FT_RACCESS_N_RULES]; FT_Error errors[FT_RACCESS_N_RULES]; FT_Bool is_darwin_vfs, vfs_rfork_has_no_font = FALSE; /* not tested */ FT_Open_Args args2;
*** 2252,2262 **** error = FT_ERR( Unknown_File_Format ); return error; #undef FT_COMPONENT ! #define FT_COMPONENT trace_objs } /* Check for some macintosh formats without Carbon framework. */ --- 2296,2306 ---- error = FT_ERR( Unknown_File_Format ); return error; #undef FT_COMPONENT ! #define FT_COMPONENT objs } /* Check for some macintosh formats without Carbon framework. */
*** 2280,2290 **** error = IsMacBinary( library, stream, face_index, aface ); if ( FT_ERR_EQ( error, Unknown_File_Format ) ) { #undef FT_COMPONENT ! #define FT_COMPONENT trace_raccess #ifdef FT_DEBUG_LEVEL_TRACE FT_TRACE3(( "Try as dfont: " )); if ( !( args->flags & FT_OPEN_MEMORY ) ) FT_TRACE3(( "%s ...", args->pathname )); --- 2324,2334 ---- error = IsMacBinary( library, stream, face_index, aface ); if ( FT_ERR_EQ( error, Unknown_File_Format ) ) { #undef FT_COMPONENT ! #define FT_COMPONENT raccess #ifdef FT_DEBUG_LEVEL_TRACE FT_TRACE3(( "Try as dfont: " )); if ( !( args->flags & FT_OPEN_MEMORY ) ) FT_TRACE3(( "%s ...", args->pathname ));
*** 2293,2303 **** error = IsMacResource( library, stream, 0, face_index, aface ); FT_TRACE3(( "%s\n", error ? "failed" : "successful" )); #undef FT_COMPONENT ! #define FT_COMPONENT trace_objs } if ( ( FT_ERR_EQ( error, Unknown_File_Format ) || FT_ERR_EQ( error, Invalid_Stream_Operation ) ) && --- 2337,2347 ---- error = IsMacResource( library, stream, 0, face_index, aface ); FT_TRACE3(( "%s\n", error ? "failed" : "successful" )); #undef FT_COMPONENT ! #define FT_COMPONENT objs } if ( ( FT_ERR_EQ( error, Unknown_File_Format ) || FT_ERR_EQ( error, Invalid_Stream_Operation ) ) &&
*** 2691,2701 **** if ( clazz->attach_file ) error = clazz->attach_file( face, stream ); /* close the attached stream */ FT_Stream_Free( stream, ! (FT_Bool)( parameters->stream && ( parameters->flags & FT_OPEN_STREAM ) ) ); Exit: return error; } --- 2735,2745 ---- if ( clazz->attach_file ) error = clazz->attach_file( face, stream ); /* close the attached stream */ FT_Stream_Free( stream, ! FT_BOOL( parameters->stream && ( parameters->flags & FT_OPEN_STREAM ) ) ); Exit: return error; }
*** 3462,3472 **** if ( !face ) return FT_THROW( Invalid_Face_Handle ); ! if ( encoding == FT_ENCODING_NONE ) return FT_THROW( Invalid_Argument ); /* FT_ENCODING_UNICODE is special. We try to find the `best' Unicode */ /* charmap available, i.e., one with UCS-4 characters, if possible. */ /* */ --- 3506,3517 ---- if ( !face ) return FT_THROW( Invalid_Face_Handle ); ! /* FT_ENCODING_NONE is a valid encoding for BDF, PCF, and Windows FNT */ ! if ( encoding == FT_ENCODING_NONE && !face->num_charmaps ) return FT_THROW( Invalid_Argument ); /* FT_ENCODING_UNICODE is special. We try to find the `best' Unicode */ /* charmap available, i.e., one with UCS-4 characters, if possible. */ /* */
*** 3483,3493 **** for ( ; cur < limit; cur++ ) { if ( cur[0]->encoding == encoding ) { face->charmap = cur[0]; ! return 0; } } return FT_THROW( Invalid_Argument ); } --- 3528,3538 ---- for ( ; cur < limit; cur++ ) { if ( cur[0]->encoding == encoding ) { face->charmap = cur[0]; ! return FT_Err_Ok; } } return FT_THROW( Invalid_Argument ); }
*** 3508,3525 **** cur = face->charmaps; if ( !cur || !charmap ) return FT_THROW( Invalid_CharMap_Handle ); - if ( FT_Get_CMap_Format( charmap ) == 14 ) - return FT_THROW( Invalid_Argument ); - limit = cur + face->num_charmaps; for ( ; cur < limit; cur++ ) { ! if ( cur[0] == charmap ) { face->charmap = cur[0]; return FT_Err_Ok; } } --- 3553,3568 ---- cur = face->charmaps; if ( !cur || !charmap ) return FT_THROW( Invalid_CharMap_Handle ); limit = cur + face->num_charmaps; for ( ; cur < limit; cur++ ) { ! if ( cur[0] == charmap && ! FT_Get_CMap_Format ( charmap ) != 14 ) { face->charmap = cur[0]; return FT_Err_Ok; } }
*** 4485,4504 **** FT_Render_Glyph_Internal( FT_Library library, FT_GlyphSlot slot, FT_Render_Mode render_mode ) { FT_Error error = FT_Err_Ok; FT_Renderer renderer; - /* if it is already a bitmap, no need to do anything */ switch ( slot->format ) { case FT_GLYPH_FORMAT_BITMAP: /* already a bitmap, don't do anything */ break; default: { FT_ListNode node = NULL; /* small shortcut for the very common case */ --- 4528,4620 ---- FT_Render_Glyph_Internal( FT_Library library, FT_GlyphSlot slot, FT_Render_Mode render_mode ) { FT_Error error = FT_Err_Ok; + FT_Face face = slot->face; FT_Renderer renderer; switch ( slot->format ) { case FT_GLYPH_FORMAT_BITMAP: /* already a bitmap, don't do anything */ break; default: + if ( slot->internal->load_flags & FT_LOAD_COLOR ) + { + FT_LayerIterator iterator; + + FT_UInt base_glyph = slot->glyph_index; + + FT_Bool have_layers; + FT_UInt glyph_index; + FT_UInt color_index; + + + /* check whether we have colored glyph layers */ + iterator.p = NULL; + have_layers = FT_Get_Color_Glyph_Layer( face, + base_glyph, + &glyph_index, + &color_index, + &iterator ); + if ( have_layers ) + { + error = FT_New_GlyphSlot( face, NULL ); + if ( !error ) + { + TT_Face ttface = (TT_Face)face; + SFNT_Service sfnt = (SFNT_Service)ttface->sfnt; + + + do + { + FT_Int32 load_flags = slot->internal->load_flags; + + + /* disable the `FT_LOAD_COLOR' flag to avoid recursion */ + /* right here in this function */ + load_flags &= ~FT_LOAD_COLOR; + + /* render into the new `face->glyph' glyph slot */ + load_flags |= FT_LOAD_RENDER; + + error = FT_Load_Glyph( face, glyph_index, load_flags ); + if ( error ) + break; + + /* blend new `face->glyph' into old `slot'; */ + /* at the first call, `slot' is still empty */ + error = sfnt->colr_blend( ttface, + color_index, + slot, + face->glyph ); + if ( error ) + break; + + } while ( FT_Get_Color_Glyph_Layer( face, + base_glyph, + &glyph_index, + &color_index, + &iterator ) ); + + if ( !error ) + slot->format = FT_GLYPH_FORMAT_BITMAP; + + /* this call also restores `slot' as the glyph slot */ + FT_Done_GlyphSlot( face->glyph ); + } + + if ( !error ) + return error; + + /* Failed to do the colored layer. Draw outline instead. */ + slot->format = FT_GLYPH_FORMAT_OUTLINE; + } + } + { FT_ListNode node = NULL; /* small shortcut for the very common case */
*** 4530,4551 **** } #ifdef FT_DEBUG_LEVEL_TRACE #undef FT_COMPONENT ! #define FT_COMPONENT trace_bitmap /* * Computing the MD5 checksum is expensive, unnecessarily distorting a * possible profiling of FreeType if compiled with tracing support. For * this reason, we execute the following code only if explicitly * requested. */ /* we use FT_TRACE3 in this block */ if ( !error && ! ft_trace_levels[trace_bitmap] >= 3 && slot->bitmap.buffer ) { FT_Bitmap bitmap; FT_Error err; --- 4646,4667 ---- } #ifdef FT_DEBUG_LEVEL_TRACE #undef FT_COMPONENT ! #define FT_COMPONENT checksum /* * Computing the MD5 checksum is expensive, unnecessarily distorting a * possible profiling of FreeType if compiled with tracing support. For * this reason, we execute the following code only if explicitly * requested. */ /* we use FT_TRACE3 in this block */ if ( !error && ! ft_trace_levels[trace_checksum] >= 3 && slot->bitmap.buffer ) { FT_Bitmap bitmap; FT_Error err;
*** 4563,4574 **** int i, j; int rows = (int)bitmap.rows; int pitch = bitmap.pitch; ! FT_TRACE3(( "FT_Render_Glyph: bitmap %dx%d, mode %d\n", ! rows, pitch, slot->bitmap.pixel_mode )); for ( i = 0; i < rows; i++ ) for ( j = 0; j < pitch; j++ ) coverage += bitmap.buffer[i * pitch + j]; --- 4679,4693 ---- int i, j; int rows = (int)bitmap.rows; int pitch = bitmap.pitch; ! FT_TRACE3(( "FT_Render_Glyph: bitmap %dx%d, %s (mode %d)\n", ! pitch, ! rows, ! pixel_modes[slot->bitmap.pixel_mode], ! slot->bitmap.pixel_mode )); for ( i = 0; i < rows; i++ ) for ( j = 0; j < pitch; j++ ) coverage += bitmap.buffer[i * pitch + j];
*** 4593,4613 **** * Dump bitmap in Netpbm format (PBM or PGM). */ /* we use FT_TRACE7 in this block */ if ( !error && ! ft_trace_levels[trace_bitmap] >= 7 && ! slot->bitmap.rows < 128U && slot->bitmap.width < 128U && slot->bitmap.buffer ) { int rows = (int)slot->bitmap.rows; int width = (int)slot->bitmap.width; int pitch = slot->bitmap.pitch; int i, j, m; unsigned char* topleft = slot->bitmap.buffer; if ( pitch < 0 ) topleft -= pitch * ( rows - 1 ); FT_TRACE7(( "Netpbm image: start\n" )); switch ( slot->bitmap.pixel_mode ) --- 4712,4735 ---- * Dump bitmap in Netpbm format (PBM or PGM). */ /* we use FT_TRACE7 in this block */ if ( !error && ! ft_trace_levels[trace_checksum] >= 7 ) ! { ! if ( slot->bitmap.rows < 128U && slot->bitmap.width < 128U && slot->bitmap.buffer ) { int rows = (int)slot->bitmap.rows; int width = (int)slot->bitmap.width; int pitch = slot->bitmap.pitch; int i, j, m; + unsigned char* topleft = slot->bitmap.buffer; + if ( pitch < 0 ) topleft -= pitch * ( rows - 1 ); FT_TRACE7(( "Netpbm image: start\n" )); switch ( slot->bitmap.pixel_mode )
*** 4616,4626 **** FT_TRACE7(( "P1 %d %d\n", width, rows )); for ( i = 0; i < rows; i++ ) { for ( j = 0; j < width; ) for ( m = 128; m > 0 && j < width; m >>= 1, j++ ) ! FT_TRACE7(( " %d", ( topleft[i * pitch + j / 8] & m ) != 0 )); FT_TRACE7(( "\n" )); } break; default: --- 4738,4749 ---- FT_TRACE7(( "P1 %d %d\n", width, rows )); for ( i = 0; i < rows; i++ ) { for ( j = 0; j < width; ) for ( m = 128; m > 0 && j < width; m >>= 1, j++ ) ! FT_TRACE7(( " %d", ! ( topleft[i * pitch + j / 8] & m ) != 0 )); FT_TRACE7(( "\n" )); } break; default:
*** 4632,4644 **** FT_TRACE7(( "\n" )); } } FT_TRACE7(( "Netpbm image: end\n" )); } #undef FT_COMPONENT ! #define FT_COMPONENT trace_objs #endif /* FT_DEBUG_LEVEL_TRACE */ return error; } --- 4755,4770 ---- FT_TRACE7(( "\n" )); } } FT_TRACE7(( "Netpbm image: end\n" )); } + else + FT_TRACE7(( "Netpbm image: too large, omitted\n" )); + } #undef FT_COMPONENT ! #define FT_COMPONENT objs #endif /* FT_DEBUG_LEVEL_TRACE */ return error; }
*** 4673,4697 **** /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ ! /*************************************************************************/ ! /* */ ! /* <Function> */ ! /* Destroy_Module */ ! /* */ ! /* <Description> */ ! /* Destroys a given module object. For drivers, this also destroys */ ! /* all child faces. */ ! /* */ ! /* <InOut> */ ! /* module :: A handle to the target driver object. */ ! /* */ ! /* <Note> */ ! /* The driver _must_ be LOCKED! */ ! /* */ static void Destroy_Module( FT_Module module ) { FT_Memory memory = module->memory; FT_Module_Class* clazz = module->clazz; --- 4799,4824 ---- /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ ! /************************************************************************** ! * ! * @Function: ! * Destroy_Module ! * ! * @Description: ! * Destroys a given module object. For drivers, this also destroys ! * all child faces. ! * ! * @InOut: ! * module :: ! * A handle to the target driver object. ! * ! * @Note: ! * The driver _must_ be LOCKED! ! */ static void Destroy_Module( FT_Module module ) { FT_Memory memory = module->memory; FT_Module_Class* clazz = module->clazz;
*** 5026,5038 **** } service = (FT_Service_Properties)interface; if ( set ) ! missing_func = (FT_Bool)( !service->set_property ); else ! missing_func = (FT_Bool)( !service->get_property ); if ( missing_func ) { FT_ERROR(( "%s: property service of module `%s' is broken\n", func_name, module_name )); --- 5153,5165 ---- } service = (FT_Service_Properties)interface; if ( set ) ! missing_func = FT_BOOL( !service->set_property ); else ! missing_func = FT_BOOL( !service->get_property ); if ( missing_func ) { FT_ERROR(( "%s: property service of module `%s' is broken\n", func_name, module_name ));
*** 5154,5187 **** if ( FT_NEW( library ) ) return error; library->memory = memory; - #ifdef FT_CONFIG_OPTION_PIC - /* initialize position independent code containers */ - error = ft_pic_container_init( library ); - if ( error ) - goto Fail; - #endif - library->version_major = FREETYPE_MAJOR; library->version_minor = FREETYPE_MINOR; library->version_patch = FREETYPE_PATCH; library->refcount = 1; /* That's ok now */ *alibrary = library; return FT_Err_Ok; - - #ifdef FT_CONFIG_OPTION_PIC - Fail: - ft_pic_container_destroy( library ); - FT_FREE( library ); - return error; - #endif } /* documentation is in freetype.h */ --- 5281,5300 ----
*** 5308,5322 **** } } } #endif - #ifdef FT_CONFIG_OPTION_PIC - /* Destroy pic container contents */ - ft_pic_container_destroy( library ); - #endif - FT_FREE( library ); Exit: return FT_Err_Ok; } --- 5421,5430 ----
*** 5400,5405 **** --- 5508,5550 ---- return error; } + /* documentation is in freetype.h */ + + FT_EXPORT_DEF( FT_Bool ) + FT_Get_Color_Glyph_Layer( FT_Face face, + FT_UInt base_glyph, + FT_UInt *aglyph_index, + FT_UInt *acolor_index, + FT_LayerIterator* iterator ) + { + TT_Face ttface; + SFNT_Service sfnt; + + + if ( !face || + !aglyph_index || + !acolor_index || + !iterator || + base_glyph >= (FT_UInt)face->num_glyphs ) + return 0; + + if ( !FT_IS_SFNT( face ) ) + return 0; + + ttface = (TT_Face)face; + sfnt = (SFNT_Service)ttface->sfnt; + + if ( sfnt->get_colr_layer ) + return sfnt->get_colr_layer( ttface, + base_glyph, + aglyph_index, + acolor_index, + iterator ); + else + return 0; + } + + /* END */
< prev index next >