2 #include <Xw_Extension.h>
4 /* ifdef then trace on */
6 #define TRACE_DEF_FONTMAP
10 XW_EXT_FONTMAP* Xw_def_fontmap(adisplay,nfont):
11 XW_EXT_DISPLAY *adisplay Extended Display structure
13 int nfont Number of font cells to be allocated
15 Create a fontmap extension
16 allocate the font cells in the fontmap as if possible
17 depending of the MAXFONT define .
19 Returns Fontmap extension address if successuful
22 STATUS = Xw_close_fontmap(afontmap)
23 XW_EXT_FONTMAP* afontmap Extended fontmap
26 Destroy The Extended TypeMap
28 Returns ERROR if Bad Extended TypeMap Address
29 SUCCESS if successfull
34 void* Xw_def_fontmap (void* adisplay,int nfont)
36 void* Xw_def_fontmap (adisplay,nfont)
39 #endif /*XW_PROTOTYPE*/
41 XW_EXT_DISPLAY *pdisplay = (XW_EXT_DISPLAY*)adisplay ;
42 XW_EXT_FONTMAP *pfontmap = NULL ;
43 XFontStruct *dfstruct ;
48 char *dfstring = NULL ;
50 if( !Xw_isdefine_display(pdisplay) ) {
51 /*ERROR*Bad EXT_DISPLAY Address*/
52 Xw_set_error(96,"Xw_def_fontmap",pdisplay) ;
56 gc = DefaultGCOfScreen(_DSCREEN) ;
57 XGetGCValues(_DDISPLAY,gc,GCFont,&values) ;
58 dfstruct = XQueryFont(_DDISPLAY,XGContextFromGC(gc)) ;
59 for( i=0 ; i<dfstruct->n_properties ; i++ ) {
60 if( dfstruct->properties[i].name == XA_FONT ) {
61 dfstring = XGetAtomName(_DDISPLAY,dfstruct->properties[i].card32) ;
67 if( !(pfontmap = Xw_add_fontmap_structure(sizeof(XW_EXT_FONTMAP))) )
70 if( nfont <= 0 ) nfont = MAXFONT ;
73 pfontmap->connexion = pdisplay ;
74 pfontmap->maxfont = min(nfont,MAXFONT) ;
75 pfontmap->gnames[0] = (char*) "Defaultfont";
76 pfontmap->snames[0] = dfstring ;
77 pfontmap->fonts[0] = dfstruct ;
78 pfontmap->fonts[0]->fid = values.font ;
80 psize = (pfontmap->fonts[0])->max_bounds.ascent +
81 (pfontmap->fonts[0])->max_bounds.descent ;
83 pfontmap->gsizes[0] = (float)psize*HeightMMOfScreen(_DSCREEN)/
84 (float)HeightOfScreen(_DSCREEN) ;
85 pfontmap->fsizes[0] = pfontmap->gsizes[0];
86 pfontmap->fratios[0] = 0.;
87 pfontmap->ssizex[0] = pfontmap->ssizey[0] = pfontmap->fsizes[0] ;
88 pfontmap->gslants[0] = pfontmap->sslants[0] = 0. ;
90 #ifdef TRACE_DEF_FONTMAP
91 if( Xw_get_trace() ) {
92 printf(" %lx = Xw_def_fontmap(%lx,%d)\n", (long ) pfontmap,(long ) adisplay,nfont) ;
99 static XW_EXT_FONTMAP *PfontmapList =NULL ;
102 XW_EXT_FONTMAP* Xw_add_fontmap_structure(int size)
104 XW_EXT_FONTMAP* Xw_add_fontmap_structure(size)
106 #endif /*XW_PROTOTYPE*/
108 Create and Insert one Extended fontmap structure in the
109 EXtended fontmap List
111 returns Extended fontmap address if successful
112 or NULL if Bad Allocation
115 XW_EXT_FONTMAP *pfontmap = (XW_EXT_FONTMAP*) Xw_malloc(size) ;
119 pfontmap->type = FONTMAP_TYPE ;
120 pfontmap->link = PfontmapList ;
121 PfontmapList = pfontmap ;
122 pfontmap->connexion = NULL ;
123 pfontmap->maxfont = 0 ;
124 pfontmap->maxwindow = 0 ;
125 for( i=0 ; i<MAXFONT ; i++ ) {
126 pfontmap->gnames[i] = NULL ;
127 pfontmap->snames[i] = NULL ;
128 pfontmap->fonts[i] = NULL ;
129 pfontmap->gsizes[i] = 0. ;
130 pfontmap->fsizes[i] = 0. ;
131 pfontmap->ssizex[i] = 0. ;
132 pfontmap->ssizey[i] = 0. ;
133 pfontmap->gslants[i] = 0. ;
134 pfontmap->sslants[i] = 0. ;
135 pfontmap->fratios[i] = 0. ;
138 /*EXT_FONTMAP allocation failed*/
139 Xw_set_error(9,"Xw_add_fontmap_structure",NULL) ;
146 XW_STATUS Xw_close_fontmap(void* afontmap)
148 XW_STATUS Xw_close_fontmap(afontmap)
150 #endif /*XW_PROTOTYPE*/
152 XW_EXT_FONTMAP* pfontmap = (XW_EXT_FONTMAP*) afontmap ;
155 if( !Xw_isdefine_fontmap(pfontmap) ) {
156 /*Bad EXT_FONTMAP Address*/
157 Xw_set_error(51,"Xw_close_fontmap",pfontmap) ;
161 status = Xw_del_fontmap_structure(pfontmap) ;
163 #ifdef TRACE_DEF_FONTMAP
164 if( Xw_get_trace() ) {
165 printf(" %d = Xw_close_fontmap(%lx)\n",status,(long ) pfontmap) ;
173 XW_STATUS Xw_del_fontmap_structure(XW_EXT_FONTMAP* afontmap)
175 XW_STATUS Xw_del_fontmap_structure(afontmap)
176 XW_EXT_FONTMAP *afontmap;
177 #endif /*XW_PROTOTYPE*/
179 Remove the Extended fontmap address from the Extended List
181 returns ERROR if the fontmap address is not Found in the list
182 returns SUCCESS if successful
185 XW_EXT_FONTMAP *pfontmap = PfontmapList ;
188 if( !afontmap ) return (XW_ERROR) ;
190 if( afontmap->maxwindow ) {
193 for( i=1 ; i<MAXFONT ; i++) {
194 if( afontmap->fonts[i] ) {
195 if( afontmap->gnames[i] ) Xw_free(afontmap->gnames[i]) ;
196 if( afontmap->snames[i] ) Xw_free(afontmap->snames[i]) ;
197 if( afontmap->fonts[i]->fid != afontmap->fonts[0]->fid )
198 XFreeFont(_FDISPLAY,afontmap->fonts[i]) ;
202 if( afontmap == pfontmap ) {
203 PfontmapList = (XW_EXT_FONTMAP*) afontmap->link ;
205 for( ; pfontmap ; pfontmap = (XW_EXT_FONTMAP*) pfontmap->link ) {
206 if( pfontmap->link == afontmap ) {
207 pfontmap->link = afontmap->link ;
214 return (XW_SUCCESS) ;