Refactor and reimplement dtudcfonted

This commit is contained in:
chase
2018-07-27 16:44:10 -05:00
committed by Jon Trulson
parent 0f1aaa3e46
commit b491f9134f
83 changed files with 3706 additions and 7498 deletions

View File

@@ -209,12 +209,12 @@ typedef struct _FalGIInf {
#include <stdlib.h>
#include <dirent.h>
#ifdef Bool
#undef Bool
#ifdef Bool
#undef Bool
#endif
#include "snfstruct.h"
#include "fontstruct.h"
#include <X11/fonts/fontstruct.h>
#include "pcf.h"
struct pcf_inf {
@@ -263,88 +263,66 @@ typedef Oak_FontInf * FalFontID; /* font distinction */
* function prototypes
*/
extern FalFontID FalOpenSysFont(
#if NeedFunctionPrototypes
FalFontData* /* open_font_data */,
int /* font_data_mask */,
FalFontDataList** /* missing_font_list_return */
#endif
) ;
extern int FalGetFontList(
#if NeedFunctionPrototypes
FalFontData* /* key_data */,
int /* mask */,
FalFontDataList** /* list_ret */
#endif
) ;
extern int FalFreeFontList(
#if NeedFunctionPrototypes
FalFontDataList* /* list */
#endif
) ;
extern char *
FalReadFont(
#if NeedFunctionPrototypes
FalFontID /* fid */ ,
int /* code */ ,
int /* width */ ,
int /* height */
#endif
) ;
extern int FalQueryFont(
#if NeedFunctionPrototypes
FalFontID /* fid */ ,
FalFontinfo* /* fontinfo */
#endif
) ;
extern int FalFontOfFontID(
#if NeedFunctionPrototypes
FalFontID /* fid */,
FalFontData* /* fontdata */
#endif
) ;
extern int FalCloseFont(
#if NeedFunctionPrototypes
FalFontID /* fid */
#endif
) ;
extern int FalFontIDToFileName(
#if NeedFunctionPrototypes
FalFontID /* fid */ ,
char** /* file_name */
#endif
) ;
extern int FalFree(
#if NeedFunctionPrototypes
void* /* list */
#endif
) ;
extern int FalGetUDCCPArea(
#if NeedFunctionPrototypes
char* /* locale */ ,
int /* code_set */ ,
char* /* charset_str */ ,
FalCodeRegion** /* cr */ ,
int* /* num_cr */
#endif
) ;
extern int FalGetUDCGIArea(
#if NeedFunctionPrototypes
char* /* locale */ ,
int /* codeset */ ,
char* /* charset_str */ ,
FalGlyphRegion** /* gr */ ,
int* /* num_gr */
#endif
) ;
extern FalFontID FalOpenFont() ;

View File

@@ -29,6 +29,7 @@
*/
#include "udccom.h"
#include "FaLib.h"
struct btophead {
char *in_file;
@@ -68,17 +69,17 @@ struct ptobhead {
int bdf_width;
int bdf_height;
int bdf_x;
int bdf_y;
int bdf_x;
int bdf_y;
float bdf_point;
int bdf_xdpi;
int reserve ;
int reserve ;
int *code;
char **ptn;
int zoomf;
int code_category;
int code_category;
int start_code;
int end_code;
@@ -234,287 +235,212 @@ extern char *bdftopcf;
* Function prototypes
*/
extern int falcom_atoi(
#if NeedFunctionPrototypes
char* /* str */,
char /* ed_cod */,
int* /* val */
#endif
);
extern int GetDefaultFile(
#if NeedFunctionPrototypes
int /* size */,
char* /* style */,
char* /* fname */
#endif
);
extern int get_default_file(
#if NeedFunctionPrototypes
FILE* /* fp */,
int /* size */,
char* /* style */,
char* /* fname */
#endif
);
extern char *falcom_get_base_name(
#if NeedFunctionPrototypes
char* /* str */
#endif
);
extern int GetFileName(
#if NeedFunctionPrototypes
char* /* com */,
char* /* size_str */,
char* /* style */,
int /* codeset */,
char* /* ofile */
#endif
);
extern void ErrMsgTable_FalGetFontList(
#if NeedFunctionPrototypes
char* /* com */,
int /* utyerr */,
int /* utyderr */
#endif
);
extern void fal_cut_tailslash(
#if NeedFunctionPrototypes
char* /* name */
#endif
);
extern char *GetRealFileName(
#if NeedFunctionPrototypes
char* /* name */
#endif
);
extern int IsInRegion(
#if NeedFunctionPrototypes
int /* code */,
int /* num_gr */,
FalGlyphRegion* /* gr */
#endif
);
extern int GetUdcFileName(
#if NeedFunctionPrototypes
char* /* com */,
int /* code_no */,
char* /* xlfdname */,
char* /* fname */
#endif
);
extern int GetUdcRegion(
#if NeedFunctionPrototypes
char* /* com */,
int /* codeset */,
char* /* gpf_file */,
int* /* num_gr */,
FalGlyphRegion** /* gr */
#endif
);
extern int DispUdcCpArea(
#if NeedFunctionPrototypes
FILE* /* fp */
#endif
);
extern int GetUdcFontName(
#if NeedFunctionPrototypes
char* /* gpf_file */,
char* /* bdf_file */,
char** /* fontname */
#endif
);
extern int FileLock(
#if NeedFunctionPrototypes
int /* fd */
#endif
);
extern int FileUnLock(
#if NeedFunctionPrototypes
int /* fd */
#endif
);
extern int isLock(
#if NeedFunctionPrototypes
int /* fd */
#endif
);
extern int ReadBdfHeader(
#if NeedFunctionPrototypes
struct btophead* /* head */,
char* /* buf */
#endif
);
extern int ReadGpfHeader(
#if NeedFunctionPrototypes
struct ptobhead* /* head */,
char* /* buf */
#endif
);
extern int WriteBdfHeader(
#if NeedFunctionPrototypes
struct ptobhead* /* head */
#endif
);
extern void WriteGpfHeader(
#if NeedFunctionPrototypes
struct btophead* /* head */
#endif
);
extern int WritePtnToBdf(
#if NeedFunctionPrototypes
struct ptobhead* /* head */
#endif
);
extern int putDefaultChars(
#if NeedFunctionPrototypes
struct ptobhead* /* head */
#endif
);
extern int WritePtnToGpf(
#if NeedFunctionPrototypes
struct btophead* /* head */
#endif
);
extern int ReadBdfToMemory(
#if NeedFunctionPrototypes
struct btophead* /* head */,
char* /* buf */
#endif
);
extern int ReadBdfToMemory_with_init(
#if NeedFunctionPrototypes
struct btophead* /* head */,
int /* init_start */,
int /* init_end */,
char* /* buf */
#endif
);
extern int GetBdfCode(
#if NeedFunctionPrototypes
struct btophead* /* head */,
char* /* buf */,
int* /* code */
#endif
);
extern int GetBdfPtn(
#if NeedFunctionPrototypes
struct btophead* /* head */,
char* /* buf */,
char* /* ptn */,
int /* mwidth */,
int /* bsize */
#endif
);
extern int ReadGpfToMemory(
#if NeedFunctionPrototypes
struct ptobhead* /* head */,
char* /* buf */
#endif
);
extern int GetGpfCode(
#if NeedFunctionPrototypes
struct ptobhead* /* head */,
char* /* buf */,
int* /* code */
#endif
);
extern int GetGpfPtn(
#if NeedFunctionPrototypes
struct ptobhead* /* head */,
char* /* buf */,
char* /* ptn */,
int /* mwidth */,
int /* bsize */
#endif
);
extern void GetBdfLinePtn(
#if NeedFunctionPrototypes
char* /* mem */,
char* /* buf */,
int /* width */
#endif
);
extern void GetGpfLinePtn(
#if NeedFunctionPrototypes
char* /* mem */,
char* /* buf */,
int /* width */
#endif
);
extern int PutBdfPtn(
#if NeedFunctionPrototypes
unsigned char* /* ptn */,
int /* width */,
int /* height */,
FILE* /* fp */
#endif
);
extern int PutGpfPtn(
#if NeedFunctionPrototypes
char* /* ptn */,
int /* width */,
int /* height */,
FILE* /* fp */
#endif
);
extern int PtnZoom(
#if NeedFunctionPrototypes
char* /* dmem */,
char* /* smem */,
int /* sw */,
int /* sh */,
int /* dw */,
int /* dh */
#endif
);
extern char *GetTmpPath(
#if NeedFunctionPrototypes
char* /* path */
#endif
);
extern int ChkNumString(
#if NeedFunctionPrototypes
char* /* str */
#endif
);
extern void ErrMsgTable_AndExit(
#if NeedFunctionPrototypes
int /* er_no */,
char* /* snf_in */,
char* /* snf_out */,
@@ -522,95 +448,72 @@ extern void ErrMsgTable_AndExit(
char* /* gpf_out */,
char* /* bdf_in */,
char* /* prog_name */
#endif
);
extern void fatal_err_msg(
#if NeedFunctionPrototypes
int /* er_no */,
char* /* prog_name */
#endif
);
extern void ChatchSig() ;
extern void Put_File_Create_Err_Msg(
#if NeedFunctionPrototypes
int /* msg_level */,
char* /* org_name */,
char* /* tmp_name */,
char* /* save_name */,
char* /* com */
#endif
);
extern int Make_NewFefFile(
#if NeedFunctionPrototypes
char* /* org_name */,
char* /* tmp_name */,
mode_t /* mode */,
uid_t /* owner */,
gid_t /* group */,
char* /* com */
#endif
);
extern int Unlink_Tmpfile(
#if NeedFunctionPrototypes
char* /* file */,
char* /* com */
#endif
);
extern int Chmod_File (
#if NeedFunctionPrototypes
char* /* fname */,
mode_t /* mode */,
char* /* com */
#endif
);
extern int Chown_File (
#if NeedFunctionPrototypes
char* /* fname */,
uid_t /* owner */,
gid_t /* group */,
char* /* com */
#endif
);
extern int ChkPcfFontFile(
#if NeedFunctionPrototypes
char* /* filename */
#endif
);
extern int ChkSnfFontFile(
#if NeedFunctionPrototypes
char* /* filename */
#endif
);
extern char *get_cmd_path(
#if NeedFunctionPrototypes
char* /* path */,
char* /* cmd */
#endif
);
extern int SetCmdPath(
#if NeedFunctionPrototypes
char* /* com */,
char** /* path */,
char* /* dflt_path */,
char* /* cmd */
#endif
);
extern int
Link_NewFile(
#if NeedFunctionPrototypes
char * /* rd_file */,
char * /* wr_file */
#endif
) ;
);

View File

@@ -0,0 +1,107 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: pcf.h /main/2 1996/02/10 16:25:46 cde-fuj $ */
/*
*
* Copyright 1990 Massachusetts Institute of Technology
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. M.I.T. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
(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
*/
#ifndef _PCF_H_
#define _PCF_H_
/*
* Information used to read/write PCF fonts
*/
typedef struct _PCFTable {
CARD32 type;
CARD32 format;
CARD32 size;
CARD32 offset;
} PCFTableRec, *PCFTablePtr;
#define PCF_FILE_VERSION (('p'<<24)|('c'<<16)|('f'<<8)|1)
#define PCF_FORMAT_MASK 0xffffff00
#define PCF_DEFAULT_FORMAT 0x00000000
#define PCF_INKBOUNDS 0x00000200
#define PCF_ACCEL_W_INKBOUNDS 0x00000100
#define PCF_COMPRESSED_METRICS 0x00000100
#define PCF_FORMAT_MATCH(a,b) (((a)&PCF_FORMAT_MASK) == ((b)&PCF_FORMAT_MASK))
#define PCF_GLYPH_PAD_MASK (3<<0)
#define PCF_BYTE_MASK (1<<2)
#define PCF_BIT_MASK (1<<3)
#define PCF_SCAN_UNIT_MASK (3<<4)
#define PCF_BYTE_ORDER(f) (((f) & PCF_BYTE_MASK)?MSBFirst:LSBFirst)
#define PCF_BIT_ORDER(f) (((f) & PCF_BIT_MASK)?MSBFirst:LSBFirst)
#define PCF_GLYPH_PAD_INDEX(f) ((f) & PCF_GLYPH_PAD_MASK)
#define PCF_GLYPH_PAD(f) (1<<PCF_GLYPH_PAD_INDEX(f))
#define PCF_SCAN_UNIT_INDEX(f) (((f) & PCF_SCAN_UNIT_MASK) >> 4)
#define PCF_SCAN_UNIT(f) (1<<PCF_SCAN_UNIT_INDEX(f))
#define PCF_FORMAT_BITS(f) ((f) & (PCF_GLYPH_PAD_MASK|PCF_BYTE_MASK|PCF_BIT_MASK|PCF_SCAN_UNIT_MASK))
#define PCF_SIZE_TO_INDEX(s) ((s) == 4 ? 2 : (s) == 2 ? 1 : 0)
#define PCF_INDEX_TO_SIZE(b) (1<<b)
#define PCF_FORMAT(bit,byte,glyph,scan) (\
(PCF_SIZE_TO_INDEX(scan) << 4) | \
(((bit) == MSBFirst ? 1 : 0) << 3) | \
(((byte) == MSBFirst ? 1 : 0) << 2) | \
(PCF_SIZE_TO_INDEX(glyph) << 0))
#define PCF_PROPERTIES (1<<0)
#define PCF_ACCELERATORS (1<<1)
#define PCF_METRICS (1<<2)
#define PCF_BITMAPS (1<<3)
#define PCF_INK_METRICS (1<<4)
#define PCF_BDF_ENCODINGS (1<<5)
#define PCF_SWIDTHS (1<<6)
#define PCF_GLYPH_NAMES (1<<7)
#define PCF_BDF_ACCELERATORS (1<<8)
#endif /* _PCF_H_ */

View File

@@ -51,8 +51,7 @@ This is unpublished proprietary source code of FUJITSU LIMITED
******************************************************************/
#ifndef SNFSTRUCT_H
#define SNFSTRUCT_H 1
#include "font.h"
#include "misc.h"
#include <X11/fonts/font.h>
#include <X11/Xlib.h>
/*
@@ -87,12 +86,6 @@ This is unpublished proprietary source code of FUJITSU LIMITED
#define FONT_FILE_VERSION 4
typedef struct _FontProp {
CARD32 name; /* offset of string */
INT32 value; /* number or offset of string */
Bool indirect; /* value is a string offset */
} FontPropRec;
/*
* the following macro definitions describe a font file image in memory
*/
@@ -106,7 +99,7 @@ typedef struct _FontProp {
* pad out glyphs to a CARD32 boundary
*/
#define ADDRXFONTPROPS( pfi) \
((DIXFontProp *) ((char *)ADDRCHARGLYPHS( pfi) + BYTESOFGLYPHINFO(pfi)))
((DIXFontProp *) (char *)ADDRCHARGLYPHS( pfi))
#define ADDRSTRINGTAB( pfi) \
((char *)ADDRXFONTPROPS( pfi) + BYTESOFPROPINFO(pfi))
@@ -115,7 +108,7 @@ typedef struct _FontProp {
#define BYTESOFCHARINFO(pfi) (sizeof(CharInfoRec) * n2dChars(pfi))
#define BYTESOFPROPINFO(pfi) (sizeof(FontPropRec) * (pfi)->nProps)
#define BYTESOFSTRINGINFO(pfi) ((pfi)->lenStrings)
#define BYTESOFGLYPHINFO(pfi) (((pfi)->maxbounds.byteOffset+3) & ~0x3)
#define BYTESOFINKINFO(pfi) (sizeof(CharInfoRec) * (2 + n2dChars(pfi)))
#endif /* SNFSTRUCT_H */

View File

@@ -45,16 +45,6 @@
snprintf( (buf), sizeof((buf)), " -i " ) ; \
snprintf( (command), sizeof((command)), "%s %s > %s", bdftosnf, (buf), (out_file) ); \
}
#define COMM_SNF_FILEVERSION( snf_fd, finf, buf, permission ) { \
read( (snf_fd), (buf), sizeof(FontInfoRec) ); \
close( (snf_fd) ); \
(finf) = (FontInfoRec *) (buf) ; \
if( \
((finf)->version1 != FONT_FILE_VERSION) || \
((finf)->version2 != FONT_FILE_VERSION) \
) \
(permission) = -1 ; \
}
#define COMM_SNF_NEWTARGET( permission ) (permission) = 0
#define COMM_SNF_EXECLBDFTOSNF( permission, buf, snf_file ) { \
execl( bdftosnf, bdftosnf, "-i", 0 ); \
@@ -69,20 +59,8 @@
/* case of a snf former font */
#define FAL_GET_SNF_HEADER( buf, protect_key_data, fal_utyerror, fal_utyderror, fd, finf, openfontfile ) { \
(finf)->pFinf = ( FontInfoPtr )(buf); \
if ( \
((finf)->pFinf->version1 != (finf)->pFinf->version2) || \
((finf)->pFinf->version1 != FONT_FILE_VERSION) \
) { \
set_errfile_str( fal_err_file, (openfontfile) ) ; \
(fal_utyerror) = _FAL_FONT_ER; \
(fal_utyderror) = 0; \
fal_utyerrno = FAL_ERR_FONT ; \
fal_utyerrno |= (FAL_FUNCNUM_OPNFNT<<8) ; \
goto FalError01 ; \
} else { \
(finf)->isFef = TRUE ; \
(finf)->isPcf = FALSE; \
} \
}
/* falReadGpfProp() */
@@ -90,12 +68,6 @@
(finf)->isFef = TRUE; \
(finf)->isPcf = FALSE; \
(finf)->pFinf = ( FontInfoPtr )(finf)->buf ; \
if ( /* not a snf or fef format */ \
((finf)->pFinf->version1 != (finf)->pFinf->version2) || \
((finf)->pFinf->version1 != FONT_FILE_VERSION) \
) { \
return _FAL_TRY_NEXT ; \
} \
}
#define ISOPTFONT( file ) 1