Initial import of the CDE 2.1.30 sources from the Open Group.

This commit is contained in:
Peter Howkins
2012-03-10 18:21:40 +00:00
commit 83b6996daa
18978 changed files with 3945623 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
XCOMM $XConsortium: Imakefile /main/12 1996/10/17 01:48:11 cde-fuj $
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
FONTEDT_PATH1 = ../dtudcfonted
UDC_INC_PATH0 = -I./
UDC_INC_PATH1 = -I$(FONTEDT_PATH1)
UDC_INC_PATH2 = -I$(FONTEDT_PATH1)/include
UDC_INC_PATH3 = -I$(FONTEDT_PATH1)/libfal
UDC_INC_PATH4 = -I$(FONTEDT_PATH1)/libfal/include
UDC_INC_PATH7 = -I$(FONTEDT_PATH1)/dtgpftobdf
INCLUDES = \
$(UDC_INC_PATH0)\
$(UDC_INC_PATH1)\
$(UDC_INC_PATH2)\
$(UDC_INC_PATH3)\
$(UDC_INC_PATH4)\
$(UDC_INC_PATH7)
#ifdef X11ProjectRoot
OPT2 = -DFONTC='"'$(XPROJECTROOT)/bin/bdftopcf'"'
#else
OPT2 = -DFONTC='"'$(BINDIR)/bdftopcf'"'
#endif
DEFINES = $(OPT2)
DEPLIBS = $(DEPDTSVCLIB) $(DEPTTLIB) $(DEPXMLIB) $(DEPXTOOLLIB) \
$(DEPXPLIB) $(DEPXLIB) \
$(FONTEDT_PATH1)/libfuty/liboakfuty.a \
$(FONTEDT_PATH1)/libfal/libfal.a
LOCAL_LIBRARIES = $(DTSVCLIB) $(TTLIB) $(XMLIB) $(XTOOLLIB) $(XPLIB) $(XLIB) \
$(FONTEDT_PATH1)/libfuty/liboakfuty.a \
$(FONTEDT_PATH1)/libfal/libfal.a
SYS_LIBRARIES = DtClientSysLibs
SRCS = udcexc.c udcexp.c udcimp.c getbdffn.c excutil.c\
selectx.c exportbdf.c importbdf.c
OBJS = udcexc.o udcexp.o udcimp.o getbdffn.o excutil.o\
selectx.o exportbdf.o importbdf.o
ComplexProgramTarget(dtudcexch)

View File

@@ -0,0 +1,31 @@
$XConsortium: README /main/3 1996/10/17 01:48:23 cde-fuj $
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
UDC data exchange utility README
Source code and directory structure
$(TOP)/cde/dtudcexch:
Imakefile
udcexc.c
udcexp.c
udcimp.c
getbdffn.c
excutil.c
excutil.h
selectx.c
exportbdf.c
importbdf.c
The dtudcexch command uses following commands.
dtaddcpf dtbdftocpf dtcpftobdf dtcpftogpf
dtcpgpf dtfonteditor dtgpftobdf dtgpftocpf
dtlsgpf
The dtudcexch command uses following libraries.
libfal.a
liboakfuty.a

View File

@@ -0,0 +1,127 @@
$ $XConsortium: dtudcfonted.msg
$ *************************************<+>*************************************
$ *****************************************************************************
$ **
$ ** File: dtudcexch.msg
$ **
$ ** Project: Fujitsu DT UDC Exchange
$ **
$ ** Description:
$ ** -----------
$ ** This file is the source for the message catalog for dtudcexch
$ **
$ **
$ *****************************************************************************
$ **
$ ** (c) Copyright 1996 Fujitsu Ltd.
$ **
$set 2
$ *****************************************************************************
$ ** _DtMessage set for getbdffn.c
$ *****************************************************************************
2 BDF file selection
4 The selected file exists. Overwrite?
6 Failed to open the selected file.
$set 4
$ *****************************************************************************
$ ** _DtMessage set for selectx.c
$ *****************************************************************************
2 This font has no user defined characters.
4 Failed to open the selected font. You do not have permission to access the font file, or the format of the file is incorrect.
6 The font file is in use by another UDC application.
8 There is no font
10 Open
12 Cancel
14 UDC data exchange utility
16 SelectItems
18 - Codeset:
20 - Style:
22 - Width:
24 - Height:
$set 6
$ *****************************************************************************
$ ** _DtMessage set for selectxlfd.c
$ *****************************************************************************
2 Do you want to terminate UDC Exchange?
4 No UDCs exist in this font
6 XLFD name is not selected
8 Cannot open the font file
10 The font file is in use by another UDC application.
$set 8
$ *****************************************************************************
$ ** _DtMessage set for udcexc.c
$ *****************************************************************************
2 UDC data exchange utility
4 Fatal error occurred.
6 Cannot open the font file.
8 Cannot read the font file.
10 There is no more memory.
12 Fatal error occurred.
14 The specified font file does not exist.
16 This font is not a pcf or snf font.
18 Cannot open the fonts.list file.
20 The format of the fonts.list file is incorrect.
22 The descriptions of the fonts.list file are incorrect.
24 The format of the fonts.list file is incorrect.
26 Cannot open the fonts.dir file.
28 Cannot read the fonts.dir file.
30 Cannot read the font properties.
32 Cannot get the FONT property.
34 Cannot get the FAMILY_NAME property.
36 This font file is already in use by another application.
38 Cannot lock the font file.
40 Cannot unlock the font file.
42 Cannot get lock information from the font file.
44 Cannot find the specified font file.
46 Cannot read the NLS database.
48 Cannot get charset names from the NLS database.
50 The charset name is not defined in the NLS database.
52 The specified font has not been opened.
54 A fatal error occurred.
56 XLFD name :
58 Original font (XLFD name) :
60 UDC code area :
62 Style :
64 Size (letter size) :
66 Open
68 Cancel
70 OK
72 cancel
74 Copy origin code(hex) :
76 Copy target code(hex) :
78 Copy
80 Overlay
82 export function
84 import function
86 Cancel
$set 10
$ *****************************************************************************
$ ** _DtMessage set for udcexp.c
$ *****************************************************************************
2 Failed to create the BDF file
4 No indexes are selected
6 OK
8 Cancel
10 glyph indexes
$set 12
$ *****************************************************************************
$ ** _DtMessage set for udcexp.c
$ *****************************************************************************
2 Glyph images in this BDF file cannot be added to the font.
4 Failed to open the selected BDF font. You do not have permission to access the font file, or the format of the file is incorrect.
6 One or more glyph images will be overwritten. Overwrite?
8 Failed to open the selected font. You do not have permission to access the font file, or the format of the file is incorrect.
10 Glyph images in this BDF file cannot be added to the font.
12 Registration of the font file failed.

View File

