/**************************************************************************** * * ftccmap.c * * FreeType CharMap cache (body) * * Copyright (C) 2000-2023 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 <freetype/freetype.h> #include <freetype/ftcache.h> #include "ftcmanag.h" #include <freetype/internal/ftmemory.h> #include <freetype/internal/ftobjs.h> #include <freetype/internal/ftdebug.h> #include "ftccback.h" #include "ftcerror.h" #undef FT_COMPONENT #define FT_COMPONENT … /************************************************************************** * * Each FTC_CMapNode contains a simple array to map a range of character * codes to equivalent glyph indices. * * For now, the implementation is very basic: Each node maps a range of * 128 consecutive character codes to their corresponding glyph indices. * * We could do more complex things, but I don't think it is really very * useful. * */ /* number of glyph indices / character code per node */ #define FTC_CMAP_INDICES_MAX … /* compute a query/node hash */ #define FTC_CMAP_HASH( faceid, index, charcode ) … /* the charmap query */ FTC_CMapQuery; #define FTC_CMAP_QUERY( x ) … /* the cmap cache node */ FTC_CMapNode; #define FTC_CMAP_NODE( x ) … /* if (indices[n] == FTC_CMAP_UNKNOWN), we assume that the corresponding */ /* glyph indices haven't been queried through FT_Get_Glyph_Index() yet */ #define FTC_CMAP_UNKNOWN … /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** CHARMAP NODES *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ FT_CALLBACK_DEF( void ) ftc_cmap_node_free( FTC_Node ftcnode, FTC_Cache cache ) { … } /* initialize a new cmap node */ FT_CALLBACK_DEF( FT_Error ) ftc_cmap_node_new( FTC_Node *ftcanode, FT_Pointer ftcquery, FTC_Cache cache ) { … } /* compute the weight of a given cmap node */ FT_CALLBACK_DEF( FT_Offset ) ftc_cmap_node_weight( FTC_Node cnode, FTC_Cache cache ) { … } /* compare a cmap node to a given query */ FT_CALLBACK_DEF( FT_Bool ) ftc_cmap_node_compare( FTC_Node ftcnode, FT_Pointer ftcquery, FTC_Cache cache, FT_Bool* list_changed ) { … } FT_CALLBACK_DEF( FT_Bool ) ftc_cmap_node_remove_faceid( FTC_Node ftcnode, FT_Pointer ftcface_id, FTC_Cache cache, FT_Bool* list_changed ) { … } /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** GLYPH IMAGE CACHE *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ static const FTC_CacheClassRec ftc_cmap_cache_class = …; /* documentation is in ftcache.h */ FT_EXPORT_DEF( FT_Error ) FTC_CMapCache_New( FTC_Manager manager, FTC_CMapCache *acache ) { … } /* documentation is in ftcache.h */ FT_EXPORT_DEF( FT_UInt ) FTC_CMapCache_Lookup( FTC_CMapCache cmap_cache, FTC_FaceID face_id, FT_Int cmap_index, FT_UInt32 char_code ) { … } /* END */