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 /* comsub.c 1.36 - Fujitsu source for CDEnext 96/09/09 15:30:40 */
24 /* $XConsortium: comsub.c /main/8 1996/09/19 19:36:37 cde-fuj $ */
26 * (c) Copyright 1995 FUJITSU LIMITED
27 * This is source code modified by FUJITSU LIMITED under the Joint
28 * Development Agreement for the CDEnext PST.
29 * This is unpublished proprietary source code of FUJITSU LIMITED
35 #include <sys/types.h>
40 #include <X11/Intrinsic.h>
43 #include "ufontrsrc.h"
45 static void writePtn();
46 static void sig_receive();
47 char *get_cmd_path() ;
49 extern Resource resource;
51 /***********************************************************************
52 manage the character patterns
53 **********************************************************************/
55 #define GUADDPTNN 100 /* number of charcters for memory allocation */
56 /* this structure corresopnds to single font file */
57 typedef struct { /* area to manage character patterns */
58 char flag; /* invalid(=0)/valid(=1) */
59 int width; /* pattern width */
60 int height; /* pattern height */
61 int nptn; /* number of characters in editting */
62 int nmaxptn; /* maximum number of characters in editting */
63 int ptnsize; /* size per byte of single pattern */
64 UINT ptnmemsize; /* size of memory of whole patterns */
65 USHORT *ntoc; /* character list / relative code */
66 USHORT *ctop; /* relative code / bitmap area */
67 char *ptn; /* pointer to the bimap area */
68 int cptnnum; /* current pattern number */
71 static PATTERN_MNG pm; /* Pattern_Manage */
73 /* selection window for XLFD */
74 extern FalFontData fullFontData;
75 extern FalFontData copyFontData;
79 int begin_code=0, last_code=0;
81 FalCodeRegion CodeArea[10];
84 #define FAL_ERROR_STR resource.falerrmsg[((fal_utyerrno & 0xff) > 25) ? 0 : (fal_utyerrno & 0xff)]
93 if ((loc = getenv("LANG")) != NULL) {
100 /* contents : convert the sequential number in the editor into
101 * relative code in the system area
102 * values : -1 : terminated abnormally
103 * else : relative code
108 int num; /* sequential number */
110 if( (pm.flag == 0) || (num >= pm.nptn) )
113 return( pm.ntoc[num] );
119 /* contents : convert the relative code in the system area into
120 * sequential number in the editor
121 * values : -1 : terminated abnormally
122 * else : sequential number
127 int ncode; /* relative code */
134 for( sq=0 ; sq < pm.nptn ; sq++ ) {
135 if( pm.ntoc[sq] == ncode )
146 * contents : convert the character code into relative code
147 * values : relative code
148 * caution : There is no security against unusal character code.
153 int code; /* character code */
155 return( code - begin_code);
162 * contents : convert the relative code into character code
163 * values : character code
164 * caution : There is no security against unusal character code.
169 int sno; /* relative code */
171 return( sno + begin_code);
176 * contents : judge the input code with the system defined character area
177 * values : 0 : in the system defined area
178 * -1 : not in the system defined area
185 if (code < begin_code || code > last_code) {
192 * contents : allocate memories for character patterns
194 * values : ID : sequential number of the area
195 * -1 : terminated abnormally
199 ptnOpen(n, maxc, width, height)
200 int n; /* initial number of charcters */
202 int width; /* pattern width */
203 int height; /* pattern height */
208 if( (n < 0) || (width <= 0) || (height <= 0) )
218 pm.nmaxptn = n + GUADDPTNN;
219 pm.ptnsize = height * ((width+7)/8);
220 fpsize = pm.ptnsize + 1;
221 pm.ptnmemsize = (UINT) ( fpsize * pm.nmaxptn ) ;
223 if(( pm.ntoc = (USHORT *)calloc(maxc, sizeof(USHORT)) ) == NULL) {
226 if(( pm.ctop = (USHORT *)calloc(maxc, sizeof(USHORT)) ) == NULL ) {
230 if(( pm.ptn = (char *)malloc(fpsize*pm.nmaxptn) ) == NULL ) {
236 for( i=0 ; i < maxc ; i++ ) {
240 /* set null to each character pattern area */
241 for( i=0 ; i < pm.nmaxptn ; i++ ) {
242 pm.ptn[fpsize * i] = 0;
254 * contents : set free memories for character patterns
255 * values : 0 : terminated normally
256 * -1 : terminated abnormally
277 * contents : add character pattern to the character management area
279 * values : 0 : same code was exists and replaced it
280 * 1 : add new pattern
281 * -1 : terminated abnormally
286 int code; /* code to be add */
287 char *ptn; /* pointer to the pattern */
302 fpsize = pm.ptnsize + 1;
303 ncode = codeToNo( code );
305 if( (pno = pm.ctop[ncode]) != 0xFFFF ) {
306 pf = pm.ptn + fpsize*pno;
308 for( i=0 ; i < pm.ptnsize ; i++ )
313 if( pm.nptn >= pm.nmaxptn ) {
314 re_ptnmemsize = pm.ptnmemsize + GUADDPTNN*fpsize;
316 re_ptn = malloc( re_ptnmemsize );
318 re_ptn = realloc(pm.ptn, re_ptnmemsize);
320 if (re_ptn == NULL) {
323 pm.ptnmemsize = re_ptnmemsize;
325 for( i=pm.nmaxptn ; i < pm.nmaxptn + GUADDPTNN ; i++ ) {
326 pm.ptn[fpsize * i] = 0;
328 pm.nmaxptn += GUADDPTNN;
331 cpn = pm.cptnnum + 1;
332 for( i=0 ; i < pm.nmaxptn ; i++, cpn++ ) {
333 if( cpn >= pm.nmaxptn ) {
336 if( pm.ptn[fpsize * cpn] == 0 ) {
342 pm.ctop[ncode] = (USHORT) cpn;
343 pf = pm.ptn + fpsize*cpn;
346 for( i=0 ; i < pm.ptnsize ; i++ )
349 for( i=pm.nptn ; i >=0 ; i-- ) {
350 if( ncode > (int)pm.ntoc[i] ) {
353 pm.ntoc[i+1] = pm.ntoc[i];
355 pm.ntoc[i+1] = (USHORT) ncode;
363 * contents : get a character pattern from the character management area
364 * values : 0 : terminated normally
365 * -1 : terminated abnormally
380 if( (pm.flag == 0) || (codeCheck(code) == -1) )
383 ncode = codeToNo( code );
384 fpsize = pm.ptnsize +1;
386 if( (pno = pm.ctop[ncode]) == 0xFFFF )
389 pf = pm.ptn + pno*fpsize;
392 for( i=0 ; i < pm.ptnsize ; i++ )
400 * contents : judge the character pattern exist or not
401 * values : 1 : exists
403 * -1 : terminated abnormally
410 if( (pm.flag == 0) || (codeCheck(code) == -1) )
413 if( pm.ctop[ codeToNo(code) ] == 0xFFFF )
421 * contents : delete the character pattern
422 * values : 1 : deleted
423 * 0 : the pattern does not exist
424 * -1 : terminated abnormally
437 if( (pm.flag == 0) || (codeCheck(code) == -1) )
440 ncode = codeToNo( code );
441 fpsize = pm.ptnsize +1;
443 if( (pno = pm.ctop[ncode]) == 0xFFFF ) {
447 pf = pm.ptn + pno*fpsize;
450 pm.ctop[ncode] = 0xFFFF;
452 for( i=0 ; i < pm.nptn ; i++ ) {
453 if( (int)pm.ntoc[i] == ncode )
456 for( ; i < pm.nptn ; i++ )
457 pm.ntoc[i] = pm.ntoc[i+1];
465 * contents : get the infomation of the character
466 * values : 0 : terminated normally
467 * -1 : terminated abnormally
471 ptnGetInfo( n, width, height )
472 int *n; /* the number of characters in editting */
473 int *width; /* pattern width */
474 int *height; /* pattern height */
487 /********************************************************************
488 * handle bit map file(1) *
489 ********************************************************************/
491 struct { /* infomation of character pattern */
492 int width; /* pattern width */
493 int height; /* pattern height */
495 } bitInfo = { 16, 16 ,2 };
499 * contents : set infomation for handling bit-mapped files
503 bitSetInfo( width, height)
504 int width; /* pattern width */
505 int height; /* pattern height */
507 bitInfo.width = width;
508 bitInfo.height = height;
509 bitInfo.xbytesize = (width+7)/8;
516 * contents : set the bit at specefied coordinate on
520 bitSet( ptn, cx, cy )
525 if((cx < 0) || (bitInfo.width <= cx) || (cy < 0) || (bitInfo.height <= cy))
527 ptn[ bitInfo.xbytesize*cy + cx/8 ] |= (char)( 0x80 >> (cx%8) );
532 * contents : set the bit at specefied coordinate off
536 bitReset( ptn, cx, cy )
541 if((cx < 0) || (bitInfo.width <= cx) || (cy < 0) || (bitInfo.height <= cy))
543 ptn[ bitInfo.xbytesize*cy + cx/8 ] &= ~(char)( 0x80 >> (cx%8) );
548 * contents : returns 1 ( bit on ) or 0 ( bit off )
552 bitRead( ptn, cx, cy )
557 if((cx < 0) || (bitInfo.width <= cx) || (cy < 0) || (bitInfo.height <= cy))
559 return( ptn[ bitInfo.xbytesize*cy + cx/8 ]
561 (char)( 0x80 >> (cx%8) ) ? 1 : 0
567 * contents : clear the specefied bitmap file
576 for( i=0 ; i < bitInfo.height * bitInfo.xbytesize ; i++ )
582 * contents : copy the bit-mapped file
586 bitPtnCopy( d_ptn, s_ptn )
587 char *d_ptn; /* pointer of the destination file */
588 char *s_ptn; /* pointer of the source file */
592 for( i=0 ; i < bitInfo.height * bitInfo.xbytesize ; i++ )
598 /************************************************************************
599 * handle bit map file(2) *
600 * caution : You must call bitSetInfo() before use these functions. *
602 ************************************************************************/
605 * contents : draw lines between desired two points
606 * values : 0 : terminated normally
607 * -1 : outside of the edtting pane
611 bitDrawLine( ptn, x1, y1, x2, y2 ,mode )
612 char *ptn; /* pointer of the bit map file */
617 int mode; /* 0: erase 1: draw */
624 if( (x1 < 0) || (x2 < 0) || (y1 < 0) || (y2 < 0) ||
625 (bitInfo.width <= x1) || (bitInfo.width <= x2) ||
626 (bitInfo.height <= y1) || (bitInfo.height <= y2) )
634 delta = abs((int)dx) > abs((int)dy) ? dx : dy;
642 for(i=0 ; i <= (int)delta ; i++ ) {
643 mode == 0 ? bitReset(ptn,(int)x,(int)y) : bitSet(ptn,(int)x,(int)y);
652 * contents : draw circle
653 * values : 0 : terminated normally
654 * -1 : terminated abnormally
658 bitDrawCircle( ptn, x1, y1, x2, y2, mode )
670 if( (x1 < 0) || (y1 < 0) || (x2 < 0.0) || ( y2 < 0.0) ) {
676 rad = sqrt((double)(dx * dx + dy * dy)) + 0.5;
677 half = rad * sqrt(2.0)/2;
678 for (i = 0; i <= (int)half; i++) {
679 x = (int)sqrt(rad * rad - (double)(i*i));
681 bitSet (ptn, x1 - x, y1 - i);
682 bitSet (ptn, x1 - x, y1 + i);
683 bitSet (ptn, x1 + x, y1 - i);
684 bitSet (ptn, x1 + x, y1 + i);
685 bitSet (ptn, x1 - i, y1 - x);
686 bitSet (ptn, x1 - i, y1 + x);
687 bitSet (ptn, x1 + i, y1 - x);
688 bitSet (ptn, x1 + i, y1 + x);
690 bitReset(ptn, x1 - x, y1 - i);
691 bitReset(ptn, x1 - x, y1 + i);
692 bitReset(ptn, x1 + x, y1 - i);
693 bitReset(ptn, x1 + x, y1 + i);
694 bitReset(ptn, x1 - i, y1 - x);
695 bitReset(ptn, x1 - i, y1 + x);
696 bitReset(ptn, x1 + i, y1 - x);
697 bitReset(ptn, x1 + i, y1 + x);
705 * contents : draw rectangle
706 * values : 0 : terminated normally
707 * -1 : terminated abnormally
711 bitDrawRect( ptn, x, y, width, height, mode )
724 if( (x < 0) || (y < 0) || (width < 0) || (height < 0) ||
725 (bitInfo.width <= width +x) || (bitInfo.height <= height +y) )
728 for( i=x ; i <= width+x ; i++ ) {
730 bitReset( ptn, i, y );
731 bitReset( ptn, i, height+y );
735 bitSet( ptn, i, height+y );
738 for( i=y+1 ; i < height +y ; i++ ) {
740 bitReset( ptn, x, i );
741 bitReset( ptn, x+width, i );
745 bitSet( ptn, x +width, i );
754 * contents : clear the inside of the specefied rectangle
755 * values : 0 : terminated normally
756 * -1 : terminated abnormally
760 bitDrawCls( ptn, x, y, width, height )
772 if( (x < 0) || (y < 0) || (width < 0) || (height < 0) ||
773 (bitInfo.width <= width +x) || (bitInfo.height <= height +y) )
776 for( i=x ; i <= width +x ; i++ ) {
777 for( j=y ; j <= height +y ; j++ )
778 bitReset( ptn, i, j );
786 * contents : paint out the inside of the desired rectangle
787 * values : 0 : terminated normally
788 * -1 : terminated abnormally
792 bitDrawSet( ptn, x, y, width, height )
804 if( (x < 0) || (y < 0) || (width < 0) || (height < 0) ||
805 (bitInfo.width <= width +x) || (bitInfo.height <= height +y) )
808 for( i=x ; i <= width +x ; i++ ) {
809 for( j=y ; j <= height +y ; j++ )
817 * contents : reverse the inside of the desired rectangle
818 * values : 0 : terminated normally
819 * -1 : terminated abnormally
823 bitDrawRev( ptn, x, y, width, height )
835 if( (x < 0) || (y < 0) || (width < 0) || (height < 0) ||
836 (bitInfo.width <= width +x) || (bitInfo.height <= height +y) )
839 for( i=x ; i <= width +x ; i++ ) {
840 for( j=y ; j <= height +y ; j++ ) {
841 if( bitRead( ptn, i, j ) == 0 )
842 bitSet ( ptn, i, j );
844 bitReset( ptn, i, j );
852 static char cut_buffer[MAXPTNBYTE];
853 static int cut_buffer_w=0;
854 static int cut_buffer_h=0;
856 * contents : copy the specified rectangle area
857 * values : 0 : terminated normally
858 * -1 : terminated abnormally
862 bitDrawCpy(ptn, sx, sy, width, height, cut_flag)
872 if ((sx < 0) || (sy < 0) || (width < 2) || (height < 2) ||
873 (bitInfo.width < width +sx) || (bitInfo.height < height +sy))
876 cut_buffer_w = width;
877 cut_buffer_h = height;
879 for (i=0; i < width; i++) {
880 for (j=0; j < height; j++) {
881 if (bitRead(ptn, i + sx, j + sy) != 0)
882 bitSet(cut_buffer, i, j);
884 bitReset(cut_buffer, i, j);
886 bitReset(ptn, i + sx, j + sy);
893 bitDrawPaste(ptn, dx, dy)
901 if((dx < 0) || (dy < 0) || (cut_buffer == 0) ||
902 (cut_buffer_w == 0) || (cut_buffer_h == 0))
905 width = (cut_buffer_w <= bitInfo.width - dx)
906 ? cut_buffer_w : bitInfo.width - dx;
907 height = (cut_buffer_h <= bitInfo.height - dy)
908 ? cut_buffer_h : bitInfo.height - dy;
910 for (i=0; i < width; i++) {
911 for (j=0; j < height; j++) {
912 if( bitRead(cut_buffer, i, j) != 0 )
913 bitSet (ptn, i + dx, j + dy);
915 bitReset(ptn, i + dx, j + dy);
924 * contents : rotate the inside of the area specified
925 * values : 0 : terminated normally
926 * -1 : terminated abnormally
930 bitDrawRoll( ptn, x, y, width, height )
941 if( (x < 0) || (y < 0) || (width < 0) || (height < 0) ||
942 (bitInfo.width < width +x) || (bitInfo.height < height +y) )
945 point = (char *)malloc((width * height) * sizeof(int));
947 for(count=0,yy=0; yy < height; yy++) {
948 for(xx=0; xx < width; xx++ ) {
949 point[count++] = bitRead(ptn, x + xx, y + yy);
950 bitReset(ptn, x + xx, y + yy);
954 for(count=0,yy=0; yy < height; yy++) {
955 for(xx=0; xx < width; xx++ ) {
956 point[count++] == 0 ? bitReset(ptn, x + height - yy - 1, y + xx)
957 : bitSet(ptn, x + height - yy - 1, y + xx);
967 * contents : reverse the top-bottom symmetry of the rectangle specified
968 * values : 0 : terminated normally
969 * -1 : terminated abnormally
973 bitDrawSymV( ptn, x, y, width, height )
986 if( (x < 0) || (y < 0) || (width < 0) || (height < 0) ||
987 (bitInfo.width <= width +x) || (bitInfo.height <= height +y) )
990 for( k=0 ; k <= width ; k++ ) {
991 for( j=0 ; j <(height+1)/2 ; j++ ) {
992 d1 = bitRead( ptn, x +k, y +j );
993 d2 = bitRead( ptn, x +k, y + height -j );
995 d1 == 0 ? bitReset( ptn, x +k, y +height -j )
996 : bitSet( ptn, x +k, y +height -j );
997 d2 == 0 ? bitReset( ptn, x +k, y +j )
998 : bitSet( ptn, x +k, y +j );
1006 * contents : reverse the left-right symmetry of the rectangle specified
1007 * values : 0 : terminated normally
1008 * -1 : terminated abnormally
1012 bitDrawSymH( ptn, x, y, width, height )
1025 if( (x < 0) || (y < 0) || (width < 0) || (height < 0) ||
1026 (bitInfo.width <= width +x) || (bitInfo.height <= height +y) )
1029 for( k=0 ; k < (width+1)/2 ; k++ ) {
1030 for( j=0 ; j <= height ; j++ ) {
1031 d1 = bitRead( ptn, x +k, y +j );
1032 d2 = bitRead( ptn, x +width -k, y +j );
1034 d1 == 0 ? bitReset( ptn, x +width -k, y +j )
1035 : bitSet( ptn, x +width -k, y +j );
1036 d2 == 0 ? bitReset( ptn, x +k, y +j )
1037 : bitSet( ptn, x +k, y +j );
1049 for (i=strlen(str),p=&(str[i]),count=0; i && count < 2; i--,p--) {
1060 /****************************************************************
1061 * read and write SNF file *
1064 ****************************************************************/
1067 * contents : read character patterns from specified SNF file
1068 * values : number of the area that was allocated to manage font file
1069 * -1 : terminated abnormally
1070 * -2 : file is locked
1073 readSNF(fdata, width, height, err)
1074 FalFontData **fdata;
1085 static FalFontDataList *fulllist;
1088 FalGlyphRegion *gr, *gr_p;
1095 FalFreeFontList(fulllist);
1098 mask = FAL_FONT_MASK_XLFDNAME | FAL_FONT_MASK_UPDATE |
1099 FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED;
1100 if (fullFontData.cd_set != -1) {
1101 mask |= FAL_FONT_MASK_CODE_SET;
1104 mask |= FAL_FONT_MASK_GLYPH_INDEX;
1106 if (FalGetFontList(&fullFontData, mask, &fulllist) == FAL_ERROR) {
1107 strcpy(err, FAL_ERROR_STR);
1110 if(fulllist == NULL) {
1111 strcpy(err, resource.mn_no_font);
1114 if (fulllist->num != 1) {
1115 FalFreeFontList(fulllist);
1117 strcpy(err, resource.mn_plural_font);
1120 *fdata = &(fulllist->list[0]);
1121 font_id = FalOpenSysFont(&fullFontData, mask, &fulllist);
1123 if (font_id == 0 && (fal_utyerrno & 0xff) == FAL_ERR_FNT_OPN) {
1124 mes = (char *) malloc(strlen(resource.mn_no_perm)+strlen(fal_err_file)+10);
1126 strcpy(err, resource.mn_no_mem);
1127 FalFreeFontList(fulllist);
1130 sprintf(mes, "%sfile: %s", resource.mn_no_perm, fal_err_file);
1132 mask &= ~FAL_FONT_MASK_UPDATE;
1133 font_id = FalOpenSysFont(&fullFontData, mask, &fulllist);
1136 strcpy(err, FAL_ERROR_STR);
1137 FalFreeFontList(fulllist);
1140 } else if (font_id == 0) {
1141 strcpy(err, FAL_ERROR_STR);
1142 FalFreeFontList(fulllist);
1145 if (fullpath != NULL)
1147 if (FalFontIDToFileName(font_id, &fullpath) == FAL_ERROR) {
1148 strcpy(err, FAL_ERROR_STR);
1154 if( FalQueryFont( font_id, &finfo ) == FAL_ERROR ) {
1155 strcpy(err, FAL_ERROR_STR);
1156 FalCloseFont( font_id );
1161 *width = finfo.width;
1162 *height = finfo.height;
1164 fullFontData.cd_set = (* fdata)->cd_set;
1166 if (FalGetUDCCPArea(get_locale(),(* fdata)->cd_set,
1167 char_set(( *fdata)->xlfdname), (FalCodeRegion **) &gr, &num_gr) == FAL_ERROR) {
1168 strcpy(err, FAL_ERROR_STR);
1169 FalCloseFont( font_id );
1175 if (FalGetUDCGIArea(get_locale(),(* fdata)->cd_set,
1176 char_set(( *fdata)->xlfdname), &gr, &num_gr) == FAL_ERROR) {
1177 strcpy(err, FAL_ERROR_STR);
1178 FalCloseFont( font_id );
1185 FalCloseFont( font_id );
1186 strcpy(err, resource.mn_not_udc);
1192 Error_message2(NULL, mes);
1194 fullFontData.prm = True;
1198 for (i=0, gr_p=gr; i < num_gr; i++, gr_p++) {
1199 CodeArea[i].start = gr_p->start;
1200 CodeArea[i].end = gr_p->end;
1201 s = (gr_p->start & 0xff00) >> 8;
1202 e = (gr_p->end & 0xff00) >> 8;
1204 sprintf(tmp, "0x%x:0x%x", s, e);
1205 strcpy(AreaStr, tmp);
1207 sprintf(tmp, ",0x%x:0x%x", s, e);
1208 strcat(AreaStr, tmp);
1210 if (start > gr_p->start)
1211 start = gr_p->start;
1212 if (end < gr_p->end)
1215 CodeArea[i].start = -1;
1220 FalCloseFont( font_id );
1221 sprintf(err, "%s\nStart address = %x End address = %x\n", resource.mn_illegal_area, start, end);
1225 if( ptnOpen(1, end - start + 1, finfo.width, finfo.height) < 0 ) {
1226 FalCloseFont( font_id );
1227 strcpy(err, resource.mn_no_mem);
1230 bitSetInfo( finfo.width, finfo.height );
1232 for (i=0, gr_p=gr; i < num_gr; i++, gr_p++) {
1233 if (start > gr_p->start)
1234 gr_p->start = start;
1235 if (end < gr_p->end)
1240 for (code=gr_p->start; code <= gr_p->end; code++) {
1247 ptn = (char *)FalReadFont( font_id, code, finfo.width, finfo.height );
1248 if( ptn == (char *)FAL_ERROR ) {
1249 strcpy(err, FAL_ERROR_STR);
1251 FalCloseFont( font_id );
1256 if( EXISTS_FLAG == 0 ) {
1257 if( ptnAdd( code, ptn ) != 1 ) {
1259 strcpy(err, resource.mn_no_read);
1260 FalCloseFont( font_id );
1268 for (code=gr_p->start; code <= gr_p->end; code++) {
1269 if (! (code & 0x80)) {
1275 ptn = (char *)FalReadFont( font_id, code, finfo.width, finfo.height );
1276 if( ptn == (char *)FAL_ERROR ) {
1277 strcpy(err, FAL_ERROR_STR);
1279 FalCloseFont( font_id );
1284 if( EXISTS_FLAG == 0 ) {
1285 if( ptnAdd( code, ptn ) != 1 ) {
1287 strcpy(err, resource.mn_no_read);
1288 FalCloseFont( font_id );
1303 bicopy(s1, s2, size)
1308 for(i=size; i; i--, s1++, s2++)
1313 copySNF(start, end, ptn, num, err)
1324 static FalFontDataList *copylist;
1329 mask = FAL_FONT_MASK_XLFDNAME | FAL_FONT_MASK_DEFINED |
1330 FAL_FONT_MASK_UNDEFINED;
1331 if (copyFontData.cd_set != -1) {
1332 mask |= FAL_FONT_MASK_CODE_SET;
1335 mask |= FAL_FONT_MASK_GLYPH_INDEX;
1338 fid = FalOpenSysFont(©FontData, mask, ©list);
1340 strcpy(err, FAL_ERROR_STR);
1341 FalFreeFontList(copylist);
1345 _ptn = (char **)malloc(sizeof(char *) * (end - start + 1));
1347 for (i = start, count = 0, p = _ptn; i <= end; i++) {
1353 point = (char *)FalReadFont( fid, i, pm.width, pm.height );
1354 if( point == (char *)FAL_ERROR ) {
1355 strcpy(err, FAL_ERROR_STR);
1356 FalCloseFont( fid );
1359 if (EXISTS_FLAG != 0)
1361 size = pm.height * ((pm.width+7)/8);
1362 *p = (char *) XtMalloc(size);
1363 bicopy(point, *p, size);
1367 for (i = start, count = 0, p = _ptn; i <= end; i++) {
1373 point = (char *)FalReadFont( fid, i, pm.width, pm.height );
1374 if( point == (char *)FAL_ERROR ) {
1375 strcpy(err, FAL_ERROR_STR);
1376 FalCloseFont( fid );
1379 if (EXISTS_FLAG != 0)
1381 size = pm.height * ((pm.width+7)/8);
1382 *p = (char *) XtMalloc(size);
1383 bicopy(point, *p, size);
1389 FalCloseFont( fid );
1391 strcpy(err, resource.mg_non_code);
1398 freeSNF(addr, count)
1403 for (p=addr; count; count--, p++)
1405 XtFree((char *)addr);
1408 static int sig_flg = 0; /* flag for signal */
1411 * contents : write character patterns to the specified SNF file
1412 * values : 0 : terminated normally
1413 * -1 : terminated abnormally
1414 * 1xxx : process is not completed ¡Êxxx:persents finished¡Ë
1420 writeSNF( restart, err )
1421 int restart; /* ON:continue OFF:initial */
1422 int *err; /* errors : */
1424 static int pfstdi[2];
1427 static int width, height;
1429 static int persents = 0;
1435 char ptn[MAXPTNBYTE];
1443 /* get command path */
1444 if (!(command = (char *)get_cmd_path(getenv("PATH"), resource.l_ptog_cmd))){
1445 command = resource.l_ptog;
1448 if (fullFontData.cd_set == FAL_FONT_CS0)
1449 sprintf(code_set, "0");
1450 else if (fullFontData.cd_set == FAL_FONT_CS1)
1451 sprintf(code_set, "1");
1452 else if (fullFontData.cd_set == FAL_FONT_CS2)
1453 sprintf(code_set, "2");
1454 else if (fullFontData.cd_set == FAL_FONT_CS3)
1455 sprintf(code_set, "3");
1458 signal( SIGPIPE, sig_receive );
1461 if( restart == 0 ) {
1465 if( ptnGetInfo( &nptn, &width, &height ) != 0 ) {
1470 if( pipe(pfstdi) !=0 ) {
1482 close( 0 ); /** 0 ... stdin **/
1487 argv[0] = resource.l_ptog_cmd;
1488 argv[1] = "-codeset";
1491 argv[4] = fullFontData.xlfdname;
1495 execv (command, argv );
1501 fstdi = (FILE *)fdopen( pfstdi[1], "w" );
1502 fprintf( fstdi, "numfonts:%d\n", nptn );
1503 fprintf( fstdi, "width:%d\n", width );
1504 fprintf( fstdi, "height:%d\n", height );
1506 bitSetInfo( width, height );
1510 while( (n < nptn) && ( sig_flg == 0) ) {
1511 code = noToCode( ptnSqToNo(n) );
1512 if( ptnGet(code, ptn ) != 0 ) {
1520 fal_code_to_glyph(get_locale(), code, &gi, &num_gi);
1521 fprintf( fstdi, "code:0x%x\n", gi[0].glyph_index );
1522 FalFreeGI(gi, num_gi);
1524 fprintf( fstdi, "code:0x%x\n", code );
1526 writePtn(ptn, width, height, fstdi);
1535 if( (persents_ = (n*100)/nptn) != persents ) {
1536 persents = persents_;
1537 return( 1000 + persents );
1541 if(sig_flg == 0 ) fprintf( fstdi, "enddata\n" );
1549 if ( WIFEXITED(endst) && !WEXITSTATUS(endst) ) {
1554 if ( WIFEXITED(endst) )
1555 *err = WEXITSTATUS(endst);
1557 if ( WIFSTOPPED(endst) )
1558 *err = ( WTERMSIG(endst) << 8 );
1566 * contents : set flag when dtudcfonted received signal
1578 * contents : convert bit map file into SNF file
1582 writePtn(ptn, width, height, fp)
1592 static char buf[ (MAXPTNSIZE+1)*MAXPTNSIZE+1 ];
1594 nbyte = (width + 7) / 8;
1597 for (i=0 ; i < height ; i++) {
1598 for (j=0, tw=width ; j < nbyte ; j++ ) {
1600 for ( k=0 ; (k < 8) && (tw > 0) ; k++, tw--) {
1611 fprintf(fp, "%s", buf);