@@ -0,0 +1,314 @@
/* $XConsortium: excutil.c /main/3 1996/04/08 15:51:03 cde-fuj $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
#include "excutil.h"
extern char *maintitle;
Widget excCreatePushButton(Widget parent, String name, String label,
XtCallbackProc callback_func,
XtPointer client_data)
{
Widget widget;
XmString xms;
Arg args[20];
Cardinal n;
n = 0;
xms = XmStringCreateLocalized(label);
XtSetArg(args[n], XmNlabelString, xms); n++;
widget = XmCreatePushButton(parent, name, args, n);
XmStringFree(xms);
XtAddCallback(widget, XmNactivateCallback,
(XtCallbackProc) callback_func,
(XtPointer) client_data);
XtManageChild(widget);
return (widget);
}
void excerror(Exc_data * ed, int excerrno, char * funcname, char * func)
{
switch (excerrno)
{
case EXCERRMALLOC:
fprintf(stderr, "dtudcexch:memory allocation error\n");
freeExcdata(ed);
exit (-1);
case EXCERRNOUDC:
fprintf(stderr, "dtudcexch:UDC is not defined in current locale\n");
freeExcdata(ed);
exit (-1);
}
}
void dialogokCB(Widget widget, int * ans, XtPointer call_data)
{
/* ok button pushed */
*ans = 1;
}
void dialogcancelCB(Widget widget, int * ans, XtPointer call_data)
{
/* cancel button pushed */
*ans = 2;
}
void AskUser(Widget parent, Exc_data * ed, char *msg, int *r, char * type)
/* If ok button pushed, *r = 1. */
/* If cancel button pushed(if exists), *r = 2. */
{
XmString message;
Widget dialog;
int ans = 0;
Cardinal n;
Arg args[20];
n = 0;
message = XmStringCreateLocalized(msg);
XtSetArg(args[n], XmNmessageString, message); n++;
XtSetArg(args[n], XmNtitle, maintitle); n++;
XtSetArg(args[n], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL); n++;
if (strcmp(type, "warning") == 0) {
dialog = XmCreateWarningDialog(parent, type, args, n);
} else if (strcmp(type, "error") == 0) {
dialog = XmCreateErrorDialog(parent, type, args, n);
XtUnmanageChild(XmMessageBoxGetChild(dialog, XmDIALOG_CANCEL_BUTTON));
} else if (strcmp(type, "information") == 0) {
dialog = XmCreateInformationDialog(parent, type, args, n);
XtUnmanageChild(XmMessageBoxGetChild(dialog, XmDIALOG_CANCEL_BUTTON));
} else if (strcmp(type, "question") == 0) {
dialog = XmCreateQuestionDialog(parent, type, args, n);
} else {
fprintf(stderr, "error in AskUser\n");
}
XtUnmanageChild(XmMessageBoxGetChild(dialog, XmDIALOG_HELP_BUTTON));
XmStringFree(message);
XtAddCallback(dialog, XmNokCallback, (XtCallbackProc) dialogokCB,
(XtPointer) &ans);
XtAddCallback(dialog, XmNcancelCallback, (XtCallbackProc) dialogcancelCB,
(XtPointer) &ans);
XtManageChild(dialog);
while (ans == 0) {
XtAppProcessEvent(ed->app, XtIMAll);
XSync(XtDisplay(dialog), 0);
}
*r = ans;
XSync(XtDisplay(dialog), 0);
XmUpdateDisplay(dialog);
}
int beki(int n, int num)
{
int a,i;
a = 1;
for (i=0; i<num; i++)
a = a * n;
return a;
}
int c2h(char * num)
{
int i,n;
char *c;
if ((strlen(num)==6)&&(strncmp(num,"0x",2)==0))
{
c = num;
c=c+2;
n=0;
for (i=3;i>=0;i--)
{
if (('0'<= *c)&&(*c <= '9'))
n = n + ((*c - '0')*beki(16,i));
else if (('a' <= *c)&&(*c <= 'f'))
n = n + ((*c - 'a'+10)*beki(16,i));
else
Ecs("error in c2h.here");
c++;
}
} else
Ecs("error in c2h");
return n;
}
char * renge2num(char * renge)
{
char * num;
num = (char *) calloc(7, sizeof(char));
strncpy(num,renge,6);
return num;
}
void Ecs(char * string)
{
fprintf(stderr,"%s\n",string);
}
void Ecd(int data)
{
fprintf(stderr,"%d\n",data);
}
void freecsrec(UDCcsREC *rec)
{
if (rec->charset != NULL)
free(rec->charset);
if (rec->udcrenge != NULL)
free(rec->udcrenge);
}
void freecslist(int n, UDCcsREC *rec)
{
int i;
UDCcsREC *recp;
recp = rec;
for (i = 0; i < n; i++)
{
if (recp != NULL)
{
freecsrec(recp);
recp++;
} else {
break;
}
}
}
void freeExcdata(Exc_data *ed)
{
if (ed == NULL)
return;
/* Don't free ed->toplevel */
if (ed->locale != NULL)
free(ed->locale);
if (ed->cslist != NULL)
free(ed->cslist);
if (ed->xlfdname != NULL)
free(ed->xlfdname);
if (ed->style != NULL)
free(ed->style);
if (ed->size != NULL)
free(ed->size);
/* Don't free ed->fontfile */
if (ed->bdffile != NULL)
XtFree(ed->bdffile);
if (ed->udcrenge != NULL)
free(ed->udcrenge);
if (ed->gpf_code_list != NULL)
free(ed->gpf_code_list);
if (ed->bdf_code_list != NULL)
free(ed->bdf_code_list);
if (ed->comment_list != NULL)
free(ed->comment_list);
free(ed);
}
void Ecss(char * s1, char * s2)
{
fprintf(stderr,"%s is %s\n", s1, s2);
}
void Ecsd(char * s1, int i)
{
fprintf(stderr,"%s = %d\n", s1, i);
}
void checkdata(Exc_data *ed)
{
if (ed == NULL)
return;
/* Don't free ed->toplevel */
if (ed->locale != NULL)
Ecss("ed->locale", ed->locale);
Ecsd("ed->csnum", ed->csnum);
if (ed->xlfdname != NULL)
Ecss("ed->xlfdname",ed->xlfdname);
if (ed->fontfile != NULL)
Ecss("ed->fontfile",ed->fontfile);
if (ed->bdffile != NULL)
Ecss("ed->bdffile",ed->bdffile);
if (ed->udcrenge != NULL)
Ecss("ed->udcrenge",ed->udcrenge);
Ecsd("ed->code_num", ed->code_num);
}
void excterminate(Exc_data * ed)
{
freeExcdata(ed);
exit(0);
}
void excexit(Exc_data * ed)
{
excterminate(ed);
}
void freeld(ListData *ld)
{
int i;
char **cp;
if (ld != NULL) {
if (ld->allcode != NULL)
free(ld->allcode);
if (ld->existcode != NULL)
free(ld->existcode);
if (ld->existcode_c != NULL) {
cp = ld->existcode_c;
for (i = 0; i < ld->existcode_num; i++) {
if (*cp != NULL)
free(*cp);
cp++;
}
free(ld->existcode_c);
}
free(ld);
}
}
int bigger(int num1, int num2)
{
if (num1 >= num2)
return (num1);
else
return (num2);
}
int smaller(int num1, int num2)
{
if (num1 < num2)
return (num1);
else
return (num2);
}

View File

@@ -0,0 +1,115 @@
/* $XConsortium: excutil.h /main/6 1996/12/23 08:48:26 barstow $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
#include <stdio.h>
#include <stdlib.h>
#include <Xm/Xm.h>
#include <Xm/MessageB.h>
#include <Xm/PushB.h>
#define EXPORT 1
#define IMPORT 2
#define EXCERRMALLOC 101
#define EXCERRNOUDC 102
void Ecs();
void Ecd();
/*void getpcffn();*/
void getbdffn();
void selcharcd();
void getcharcd();
void createbdf();
int bigger();
int smaller();
int c2h();
char *renge2num();
void freeExcdata();
void checkdata();
void excexit();
void excterminate();
void freeld();
void getexistcode();
void AskUser();
void excerror();
Widget excCreatePushButton();
typedef struct {
char * charset;
char * udcrenge;
} UDCcsREC;
typedef struct {
int function;
XtAppContext app;
Widget toplevel;
char *locale;
int csnum;
UDCcsREC *cslist;
char *xlfdname;
char *style;
char *size;
char *fontfile;
char *bdffile;
char bdfmode[2];
char *udcrenge;
int code_num;
int *gpf_code_list;
int *bdf_code_list;
int comment_num;
char **comment_list;
} Exc_data;
typedef struct {
Widget list;
int allcode_num;
int *allcode;
int existcode_num;
int *existcode;
char **existcode_c;
Exc_data *ed;
} ListData;
#ifndef NO_MESSAGE_CATALOG
# ifdef __ultrix
# define _CLIENT_CAT_NAME "dtudcexch.cat"
# else /* __ultrix */
# define _CLIENT_CAT_NAME "dtudcexch"
# endif /* __ultrix */
# ifdef _NO_PROTO
extern char *_DtGetMessage();
# else /* _NO_PROTO */
extern char *_DtGetMessage(
char *filename,
int set,
int n,
char *s );
# endif /* _NO_PROTO */
#define GETMESSAGE(set, number, string) GetMessage(set, number, string)
static char *
GetMessage(set, number, string)
int set, number;
char *string;
{
char *tmp;
static char * point[100];
static int first = True;
if (first) {
memset(point, 0, sizeof(char *) * 100);
first = False;
}
if (point[number])
return(point[number]);
tmp = _DtGetMessage(_CLIENT_CAT_NAME, set, number, string);
point[number] = (char *) malloc(strlen(tmp) + 1);
strcpy(point[number], tmp);
return (point[number]);
}
#else /* NO_MESSAGE_CATALOG */
# define GETMESSAGE(set, number, string)\
string
#endif /* NO_MESSAGE_CATALOG */

View File

