2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: xlfdutil.c /main/2 1996/10/14 14:45:50 barstow $ */
25 * All Rights Reserved, Copyright (c) FUJITSU LIMITED 1995
27 * This is unpublished proprietary source code of FUJITSU LIMITED
29 * Authors: Seiya Miyazaki FUJITSU LIMITED
30 * Hiroyuki Chiba Fujitsu Basic Software Corporation
47 #include <Xm/SeparatoG.h>
49 #include <Xm/ToggleB.h>
50 #include <Xm/MessageB.h>
55 #include "selectxlfd.h"
59 #define Dprintf fprintf
67 static char* skipSpace() ;
69 extern FalFontDataList *font_L ;
70 extern FalxFontDataBuff KeyBuff ;
71 extern FalxCodeList *CodeList ;
72 extern FalxStyleList *StyleList ;
73 extern FalxSizeList *SizeList ;
74 extern int SelectedOffset ;
77 extern char *fullPathName ;
80 extern Widget toplevel ;
83 slctBLabel[BUTTONITEMS],slctBText[BUTTONITEMS], slctButton[BUTTONITEMS],
84 listPop[BUTTONITEMS], listW[BUTTONITEMS],
88 /****************************************************************
89 * functions for get font infomation
90 ****************************************************************/
95 Dprintf( stdout, "GetXLFDInfomations()\n" ) ;
100 fullPathName = NULL ;
101 FalxInitDataBuff( &KeyBuff ) ;
103 /* get UDC informations */
104 if( FalxGetFontList( &font_L, XtDisplayOfObject( toplevel ) ) ){
105 Dprintf( stderr, "GetXLFDInfomations() : FalxGetFontList() error.\n" ) ;
109 /* create code area list */
110 if( FalxCreateCodeList( &CodeList, font_L ) ){
111 Dprintf( stderr, "\nGetXLFDInfomations() : FalxCreateCodeList() error.\n" ) ;
115 /* create style list */
116 if( FalxCreateStyleList( &StyleList, font_L ) ){
117 Dprintf( stderr, "\nGetXLFDInfomations() : FalxCreateStyleList() error.\n" ) ;
121 /* create size list */
122 if( FalxCreateSizeList( &SizeList, font_L ) ){
123 Dprintf( stderr, "\nGetXLFDInfomations() : FalxCreateSizeList() error.\n" ) ;
135 GetItemsToDisplay( num, itemcnt, xms_list )
138 XmString **xms_list ;
141 char *sp ,string[256], buf[256] ;
143 int length, maxlength ;
144 FalxXlfdList *xlist ;
147 char **tmp_dlist, *str ;
156 for( i=1; i<BUTTONITEMS; i++ ){
157 if( (str = XmTextGetString( slctBText[i] )) == NULL ){
160 if( *str == ' ' || *str == NULL ) continue ;
161 if( SetKeyBuff( i, str ) ){
165 rtn = FalxGetXlfdList( &xlist, font_L, &KeyBuff, getmask ) ;
166 if( rtn ) return( rtn ) ;
167 tmp_cnt = xlist->num ;
168 tmp_dlist = xlist->list ;
170 case 1 : /* code area */
171 tmp_cnt = CodeList->num ;
172 tmp_dlist = (char **)malloc( sizeof(char *) * tmp_cnt ) ;
173 if( tmp_dlist == NULL ) return(-1) ;
174 for( i=0; i<tmp_cnt; i++ ){
176 rlen = sprintf( sp, "CS:%d ", (CodeList->dlist[i]->fontset) ) ;
178 for( j=0; j<CodeList->dlist[i]->code_area_num; j++ ){
179 rlen = sprintf( sp, "%x - %x ",
180 CodeList->dlist[i]->alist[j]->udc_start,
181 CodeList->dlist[i]->alist[j]->udc_end ) ;
184 if( (tmp_dlist[i] = strdup( string )) == NULL ){
190 tmp_cnt = StyleList->num ;
191 tmp_dlist = (char **)malloc( sizeof(char *) * tmp_cnt ) ;
192 for( i=0; i<tmp_cnt; i++ ){
193 if( (tmp_dlist[i] = strdup( StyleList->list[i] )) == NULL ){
199 tmp_cnt = SizeList->num ;
200 tmp_dlist = (char **)malloc( sizeof(char *) * tmp_cnt ) ;
201 for( i=0; i<tmp_cnt; i++ ){
202 sprintf( string, "%d ", SizeList->list[i] ) ;
203 if( (tmp_dlist[i] = strdup( string )) == NULL ){
208 default : /* error */
211 if( (xms = (XmString *)calloc( tmp_cnt, sizeof(XmString) )) == NULL ){
216 * set list for display
219 for ( i=0; i<tmp_cnt; i++ ){
220 xms[i] = XmStringCreateLocalized( tmp_dlist[i] );
224 * free allocated memory
229 FalxFreeXlfdList( xlist ) ;
231 case 1 : /* code area */
234 for( i=0; i<tmp_cnt; i++ ){
235 free( tmp_dlist[i] ) ;
239 default : /* error */
255 skipSpace( str, skipcnt )
263 if( *str == NULL ) return( NULL ) ;
264 len = strlen( str ) ;
266 for( i=0,spacecnt=0; i<len-1; i++, sp++ ) {
267 if( *sp == NULL ) return( NULL ) ;
268 if( *sp == ' ' ) spacecnt++ ;
269 if( spacecnt == skipcnt ) break ;
279 SetKeyBuff( num, str )
284 int cdset, start, end ;
285 FalxUdcArea *tmp_list ;
290 KeyBuff.FontData.xlfdname = str ;
292 case 1 : /* code area */
293 getmask |= FAL_FONT_MASK_CODE_SET ;
294 if( KeyBuff.FileData.list != NULL ){
295 free( KeyBuff.FileData.list ) ;
297 KeyBuff.FileData.list = NULL ;
301 if( sscanf( sp, "CS:%d ", &cdset ) != 1 ){
304 if( (sp = skipSpace( sp, 1 )) == NULL ) return( -1 ) ;
306 KeyBuff.FontData.cd_set = cdset ;
307 while( sscanf( sp, "%x %c %x ", &start, &hyp, &end ) == 3 ){
308 if( hyp != '-' ) break ;
309 if( tmp_list == NULL ){
310 tmp_list = (FalxUdcArea *)malloc( sizeof(FalxUdcArea) ) ;
312 tmp_list = (FalxUdcArea *)realloc( KeyBuff.FileData.list,
313 sizeof(FalxUdcArea) * (num+1) ) ;
315 if( tmp_list == NULL ) return(-1) ;
316 tmp_list[num].udc_start = (int)start ;
317 tmp_list[num].udc_end = (int)end ;
319 if( (sp = skipSpace( sp, 3 )) == NULL ) break ;
321 if( num == 0 ) return(-1) ;
322 KeyBuff.FileData.code_area_num = num ;
323 KeyBuff.FileData.list = tmp_list ;
326 getmask |= FAL_FONT_MASK_STYLE_NAME ;
327 KeyBuff.FontData.style.name = str ;
330 getmask |= FAL_FONT_MASK_LETTER_W ;
331 getmask |= FAL_FONT_MASK_LETTER_H ;
332 KeyBuff.FontData.letter.w = atoi( str ) ;
333 KeyBuff.FontData.letter.h = atoi( str ) ;