bool FreeTypeFontInfo::EmbeddedBmpExist(int px) { if (px>=256 || px<0) return false; if (m_ebmps[px]!=-1) return !!m_ebmps[px]; CCriticalSectionLock __lock(CCriticalSectionLock::CS_MANAGER); FTC_ImageTypeRec imgtype={(FTC_FaceID)m_id, px, px, FT_LOAD_DEFAULT}; //构造一个当前大小的imagetype FT_Glyph temp_glyph=NULL; FT_UInt gindex = FTC_CMapCache_Lookup(cmap_cache, (FTC_FaceID)m_id, -1, FT_UInt32(L'0')); //获得0的索引值 FTC_ImageCache_Lookup(image_cache, &imgtype, gindex, &temp_glyph, NULL); if (temp_glyph && temp_glyph->format==FT_GLYPH_FORMAT_BITMAP) //如果可以读到0的点阵 m_ebmps[px]=1; //则该字号存在点阵 else { gindex = FTC_CMapCache_Lookup(cmap_cache, (FTC_FaceID)m_id, -1, FT_UInt32(L'的')); //获得"的"的索引值 if (gindex) FTC_ImageCache_Lookup(image_cache, &imgtype, gindex, &temp_glyph, NULL); //读取“的”的点阵 if (temp_glyph && temp_glyph->format==FT_GLYPH_FORMAT_BITMAP) //如果可以读到0的点阵 m_ebmps[px]=1; //则该字号存在点阵 else m_ebmps[px]=0; } return !!m_ebmps[px]; }
inline FT_Error fontRenderClass::getGlyphImage(FTC_Image_Desc *font, FT_ULong glyph_index, FT_Glyph *glyph, FT_Glyph *borderglyph, int bordersize) #endif { FT_Glyph image; FT_Error err = FTC_ImageCache_Lookup(imageCache, font, glyph_index, &image, NULL); if (err) return err; if (glyph) { err = FT_Glyph_Copy(image, glyph); if (err) return err; } if (borderglyph && bordersize) { err = FT_Glyph_Copy(image, borderglyph); if (err) return err; if (bordersize != strokerRadius) { strokerRadius = bordersize; FT_Stroker_Set(stroker, strokerRadius, FT_STROKER_LINECAP_ROUND, FT_STROKER_LINEJOIN_ROUND, 0); } err = FT_Glyph_Stroke(borderglyph, stroker, 1); } return err; }
int test_image_cache( btimer_t* timer, FT_Face face, void* user_data ) { FT_Glyph glyph; int i, done = 0; FT_UNUSED( user_data ); if ( !image_cache ) { if ( FTC_ImageCache_New(cache_man, &image_cache) ) return 0; } TIMER_START( timer ); for ( i = 0; i < face->num_glyphs; i++ ) { if ( !FTC_ImageCache_Lookup(image_cache, &font_type, i, &glyph, NULL) ) done++; } TIMER_STOP( timer ); return done; }
FTC_Image_Cache_Lookup( FTC_Image_Cache icache, FTC_Image_Desc* desc, FT_UInt gindex, FT_Glyph *aglyph ) { FTC_ImageTypeRec type0; if ( !desc ) return FTC_Err_Invalid_Argument; type0.font = desc->font; /* convert image type flags to load flags */ { FT_UInt load_flags = FT_LOAD_DEFAULT; FT_UInt type = desc->image_type; /* determine load flags, depending on the font description's */ /* image type */ if ( ftc_image_format( type ) == ftc_image_format_bitmap ) { if ( type & ftc_image_flag_monochrome ) load_flags |= FT_LOAD_MONOCHROME; /* disable embedded bitmaps loading if necessary */ if ( type & ftc_image_flag_no_sbits ) load_flags |= FT_LOAD_NO_BITMAP; } else { /* we want an outline, don't load embedded bitmaps */ load_flags |= FT_LOAD_NO_BITMAP; if ( type & ftc_image_flag_unscaled ) load_flags |= FT_LOAD_NO_SCALE; } /* always render glyphs to bitmaps */ load_flags |= FT_LOAD_RENDER; if ( type & ftc_image_flag_unhinted ) load_flags |= FT_LOAD_NO_HINTING; if ( type & ftc_image_flag_autohinted ) load_flags |= FT_LOAD_FORCE_AUTOHINT; type0.flags = load_flags; } return FTC_ImageCache_Lookup( (FTC_ImageCache)icache, &type0, gindex, aglyph, NULL ); }
FTC_Image_Cache_Lookup( FTC_ImageCache icache, FTC_OldImage_Desc* desc, FT_UInt gindex, FT_Glyph *aglyph ) { FTC_ImageTypeRec type0; if ( !desc ) return FTC_Err_Invalid_Argument; ftc_image_type_from_old_desc( &type0, desc ); return FTC_ImageCache_Lookup( (FTC_ImageCache)icache, &type0, gindex, aglyph, NULL ); }