@@ -0,0 +1,350 @@
/* $XConsortium: exportbdf.c /main/4 1996/04/10 13:49:20 ageorge $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*
* Authors: Seiya Miyazaki FUJITSU LIMITED
* Hiroyuki Chiba FUJITSU LIMITED
*/
#include <stdio.h>
#include <fcntl.h>
#include <signal.h>
#ifndef SVR4
#if !defined( SYSV )
#include <sys/resource.h>
#endif
#ifdef __osf__
#define _BSD
#endif
#include <sys/wait.h>
#ifdef __osf__
#undef _BSD
#endif
#else
#include <wait.h>
#endif
#include <memory.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
#include "bdfgpf.h"
static int writeBdfHeader();
static int readBdfToMemory();
static void sigint_out();
static char buf[BUFSIZE];
static struct ptobhead w_bdf ;
static void
sigint_out()
{
fclose(w_bdf.output) ;
fclose(w_bdf.input) ; /* stream */
exit( 0 );
}
int
expCheckCode( code, code_num, code_list )
unsigned int code ;
int code_num ;
int *code_list ;
{
int i ;
if( code < MIN_CODE || code > MAX_CODE ) return -1 ;
for( i=0; i<code_num; i++ ){
if( code == code_list[i] ) return 0 ;
}
return -1 ;
}
int
ExpGpftoBDF( gpf_name, bdf_name, code_num, code_list, comment_num, comment_list, make_all )
char *gpf_name ; /* pointer to GPF file name area */
char *bdf_name ; /* pointer to BDF file name area */
int code_num ; /* number of GPF code */
int *code_list ; /* pointer to GPF code lists */
int comment_num ; /* number comments */
char **comment_list ;/* pointer to the list of comments */
int make_all ; /* convert whole GPF fomat file to BDF */
{
struct stat statbuf ;
struct btophead r_gpf ;
int rtn, i, num_chars ;
/*
* parameter check
*/
if( gpf_name == NULL || bdf_name == NULL ){
fprintf(stderr, "GPF or BDF file name is not specified.\n" ) ;
return -1 ;
}
/*
* initiation
*/
memset( &w_bdf, 0, sizeof(struct ptobhead) ) ;
memset( &r_gpf, 0, sizeof(struct btophead) ) ;
if ( stat( SNFTOBDF, &statbuf ) ) {
if (!( oakgtobdf = get_cmd_path( getenv( "PATH" ), SNFTOBDF_CMD ))) {
fprintf( stderr, "There is not %s command.\n", SNFTOBDF_CMD ) ;
return -1 ;
}
}else{
oakgtobdf = SNFTOBDF;
}
/*
* export glyphs in BDF format
*/
w_bdf.snf_file = gpf_name ;
if( (w_bdf.output = fopen( bdf_name, "w" )) == NULL ){
fprintf(stderr, "\"%s\" cannot open.\n", bdf_name ) ;
return -1 ;
}
signal( SIGHUP , (void(*)())sigint_out );
signal( SIGINT , (void(*)())sigint_out );
signal( SIGQUIT, (void(*)())sigint_out );
signal( SIGTERM, (void(*)())sigint_out );
if( (rtn = writeBdfHeader(&w_bdf, comment_num, comment_list)) ){
fprintf(stderr, "\"%s\" cannot write header.\n", bdf_name ) ;
fclose(w_bdf.output) ;
fclose(w_bdf.input) ; /* stream */
return rtn ;
}
r_gpf.bdf_width = w_bdf.bdf_width ;
r_gpf.bdf_height = w_bdf.bdf_height ;
r_gpf.input = w_bdf.input ;
num_chars = ((make_all) ? w_bdf.num_chars : code_num) ;
if( (r_gpf.code = (int *)malloc( sizeof(int) * num_chars)) == NULL ) {
fclose(w_bdf.output) ;
fclose(w_bdf.input) ;
return(MALLOC_ERROR);
}
if( (r_gpf.ptn = (char **)calloc( num_chars, sizeof(char *) )) == NULL ) {
fclose(w_bdf.output) ;
fclose(w_bdf.input) ;
return(MALLOC_ERROR);
}
if( (rtn = readBdfToMemory(&r_gpf, buf, code_num, code_list, make_all)) ){
fprintf(stderr, "\"%s\" cannot read glyph.\n", bdf_name ) ;
fclose(w_bdf.output) ;
fclose(w_bdf.input) ;
return rtn ;
}
fclose(w_bdf.input) ;
wait(0) ;
w_bdf.zoomf = 0 ;
w_bdf.num_chars = r_gpf.num_chars ;
w_bdf.code = r_gpf.code ;
w_bdf.ptn = r_gpf.ptn ;
if( (rtn = WritePtnToBdf( &w_bdf, buf )) ){
fprintf(stderr, "\"%s\" cannot write glyph.\n", bdf_name ) ;
fclose(w_bdf.output) ;
return rtn ;
}
fclose(w_bdf.output) ;
signal( SIGHUP , SIG_IGN );
signal( SIGINT , SIG_IGN );
signal( SIGQUIT, SIG_IGN );
signal( SIGTERM, SIG_IGN );
/*
* free memories
*/
free( r_gpf.code ) ;
for(i=0; i<r_gpf.num_chars; i++){
if(r_gpf.ptn[i]) free(r_gpf.ptn[i]) ;
}
free( r_gpf.ptn ) ;
return 0 ;
}
static int
writeBdfHeader(head, comment_num, comment_list)
struct ptobhead *head;
int comment_num ; /* number comments */
char **comment_list ;/* pointer to the list of comments */
{
FILE *fp;
int fd[2];
unsigned int getstat;
char buf[BUFSIZE], *p;
int cnt ;
int comflg ;
pid_t chld_pid = 0;
#if defined( SVR4 ) || defined( SYSV )
int chld_stat ;
#else
union wait chld_stat ;
#endif
if (head->snf_file != NULL) {
if (pipe(fd) != 0) {
return PIPE_ERROR;
}
switch (chld_pid = fork()) {
case 0:
close(1);
if(dup(fd[1]) < 0) {
return(DUP_ERROR);
}
close(fd[0]);
close(fd[1]);
execl( oakgtobdf, oakgtobdf, head->snf_file, 0);
return EXEC_ERROR;
case -1:
return(FORK_ERROR);
default:
break;
}
close(fd[1]);
if((fp = (FILE *)fdopen(fd[0], "r")) == NULL) {
close( fd[0] );
kill( chld_pid, SIGKILL );
WaitID( chld_pid, chld_stat ) ;
return FDOPEN_ERROR;
}
} else {
return(BDF_OPEN_HEAD);
}
head->input = fp ;
getstat = 0;
comflg = 0 ;
while ( 1 ) {
if (fgets(buf, BUFSIZE, fp) == NULL) {
fclose( fp );
if (head->snf_file != NULL) {
close(fd[0]);
kill( chld_pid, SIGKILL );
WaitID( chld_pid, chld_stat ) ;
}
return(BDF_INVAL);
}
p = buf;
SCAN_TO_NONSP(p);
if (!strncmp(p, CHARS, CHARSsz)) {
if ((sscanf(p, "CHARS %d", &(head->num_chars))) != 1 ){
return(BDF_INVAL);
}
getstat |= 0x04;
break;
}
/*
* write user comments
*/
if ( !strncmp(p, "FONT", strlen("FONT"))
&& comment_list && !comflg
) {
int i ;
for( i=0; i<comment_num; i++ ){
char *ep ;
if( (ep = (char *)strchr( comment_list[i], '\n' )) != NULL )
*ep = '\0' ;
if( comment_list[i] == '\0' ) continue ;
fprintf(head->output, "COMMENT %s\n", comment_list[i]);
}
fprintf(head->output, "COMMENT\n");
comflg++ ;
}
fprintf(head->output, "%s", buf);
if (!strncmp(p, SIZE, SIZEsz)) {
if ((sscanf(p, "SIZE %f%d",
&(head->bdf_point), &(head->bdf_xdpi))) != 2) {
fclose(fp);
if (head->snf_file != NULL) {
close(fd[0]);
kill( chld_pid, SIGKILL );
WaitID( chld_pid, chld_stat ) ;
}
return(BDF_INVAL);
}
getstat |= 0x01;
continue;
}
if (!strncmp(p, FONTBOUNDINGBOX, FONTBOUNDINGBOXsz)) {
if (( cnt = sscanf( p, "FONTBOUNDINGBOX %d%d%d%d",
&(head->bdf_width), &(head->bdf_height),
&(head->bdf_x), &(head->bdf_y))) != 4
) {
fclose(fp);
if (head->snf_file != NULL) {
close(fd[0]);
kill( chld_pid, SIGKILL );
WaitID( chld_pid, chld_stat ) ;
}
return BDF_INVAL;
}
getstat |= 0x02;
continue;
}
get_charset_registry(head, p) ;
}
if (getstat != 0x07) {
return BDF_INVAL;
}
return 0;
}
static int
readBdfToMemory(head, buf, code_num, code_list, make_all)
struct btophead *head;
char *buf;
int code_num ; /* number of GPF code */
int *code_list ; /* pointer to GPF code lists */
int make_all ; /* convert whole GPF fomat file to BDF */
{
int code, mwidth, num_char, bsize, rtn;
char *ptn;
num_char = 0;
mwidth = (head->bdf_width + 7) / 8;
bsize = mwidth * head->bdf_height;
while(1) {
if ((rtn = GetBdfCode(head, buf, &code)) < 0) {
return(rtn); /* contain BDF_INVAL */
} else if (rtn == FILE_END) {
head->num_chars = num_char;
break;
}
if ( !make_all ) {
if ( expCheckCode(code, code_num, code_list) ) {
continue;
}
}
head->code[num_char] = code;
if ( ( ptn = head->ptn[num_char++] = (char *)malloc( bsize ) ) == NULL ) {
return(MALLOC_ERROR);
}
if ((rtn = GetBdfPtn(head, buf, ptn, mwidth, bsize)) != 0) {
return(rtn);
}
}
return(0);
}

View File

