1 #   ifndef		PS_TO_GLYPH_MAPPING_H
2 #   define		PS_TO_GLYPH_MAPPING_H
3 
4 /************************************************************************/
5 /*									*/
6 /*  Map Unicode values to glyph numbers. Typically, a font has been	*/
7 /*  analyzed and we know the unicode values that belong to its glyphs.	*/
8 /*  Then inside a printing task, we have to to the other way: We have	*/
9 /*  unicodes and we want to know the glyph index that corresponds to	*/
10 /*  the unicode. As this is a per-character operation the		*/
11 /*  implementation must be fast.					*/
12 /*									*/
13 /*  Glyph indices are positive. All negative values indicate unmapped	*/
14 /*  characters.								*/
15 /*									*/
16 /************************************************************************/
17 
18 typedef struct IndexMapping
19     {
20     int	**		imPages;
21     int			imPageCount;
22     } IndexMapping;
23 
24 # define TGM_PSZ 256
25 
26 # define utilIndexMappingGet( m, f ) \
27 	(((f)>=0&&(f)/TGM_PSZ<(m)->imPageCount&&(m)->imPages[(f)/TGM_PSZ])? \
28 	(m)->imPages[(f)/TGM_PSZ][(f)%TGM_PSZ]:-1)
29 
30 # define utilIndexMappingGetU( m, f ) \
31 	(((f)/TGM_PSZ<(m)->imPageCount&&(m)->imPages[(f)/TGM_PSZ])? \
32 	(m)->imPages[(f)/TGM_PSZ][(f)%TGM_PSZ]:-1)
33 
34 # define utilIndexMappingIsEmpty( m ) \
35 	( (m)->imPageCount == 0 )
36 
37 typedef int (*IndexMappingForOne)(	int		from,
38 					int		to,
39 					void *		through );
40 
41 /************************************************************************/
42 /*									*/
43 /*  Map a unicode value to a glyph index.				*/
44 /*									*/
45 /************************************************************************/
46 
47 extern void utilInitIndexMapping(	IndexMapping *	im );
48 extern void utilCleanIndexMapping(	IndexMapping *	im );
49 extern void utilClearIndexMapping(	IndexMapping *	im );
50 
51 extern int utilIndexMappingBuildBackward( IndexMapping *	im,
52 					const int *		forward,
53 					int			forwardCount );
54 
55 extern int  utilIndexMappingPut(	IndexMapping *		im,
56 					int			from,
57 					int			to );
58 
59 extern int utilIndexMappingAppend(	IndexMapping *		im,
60 					int *			pFrom,
61 					int			to );
62 
63 extern int utilIndexMappingForAll(	const IndexMapping *	im,
64 					IndexMappingForOne	forOne,
65 					void *			through );
66 
67 #   endif	/*	PS_TO_GLYPH_MAPPING_H	*/
68