summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaleb Keithley <kaleb@freedesktop.org>2003-11-14 16:48:57 +0000
committerKaleb Keithley <kaleb@freedesktop.org>2003-11-14 16:48:57 +0000
commit3d0472cc0132d55891f7f177f9b345036902a2ad (patch)
treeac3beaa6ac131a27360d3ff6f8d181caaa35a60a
Initial revisionXORG-STABLE
-rw-r--r--mkcfm.c277
-rw-r--r--mkcfm.man60
2 files changed, 337 insertions, 0 deletions
diff --git a/mkcfm.c b/mkcfm.c
new file mode 100644
index 0000000..37e48e9
--- /dev/null
+++ b/mkcfm.c
@@ -0,0 +1,277 @@
+/* From: Header: xc/programs/mkcfm/RCS/mkcfm.c,v 1.3 1996/05/08 21:38:21 ib Exp $ */
+/* Copyright (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+/* $XFree86: xc/programs/mkcfm/mkcfm.c,v 1.12 2002/12/09 17:30:12 dawes Exp $ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <sys/types.h>
+#include <dirent.h>
+
+#include "os.h"
+
+#include "fntfilst.h"
+#include "FSproto.h"
+#include "FS.h"
+#include "font.h"
+#include "fontenc.h"
+#include "fontstruct.h"
+#include "fsmasks.h"
+#include "range.h"
+#include "objects.h"
+#include "spaces.h"
+
+#include "fontutil.h"
+#include "util.h"
+#include "fontfcn.h"
+#include "blues.h"
+#include "t1intf.h"
+#include "t1unicode.h"
+
+static void CIDFillVals(FontScalablePtr);
+static Bool DoDirectory(char *dirName);
+
+#define DEFAULTCID "/usr/X11R6/lib/X11/fonts/CID"
+#define DECIPOINTSPERINCH 722.7
+#define DEFAULTRES 75
+#define DEFAULTPOINTSIZE 120
+
+FontScalableRec vals;
+FontEntryRec entry;
+
+int
+main(int argc, char **argv)
+{
+ char temp[CID_NAME_MAX];
+ int failed;
+ char *p;
+
+ temp[0] = '\0';
+
+ CIDFillVals(&vals);
+ CIDRegisterFontFileFunctions();
+
+ failed = 0;
+
+ if (argc == 1) {
+ if (!DoDirectory(DEFAULTCID)) {
+ fprintf(stderr, "Default CID directory %s not found.\n",
+ DEFAULTCID);
+ fprintf(stderr, "CFM files not created.\n");
+ fprintf(stderr,
+ "Specify CID directory: mkcfm directory-name.\n");
+ exit(1);
+ }
+ } else if(argc == 2) {
+ if ((p = strstr(argv[1], "CID")) == NULL || !DoDirectory(argv[1])) {
+ fprintf(stderr,
+ "Specified CID directory not found. CFM files not created.\n");
+ exit(1);
+ }
+ }
+ exit(0);
+}
+
+static Bool
+DoDirectory(char *dirName) {
+ DIR *dir, *dir1, *dir2, *dir3;
+ struct dirent *dp, *dp1, *dp2;
+ char fname[CID_NAME_MAX];
+ char dirName1[CID_NAME_MAX], dirName2[CID_NAME_MAX];
+ char dirName3[CID_NAME_MAX];
+ FontPtr fontptr = NULL;
+
+ entry.name.name =
+ "-foundry-familyname-bold-r-normal--0-0-0-0-p-0-jisx0201.1976-0";
+
+ if ((dir = opendir(dirName))) {
+ while((dp = readdir(dir))) {
+ if (dp->d_name[0] == '.' || !strncmp(dp->d_name,"fonts.dir",9) ||
+ !strncmp(dp->d_name, "fonts.scale", 11))
+ continue;
+ strcpy(dirName1, dirName);
+ strcat(dirName1, "/");
+ strcat(dirName1, dp->d_name);
+ if ((dir1 = opendir(dirName1))) {
+ strcpy(dirName2, dirName1);
+ strcat(dirName2, "/CIDFont");
+ if ((dir2 = opendir(dirName2))) {
+ while((dp1 = readdir(dir2))) {
+ if (dp1->d_name[0] == '.')
+ continue;
+ strcpy(dirName3, dirName1);
+ strcat(dirName3, "/CMap");
+ if ((dir3 = opendir(dirName3))) {
+ while((dp2 = readdir(dir3))) {
+ if (dp2->d_name[0] == '.')
+ continue;
+ strcpy(fname, dirName1);
+ strcat(fname, "/");
+ strcat(fname, dp1->d_name);
+ strcat(fname, "--");
+ strcat(fname, dp2->d_name);
+ strcat(fname, ".cid");
+ (void)CIDOpenScalable(NULL, &fontptr, 0, &entry, fname, &vals, 0, 0, NULL);
+ }
+ closedir(dir3);
+ }
+ }
+ closedir(dir2);
+ }
+ closedir(dir1);
+ }
+ }
+ closedir(dir);
+ return TRUE;
+ } return FALSE;
+}
+
+static void
+CIDFillVals(FontScalablePtr vals)
+{
+ FontResolutionPtr res;
+ int x_res = DEFAULTRES;
+ int y_res = DEFAULTRES;
+ int pointsize = DEFAULTPOINTSIZE; /* decipoints */
+ int num_res;
+
+ /* Must have x, y, and pixel */
+ if (!vals->x || !vals->y || !vals->pixel) {
+ res = (FontResolutionPtr) GetClientResolutions(&num_res);
+ if (num_res) {
+ if (res->x_resolution)
+ x_res = res->x_resolution;
+ if (res->y_resolution)
+ y_res = res->y_resolution;
+ if (res->point_size)
+ pointsize = res->point_size;
+ }
+ if (!vals->x)
+ vals->x = x_res;
+ if (!vals->y)
+ vals->y = y_res;
+ if (!vals->point) {
+ if (!vals->pixel) vals->point = pointsize;
+ else vals->point = (vals->pixel * DECIPOINTSPERINCH) / vals->y;
+ vals->point_matrix[0] = vals->point_matrix[3] = vals->point;
+ vals->point_matrix[1] = vals->point_matrix[2] = 0;
+ }
+ if (!vals->pixel) {
+ vals->pixel = (vals->point * vals->y) / DECIPOINTSPERINCH;
+ vals->pixel_matrix[0] = vals->pixel_matrix[3] = vals->pixel;
+ vals->pixel_matrix[1] = vals->pixel_matrix[2] = 0;
+ }
+ /* Make sure above arithmetic is normally in range and will
+ round properly. +++ */
+ }
+}
+
+int
+CheckFSFormat(fsBitmapFormat format, fsBitmapFormatMask fmask, int *bit,
+ int *byte, int *scan, int *glyph, int *image)
+{
+ *bit = *byte = 1;
+ *glyph = *scan = *image = 1;
+ return Successful;
+
+}
+
+
+Atom
+MakeAtom(char *p, unsigned len, int makeit)
+{
+ return *p;
+}
+
+FontResolutionPtr
+GetClientResolutions(int *resP)
+{
+ *resP = 0;
+ return NULL;
+}
+
+pointer
+Xalloc(unsigned long size)
+{
+ return(malloc(size));
+}
+
+void
+Xfree(pointer p)
+{
+ free((char *)p);
+}
+
+void
+FontDefaultFormat(int *bit, int *byte, int *glyph, int *scan) { ; }
+
+Bool
+FontFilePriorityRegisterRenderer(FontRendererPtr renderer, int priority)
+{ return TRUE; }
+
+Bool
+FontFileRegisterRenderer(FontRendererPtr renderer) { return TRUE; }
+
+Bool
+FontParseXLFDName(char *fname, FontScalablePtr vals, int subst)
+{ return TRUE; }
+
+void
+FontComputeInfoAccelerators(FontInfoPtr f) { ; }
+
+void
+FatalError(const char *f, ...) { exit (1); }
+
+void
+ErrorF(const char *f, ...) { ; }
+
+char *
+FontEncFromXLFD(const char *name, int n ) { return NULL; }
+
+FontMapPtr
+FontEncMapFind(const char *c1, int n1, int n2, int n3, const char *c2)
+{ return NULL; }
+
+char *
+unicodetoPSname(unsigned short code) { return NULL; }
+
+unsigned
+FontEncRecode(unsigned i, FontMapPtr m) { return 0; }
+
+char *
+FontEncName(unsigned i, FontMapPtr m) { return NULL; }
+
+FontPtr
+CreateFontRec (void)
+{
+ FontPtr pFont;
+
+ pFont = (FontPtr)xalloc(sizeof(FontRec));
+ if(pFont)
+ bzero((char*)pFont, sizeof(FontRec));
+
+ return pFont;
+}
+
+void DestroyFontRec (FontPtr pFont)
+{
+ xfree(pFont);
+}
+
diff --git a/mkcfm.man b/mkcfm.man
new file mode 100644
index 0000000..9826eb7
--- /dev/null
+++ b/mkcfm.man
@@ -0,0 +1,60 @@
+.\" Copyright (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+.\"
+.\" The contents of this file are subject to the CID Font Code Public Licence
+.\" Version 1.0 (the "License"). You may not use this file except in compliance
+.\" with the Licence. You may obtain a copy of the License at Silicon Graphics,
+.\" Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+.\" 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+.\"
+.\" Software distributed under the License is distributed on an "AS IS" basis.
+.\" ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+.\" WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+.\" NON-INFRINGEMENT. See the License for the specific language governing
+.\" rights and limitations under the License.
+.\"
+.\" The Original Software is CID font code that was developed by Silicon
+.\" Graphics, Inc.
+.\"
+.\" $XFree86: xc/programs/mkcfm/mkcfm.man,v 1.2 1999/05/15 12:10:37 dawes Exp $
+.TH MKCFM 1 "Release 1.0" "CID Fonts Version 1.0"
+.SH NAME
+mkcfm - create summaries of font metric files in CID font directories
+.SH SYNOPSIS
+.B "mkcfm"
+[\fICID-font-directory-name\fP]
+.SH DESCRIPTION
+There is usually only one CID font directory on the X font path. It is
+usually called \fI/usr/X11R6/lib/X11/fonts/CID\fP. If you do not specify
+an argument, \fImkcfm\fP will try to go through the subdirectories of
+that directory, and create one summary of font metric files for each
+CIDFont (character descriptions) file and each CMap (Character Maps) file
+it finds. The summaries of font metric files are put in the existing CFM
+subdirectory. The CFM subdirectories are created when CID-keyed fonts
+are installed.
+.PP
+If you specify a CID font directory as an argument, \fImkcfm\fP will try
+to go through the subdirectories of that directory, and create one summary
+of font metric files for each CIDFont file and each CMap file it finds.
+.I mkcfm
+will calculate the summaries of the font metric files stored in AFM
+subdirectories of the CID font directory.
+.PP
+Those summaries are needed by the rasterizer of CID-keyed fonts to
+speed up the response to X font calls. If those files do not exist, CID
+rasterizer will have to go through usually large font metric files, and
+calculate the summaries itself each time the font is called. You will
+notice a substantial wait on a call to a large CID-keyed font.
+.SH FILES
+.TP 15
+.B .afm files
+Each CID-keyed font file is supposed to have a font metric file
+(.afm file). \fImkcfm\fP creates summary files (.cfm files) of those
+font metric files. \fImkcfm\fP should be run whenever a change is
+made to the files stored in the subdirectories of the CID font
+directory. For example, it should be run when new CID fonts are installed.
+.TP 15
+.B .cfm files
+Summaries of font metric (.afm) files created by \fImkcfm\fP.
+.SH "SEE ALSO"
+The rasterizer for CID-keyed fonts in the directory
+\fIxc/lib/font/Type1\fP.