@@ -0,0 +1,158 @@
/* $XConsortium: getbdffn.c /main/5 1996/10/14 14:44:32 barstow $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
#include "excutil.h"
#include <Xm/FileSB.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
/*
* There is no public header file for this function (only an
* internal header XmStringI.h).
*/
extern XtPointer _XmStringUngenerate (XmString string,
XmStringTag tag,
XmTextType tag_type,
XmTextType output_type);
void filesbokCB();
void filesbcancelCB();
extern char *maintitle;
void getbdffn(Exc_data * ed)
{
Widget filesb;
Arg args[20];
Cardinal n;
char *selectlabel;
XmString xms;
selectlabel = GETMESSAGE(2, 2, "BDF file selection");
n = 0;
XtSetArg(args[n], XmNtitle, maintitle); n++;
xms = XmStringCreateLocalized(selectlabel);
XtSetArg(args[n], XmNselectionLabelString, xms); n++;
filesb = XmCreateFileSelectionDialog(ed->toplevel, "filesb", args, n);
XtAddCallback(filesb, XmNokCallback,
(XtCallbackProc) filesbokCB,
(XtPointer) ed);
XtAddCallback(filesb, XmNcancelCallback,
(XtCallbackProc) filesbcancelCB,
(XtPointer) ed);
XtUnmanageChild(XmFileSelectionBoxGetChild(filesb, XmDIALOG_HELP_BUTTON));
XtManageChild(filesb);
}
int fopencheck(char *file, char *dir, char *mode)
/*
* when mode = "r", if fopen can open the file with read only mode, return 0
* when mode = "w", if fopen can open the file with write mode, return 0
* but if the file exists, return 1
* otherwise return -1
*/
{
struct stat buf;
if (strcmp(mode, "r") == 0) {
if (stat(file, &buf) == 0)
if ((buf.st_mode & S_IFMT) == S_IFREG)
return 0; /* readable regular file */
} else if (strcmp(mode, "w") == 0) {
if (stat(file, &buf) == 0) {
if (((buf.st_mode & S_IFMT) == S_IFREG) &&
(access(file, W_OK) == 0))
return 1; /* writable existing file */
} else {
if (stat(dir, &buf) == 0) {
if (((buf.st_mode & S_IFMT) == S_IFDIR) &&
(access(dir, W_OK) == 0)) {
return 0; /* writable new file */
}
}
}
} else
fprintf(stderr, "Unanticipatable error occured in fopencheck.\n");
return -1;
}
void filesbcancelCB(Widget widget, Exc_data * ed, XtPointer call_data)
{
excexit(ed);
}
void freeStrings(char * dir, char * file)
{
if (dir != NULL)
XtFree(dir);
if (file != NULL)
XtFree(file);
}
void filesbokCB(Widget widget, Exc_data * ed, XtPointer call_data)
{
XmFileSelectionBoxCallbackStruct *ptr;
char *file = NULL, *dir = NULL, *tmpfile;
int r, ans = 0;
char *msg1;
char *msg2;
msg1 = GETMESSAGE(2, 4, "The selected file exists. Overwrite?");
msg2 = GETMESSAGE(2, 6, "Failed to open the selected file.");
ptr = (XmFileSelectionBoxCallbackStruct *) call_data;
file = (char *) _XmStringUngenerate((XmString) ptr->value, NULL,
XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
if (!file) {
return;
}
dir = (char *) _XmStringUngenerate((XmString) ptr->dir, NULL,
XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
if (!dir) {
return;
} else {
if (*file != '/') {
if ((tmpfile = XtMalloc(strlen(dir) + 1 + strlen(file) + 1))
== NULL) {
excerror(ed, EXCERRMALLOC, "filesbokCB", "exit");
}
sprintf(tmpfile, "%s/%s", dir, file);
XtFree(file);
file = tmpfile;
}
}
r = fopencheck(file, dir, ed->bdfmode);
if (r == 0) {/* no problem */
/*fprintf(stderr, "%s will be opened\n", file);*/
} else if (r == 1) { /* file exist at export function */
AskUser(widget, ed, msg1, &ans, "warning");
if (ans != 1) { /* overwrite cancel */
freeStrings(dir, file);
return;
}
} else { /* file will not be opened */
AskUser(widget, ed, msg2, &ans, "error");
freeStrings(dir, file);
return;
}
ed->bdffile = (char *) malloc(strlen(file) + 1);
strcpy(ed->bdffile, file);
freeStrings(dir, file);
XtUnmanageChild(widget);
if (ed->function == EXPORT)
{
createbdf(ed);
} else if (ed->function == IMPORT)
{
PopupSelectXLFD(ed->toplevel);
}
}

View File

@@ -0,0 +1,686 @@
/* $XConsortium: importbdf.c /main/5 1996/06/27 10:40:33 ageorge $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*
* Authors: Seiya Miyazaki FUJITSU LIMITED
* Hiroyuki Chiba FUJITSU LIMITED
*
*/
#include <stdio.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifndef SVR4
#if !defined( SYSV )
#include <sys/resource.h>
#endif
#include <sys/wait.h>
#else
#include <wait.h>
#endif
#include <unistd.h>
#include <X11/Xmd.h>
#include <X11/Xproto.h>
#include "bdfgpf.h"
#include "FaLib.h"
#include <errno.h>
#define UNLINK_TMPFILE( file ){ \
if ( unlink( file ) != 0 ) { \
exit(-1) ; \
} \
}
static impFileConvInit();
static impGetGpfInf();
static impReadBdfHeaderAndPut();
static impMergePtn();
static impModifyPtn();
static impInsertPtn();
static impWriteSnf();
static int impWritePtnToBdf();
static int impPutDefaultChars();
static int impReadBdfToMemory();
extern int expCheckCode();
static struct ptobhead WriteGpf;
static char *targ_file = NULL; /* UDC_file_name */
static void
sigint_out()
{
if (WriteGpf.out_file) {
UNLINK_TMPFILE( WriteGpf.out_file );
}
exit( 0 );
}
int
ImpBDFCodeList( bdf_name, code_num, code_list )
char *bdf_name ;
int *code_num ;
int **code_list ;
{
int *glyph_list ;
FILE *bdfp ;
char *p ;
char buf[2048] ;
int cnt ;
/* open BDF file */
if( (bdfp = fopen( bdf_name, "r" )) == NULL ){
return(-1);
}
/* get number of characters in BDF file */
while ( 1 ) {
if( fgets( buf, BUFSIZE, bdfp ) == NULL) {
return (BDF_INVAL);
}
p = buf;
SCAN_TO_NONSP( p )
if ( !strncmp( p, CHARS, (unsigned int)strlen( CHARS ) ) ) {
if ( ( sscanf( p, "CHARS %d", code_num ) ) != 1 ) {
return BDF_INVAL;
}
break ;
}
}
/* alloc memory for codes */
if( (glyph_list = (int *)calloc( *code_num, (unsigned int)sizeof(int) )) == NULL ){
return(-1);
}
/* get codes of BDF file */
cnt = 0 ;
while( cnt < *code_num ) {
if (fgets(buf, BUFSIZE, bdfp ) == NULL) {
return (BDF_INVAL);
}
p = buf;
SCAN_TO_NONSP( p )
if (!strncmp(p, ENDFONT, (unsigned int)ENDFONTsz)) {
break;
}else if (!strncmp(p, ENCODING, (unsigned int)ENCODINGsz)) {
if ((sscanf(p, "ENCODING %d", &glyph_list[cnt] )) != 1) {
return(BDF_INVAL);
}
cnt ++ ;
}
}
if( cnt != *code_num ){
return(-1) ;
}
/* close BDF file */
if( fclose( bdfp ) ){
return(-1);
}
*code_list = glyph_list ;
return(0) ;
}
int
ImpBDFCodeListFree( code_list )
int **code_list ;
{
free( *code_list ) ;
return(0) ;
}
int
ImpBDFCheck( bdf_name, gpf_name )
char *bdf_name ; /* BDF file name */
char *gpf_name ; /* GPF file name */
{
/* parameter check */
if( bdf_name == NULL || gpf_name == NULL ){
return(-1) ;
}
return(0) ;
}
int
ImpBDFtoGpf( bdf_name, gpf_name, bdf_codenum, bdf_codelist)
char *bdf_name ;
char *gpf_name ;
int bdf_codenum ;
int *bdf_codelist ;
{
int rtn ;
int exit_stat;
struct btophead ReadGpf;
struct btophead ReadUdc;
struct stat statbuf;
char buf[BUFSIZE];
int chk_fd;
ReadGpf.in_file = ReadUdc.in_file = WriteGpf.out_file = NULL;
if (!( bdftopcf = get_cmd_path( getenv( "PATH" ), BDFTOPCF_CMD ))) {
bdftopcf = BDFTOPCF;
}
if (!( oakgtobdf = get_cmd_path( getenv( "PATH" ), SNFTOBDF_CMD ))) {
oakgtobdf = SNFTOBDF;
}
if (!( bdftosnf = get_cmd_path( getenv( "PATH" ), BDFTOSNF_CMD ))) {
bdftosnf = BDFTOSNF;
}
/*
* set input/output file name
*/
ReadUdc.in_file = bdf_name ;
ReadUdc.code_category = ALL_CODE ;
ReadUdc.start_code = MIN_CODE ;
ReadUdc.end_code = MAX_CODE ;
ReadGpf.in_file = gpf_name ;
ReadGpf.code_category = ALL_CODE ;
ReadGpf.start_code = MIN_CODE ;
ReadGpf.end_code = MAX_CODE ;
/*
* get real file name of GPF file
*/
if ((targ_file = GetRealFileName( ReadGpf.in_file )) == NULL){
return(-1);
}
/*
* WriteGpf.snf_file = ReadGpf.in_file
*/
WriteGpf.snf_file = targ_file;
signal( SIGHUP , (void(*)())sigint_out );
signal( SIGINT , (void(*)())sigint_out );
signal( SIGQUIT, (void(*)())sigint_out );
signal( SIGTERM, (void(*)())sigint_out );
/*
* impFileConvInit()
*
* SNFTOBDF, BDFTOSNF
*
* (ReadGpf.in_file) --> SNFTOBDF ==H
* H
* oakaddp <-- (ReadUdc.in_file)
* H
* (WriteGpf.out_file) <-- BDFTOSNF ==H
*
*/
/*
* make a temporary file by BDF format corresponded to target GPF file
*/
if ( rtn = impFileConvInit( &ReadUdc, &ReadGpf, &WriteGpf ) ) {
if ( WriteGpf.out_file ) {
UNLINK_TMPFILE( WriteGpf.out_file );
}
return(-1) ;
}
/*
* get informations from import file in BDF format
*/
if ( rtn = ReadBdfHeader( &ReadUdc, buf ) ) {
if ( WriteGpf.out_file ) {
UNLINK_TMPFILE( WriteGpf.out_file );
}
return(-1) ;
}
/*
* get informations from target file in BDF format
*/
if ( rtn = impGetGpfInf( &ReadGpf, &WriteGpf, buf, bdf_codenum ) ) {
if ( WriteGpf.out_file ) {
UNLINK_TMPFILE( WriteGpf.out_file );
}
return(-1) ;
}
/* wait for dtgpftobdf */
fclose( ReadGpf.input );
wait( 0 );
/*
* merge the UDC glyphs into GPF file (in BDF format)
*/
if ( ( rtn = impMergePtn( &ReadUdc, &ReadGpf, buf,
bdf_codenum, bdf_codelist ) ) ) {
if ( WriteGpf.out_file ) {
UNLINK_TMPFILE( WriteGpf.out_file );
}
return(-1) ;
}
/*
* write the UDC data into GPF output file (in BDF format)
*/
if ( ( rtn = impWriteSnf( &ReadGpf, &WriteGpf ) ) ) {
if ( WriteGpf.out_file ) {
UNLINK_TMPFILE( WriteGpf.out_file );
}
return(-1) ;
}
/*
* convert temporary file into GPF format
*/
fclose( ReadUdc.input );
fclose( WriteGpf.output );
wait( &exit_stat );
#if !defined( SVR4 ) && !defined( SYSV )
if ( !WIFEXITED(exit_stat) ) {
#else
if ( ! ( WIFEXITED(exit_stat) && !WEXITSTATUS(exit_stat) ) ) {
#endif
UNLINK_TMPFILE( WriteGpf.out_file );
return(-1) ;
}
signal( SIGHUP , SIG_IGN );
signal( SIGINT , SIG_IGN );
signal( SIGQUIT, SIG_IGN );
signal( SIGTERM, SIG_IGN );
sleep( 1 );
if ( ( stat( WriteGpf.out_file, &statbuf ) ) || ( statbuf.st_size == 0 )
) {
UNLINK_TMPFILE( WriteGpf.out_file );
return(-1) ;
}
if ( stat( WriteGpf.snf_file, &statbuf ) ) {
UNLINK_TMPFILE( WriteGpf.out_file );
return( -1 );
}
/*
* convert the temporary file to target file
*/
return( Make_NewFefFile( WriteGpf.snf_file, WriteGpf.out_file,
FONT_FILE_PARM, (uid_t)statbuf.st_uid, (gid_t)statbuf.st_gid, "ImpBDFtoGpf()" ));
}
/*
* sub functions
*/
static
impFileConvInit(r_udc, r_gpf, w_gpf )
struct btophead *r_udc;
struct btophead *r_gpf;
struct ptobhead *w_gpf;
{
int fd[2], snf_fd, permission;
char buf[BUFSIZE];
int pfd[2], ofd;
FontInfoRec *finf;
char *optlist[5] = {0,0,0,0,0};
char *ep ;
int i ;
struct stat statbuf ;
if ( ( r_udc->input = fopen(r_udc->in_file, "r")) == NULL ) {
return GPF_OPEN_IN;
}
/*
* case of SNF file
*/
if ( ChkPcfFontFile( w_gpf->snf_file ) ) {
/* snf */
if ( ( snf_fd = open( w_gpf->snf_file, O_RDONLY ) ) >= 0 ) {
COMM_SNF_FILEVERSION( snf_fd, finf, buf, permission ) ;
if( permission < 0 ) {
return BDF_INVAL;
}
} else {
return BDF_OPEN_IN;
}
}
if (pipe(fd) != 0) {
return PIPE_ERROR;
}
switch ( fork() ) {
case 0:
close( fd[0] );
close( 1 );
if ( dup( fd[1] ) < 0 ) {
return DUP_ERROR;
}
close( fd[1] );
/* gpf -> bdf */
execl( oakgtobdf, oakgtobdf, r_gpf->in_file, 0 );
return EXEC_ERROR;
case -1:
return FORK_ERROR;
default:
break;
}
close( fd[1] );
if ( ( r_gpf->input = (FILE *)fdopen( fd[0], "r" ) ) == NULL ) {
return FDOPEN_ERROR;
}
if ( !( w_gpf->out_file = GetTmpPath( targ_file ) ) ) {
return MKTMP_ERROR;
}
if ( pipe( pfd ) != 0 ) {
return PIPE_ERROR;
}
switch ( fork() ) {
case 0:
if ( ( ofd = open( w_gpf->out_file, O_WRONLY | O_CREAT, 0664 ) ) < 0 ) {
return BDF_OPEN_OUT;
}
close( 0 );
if ( dup(pfd[0]) < 0 ) {
return DUP_ERROR;
}
close( pfd[0] );
close( pfd[1] );
close( 1 );
if( dup( ofd ) < 0 ) {
return DUP_ERROR;
}
close( ofd );
/*
* case of PCF file format
*/
if ( ChkPcfFontFile( w_gpf->snf_file ) == 0 ) {
execl( bdftopcf, bdftopcf, 0 );
return EXEC_ERROR;
}
/*
* case of SNF file format
*/
COMM_SNF_EXECLBDFTOSNF( permission, buf, w_gpf->snf_file ) ;
return EXEC_ERROR;
case -1:
return FORK_ERROR;
default:
break;
}
close( pfd[0] );
if ( ( w_gpf->output = (FILE *)fdopen( pfd[1], "w" ) ) == NULL ) {
return FDOPEN_ERROR;
}
return 0;
}
static
impGetGpfInf( r_gpf, w_gpf, buf, bdf_codenum )
struct btophead *r_gpf;
struct ptobhead *w_gpf;
char *buf;
int bdf_codenum ;
{
int nchar, rtn;
if ( ( rtn = impReadBdfHeaderAndPut( r_gpf, w_gpf, buf ) ) ) {
return rtn;
}
nchar = r_gpf->num_chars + bdf_codenum ;
if ( ( r_gpf->code = (int *)malloc( sizeof(int) * nchar ) ) == NULL ) {
return MALLOC_ERROR;
}
if ( ( r_gpf->ptn = (char **)malloc( sizeof(char *) * nchar ) ) == NULL ) {
return MALLOC_ERROR;
}
return ReadBdfToMemory( r_gpf, buf ) ;
}
static
impReadBdfHeaderAndPut(r_gpf, w_gpf, buf)
struct btophead *r_gpf;
struct ptobhead *w_gpf;
char *buf;
{
char *p;
unsigned int getstat = 0;
while ( 1 ) {
if ( fgets( buf, BUFSIZE, r_gpf->input ) == NULL ) {
return BDF_INVAL;
}
p = buf;
SCAN_TO_NONSP( p )
if ( !strncmp( p, SIZE, (unsigned int)strlen( SIZE ) ) ) {
if ( ( sscanf( p, "SIZE %f%d",
&(r_gpf->bdf_point), &(r_gpf->bdf_xdpi))) != 2 ) {
return BDF_INVAL;
}
fprintf( w_gpf->output, "%s", buf );
getstat |= 0x01;
} else if ( !strncmp( p, FONTBOUNDINGBOX, (unsigned int)strlen( FONTBOUNDINGBOX ) ) ) {
if ( ( sscanf( p, "FONTBOUNDINGBOX %d %d %d %d",
&(r_gpf->bdf_width), &(r_gpf->bdf_height),
&(r_gpf->bdf_x), &(r_gpf->bdf_y) ) ) != 4 ) {
return BDF_INVAL;
}
fprintf( w_gpf->output, "%s", buf );
getstat |= 0x02;
} else if ( !strncmp( p, CHARS, (unsigned int)strlen( CHARS ) ) ) {
if ( ( sscanf( p, "CHARS %d", &( r_gpf->num_chars ) ) ) != 1 ) {
return BDF_INVAL;
}
getstat |= 0x04;
break;
} else {
fprintf( w_gpf->output, "%s", buf );
}
}
if ( getstat != 0x07 ) {
return BDF_INVAL;
}
return 0;
}
static
impMergePtn(r_udc, r_gpf, buf, bdf_codenum, bdf_codelist )
struct btophead *r_udc;
struct btophead *r_gpf;
char *buf;
int bdf_codenum ;
int *bdf_codelist ;
{
int code, rtn, msize, i, j;
char *ptn;
if ( ( r_udc->bdf_width != r_gpf->bdf_width )
|| ( r_udc->bdf_height != r_gpf->bdf_height )
) {
r_udc->zoomf = 1;
msize = ( r_udc->bdf_width + 7 ) / 8 * r_udc->bdf_height;
if ( ( ptn = (char *)malloc( msize ) ) == NULL ) {
return MALLOC_ERROR;
}
r_udc->ptn = &ptn;
} else {
r_udc->zoomf = 0;
}
for ( i = 0; i < r_udc->num_chars; i++ ) {
if ( ( rtn = GetBdfCode( r_udc, buf, &code ) ) < 0 ) {
return rtn;
} else if ( rtn == FILE_END ) {
break;
}
if( expCheckCode( code, bdf_codenum, bdf_codelist ) ) {
continue ;
}
for ( j = 0; j < r_gpf->num_chars; j++ ) {
if ( r_gpf->code[j] == code ) {
if ( ( rtn = impModifyPtn( r_udc, r_gpf, buf, j ) ) ) {
return rtn;
}
break;
} else if ( r_gpf->code[j] > code ) {
if ( ( rtn = impInsertPtn( r_udc, r_gpf, buf, code, j ) ) ) {
return rtn;
}
break;
}
}
if ( j == r_gpf->num_chars ) {
if ( ( rtn = impInsertPtn( r_udc, r_gpf, buf, code, j ) ) ) {
return rtn;
}
}
}
return 0;
}
static
impModifyPtn( r_udc, r_gpf, buf, ix )
struct btophead *r_udc;
struct btophead *r_gpf;
char *buf;
int ix;
{
int mwidth, msize, rtn;
mwidth = ( r_udc->bdf_width + 7 ) / 8;
msize = mwidth * r_udc->bdf_height;
if ( r_udc->zoomf ) {
if ( ( rtn = GetBdfPtn( r_udc, buf, r_udc->ptn[0], mwidth, msize ) ) ) {
return rtn;
}
if ( ( rtn = PtnZoom( r_gpf->ptn[ix], r_udc->ptn[0],
r_udc->bdf_width, r_udc->bdf_height,
r_gpf->bdf_width, r_gpf->bdf_height ) ) ) {
return rtn;
}
} else {
if ( ( rtn = GetBdfPtn( r_udc, buf, r_gpf->ptn[ix], mwidth, msize ) ) ) {
return rtn;
}
}
return 0;
}
static
impInsertPtn( r_udc, r_gpf, buf, code, ix )
struct btophead *r_udc;
struct btophead *r_gpf;
char *buf;
int code;
int ix;
{
int mwidth, msize, rtn, i;
for ( i = r_gpf->num_chars; i > ix; i-- ) {
r_gpf->code[i] = r_gpf->code[i-1];
r_gpf->ptn[i] = r_gpf->ptn[i-1];
}
r_gpf->code[ix] = code;
r_gpf->num_chars++;
mwidth = (r_gpf->bdf_width + 7) / 8;
msize = mwidth * r_gpf->bdf_height;
if ( ( r_gpf->ptn[ix] = (char *)malloc( msize ) ) == NULL ) {
return MALLOC_ERROR;
}
if ( r_udc->zoomf ) {
mwidth = (r_udc->bdf_width + 7) / 8;
msize = mwidth * r_udc->bdf_height;
if ( ( rtn = GetBdfPtn( r_udc, buf, r_udc->ptn[0], mwidth, msize ) ) ) {
return rtn;
}
if ( ( rtn = PtnZoom( r_gpf->ptn[ix], r_udc->ptn[0],
r_udc->bdf_width, r_udc->bdf_height,
r_gpf->bdf_width, r_gpf->bdf_height ) ) ) {
return rtn;
}
} else {
if ( ( rtn = GetBdfPtn( r_udc, buf, r_gpf->ptn[ix], mwidth, msize ) ) ) {
return rtn;
}
}
return(0);
}
static
impWriteSnf( r_gpf, w_gpf )
struct btophead *r_gpf;
struct ptobhead *w_gpf;
{
w_gpf->zoomf = 0;
w_gpf->num_chars = r_gpf->num_chars;
w_gpf->code = r_gpf->code;
w_gpf->ptn = r_gpf->ptn;
w_gpf->bdf_width = r_gpf->bdf_width;
w_gpf->bdf_height = r_gpf->bdf_height;
w_gpf->bdf_x = r_gpf->bdf_x;
w_gpf->bdf_y = r_gpf->bdf_y;
w_gpf->bdf_point = r_gpf->bdf_point;
w_gpf->bdf_xdpi = r_gpf->bdf_xdpi;
return WritePtnToBdf( w_gpf );
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,214 @@
/* $XConsortium: udcexc.c /main/4 1996/09/02 18:50:32 cde-fuj $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
#include "excutil.h"
#include "xoakufont.h"
#include "selectxlfd.h"
#include <locale.h>
#include <Xm/RowColumn.h>
#include <Xm/ToggleB.h>
#include <Xm/MessageB.h>
#include <Xm/MainW.h>
void callexpCB();
void callimpCB();
void exitCB();
void helpCB();
void udcexp();
void udcimp();
#define ERROR_1 errmsg_org[fal_utyerrno & 0xff]
/*#define ERROR_1 fal_errmsg_org[fal_utyerrno & 0xff]*/
/*#define ERROR_2 fal_errmsg_func[fal_utyerrno >>8]*/
Widget toplevel, mainw;
Exc_data *ed = NULL;
ListData *ld = NULL;
char *maintitle;
/*char *terminatemsg = "Do you want to terminate dtudcexch";*/
/*
* Error messages(by origin)
* fal_errmsg_org
*/
char *errmsg_org[0xff];
Rsrc resource ;
#define Rchar(name, class, member,def){ \
name, class, XtRString, sizeof(char *), \
XtOffsetOf(Rsrc, member), XtRString, (XtPointer)def }
Widget excCreateRadioButton(Widget parent, String name, String label,
XtCallbackProc callback_func,
XtPointer client_data)
{
Widget widget;
XmString xms;
widget = XtVaCreateManagedWidget(name,
xmToggleButtonWidgetClass, parent,
XmNindicatorType, XmONE_OF_MANY,
NULL);
XtAddCallback(widget, XmNvalueChangedCallback,
(XtCallbackProc) callback_func,
(XtPointer) client_data);
xms = XmStringCreateLocalized(label);
XtVaSetValues(widget,
XmNlabelString, xms,
NULL);
XmStringFree(xms);
return (widget);
}
int main(int argc, char * argv[])
{
XtAppContext app_context;
Widget row, expfunc, impfunc, exit/*, help*/;
Arg args[20];
Cardinal n;
static char *explabel;
static char *implabel;
static char *exitlabel;
/* static char helplabel[] = "Help";*/
/* char msg1[] = "Failed in the start of dtudcexch";*/
char err[128];
int ans;
int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED;
FalFontData key;
FalFontDataList *fontlist;
/* appinitialize */
XtSetLanguageProc(NULL,NULL,NULL);
_DtEnvControl(0);
n = 0;
toplevel = XtAppInitialize(&app_context, "UDCexchange",
(XrmOptionDescList) NULL,
0, (int *) &argc, argv, (String *) NULL,
args, n);
maintitle = GETMESSAGE(8, 2, "UDC data exchange utitlity");
errmsg_org[0] = GETMESSAGE(8, 4, "Fatal error occurred.");
errmsg_org[1] = GETMESSAGE(8, 6, "Cannot open the font file.");
errmsg_org[2] = GETMESSAGE(8, 8, "Cannot read the font file.");
errmsg_org[3] = GETMESSAGE(8, 10, "There is no more memory.");
errmsg_org[4] = GETMESSAGE(8, 12, "Fatal error occurred.");
errmsg_org[5] = GETMESSAGE(8, 14, "The specified font file does not exist.");
errmsg_org[6] = GETMESSAGE(8, 16, "This font is not a pcf or snf font.");
errmsg_org[7] = GETMESSAGE(8, 18, "Cannot open fonts.list file.");
errmsg_org[8] = GETMESSAGE(8, 20, "The format of fonts.list file is illegal.");
errmsg_org[9] = GETMESSAGE(8, 22, "The descriptions of the fonts.list file are incorrect.");
errmsg_org[10] = GETMESSAGE(8, 24, "The format of fonts.list file is illegal.");
errmsg_org[11] = GETMESSAGE(8, 26, "Cannot open fonts.dir file.");
errmsg_org[12] = GETMESSAGE(8, 28, "Cannot read fonts.dir file.");
errmsg_org[13] = GETMESSAGE(8, 30, "Cannot read font properties.");
errmsg_org[14] = GETMESSAGE(8, 32, "Cannot get FONT property.");
errmsg_org[15] = GETMESSAGE(8, 34, "Cannot get FAMILY_NAME property.");
errmsg_org[16] = GETMESSAGE(8, 36, "This font file is already opened by other application.");
errmsg_org[17] = GETMESSAGE(8, 38, "Cannot lock font file.");
errmsg_org[18] = GETMESSAGE(8, 40, "Cannot unlock font file.");
errmsg_org[19] = GETMESSAGE(8, 42, "Cannot get lock information from the font file.");
errmsg_org[20] = GETMESSAGE(8, 44, "Cannot find the specified font file.");
errmsg_org[21] = GETMESSAGE(8, 46, "Cannot read NLS database.");
errmsg_org[22] = GETMESSAGE(8, 48, "Cannot get charset names from NLS database.");
errmsg_org[23] = GETMESSAGE(8, 50, "Charset name not defined in NLS database.");
errmsg_org[24] = GETMESSAGE(8, 52, "The specified font has not been opened.");
errmsg_org[25] = GETMESSAGE(8, 54, "Fatal error occurred.");
resource.xlfd_label = GETMESSAGE(8, 56, "XLFD name :" ),
resource.copy_xlfd_label = GETMESSAGE(8, 58, "Original font (XLFD name) :");
resource.code_label = GETMESSAGE(8, 60, "UDC code area :");
resource.style_label = GETMESSAGE(8, 62, "Style :");
resource.size_label = GETMESSAGE(8, 64, "Size (letter size) :");
resource.exec_label = GETMESSAGE(8, 66, "Open");
resource.quit_label = GETMESSAGE(8, 68, "Cancel");
resource.ok_label = GETMESSAGE(8, 70, "OK");
resource.cancel_label = GETMESSAGE(8, 72, "cancel");
resource.copy_orgin = GETMESSAGE(8, 74, "Copy orgin code(hex) :");
resource.copy_target = GETMESSAGE(8, 76, "Copy target code(hex) :");
resource.copy_label = GETMESSAGE(8, 78, "Copy");
resource.overlay_label = GETMESSAGE(8, 80, "Overlay");
explabel = GETMESSAGE(8, 82, "export function");
implabel = GETMESSAGE(8, 84, "import function");
exitlabel = GETMESSAGE(8, 86, "Cancel");
/* initialize ed */
if ((ed = (Exc_data *) malloc(sizeof(Exc_data))) == NULL) {
excerror(ed, EXCERRMALLOC, "main", "exit");
}
memset(ed,0x00,sizeof(Exc_data));
ed->app = app_context;
ed->toplevel = toplevel;
if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) {
fprintf( stderr, "GetFontList Err\n" );
sprintf(err, "%s", ERROR_1);
AskUser(ed->toplevel, ed, err, &ans, "error");
/* AskUser(ed->toplevel, ed, msg1, &ans, "error");*/
excexit(ed);
}
FalFreeFontList(fontlist);
/* make main window */
n = 0;
XtSetArg( args[n], XmNautoUnmanage, False ) ; n++ ;
XtSetArg(args[n], XmNtitle, maintitle); n++;
mainw = XmCreateTemplateDialog(toplevel, "mainw", args, n);
row = XtVaCreateManagedWidget("row", xmRowColumnWidgetClass, mainw,
XmNradioBehavior, True,
XmNradioAlwaysOne, True,
NULL);
expfunc = excCreateRadioButton(row, "expfunc", explabel,
(XtCallbackProc) callexpCB, (XtPointer) ed);
impfunc = excCreateRadioButton(row, "impfunc", implabel,
(XtCallbackProc) callimpCB, (XtPointer) ed);
exit = excCreatePushButton(mainw, "exit", exitlabel,
(XtCallbackProc) exitCB, (XtPointer) ed);
/* help = excCreatePushButton(mainw, "help", helplabel,
(XtCallbackProc) helpCB, (XtPointer) ed);
*/
XtVaSetValues(mainw,
XmNmessageWindow, exit,
NULL);
XtManageChild(mainw);
/* XtRealizeWidget(toplevel);*/
XtAppMainLoop(app_context);
}
void callexpCB(Widget widget, Exc_data * ed, XtPointer call_data)
{
XtUnmanageChild(mainw);
udcexp(ed);
}
void callimpCB(Widget widget, Exc_data * ed, XtPointer call_data)
{
XtUnmanageChild(mainw);
udcimp(ed);
}
void exitCB(Widget widget, Exc_data * ed, XtPointer call_data)
{
excexit(ed);
}
/*void helpCB(Widget widget, Exc_data * ed, XtPointer call_data)
{
}*/

View File

@@ -0,0 +1,192 @@
/* $XConsortium: udcexp.c /main/5 1996/10/14 14:45:34 barstow $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
#include "excutil.h"
#include <Xm/MessageB.h>
#include <Xm/RowColumn.h>
#include <Xm/List.h>
#include <Xm/Form.h>
#include <Xm/Label.h>
void setselectedcode();
extern char *maintitle;
void udcexp(Exc_data * ed)
{
ed->function = EXPORT;
strcpy(ed->bdfmode,"w");
PopupSelectXLFD(ed->toplevel);
}
void createbdf(Exc_data * ed)
{
int i = 0;
char *comment_list[] = {""};
int comment_num = 0;
char *msg;
int ans;
msg = GETMESSAGE(10, 2, "Failed to make the BDF file");
i = ExpGpftoBDF(ed->fontfile, ed->bdffile,
ed->code_num, ed->gpf_code_list,
comment_num, comment_list, 0);
if (i != 0) {
AskUser(ed->toplevel, ed, msg, &ans, "error");
}
excterminate(ed);
}
void selcharokCB(Widget widget, ListData * ld, XtPointer call_data)
{
int num;
Exc_data *ed;
int ans;
char *msg;
msg = GETMESSAGE(10, 4, "No indexes are selected");
XtVaGetValues(ld->list, XmNselectedItemCount, &num, NULL);
if (num == 0) {
/* AskUser(widget, ld->ed, msg, &ans, "error");*/
return;
} else {
setselectedcode(ld);
XtUnmanageChild(XtParent(widget));
ed = ld->ed;
freeld(ld);
getbdffn(ed);
}
}
void selcharcancelCB(Widget widget, ListData * ld, XtPointer call_data)
{
Exc_data *ed;
ed = ld->ed;
freeld(ld);
excterminate(ed);
}
XmString * setxmslist(ListData * ld)
{
char **cp;
XmString *xmslist, *xmsp;
int i;
if ((xmslist = (XmString *) calloc(ld->existcode_num, sizeof(XmString *)))
== NULL) {
excerror(ld->ed, EXCERRMALLOC, "setxmslist", "exit");
}
cp = ld->existcode_c;
xmsp = xmslist;
for (i = 0; i < ld->existcode_num; i++) {
*xmsp = XmStringCreateLocalized(*cp);
xmsp++;
cp++;
}
return (xmslist);
}
void freexmslist(ListData * ld, XmString * xmslist)
{
XmString *xmsp;
int i;
if (xmslist != NULL) {
xmsp = xmslist;
for (i = 0; i < ld->existcode_num; i++) {
XmStringFree(*xmsp);
xmsp++;
}
free(xmslist);
}
}
void selcharcd(Exc_data * ed)
{
Widget mainw, selcd, ok, cancel;
Widget slctLabel, form;
Arg args[20];
Cardinal n;
char *oklabel;
char *cancellabel;
XmString *xmslist;
extern ListData *ld;
char *p;
oklabel = GETMESSAGE(10, 6, "OK");
cancellabel = GETMESSAGE(10, 8, "Cancel");
n = 0;
XtSetArg(args[n], XmNautoUnmanage, False); n++;
XtSetArg(args[n], XmNtitle, maintitle); n++;
mainw = XmCreateTemplateDialog(ed->toplevel, "mainw", args, n);
n = 0;
form = XmCreateForm( mainw, "form", args, n);
XtManageChild(form);
p = GETMESSAGE(10, 10, "glyph indexes");
n = 0;
XtSetArg( args[n], XmNx, 20 ) ; n++;
XtSetArg( args[n], XmNheight, 20 ) ; n++ ;
XtSetArg( args[n], XmNtopAttachment, XmATTACH_FORM ) ; n++ ;
XtSetArg( args[n], XmNtopOffset, 10 ) ; n++ ;
slctLabel = XmCreateLabel( form, p, args, n);
XtManageChild(slctLabel);
n = 0;
xmslist = setxmslist(ld);
XtSetArg( args[n], XmNleftAttachment, XmATTACH_FORM ) ; n++ ;
XtSetArg( args[n], XmNleftOffset, 20 ) ; n++ ;
XtSetArg( args[n], XmNtopAttachment, XmATTACH_WIDGET ); n++ ;
XtSetArg( args[n], XmNtopOffset, 5 ) ; n++ ;
XtSetArg( args[n], XmNwidth, 200 ) ; n++ ;
XtSetArg (args[n], XmNtopWidget, slctLabel ); n++;
XtSetArg(args[n], XmNitems, xmslist); n++;
XtSetArg(args[n], XmNitemCount, ld->existcode_num); n++;
XtSetArg(args[n], XmNvisibleItemCount, 10); n++;
XtSetArg(args[n], XmNlistSizePolicy, XmCONSTANT); n++;
XtSetArg(args[n], XmNscrollBarDisplayPolicy, XmAS_NEEDED); n++;
XtSetArg(args[n], XmNselectionPolicy, XmEXTENDED_SELECT); n++;
selcd = XmCreateScrolledList(form, "Select codes", args, n);
freexmslist(ld, xmslist);
XtManageChild(selcd);
ld->list = selcd;
ok = excCreatePushButton(mainw, "ok", oklabel,
(XtCallbackProc) selcharokCB, (XtPointer) ld);
cancel = excCreatePushButton(mainw, "cancel", cancellabel,
(XtCallbackProc) selcharcancelCB,
(XtPointer) ld);
XtManageChild(mainw);
}
void setselectedcode(ListData *ld)
{
int *position_list;
int position_count;
int i;
int *codep;
XmListGetSelectedPos(ld->list, &position_list, &position_count);
ld->ed->code_num = position_count;
ld->ed->gpf_code_list = (int *) calloc(position_count, sizeof(int));
codep = ld->ed->gpf_code_list;
for (i = 0; i < position_count; i++) {
*codep = *((ld->existcode)+(position_list[i]-1));
codep++;
}
}

