1 /************************************************************************/
2 /*									*/
3 /*  Basic font matching.						*/
4 /*									*/
5 /************************************************************************/
6 
7 #   include	"appFrameConfig.h"
8 
9 #   include	"appMatchFont.h"
10 #   include	<psMatchFont.h>
11 
12 #   include	<appDebugon.h>
13 
14 /************************************************************************/
15 /*									*/
16 /*  Find a PostScript font.						*/
17 /*									*/
18 /************************************************************************/
19 
appGetFontInfo(const char * familyName,int styleInt,const IndexSet * unicodesUsed,const TextAttribute * ta,const PostScriptFontList * psfl)20 AfmFontInfo * appGetFontInfo(	const char *			familyName,
21 				int				styleInt,
22 				const IndexSet *		unicodesUsed,
23 				const TextAttribute *		ta,
24 				const PostScriptFontList *	psfl )
25     {
26     AfmFontInfo *	afi= (AfmFontInfo *)0;
27 
28 #   ifdef USE_FONTCONFIG
29     if  ( psfl->psflAvoidFontconfig )
30 	{
31 	afi= psGetPsFontInfoForAttribute( familyName, styleInt,
32 						    unicodesUsed, ta, psfl );
33 	if  ( ! afi )
34 	    { SXDEB(familyName,afi);	}
35 	}
36     else{
37 	afi= appFcGetFontInfoForAttribute( familyName, styleInt,
38 						    unicodesUsed, ta, psfl );
39 	if  ( ! afi )
40 	    { SXDEB(familyName,afi);	}
41 	}
42 #   else
43     afi= psGetPsFontInfoForAttribute( familyName, styleInt,
44 						    unicodesUsed, ta, psfl );
45     if  ( ! afi )
46 	{ SXDEB(familyName,afi);	}
47 #   endif
48 
49     return afi;
50     }
51 
52 /************************************************************************/
53 /*									*/
54 /*  Find a PostScript font for a document font.				*/
55 /*									*/
56 /************************************************************************/
57 
appGetFontInfoForAttribute(const IndexSet ** pUnicodesWanted,const TextAttribute * ta,const DocumentFontList * dfl,const PostScriptFontList * psfl)58 const AfmFontInfo * appGetFontInfoForAttribute(
59 				const IndexSet **		pUnicodesWanted,
60 				const TextAttribute *		ta,
61 				const DocumentFontList *	dfl,
62 				const PostScriptFontList *	psfl )
63     {
64     DocumentFont *		df;
65     AfmFontInfo *		afi= (AfmFontInfo *)0;
66     int				faceIndex;
67 
68     df= docFontListGetFontByNumber( dfl, ta->taFontNumber );
69     if  ( ! df )
70 	{ LXDEB(ta->taFontNumber,df); return (AfmFontInfo *)0;	}
71 
72     faceIndex= FACE_INDEX(ta->taFontIsSlanted,ta->taFontIsBold);
73 
74     afi= df->dfPsFontInfo[faceIndex];
75     if  ( ! afi )
76 	{
77 	afi= appGetFontInfo( df->dfName, df->dfStyleInt,
78 					    &(df->dfUnicodesUsed), ta, psfl );
79 	if  ( ! afi )
80 	    { XDEB(afi); return (AfmFontInfo *)0;	}
81 
82 	df->dfPsFontInfo[faceIndex]= afi;
83 	}
84 
85     if  ( afi->afiMetricsDeferred		&&
86 	  appGetDeferredFontMetrics( afi )	)
87 	{
88 	SLDEB(afi->afiFullName,afi->afiMetricsDeferred);
89 	return (AfmFontInfo *)0;
90 	}
91 
92     if  ( pUnicodesWanted )
93 	{ *pUnicodesWanted= &(df->dfUnicodesUsed);	}
94 
95     return afi;
96     }
97 
appGetDeferredFontMetricsForList(PostScriptFontList * psfl)98 int appGetDeferredFontMetricsForList(	PostScriptFontList *	psfl )
99     {
100     int		rval= 0;
101     int		i;
102 
103     for ( i= 0; i < psfl->psflInfoCount; i++ )
104 	{
105 	if  ( appGetDeferredFontMetrics( psfl->psflInfos[i] ) )
106 	    { LDEB(i); rval= -1;	}
107 	}
108 
109     return rval;
110     }
111 
appGetDeferredFontMetrics(AfmFontInfo * afi)112 int appGetDeferredFontMetrics(		AfmFontInfo *		afi )
113     {
114 #   ifdef USE_FONTCONFIG
115     if  ( afi->afiMetricsDeferred				&&
116 	  utilMemoryBufferIsEmpty( &(afi->afiAfmFileName) )	)
117 	{
118 	if  ( appFcGetFontMetrics( afi ) )
119 	    { SDEB(afi->afiFullName); return -1;	}
120 	}
121 #   endif
122 
123     if  ( afi->afiMetricsDeferred				&&
124 	  ! utilMemoryBufferIsEmpty( &(afi->afiAfmFileName) )	)
125 	{
126 	if  ( psGetDeferredMetrics( afi ) )
127 	    { LDEB(afi->afiAfmFileName.mbSize); return -1;	}
128 	}
129 
130     if  ( afi->afiMetricsDeferred )
131 	{ SLDEB(afi->afiFullName,afi->afiMetricsDeferred); return -1; }
132 
133     return 0;
134     }
135 
136