View File

@@ -0,0 +1,188 @@
/* $XConsortium: udcimp.c /main/4 1996/09/02 18:51:02 cde-fuj $ */
/*
* (c) Copyright 1995 FUJITSU LIMITED
* This is source code modified by FUJITSU LIMITED under the Joint
* Development Agreement for the CDEnext PST.
* This is unpublished proprietary source code of FUJITSU LIMITED
*/
#include "excutil.h"
#include "FaLib.h"
void addcharptn();
void setcodelists();
extern ListData *ld;
extern int num_gr;
extern FalGlyphRegion *gr;
extern FalFontData fullFontData;
void udcimp(Exc_data * ed)
{
ed->function = IMPORT;
strcpy(ed->bdfmode,"r");
getbdffn(ed);
}
int checkcode(int code)
{
int i, j;
int code1, code2;
for (i = 0; i < num_gr; i++) {
code1 = smaller(gr[i].start, gr[i].end);
code2 = bigger(gr[i].start, gr[i].end);
if ((code >= code1) && (code <= code2)) { /*in udc area */
for (j = 0; j < ld->existcode_num; j++) {
if (code == ld->existcode[j])
return (1); /* the font has same glyph index */
}
return (0);
}
}
return (-1); /* out of udc area */
}
int checkcodes(int code_num, int * code_list)
{
int *codep;
int i, ans;
int exist = 0;
codep = code_list;
for (i = 0; i < code_num; i++) {
ans = checkcode(*codep);
if (ans == -1) {
return (-1);
} else if (ans == 1) {
exist = 1;
}
codep++;
}
return (exist);
}
void getcharcd(Exc_data * ed)
{
int code_num;
int *code_list;
int i;
char *msg;
char *msg2;
char *msg3;
int ans, ans2;
msg = GETMESSAGE(12, 2, "Glyph images in this BDF file can't be added to the font.");
msg2 = GETMESSAGE(12, 4, "Failed to open the selected BDF font. You have no right to access for the font file, or the format of the file is not consistent.");
msg3 = GETMESSAGE(12, 6, "There are one or more glyph images being overwritten. Overwrite?");
i = ImpBDFCodeList(ed->bdffile, &code_num, &code_list);
if (i != 0) { /* bad BDF format */
AskUser(ed->toplevel, ed, msg2, &ans, "error");
freeld(ld);
excterminate(ed);
}
ans2 = checkcodes(code_num, code_list);
if (ans2 == -1) { /* out of UDC code exists */
AskUser(ed->toplevel, ed, msg, &ans, "error");
freeld(ld);
excterminate(ed);
} else if (ans2 == 1) { /* font file has same glyph index */
AskUser(ed->toplevel, ed, msg3, &ans, "warning");
if (ans != 1) {
freeld(ld);
excterminate(ed);
}
}
/* set twe codelists */
setcodelists(ld, code_num, code_list);
if (ImpBDFCodeListFree(&code_list) != 0) {
fprintf(stderr,"error in ImpBDFCodeListFree\n");
}
/* add gryph images to font */
addcharptn(ed);
}
void addcharptn(Exc_data * ed)
{
int i;
int ans;
char *msg;
char *msg2;
char *msg3;
int mask;
FalFontDataList *fulllist = NULL;
FalFontID fontid;
msg = GETMESSAGE(12, 8, "Failed to open the selected font. You have no right to access for the font file, or the format of the file is not consistent.");
msg2 = GETMESSAGE(12, 10, "Glyph images in this BDF file can't be added to the font.");
msg3 = GETMESSAGE(12, 12, "Failed in the registration of the font file.");
mask = FAL_FONT_MASK_XLFDNAME | FAL_FONT_MASK_GLYPH_INDEX |
FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UPDATE |
FAL_FONT_MASK_UNDEFINED | FAL_FONT_MASK_CODE_SET;
i = ImpBDFCheck(ed->bdffile, ed->fontfile);
if (i != 0) {
AskUser(ed->toplevel, ed, msg2, &ans, "error");
excterminate(ed);
}
fontid = FalOpenSysFont(&fullFontData, mask, &fulllist);
if (fontid == 0) {
AskUser(ld->ed->toplevel, ld->ed, msg, &ans, "error");
excterminate(ed);
}
i = 0;
i = ImpBDFtoGpf(ed->bdffile, ed->fontfile,
ed->code_num, ed->bdf_code_list);
FalCloseFont( fontid );
if (i != 0) {
AskUser(ed->toplevel, ed, msg3, &ans, "error");
}
excterminate(ed);
}
void setcodelists(ListData *ld, int code_num, int *code_list)
{
int *c1, *c2;
int i;
Exc_data *ed;
ld->ed->code_num = code_num;
if ((c1 = (int *) calloc(code_num, sizeof(int))) == NULL) {
ed = ld->ed;
freeld(ld);
excerror(ed, EXCERRMALLOC, "setcodelists", "exit");
}
ld->ed->bdf_code_list = c1;
c2 = code_list;
for (i = 0; i < code_num; i++)
{
*c1 = *c2;
c1++;
c2++;
}
if ((c1 = (int *) calloc(code_num, sizeof(int))) == NULL) {
ed = ld->ed;
freeld(ld);
excerror(ed, EXCERRMALLOC, "setcodelists", "exit");
}
ld->ed->gpf_code_list = c1;
c2 = code_list;
for (i = 0; i < code_num; i++)
{
*c1 = *c2;
c1++;
c2++;
}
}

View File

@@ -0,0 +1,319 @@
/* $XConsortium: xlfdutil.c /main/2 1996/10/14 14:45:50 barstow $ */
/*
* All Rights Reserved, Copyright (c) FUJITSU LIMITED 1995
*
* This is unpublished proprietary source code of FUJITSU LIMITED
*
* Authors: Seiya Miyazaki FUJITSU LIMITED
* Hiroyuki Chiba Fujitsu Basic Software Corporation
*
*/
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <nl_types.h>
#include <Xm/Xm.h>
#include <Xm/Form.h>
#include <Xm/PushB.h>
#include <Xm/Text.h>
#include <Xm/TextF.h>
#include <Xm/Label.h>
#include <Xm/SeparatoG.h>
#include <Xm/List.h>
#include <Xm/ToggleB.h>
#include <Xm/MessageB.h>
#include "FaLib.h"
#include "falxlfd.h"
#include "selectxlfd.h"
#ifdef DEBUG
#undef Dprintf
#define Dprintf fprintf
#else
#define Dprintf
#endif /* DEBUG */
/*
* parameters
*/
static char* skipSpace() ;
extern FalFontDataList *font_L ;
extern FalxFontDataBuff KeyBuff ;
extern FalxCodeList *CodeList ;
extern FalxStyleList *StyleList ;
extern FalxSizeList *SizeList ;
extern int SelectedOffset ;
extern int getmask ;
extern char *fullPathName ;
extern Widget toplevel ;
extern Widget
xlfdWform, cpyWform,
slctBLabel[BUTTONITEMS],slctBText[BUTTONITEMS], slctButton[BUTTONITEMS],
listPop[BUTTONITEMS], listW[BUTTONITEMS],
errorMD, msgBox ;
/****************************************************************
* functions for get font infomation
****************************************************************/
int
GetXLFDInfomations()
{
Dprintf( stdout, "GetXLFDInfomations()\n" ) ;
/* initialize */
getmask = 0 ;
SelectedOffset = 0 ;
fullPathName = NULL ;
FalxInitDataBuff( &KeyBuff ) ;
/* get UDC informations */
if( FalxGetFontList( &font_L, XtDisplayOfObject( toplevel ) ) ){
Dprintf( stderr, "GetXLFDInfomations() : FalxGetFontList() error.\n" ) ;
return(-1);
}
/* create code area list */
if( FalxCreateCodeList( &CodeList, font_L ) ){
Dprintf( stderr, "\nGetXLFDInfomations() : FalxCreateCodeList() error.\n" ) ;
return(-1);
}
/* create style list */
if( FalxCreateStyleList( &StyleList, font_L ) ){
Dprintf( stderr, "\nGetXLFDInfomations() : FalxCreateStyleList() error.\n" ) ;
return(-1);
}
/* create size list */
if( FalxCreateSizeList( &SizeList, font_L ) ){
Dprintf( stderr, "\nGetXLFDInfomations() : FalxCreateSizeList() error.\n" ) ;
return(-1);
}
return(0) ;
}
int
GetItemsToDisplay( num, itemcnt, xms_list )
int num ;
int *itemcnt ;
XmString **xms_list ;
{
int i, j, cnt ;
char *sp ,string[256], buf[256] ;
Arg args[1];
int length, maxlength ;
FalxXlfdList *xlist ;
int tmp_cnt ;
char **tmp_dlist, *str ;
XmString *xms ;
int rlen ;
int rtn ;
switch( num ){
case 0 : /* XLFD */
/* set key data */
for( i=1; i<BUTTONITEMS; i++ ){
if( (str = XmTextGetString( slctBText[i] )) == NULL ){
exit(-1) ;
}
if( *str == ' ' || *str == NULL ) continue ;
if( SetKeyBuff( i, str ) ){
exit(-1) ;
}
}
rtn = FalxGetXlfdList( &xlist, font_L, &KeyBuff, getmask ) ;
if( rtn ) return( rtn ) ;
tmp_cnt = xlist->num ;
tmp_dlist = xlist->list ;
break ;
case 1 : /* code area */
tmp_cnt = CodeList->num ;
tmp_dlist = (char **)malloc( sizeof(char *) * tmp_cnt ) ;
if( tmp_dlist == NULL ) return(-1) ;
for( i=0; i<tmp_cnt; i++ ){
sp = string ;
rlen = sprintf( sp, "CS:%d ", (CodeList->dlist[i]->fontset) ) ;
sp += rlen ;
for( j=0; j<CodeList->dlist[i]->code_area_num; j++ ){
rlen = sprintf( sp, "%x - %x ",
CodeList->dlist[i]->alist[j]->udc_start,
CodeList->dlist[i]->alist[j]->udc_end ) ;
sp += rlen ;
}
if( (tmp_dlist[i] = strdup( string )) == NULL ){
return(-1) ;
}
}
break ;
case 2 : /* style */
tmp_cnt = StyleList->num ;
tmp_dlist = (char **)malloc( sizeof(char *) * tmp_cnt ) ;
for( i=0; i<tmp_cnt; i++ ){
if( (tmp_dlist[i] = strdup( StyleList->list[i] )) == NULL ){
return(-1) ;
}
}
break ;
case 3 : /* size */
tmp_cnt = SizeList->num ;
tmp_dlist = (char **)malloc( sizeof(char *) * tmp_cnt ) ;
for( i=0; i<tmp_cnt; i++ ){
sprintf( string, "%d ", SizeList->list[i] ) ;
if( (tmp_dlist[i] = strdup( string )) == NULL ){
return(-1) ;
}
}
break ;
default : /* error */
return(-1) ;
}
if( (xms = (XmString *)calloc( tmp_cnt, sizeof(XmString) )) == NULL ){
return( -1 ) ;
}
/*
* set list for display
*/
maxlength = 0 ;
for ( i=0; i<tmp_cnt; i++ ){
xms[i] = XmStringCreateLocalized( tmp_dlist[i] );
}
/*
* free allocated memory
*/
switch( num ){
case 0 : /* XLFD */
FalxFreeXlfdList( xlist ) ;
break ;
case 1 : /* code area */
case 2 : /* style */
case 3 : /* size */
for( i=0; i<tmp_cnt; i++ ){
free( tmp_dlist[i] ) ;
}
free( tmp_dlist ) ;
break ;
default : /* error */
return(-1) ;
}
*itemcnt = tmp_cnt ;
*xms_list = xms ;
return(0) ;
}
static char*
skipSpace( str, skipcnt )
char *str ;
int skipcnt ;
{
int i, spacecnt ;
char *sp ;
int len ;
if( *str == NULL ) return( NULL ) ;
len = strlen( str ) ;
sp = str ;
for( i=0,spacecnt=0; i<len-1; i++, sp++ ) {
if( *sp == NULL ) return( NULL ) ;
if( *sp == ' ' ) spacecnt++ ;
if( spacecnt == skipcnt ) break ;
}
sp++ ;
return( sp ) ;
}
int
SetKeyBuff( num, str )
int num ;
char *str ;
{
int i, j ;
int cdset, start, end ;
FalxUdcArea *tmp_list ;
char hyp, *sp ;
switch( num ){
case 0 : /* XLFD */
KeyBuff.FontData.xlfdname = str ;
break ;
case 1 : /* code area */
getmask |= FAL_FONT_MASK_CODE_SET ;
if( KeyBuff.FileData.list != NULL ){
free( KeyBuff.FileData.list ) ;
}
KeyBuff.FileData.list = NULL ;
tmp_list = NULL ;
sp = str ;
if( sscanf( sp, "CS:%d ", &cdset ) != 1 ){
return(-1) ;
}
if( (sp = skipSpace( sp, 1 )) == NULL ) return( -1 ) ;
num = 0 ;
KeyBuff.FontData.cd_set = cdset ;
while( sscanf( sp, "%x %c %x ", &start, &hyp, &end ) == 3 ){
if( hyp != '-' ) break ;
if( tmp_list == NULL ){
tmp_list = (FalxUdcArea *)malloc( sizeof(FalxUdcArea) ) ;
}else{
tmp_list = (FalxUdcArea *)realloc( KeyBuff.FileData.list,
sizeof(FalxUdcArea) * (num+1) ) ;
}
if( tmp_list == NULL ) return(-1) ;
tmp_list[num].udc_start = (int)start ;
tmp_list[num].udc_end = (int)end ;
num ++ ;
if( (sp = skipSpace( sp, 3 )) == NULL ) break ;
}
if( num == 0 ) return(-1) ;
KeyBuff.FileData.code_area_num = num ;
KeyBuff.FileData.list = tmp_list ;
break ;
case 2 : /* style */
getmask |= FAL_FONT_MASK_STYLE_NAME ;
KeyBuff.FontData.style.name = str ;
break ;
case 3 : /* size */
getmask |= FAL_FONT_MASK_LETTER_W ;
getmask |= FAL_FONT_MASK_LETTER_H ;
KeyBuff.FontData.letter.w = atoi( str ) ;
KeyBuff.FontData.letter.h = atoi( str ) ;
break ;
default :
return(-1) ;
}
return(0);
}