summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/X11/fonts/fontmisc.h5
-rw-r--r--include/X11/fonts/pcf.h3
-rw-r--r--src/FreeType/ft.h9
-rw-r--r--src/FreeType/ftenc.c87
-rw-r--r--src/FreeType/ftfuncs.c3112
-rw-r--r--src/FreeType/ftfuncs.h94
-rw-r--r--src/FreeType/fttools.c19
-rw-r--r--src/Speedo/set_trns.c9
-rw-r--r--src/Speedo/spfont.c6
-rw-r--r--src/Type1/arith.c8
-rw-r--r--src/Type1/cidchar.c9
-rw-r--r--src/Type1/hints.c40
-rw-r--r--src/Type1/lines.c5
-rw-r--r--src/Type1/objects.c51
-rw-r--r--src/Type1/objects.h14
-rw-r--r--src/Type1/paths.c106
-rw-r--r--src/Type1/regions.c100
-rw-r--r--src/Type1/scanfont.c12
-rw-r--r--src/Type1/spaces.c20
-rw-r--r--src/Type1/t1funcs.c29
-rw-r--r--src/Type1/t1info.c6
-rw-r--r--src/Type1/token.c12
-rw-r--r--src/Type1/type1.c109
-rw-r--r--src/bitmap/bdfread.c8
-rw-r--r--src/bitmap/bdfutils.c3
-rw-r--r--src/bitmap/bitscale.c12
-rw-r--r--src/bitmap/pcfread.c18
-rw-r--r--src/bitmap/pcfwrite.c8
-rw-r--r--src/bitmap/snfread.c18
-rw-r--r--src/bitmap/snfstr.h3
-rw-r--r--src/fc/fsconvert.c22
-rw-r--r--src/fc/fserve.c128
-rw-r--r--src/fc/fsio.c7
-rw-r--r--src/fc/fslibos.h23
-rw-r--r--src/fontfile/dirfile.c19
-rw-r--r--src/fontfile/ffcheck.c35
-rw-r--r--src/fontfile/fontdir.c36
-rw-r--r--src/fontfile/fontfile.c186
-rw-r--r--src/fontfile/printerfont.c36
-rw-r--r--src/stubs/errorf.c4
-rw-r--r--src/stubs/fatalerror.c4
-rw-r--r--src/stubs/initfshdl.c4
-rw-r--r--src/stubs/rmfshdl.c4
-rw-r--r--src/stubs/stubs.h10
-rw-r--r--src/util/fontxlfd.c39
-rw-r--r--src/util/private.c7
46 files changed, 3065 insertions, 1434 deletions
diff --git a/include/X11/fonts/fontmisc.h b/include/X11/fonts/fontmisc.h
index 6439ba1..e6f2540 100644
--- a/include/X11/fonts/fontmisc.h
+++ b/include/X11/fonts/fontmisc.h
@@ -25,7 +25,7 @@ used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
-/* $XFree86: xc/lib/font/include/fontmisc.h,v 3.16 2001/12/14 19:56:54 dawes Exp $ */
+/* $XFree86: xc/lib/font/include/fontmisc.h,v 3.17 2003/09/13 21:33:02 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -68,7 +68,8 @@ extern Atom MakeAtom ( char *string, unsigned len, int makeit );
extern int ValidAtom ( Atom atom );
extern char *NameForAtom (Atom atom);
-#ifndef OS_H
+#ifndef _HAVE_XALLOC_DECLS
+#define _HAVE_XALLOC_DECLS
extern pointer Xalloc(unsigned long);
extern pointer Xrealloc(pointer, unsigned long);
extern void Xfree(pointer);
diff --git a/include/X11/fonts/pcf.h b/include/X11/fonts/pcf.h
index 57f739d..c627bf8 100644
--- a/include/X11/fonts/pcf.h
+++ b/include/X11/fonts/pcf.h
@@ -27,7 +27,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
-/* $XFree86: xc/lib/font/bitmap/pcf.h,v 1.4 2001/12/14 19:56:47 dawes Exp $ */
+/* $XFree86: xc/lib/font/bitmap/pcf.h,v 1.5 2003/11/18 01:17:04 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -95,5 +95,6 @@ extern int pcfReadFontInfo ( FontInfoPtr pFontInfo, FontFilePtr file );
extern int pmfReadFont ( FontPtr pFont, FontFilePtr file,
int bit, int byte, int glyph, int scan );
extern int pcfWriteFont ( FontPtr pFont, FontFilePtr file );
+extern void pcfError ( const char *, ... );
#endif /* _PCF_H_ */
diff --git a/src/FreeType/ft.h b/src/FreeType/ft.h
index d4cacc2..b597457 100644
--- a/src/FreeType/ft.h
+++ b/src/FreeType/ft.h
@@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
-/* $XFree86: xc/lib/font/FreeType/ft.h,v 1.19 2002/10/01 00:02:09 alanh Exp $ */
+/* $XFree86: xc/lib/font/FreeType/ft.h,v 1.23 2003/10/19 18:53:49 dawes Exp $ */
#ifndef _FT_H_
#define _FT_H_
@@ -52,6 +52,10 @@ THE SOFTWARE.
/* Is x significantly different from 0 w.r.t. y? */
#define DIFFER0(x,y) (fabs(x)>=NEGLIGIBLE*fabs(y))
+#ifndef ABS
+#define ABS(x) ((x) >= 0 ? (x) : -(x))
+#endif
+
/* Two to the sixteenth power, as a double. */
#define TWO_SIXTEENTH ((double)(1<<16))
#define TWO_SIXTH ((double)(1<<6))
@@ -70,7 +74,9 @@ typedef struct _FTMapping
/* ftfuncs.c */
+#if 0
void FreeTypeRegisterFontFileFunctions(void);
+#endif
/* ftenc.c */
@@ -79,7 +85,6 @@ unsigned FTRemap(FT_Face face, FTMappingPtr, unsigned code);
/* fttools.c */
-int FTu2a(int, char*, char*, int, int);
int FTtoXReturnCode(int);
int FTGetEnglishName(FT_Face, int, char *, int);
int FTcheckForTTCName(char*, char**, int*);
diff --git a/src/FreeType/ftenc.c b/src/FreeType/ftenc.c
index 7243f3f..a3b02b9 100644
--- a/src/FreeType/ftenc.c
+++ b/src/FreeType/ftenc.c
@@ -1,5 +1,5 @@
/*
-Copyright (c) 1998-2002 by Juliusz Chroboczek
+Copyright (c) 1998-2003 by Juliusz Chroboczek
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -19,7 +19,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
-/* $XFree86: xc/lib/font/FreeType/ftenc.c,v 1.21 2002/10/01 00:02:10 alanh Exp $ */
+/* $XFree86: xc/lib/font/FreeType/ftenc.c,v 1.25 2003/11/20 22:36:34 dawes Exp $ */
#ifndef FONTMODULE
#include <string.h>
@@ -29,13 +29,19 @@ THE SOFTWARE.
#include "xf86_ansic.h"
#endif
+#include "fntfilst.h"
+#include "fontutil.h"
+#include "FSproto.h"
+
#include "fontmisc.h"
#include "fontenc.h"
-#include "freetype/freetype.h"
-#include "freetype/ttnameid.h"
-#include "freetype/tttables.h"
-#include "freetype/t1tables.h"
-#include "freetype/ftxf86.h"
+#include <ft2build.h>
+#include FT_FREETYPE_H
+#include FT_TRUETYPE_IDS_H
+#include FT_TRUETYPE_TABLES_H
+#include FT_TYPE1_TABLES_H
+#include FT_BDF_H
+#include FT_XFREE86_H
#include "ft.h"
static int find_cmap(int, int, int, FT_Face, FT_CharMap *);
@@ -45,6 +51,9 @@ FTEncFontSpecific(char *encoding)
{
char *p = encoding;
+ if(strcasecmp(encoding, "microsoft-symbol") == 0)
+ return 1;
+
while(*p != '-') {
if(*p == '\0')
return 0;
@@ -62,36 +71,46 @@ FTPickMapping(char *xlfd, int length, char *filename, FT_Face face,
FontMapPtr mapping;
FT_CharMap cmap;
int ftrc;
-
+ int symbol = 0;
+ const char *enc, *reg;
char *encoding_name = 0;
+ char buf[20];
if(xlfd)
encoding_name = FontEncFromXLFD(xlfd, length);
if(!encoding_name)
encoding_name = "iso8859-1";
- if(FTEncFontSpecific(encoding_name)) {
- ftrc = FT_Select_Charmap(face, ft_encoding_adobe_custom);
- if(ftrc != 0) {
- ErrorF("FreeType: couldn't select custom Type 1 encoding\n");
- return -1;
- } else {
- tm->named = 0;
- tm->cmap = face->charmap;
- tm->base = 0;
- tm->mapping = NULL;
- return 0;
+ symbol = FTEncFontSpecific(encoding_name);
+
+ ftrc = FT_Get_BDF_Charset_ID(face, &enc, &reg);
+ if(ftrc == 0) {
+ /* Disable reencoding for non-Unicode fonts. This will
+ currently only work for BDFs. */
+ if(strlen(enc) + strlen(reg) > 18)
+ goto native;
+ strcpy(buf, enc);
+ strcat(buf, "-");
+ strcat(buf, reg);
+ ErrorF("%s %s\n", buf, encoding_name);
+ if(strcasecmp(buf, "iso10646-1") != 0) {
+ if(strcasecmp(buf, encoding_name) == 0)
+ goto native;
+ return BadFontFormat;
}
+ } else if(symbol) {
+ ftrc = FT_Select_Charmap(face, ft_encoding_adobe_custom);
+ if(ftrc == 0)
+ goto native;
}
encoding = FontEncFind(encoding_name, filename);
+ if(symbol && encoding == NULL)
+ encoding = FontEncFind("microsoft-symbol", filename);
if(encoding == NULL) {
- ErrorF("FreeType: couldn't find encoding %s\n", encoding_name);
- encoding = FontEncFind("iso8859-1", filename);
- }
- if(encoding == NULL) {
- ErrorF("FreeType: couldn't find encoding iso8859-1.\n");
- return -1;
+ ErrorF("FreeType: couldn't find encoding '%s' for '%s'\n",
+ encoding_name, filename);
+ return BadFontName;
}
if(FT_Has_PS_Glyph_Names(face)) {
@@ -100,7 +119,7 @@ FTPickMapping(char *xlfd, int length, char *filename, FT_Face face,
tm->named = 1;
tm->base = 0;
tm->mapping = mapping;
- return 0;
+ return Successful;
}
}
}
@@ -110,8 +129,9 @@ FTPickMapping(char *xlfd, int length, char *filename, FT_Face face,
&cmap)) {
tm->named = 0;
tm->cmap = cmap;
- if(strcasecmp(encoding_name, "microsoft-symbol") == 0) {
- /* deal with undocumented lossage */
+ if(symbol) {
+ /* deal with an undocumented ``feature'' of the
+ Microsft-Symbol cmap */
TT_OS2 *os2;
os2 = FT_Get_Sfnt_Table(face, ft_sfnt_os2);
if(os2)
@@ -121,11 +141,18 @@ FTPickMapping(char *xlfd, int length, char *filename, FT_Face face,
} else
tm->base = 0;
tm->mapping = mapping;
- return 0;
+ return Successful;
}
}
- return -1;
+ return BadFontFormat;
+
+ native:
+ tm->named = 0;
+ tm->cmap = face->charmap;
+ tm->base = 0;
+ tm->mapping = NULL;
+ return Successful;
}
static int
diff --git a/src/FreeType/ftfuncs.c b/src/FreeType/ftfuncs.c
index fa58006..d942784 100644
--- a/src/FreeType/ftfuncs.c
+++ b/src/FreeType/ftfuncs.c
@@ -1,6 +1,11 @@
/*
Copyright (c) 1997 by Mark Leisher
-Copyright (c) 1998-2002 by Juliusz Chroboczek
+Copyright (c) 1998-2003 by Juliusz Chroboczek
+Copyright (c) 1998 Go Watanabe, All rights reserved.
+Copyright (c) 1998 Kazushi (Jam) Marukawa, All rights reserved.
+Copyright (c) 1998 Takuya SHIOZAKI, All rights reserved.
+Copyright (c) 1998 X-TrueType Server Project, All rights reserved.
+Copyright (c) 2003 After X-TT Project, All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -21,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
-/* $XFree86: xc/lib/font/FreeType/ftfuncs.c,v 1.27 2003/02/13 03:01:45 dawes Exp $ */
+/* $XFree86: xc/lib/font/FreeType/ftfuncs.c,v 1.37 2003/11/20 22:36:35 dawes Exp $ */
#include "fontmisc.h"
@@ -37,16 +42,58 @@ THE SOFTWARE.
#include "fntfilst.h"
#include "fontutil.h"
#include "FSproto.h"
-#include "freetype/freetype.h"
-#include "freetype/ftsizes.h"
-#include "freetype/ttnameid.h"
-#include "freetype/tttables.h"
-#include "freetype/t1tables.h"
-#include "freetype/ftxf86.h"
+#include <ft2build.h>
+#include FT_FREETYPE_H
+#include FT_SIZES_H
+#include FT_TRUETYPE_IDS_H
+#include FT_TRUETYPE_TABLES_H
+#include FT_TYPE1_TABLES_H
+#include FT_XFREE86_H
+#include FT_BBOX_H
+#include FT_INTERNAL_TRUETYPE_TYPES_H
+#include "ttobjs.h"
+/*
+ * If you want to use FT_Outline_Get_CBox instead of
+ * FT_Outline_Get_BBox, define here.
+ */
+/* #define USE_GET_CBOX */
+#ifdef USE_GET_CBOX
+#include FT_OUTLINE_H
+#endif
#include "fontenc.h"
#include "ft.h"
#include "ftfuncs.h"
+#include "xttcap.h"
+
+/* Work around FreeType bug */
+#define WORK_AROUND_UPM 2048
+
+#ifndef True
+#define True (-1)
+#endif /* True */
+#ifndef False
+#define False (0)
+#endif /* False */
+
+#define FLOOR64(x) ((x) & -64)
+#define CEIL64(x) (((x) + 64 - 1) & -64)
+
+/*
+ * If you want very lazy method(vl=y) AS DEFAULT when
+ * handling large charset, define here.
+ */
+/* #define DEFAULT_VERY_LAZY 1 */ /* Always */
+#define DEFAULT_VERY_LAZY 2 /* Multi-byte only */
+/* #define DEFAULT_VERY_LAZY 256 */ /* Unicode only */
+
+/* Does the XAA accept noSuchChar? */
+/* #define XAA_ACCEPTS_NO_SUCH_CHAR */
+
+#ifdef XAA_ACCEPTS_NO_SUCH_CHAR
+static CharInfoRec noSuchChar = { /* metrics */{0,0,0,0,0,0},
+ /* bits */ NULL };
+#endif
/* The propery names for all the XLFD properties. */
@@ -79,7 +126,7 @@ hash(char *string)
int i;
unsigned u = 0;
for(i = 0; string[i] != '\0'; i++)
- u = (u<<2) + (unsigned char)string[i];
+ u = (u<<5) + (u >> (NUMFACEBUCKETS - 5)) + (unsigned char)string[i];
return u;
}
@@ -99,13 +146,11 @@ iceil(int x, int y)
}
static int
-FreeTypeOpenFace(FTFacePtr *facep, char *fileName)
+FreeTypeOpenFace(FTFacePtr *facep, char *FTFileName, char *realFileName, int faceNumber)
{
FT_Error ftrc;
int bucket;
FTFacePtr face, otherFace;
- char *realFileName;
- int faceNumber;
if (!ftypeInitP) {
ftrc = FT_Init_FreeType(&ftypeLibrary);
@@ -117,11 +162,10 @@ FreeTypeOpenFace(FTFacePtr *facep, char *fileName)
}
/* Try to find a matching face in the hashtable */
- bucket = hash(fileName)%NUMFACEBUCKETS;
+ bucket = hash(FTFileName)%NUMFACEBUCKETS;
otherFace = faceTable[bucket];
while(otherFace) {
- if(strcmp(otherFace->filename, fileName) == 0)
- break;
+ if( strcmp(otherFace->filename, FTFileName) == 0 ) break;
otherFace = otherFace->next;
}
if(otherFace) {
@@ -135,29 +179,30 @@ FreeTypeOpenFace(FTFacePtr *facep, char *fileName)
if(face == NULL) {
return AllocError;
}
+ memset(face, 0, sizeof(FTFaceRec));
- face->filename = (char*)xalloc(strlen(fileName)+1);
+ face->filename = (char*)xalloc(strlen(FTFileName)+1);
if(face->filename == NULL) {
xfree(face);
return AllocError;
}
- strcpy(face->filename, fileName);
+ strcpy(face->filename, FTFileName);
- face->instances = NULL;
- face->active_instance = NULL;
-
- if(FTcheckForTTCName(fileName, &realFileName, &faceNumber)) {
- ftrc = FT_New_Face(ftypeLibrary, realFileName, faceNumber, &face->face);
- xfree(realFileName);
- } else
- ftrc = FT_New_Face(ftypeLibrary, fileName, 0, &face->face);
+ ftrc = FT_New_Face(ftypeLibrary, realFileName, faceNumber, &face->face);
if(ftrc != 0) {
- ErrorF("FreeType: couldn't open face %s: %d\n", fileName, ftrc);
+ ErrorF("FreeType: couldn't open face %s: %d\n", FTFileName, ftrc);
xfree(face->filename);
xfree(face);
- return BadFontPath;
+ return BadFontName;
}
+ face->bitmap = ((face->face->face_flags & FT_FACE_FLAG_SCALABLE) == 0);
+ if(!face->bitmap) {
+ TT_MaxProfile *maxp;
+ maxp = FT_Get_Sfnt_Table(face->face, ft_sfnt_maxp);
+ if(maxp && maxp->maxContours == 0)
+ face->bitmap = 1;
+ }
/* Insert face in hashtable and return it */
face->next = faceTable[bucket];
faceTable[bucket] = face;
@@ -223,19 +268,45 @@ BitmapFormatEqual(FontBitmapFormatPtr f1, FontBitmapFormatPtr f2)
}
static int
+TTCapEqual(struct TTCapInfo *t1, struct TTCapInfo *t2)
+{
+ return
+ t1->autoItalic == t2->autoItalic &&
+ t1->scaleWidth == t2->scaleWidth &&
+ t1->scaleBBoxWidth == t2->scaleBBoxWidth &&
+ t1->scaleBBoxHeight == t2->scaleBBoxHeight &&
+ t1->doubleStrikeShift == t2->doubleStrikeShift &&
+ t1->adjustBBoxWidthByPixel == t2->adjustBBoxWidthByPixel &&
+ t1->adjustLeftSideBearingByPixel == t2->adjustLeftSideBearingByPixel &&
+ t1->adjustRightSideBearingByPixel == t2->adjustRightSideBearingByPixel &&
+ t1->flags == t2->flags &&
+ t1->scaleBitmap == t2->scaleBitmap &&
+ /*
+ If we use forceConstantSpacing,
+ we *MUST* allocate new instance.
+ */
+ t1->forceConstantSpacingEnd < 0 &&
+ t2->forceConstantSpacingEnd < 0;
+}
+
+static int
FTInstanceMatch(FTInstancePtr instance,
- char *fileName, FTNormalisedTransformationPtr trans,
- int charcell, FontBitmapFormatPtr bmfmt)
+ char *FTFileName, FTNormalisedTransformationPtr trans,
+ int spacing, FontBitmapFormatPtr bmfmt,
+ struct TTCapInfo *tmp_ttcap, FT_Int32 load_flags)
{
- if(strcmp(instance->face->filename, fileName) != 0) {
+ if(strcmp(instance->face->filename, FTFileName) != 0) {
return 0;
} else if(!TransEqual(&instance->transformation, trans)) {
return 0;
- } else if((charcell && instance->monospaced != FT_CHARCELL) ||
- (!charcell && instance->monospaced == FT_CHARCELL)) {
+ } else if( spacing != instance->spacing ) {
+ return 0;
+ } else if( load_flags != instance->load_flags ) {
return 0;
} else if(!BitmapFormatEqual(&instance->bmfmt, bmfmt)) {
return 0;
+ } else if(!TTCapEqual(&instance->ttcap, tmp_ttcap)) {
+ return 0;
} else {
return 1;
}
@@ -264,26 +335,56 @@ FreeTypeActivateInstance(FTInstancePtr instance)
}
static int
-FreeTypeOpenInstance(FTInstancePtr *instance_return,
- char *fileName, FTNormalisedTransformationPtr trans,
- int charcell, FontBitmapFormatPtr bmfmt)
+FTFindSize(FT_Face face, FTNormalisedTransformationPtr trans,
+ int *x_return, int *y_return)
+{
+ int tx, ty, x, y;
+ int i, j;
+ int d, dd;
+
+ if(trans->nonIdentity)
+ return BadFontName;
+
+ tx = (int)(trans->scale * trans->xres / 72.0 + 0.5);
+ ty = (int)(trans->scale * trans->yres / 72.0 + 0.5);
+
+ d = 100;
+ j = -1;
+ for(i = 0; i < face->num_fixed_sizes; i++) {
+ x = face->available_sizes[i].width;
+ y = face->available_sizes[i].height;
+ if(ABS(x - tx) <= 1 && ABS(y - ty) <= 1) {
+ dd = ABS(x - tx) * ABS(x - tx) + ABS(y - ty) * ABS(y - ty);
+ if(dd < d) {
+ j = i;
+ d = dd;
+ }
+ }
+ }
+ if(j < 0)
+ return BadFontName;
+
+ *x_return = face->available_sizes[j].width;
+ *y_return = face->available_sizes[j].height;
+ return Successful;
+}
+
+static int
+FreeTypeOpenInstance(FTInstancePtr *instance_return, FTFacePtr face,
+ char *FTFileName, FTNormalisedTransformationPtr trans,
+ int spacing, FontBitmapFormatPtr bmfmt,
+ struct TTCapInfo *tmp_ttcap, FT_Int32 load_flags)
{
FT_Error ftrc;
int xrc;
FTInstancePtr instance, otherInstance;
- FTFacePtr face;
-
- xrc = FreeTypeOpenFace(&face, fileName);
- if(xrc != Successful) {
- return xrc;
- }
/* Search for a matching instance */
for(otherInstance = face->instances;
otherInstance;
otherInstance = otherInstance->next) {
- if(FTInstanceMatch(otherInstance, fileName, trans, charcell, bmfmt))
- break;
+ if(FTInstanceMatch(otherInstance, FTFileName, trans, spacing, bmfmt,
+ tmp_ttcap, load_flags)) break;
}
if(otherInstance) {
MUMBLE("Returning cached instance\n");
@@ -301,31 +402,53 @@ FreeTypeOpenInstance(FTInstancePtr *instance_return,
instance->refcount = 1;
instance->face = face;
- instance->monospaced = charcell?FT_CHARCELL:0;
- instance->charcellMetrics = 0;
- instance->width = 0;
-
+ instance->load_flags = load_flags;
+ instance->spacing = spacing; /* Actual spacing */
+ instance->pixel_size =0;
+ instance->pixel_width_unit_x =0;
+ instance->pixel_width_unit_y =0;
+ instance->charcellMetrics = NULL;
+ instance->averageWidth = 0;
+ instance->rawAverageWidth = 0;
+ instance->forceConstantMetrics = NULL;
+
instance->transformation = *trans;
instance->bmfmt = *bmfmt;
- instance->nglyphs = instance->face->face->num_glyphs;
instance->glyphs = NULL;
instance->available = NULL;
+ if( 0 <= tmp_ttcap->forceConstantSpacingEnd )
+ instance->nglyphs = 2 * instance->face->face->num_glyphs;
+ else
+ instance->nglyphs = instance->face->face->num_glyphs;
+
+ /* Store the TTCap info. */
+ memcpy((char*)&instance->ttcap, (char*)tmp_ttcap,
+ sizeof(struct TTCapInfo));
+
ftrc = FT_New_Size(instance->face->face, &instance->size);
if(ftrc != 0) {
ErrorF("FreeType: couldn't create size object: %d\n", ftrc);
- FreeTypeFreeFace(instance->face);
xfree(instance);
return FTtoXReturnCode(ftrc);
}
FreeTypeActivateInstance(instance);
- ftrc = FT_Set_Char_Size(instance->face->face,
- (int)(trans->scale*(1<<6)+0.5),
- (int)(trans->scale*(1<<6)+0.5),
- trans->xres, trans->yres);
+ if(!face->bitmap) {
+ ftrc = FT_Set_Char_Size(instance->face->face,
+ (int)(trans->scale*(1<<6) + 0.5),
+ (int)(trans->scale*(1<<6) + 0.5),
+ trans->xres, trans->yres);
+ } else {
+ int xsize, ysize;
+ xrc = FTFindSize(face->face, trans, &xsize, &ysize);
+ if(xrc != Successful) {
+ xfree(instance);
+ return xrc;
+ }
+ ftrc = FT_Set_Pixel_Sizes(instance->face->face, xsize, ysize);
+ }
if(ftrc != 0) {
FT_Done_Size(instance->size);
- FreeTypeFreeFace(instance->face);
xfree(instance);
return FTtoXReturnCode(ftrc);
}
@@ -343,6 +466,8 @@ FreeTypeFreeInstance(FTInstancePtr instance)
{
FTInstancePtr otherInstance;
+ if( instance == NULL ) return;
+
if(instance->face->active_instance == instance)
instance->face->active_instance = NULL;
instance->refcount--;
@@ -367,6 +492,9 @@ FreeTypeFreeInstance(FTInstancePtr instance)
if(instance->charcellMetrics) {
xfree(instance->charcellMetrics);
}
+ if(instance->forceConstantMetrics) {
+ xfree(instance->forceConstantMetrics);
+ }
if(instance->glyphs) {
for(i = 0; i < iceil(instance->nglyphs, FONTSEGMENTSIZE); i++) {
if(instance->glyphs[i]) {
@@ -392,11 +520,17 @@ FreeTypeFreeInstance(FTInstancePtr instance)
}
static int
-FreeTypeInstanceFindGlyph(unsigned idx, FTInstancePtr instance,
+FreeTypeInstanceFindGlyph(unsigned idx_in, int flags, FTInstancePtr instance,
CharInfoPtr **glyphs, int ***available,
int *found, int *segmentP, int *offsetP)
{
int segment, offset;
+ unsigned idx = idx_in;
+
+ if( 0 <= instance->ttcap.forceConstantSpacingEnd ){
+ if( (flags & FT_FORCE_CONSTANT_SPACING) )
+ idx += instance->nglyphs / 2 ;
+ }
if(idx > instance->nglyphs) {
*found = 0;
@@ -447,10 +581,9 @@ FreeTypeInstanceFindGlyph(unsigned idx, FTInstancePtr instance,
}
static int
-FreeTypeInstanceGetGlyph(unsigned idx, CharInfoPtr *g, FTInstancePtr instance)
+FreeTypeInstanceGetGlyph(unsigned idx, int flags, CharInfoPtr *g, FTInstancePtr instance)
{
int found, segment, offset;
- FT_Error ftrc;
int xrc;
int ***available;
CharInfoPtr **glyphs;
@@ -458,180 +591,662 @@ FreeTypeInstanceGetGlyph(unsigned idx, CharInfoPtr *g, FTInstancePtr instance)
available = &instance->available;
glyphs = &instance->glyphs;
- xrc = FreeTypeInstanceFindGlyph(idx, instance, glyphs, available,
+ xrc = FreeTypeInstanceFindGlyph(idx, flags, instance, glyphs, available,
&found, &segment, &offset);
if(xrc != Successful)
return xrc;
if(!found || (*available)[segment][offset] == FT_AVAILABLE_NO) {
- *g = 0;
- return Successful;
- } else if((*available)[segment][offset] == FT_AVAILABLE_RASTERISED) {
- *g = &(*glyphs)[segment][offset];
+ *g = NULL;
return Successful;
+ }
+
+ if((*available)[segment][offset] == FT_AVAILABLE_RASTERISED) {
+ *g = &(*glyphs)[segment][offset];
+ return Successful;
}
- /* Tough: need to rasterise a new glyph. */
- FreeTypeActivateInstance(instance);
- ftrc = FT_Load_Glyph(instance->face->face, idx,
- FT_LOAD_RENDER | FT_LOAD_MONOCHROME);
- if(ftrc != 0)
- return FTtoXReturnCode(ftrc);
-
- if(instance->monospaced == FT_CHARCELL &&
- (*available)[segment][offset] == 0)
- memcpy((char*)&(*glyphs)[segment][offset].metrics,
- (char*)instance->charcellMetrics,
- sizeof(xCharInfo));
+ flags |= FT_GET_GLYPH_BOTH;
- xrc = FreeTypeRasteriseGlyph(&(*glyphs)[segment][offset],
- instance, instance->monospaced == FT_CHARCELL);
- if(xrc != Successful)
- return xrc;
- else
+ xrc = FreeTypeRasteriseGlyph(idx, flags,
+ &(*glyphs)[segment][offset], instance,
+ (*available)[segment][offset] >= FT_AVAILABLE_METRICS);
+ if(xrc == Successful) {
(*available)[segment][offset] = FT_AVAILABLE_RASTERISED;
-
- /* Update the width to match the width of the font */
- if(instance->monospaced) {
- if((*available)[segment][offset] >= FT_AVAILABLE_RASTERISED)
- (*glyphs)[segment][offset].metrics.characterWidth = instance->width;
- }
-
- /* return the glyph */
- if((*available)[segment][offset] >= FT_AVAILABLE_RASTERISED)
+ /* return the glyph */
*g = &(*glyphs)[segment][offset];
- else
- *g = 0;
- return Successful;
+ }
+ return xrc;
}
static int
-FreeTypeInstanceGetGlyphMetrics(unsigned idx,
- xCharInfo **metrics, FTInstancePtr instance)
+FreeTypeInstanceGetGlyphMetrics(unsigned idx, int flags,
+ xCharInfo **metrics, FTInstancePtr instance )
{
- CharInfoPtr g;
int xrc;
int found, segment, offset;
- xrc = FreeTypeInstanceFindGlyph(idx, instance,
+ /* Char cell */
+ if(instance->spacing == FT_CHARCELL) {
+ *metrics = instance->charcellMetrics;
+ return Successful;
+ }
+ /* Force constant metrics */
+ if( flags & FT_FORCE_CONSTANT_SPACING) {
+ *metrics = instance->forceConstantMetrics;
+ return Successful;
+ }
+
+ /* Not char cell */
+
+ xrc = FreeTypeInstanceFindGlyph(idx, flags, instance,
&instance->glyphs, &instance->available,
&found, &segment, &offset);
if(xrc != Successful)
return xrc;
-
if(!found) {
- *metrics = 0;
+ *metrics = NULL;
return Successful;
}
-
- if(instance->available[segment][offset] == 0) {
- if(instance->monospaced < FT_CHARCELL) {
- xrc = FreeTypeInstanceGetGlyph(idx, &g, instance);
- if(xrc != Successful)
- return xrc;
- } else {
- memcpy((char*)&instance->glyphs[segment][offset].metrics,
- (char*)instance->charcellMetrics,
- sizeof(xCharInfo));
- instance->available[segment][offset] = FT_AVAILABLE_YES;
- }
+ if( instance->available[segment][offset] == FT_AVAILABLE_NO ) {
+ *metrics = NULL;
+ return Successful;
+ }
+
+ if( instance->available[segment][offset] >= FT_AVAILABLE_METRICS ) {
+ *metrics = &instance->glyphs[segment][offset].metrics;
+ return Successful;
}
- if(instance->available[segment][offset] >= FT_AVAILABLE_YES) {
+ flags |= FT_GET_GLYPH_METRICS_ONLY;
+
+ xrc = FreeTypeRasteriseGlyph(idx, flags,
+ &instance->glyphs[segment][offset],
+ instance, 0);
+ if(xrc == Successful) {
+ instance->available[segment][offset] = FT_AVAILABLE_METRICS;
*metrics = &instance->glyphs[segment][offset].metrics;
- } else
- *metrics = 0;
-
- return Successful;
+ }
+ return xrc;
}
-int
-FreeTypeRasteriseGlyph(CharInfoPtr tgp, FTInstancePtr instance,
- int hasMetrics)
+/*
+ * Pseudo enbolding similar as Microsoft Windows.
+ * It is useful but poor.
+ */
+static void
+ft_make_up_bold_bitmap( char *raster, int bpr, int ht, int ds_mode)
{
-#define TRANSFORM_X(x_value) \
- ((int)floor((((double)(x_value)*(double)instance->transformation.matrix.xx)/\
- (TWO_SIXTEENTH*TWO_SIXTH))+0.5))
-
-#define TRANSFORM_Y(y_value) \
- ((int)floor((((double)(y_value)*(double)instance->transformation.matrix.yy)/\
- (TWO_SIXTEENTH*TWO_SIXTH))+0.5))
+ int x, y;
+ unsigned char *p = (unsigned char *)raster;
+ if ( ds_mode & TTCAP_DOUBLE_STRIKE_MKBOLD_EDGE_LEFT ) {
+ for (y=0; y<ht; y++) {
+ unsigned char rev_pat=0;
+ unsigned char lsb = 0;
+ for (x=0; x<bpr; x++) {
+ unsigned char tmp = *p<<7;
+ if ( (rev_pat & 0x01) && (*p & 0x80) ) p[-1] &= 0xfe;
+ rev_pat = ~(*p);
+ *p |= (*p>>1) | lsb;
+ *p &= ~(rev_pat & (*p << 1));
+ lsb = tmp;
+ p++;
+ }
+ }
+ }
+ else {
+ for (y=0; y<ht; y++) {
+ unsigned char lsb = 0;
+ for (x=0; x<bpr; x++) {
+ unsigned char tmp = *p<<7;
+ *p |= (*p>>1) | lsb;
+ lsb = tmp;
+ p++;
+ }
+ }
+ }
+}
-#define TRANSFORM_X_RAW(value) \
- ((int)floor((double)(value)/instance->transformation.scale/TWO_SIXTH/(smetrics.x_ppem/72.0)*1000.0+0.5))
+static void
+ft_make_up_italic_bitmap( char *raster, int bpr, int ht, int shift,
+ int h_total, int h_offset, double a_italic)
+{
+ int x, y;
+ unsigned char *p = (unsigned char *)raster;
+ if ( a_italic < 0 ) shift = -shift;
+ for (y=0; y<ht; y++) {
+ unsigned char *tmp_p = p + y*bpr;
+ int tmp_shift = shift * (h_total -1 -(y+h_offset)) / h_total;
+ int tmp_byte_shift;
+ if ( 0 <= tmp_shift ) {
+ tmp_byte_shift = tmp_shift/8;
+ tmp_shift %= 8;
+ if ( tmp_shift ) {
+ for (x=bpr-1;0<=x;x--) {
+ if ( x != bpr-1 )
+ tmp_p[x+1] |= tmp_p[x]<<(8-tmp_shift);
+ tmp_p[x]>>=tmp_shift;
+ }
+ }
+ if ( tmp_byte_shift ) {
+ for (x=bpr-1;0<x;x--) {
+ tmp_p[x] = tmp_p[x-1];
+ }
+ tmp_p[x]=0;
+ }
+ }
+ else {
+ tmp_shift = -tmp_shift;
+ tmp_byte_shift = tmp_shift/8;
+ tmp_shift %= 8;
+ if ( tmp_shift ) {
+ for (x=0;x<bpr;x++) {
+ if ( x != 0 )
+ tmp_p[x-1] |= tmp_p[x]>>(8-tmp_shift);
+ tmp_p[x]<<=tmp_shift;
+ }
+ }
+ if ( tmp_byte_shift ) {
+ for (x=0;x<bpr-1;x++) {
+ tmp_p[x] = tmp_p[x+1];
+ }
+ tmp_p[x]=0;
+ }
+ }
+ }
+}
+
+/*
+ * The very lazy method,
+ * parse the htmx field in TrueType font.
+ */
+
+/* from src/truetype/ttgload.c */
+static void
+tt_get_metrics( TT_HoriHeader* header,
+ FT_UInt idx,
+ FT_Short* bearing,
+ FT_UShort* advance )
+/* Copyright 1996-2001, 2002 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+{
+ TT_LongMetrics longs_m;
+ FT_UShort k = header->number_Of_HMetrics;
+
+ if ( k == 0 ) {
+ *bearing = *advance = 0;
+ return;
+ }
+
+ if ( idx < (FT_UInt)k ) {
+ longs_m = (TT_LongMetrics )header->long_metrics + idx;
+ *bearing = longs_m->bearing;
+ *advance = longs_m->advance;
+ }
+ else {
+ *bearing = ((TT_ShortMetrics*)header->short_metrics)[idx - k];
+ *advance = ((TT_LongMetrics )header->long_metrics)[k - 1].advance;
+ }
+}
+
+static int
+ft_get_very_lazy_bbox( FT_UInt index,
+ FT_Face face,
+ FT_Size size,
+ double slant,
+ FT_Matrix *matrix,
+ FT_BBox *bbox,
+ FT_Long *horiAdvance,
+ FT_Long *vertAdvance)
+{
+ if ( FT_IS_SFNT( face ) ) {
+ TT_Face ttface = (TT_Face)face;
+ FT_Size_Metrics *smetrics = &size->metrics;
+ FT_Short leftBearing = 0;
+ FT_UShort advance = 0;
+ FT_Vector p0, p1, p2, p3;
+
+ /* horizontal */
+ tt_get_metrics(&ttface->horizontal, index,
+ &leftBearing, &advance);
+
+#if 0
+ fprintf(stderr,"x_scale=%f y_scale=%f\n",
+ (double)smetrics->x_scale,(double)smetrics->y_scale);
+#endif
+ bbox->xMax = *horiAdvance =
+ FT_MulFix( advance, smetrics->x_scale );
+ bbox->xMin =
+ FT_MulFix( leftBearing, smetrics->x_scale );
+ /* vertical */
+ bbox->yMin = FT_MulFix( face->bbox.yMin,
+ smetrics->y_scale );
+ bbox->yMax = FT_MulFix( face->bbox.yMax,
+ smetrics->y_scale );
+ /* slant */
+ if( 0 < slant ) {
+ bbox->xMax += slant * bbox->yMax;
+ bbox->xMin += slant * bbox->yMin;
+ }
+ else if( slant < 0 ) {
+ bbox->xMax += slant * bbox->yMin;
+ bbox->xMin += slant * bbox->yMax;
+ }
+
+ *vertAdvance = -1; /* We don't support */
+
+ p0.x = p2.x = bbox->xMin;
+ p1.x = p3.x = bbox->xMax;
+ p0.y = p1.y = bbox->yMin;
+ p2.y = p3.y = bbox->yMax;
+
+ FT_Vector_Transform(&p0, matrix);
+ FT_Vector_Transform(&p1, matrix);
+ FT_Vector_Transform(&p2, matrix);
+ FT_Vector_Transform(&p3, matrix);
+
+#if 0
+ fprintf(stderr,
+ "->(%.1f %.1f) (%.1f %.1f)"
+ " (%.1f %.1f) (%.1f %.1f)\n",
+ p0.x / 64.0, p0.y / 64.0,
+ p1.x / 64.0, p1.y / 64.0,
+ p2.x / 64.0, p2.y / 64.0,
+ p3.x / 64.0, p3.y / 64.0);
+#endif
+ bbox->xMin = MIN(p0.x, MIN(p1.x, MIN(p2.x, p3.x)));
+ bbox->xMax = MAX(p0.x, MAX(p1.x, MAX(p2.x, p3.x)));
+ bbox->yMin = MIN(p0.y, MIN(p1.y, MIN(p2.y, p3.y)));
+ bbox->yMax = MAX(p0.y, MAX(p1.y, MAX(p2.y, p3.y)));
+ return 0; /* Successful */
+ }
+ return -1;
+}
+int
+FreeTypeRasteriseGlyph(unsigned idx, int flags, CharInfoPtr tgp,
+ FTInstancePtr instance, int hasMetrics)
+{
FTFacePtr face;
FT_Bitmap *bitmap;
+ FT_BBox bbox;
+ FT_Long outline_hori_advance;
+ FT_Long outline_vert_advance;
char *raster = NULL;
- FT_Size_Metrics smetrics;
- FT_Glyph_Metrics *metrics;
+ FT_Glyph_Metrics *metrics = NULL;
int wd, ht, bpr; /* width, height, bytes per row */
+ int wd_actual, ht_actual;
+ int ftrc, is_outline, b_shift=0, correct=0;
int dx, dy;
int leftSideBearing, rightSideBearing, characterWidth, rawCharacterWidth,
ascent, descent;
- int i = 0, j;
+ double bbox_center_raw;
face = instance->face;
- smetrics = instance->size->metrics;
FreeTypeActivateInstance(instance);
- metrics = &face->face->glyph->metrics;
bitmap = &face->face->glyph->bitmap;
- if(hasMetrics) {
- wd = tgp->metrics.rightSideBearing - tgp->metrics.leftSideBearing;
- ht = tgp->metrics.ascent + tgp->metrics.descent;
- dx = -tgp->metrics.leftSideBearing +
- TRANSFORM_X(metrics->horiBearingX);
- dy = tgp->metrics.ascent - TRANSFORM_Y(metrics->horiBearingY);
- } else {
- wd = bitmap->width;
- ht = bitmap->rows;
- dx = 0;
- dy = 0;
- /* The X convention is to consider a character with an empty
- * bounding box as undefined. This convention is broken. */
- if(wd <= 0) wd = 1;
- if(ht <= 0) ht = 1;
- }
-
- /* Make sure rounding doesn't cause a crash in memcpy below */
- if(wd < bitmap->width)
- wd = bitmap->width;
- if(ht < bitmap->rows)
- ht = bitmap->rows;
+ if(!tgp) return AllocError;
- bpr = (((wd + (instance->bmfmt.glyph<<3) - 1) >> 3) &
- -instance->bmfmt.glyph);
- if(tgp) {
- raster = (char*)xalloc(ht * bpr);
- if(raster == NULL)
- return AllocError;
- memset(raster, 0, ht * bpr);
+ if( instance->spacing == FT_CHARCELL ) correct=1;
+ else if( flags & FT_FORCE_CONSTANT_SPACING ) correct=1;
+ else if( instance->ttcap.flags & TTCAP_IS_VERY_LAZY ){
+ if( hasMetrics || (!hasMetrics && (flags & FT_GET_GLYPH_METRICS_ONLY)) ){
+ /* If sbit is available, we don't use very lazy method. */
+ /* See TT_Load_Glyph */
+ if( FT_IS_SFNT( face->face ) ) {
+ TT_Size tt_size = (TT_Size)instance->size;
+ if( !( !(instance->load_flags & FT_LOAD_NO_BITMAP)
+ && tt_size->strike_index != 0xFFFFU ) ) correct=1;
+ }
+ }
}
- if(dx == 0 && dy == 0 && bpr == bitmap->pitch) {
- memcpy(raster, bitmap->buffer, bitmap->rows * bitmap->pitch);
- } else if(dx == 0) {
- for(i = MAX(0, -dy); i < bitmap->rows && i + dy < ht; i++)
- memcpy(raster + (i + dy) * bpr,
- bitmap->buffer + i * bitmap->pitch,
- bitmap->pitch);
- } else {
- for(i = MAX(0, -dy); i < bitmap->rows && i + dy < ht; i++) {
- for(j = MAX(0, -dx); j < bitmap->width && j + dx < wd; j++) {
- int set;
- set = (bitmap->buffer[i * bitmap->pitch + j / 8] &
- 1 << (7 - j % 8));
- if(set)
- raster[(i + dy) * bpr + (j + dx) / 8] |=
- 1 << (7 - (j + dx) % 8);
- }
- }
+ /*
+ * PREPARE METRICS
+ */
+
+ if(!hasMetrics) {
+ if( instance->spacing == FT_CHARCELL || flags & FT_GET_DUMMY ){
+ memcpy((char*)&tgp->metrics,
+ (char*)instance->charcellMetrics,
+ sizeof(xCharInfo));
+ }
+ else if( flags & FT_FORCE_CONSTANT_SPACING ) {
+ memcpy((char*)&tgp->metrics,
+ (char*)instance->forceConstantMetrics,
+ sizeof(xCharInfo));
+ }
+ /* mono or prop. */
+ else{
+ int new_width, try_very_lazy=correct;
+ double ratio;
+
+ if( try_very_lazy ) {
+ if( ft_get_very_lazy_bbox( idx, face->face, instance->size,
+ instance->ttcap.vl_slant,
+ &instance->transformation.matrix,
+ &bbox, &outline_hori_advance,
+ &outline_vert_advance ) == 0 ) {
+ goto bbox_ok; /* skip exact calculation */
+ }
+ }
+
+ ftrc = FT_Load_Glyph(instance->face->face, idx,
+ instance->load_flags);
+ metrics = &face->face->glyph->metrics;
+
+ if(ftrc != 0) return FTtoXReturnCode(ftrc);
+
+ if( face->face->glyph->format == FT_GLYPH_FORMAT_BITMAP ) {
+ /* bitmap, embedded bitmap */
+ leftSideBearing = metrics->horiBearingX / 64;
+ rightSideBearing = (metrics->width + metrics->horiBearingX) / 64;
+ bbox_center_raw = (2.0 * metrics->horiBearingX + metrics->width)/2.0/64.0;
+ characterWidth = (int)floor(metrics->horiAdvance
+ * instance->ttcap.scaleBBoxWidth / 64.0 + .5);
+ ascent = metrics->horiBearingY / 64;
+ descent = (metrics->height - metrics->horiBearingY) / 64 ;
+ /* */
+ new_width = characterWidth;
+ if( instance->ttcap.flags & TTCAP_DOUBLE_STRIKE_CORRECT_B_BOX_WIDTH )
+ new_width += instance->ttcap.doubleStrikeShift;
+ new_width += instance->ttcap.adjustBBoxWidthByPixel;
+ ratio = (double)new_width/characterWidth;
+ characterWidth = new_width;
+ /* adjustment by pixel unit */
+ if( instance->ttcap.flags & TTCAP_DOUBLE_STRIKE )
+ rightSideBearing += instance->ttcap.doubleStrikeShift;
+ rightSideBearing += instance->ttcap.adjustRightSideBearingByPixel;
+ leftSideBearing += instance->ttcap.adjustLeftSideBearingByPixel;
+ rightSideBearing += instance->ttcap.rsbShiftOfBitmapAutoItalic;
+ leftSideBearing += instance->ttcap.lsbShiftOfBitmapAutoItalic;
+ /* */
+ rawCharacterWidth =
+ (unsigned short)(short)(floor(1000 * metrics->horiAdvance
+ * instance->ttcap.scaleBBoxWidth * ratio / 64.
+ / instance->pixel_size));
+ }
+ else {
+ /* Outline */
+#ifdef USE_GET_CBOX
+ /* Very fast?? */
+ FT_Outline_Get_CBox(&face->face->glyph->outline, &bbox);
+ ftrc=0; /* FT_Outline_Get_CBox returns nothing. */
+#else
+ /* Calculate exact metrics */
+ ftrc=FT_Outline_Get_BBox(&face->face->glyph->outline, &bbox);
+#endif
+ if( ftrc != 0 ) return FTtoXReturnCode(ftrc);
+ outline_hori_advance = metrics->horiAdvance;
+ outline_vert_advance = metrics->vertAdvance;
+ bbox_ok:
+ descent = CEIL64(-bbox.yMin - 32) / 64;
+ leftSideBearing = FLOOR64(bbox.xMin + 32) / 64;
+ ascent = FLOOR64(bbox.yMax + 32) / 64;
+ rightSideBearing = FLOOR64(bbox.xMax + 32) / 64;
+ bbox_center_raw = (double)(bbox.xMax + bbox.xMin)/2.0/64.;
+ if ( instance->pixel_width_unit_x != 0 )
+ characterWidth =
+ (int)floor( outline_hori_advance
+ * instance->ttcap.scaleBBoxWidth
+ * instance->pixel_width_unit_x / 64. + .5);
+ else {
+ characterWidth =
+ (int)floor( outline_vert_advance
+ * instance->ttcap.scaleBBoxHeight
+ * instance->pixel_width_unit_y / 64. + .5);
+ if(characterWidth <= 0)
+ characterWidth = instance->charcellMetrics->characterWidth;
+ }
+ /* */
+ new_width = characterWidth;
+ if( instance->ttcap.flags & TTCAP_DOUBLE_STRIKE_CORRECT_B_BOX_WIDTH )
+ new_width += instance->ttcap.doubleStrikeShift;
+ new_width += instance->ttcap.adjustBBoxWidthByPixel;
+ ratio = (double)new_width/characterWidth;
+ characterWidth = new_width;
+ if ( instance->pixel_width_unit_x != 0 )
+ rawCharacterWidth =
+ (unsigned short)(short)(floor(1000 * outline_hori_advance
+ * instance->ttcap.scaleBBoxWidth * ratio
+ * instance->pixel_width_unit_x / 64.));
+ else {
+ rawCharacterWidth =
+ (unsigned short)(short)(floor(1000 * outline_vert_advance
+ * instance->ttcap.scaleBBoxHeight * ratio
+ * instance->pixel_width_unit_y / 64.));
+ if(rawCharacterWidth <= 0)
+ rawCharacterWidth = instance->charcellMetrics->attributes;
+ }
+ /* adjustment by pixel unit */
+ if( instance->ttcap.flags & TTCAP_DOUBLE_STRIKE )
+ rightSideBearing += instance->ttcap.doubleStrikeShift;
+ rightSideBearing += instance->ttcap.adjustRightSideBearingByPixel;
+ leftSideBearing += instance->ttcap.adjustLeftSideBearingByPixel;
+ }
+
+ /* Set the glyph metrics. */
+ tgp->metrics.attributes = (unsigned short)((short)rawCharacterWidth);
+ tgp->metrics.leftSideBearing = leftSideBearing;
+ tgp->metrics.rightSideBearing = rightSideBearing;
+ tgp->metrics.characterWidth = characterWidth;
+ tgp->metrics.ascent = ascent;
+ tgp->metrics.descent = descent;
+ /* Update the width to match the width of the font */
+ if( instance->spacing != FT_PROPORTIONAL )
+ tgp->metrics.characterWidth = instance->charcellMetrics->characterWidth;
+ if(instance->ttcap.flags & TTCAP_MONO_CENTER){
+ b_shift = (int)floor((instance->advance/2.0-bbox_center_raw) + .5);
+ tgp->metrics.leftSideBearing += b_shift;
+ tgp->metrics.rightSideBearing += b_shift;
+ }
+ }
+ }
+
+ if( flags & FT_GET_GLYPH_METRICS_ONLY ) return Successful;
+
+ /*
+ * RENDER AND ALLOCATE BUFFER
+ */
+
+ if( flags & FT_GET_DUMMY ) is_outline = -1;
+ else {
+ if( !metrics ) {
+ ftrc = FT_Load_Glyph(instance->face->face, idx,
+ instance->load_flags);
+ metrics = &face->face->glyph->metrics;
+
+ if(ftrc != 0) return FTtoXReturnCode(ftrc);
+ }
+
+ if( face->face->glyph->format != FT_GLYPH_FORMAT_BITMAP ) {
+ ftrc = FT_Render_Glyph(face->face->glyph,FT_RENDER_MODE_MONO);
+ if( ftrc != 0 ) return FTtoXReturnCode(ftrc);
+ is_outline = 1;
+ }
+ else{
+ is_outline=0;
+ }
+ }
+
+ /* Spacial case */
+ if( (instance->ttcap.flags & TTCAP_MONO_CENTER) && hasMetrics ) {
+ if( is_outline == 1 ){
+ if( correct ){
+ if( ft_get_very_lazy_bbox( idx, face->face, instance->size,
+ instance->ttcap.vl_slant,
+ &instance->transformation.matrix,
+ &bbox, &outline_hori_advance,
+ &outline_vert_advance ) != 0 ){
+ is_outline = -1; /* <- error */
+ }
+ }
+ else {
+#ifdef USE_GET_CBOX
+ FT_Outline_Get_CBox(&face->face->glyph->outline, &bbox);
+ ftrc=0;
+#else
+ ftrc=FT_Outline_Get_BBox(&face->face->glyph->outline, &bbox);
+#endif
+ if( ftrc != 0 ) return FTtoXReturnCode(ftrc);
+ }
+ bbox_center_raw = (double)(bbox.xMax + bbox.xMin)/2.0/64.;
+ }
+ else if( is_outline == 0 )
+ bbox_center_raw = (2.0 * metrics->horiBearingX + metrics->width)/2.0/64.0;
+ else
+ bbox_center_raw = 0;
+ b_shift = (int)floor((instance->advance/2.0-bbox_center_raw) + .5);
}
+ wd_actual = tgp->metrics.rightSideBearing - tgp->metrics.leftSideBearing;
+ ht_actual = tgp->metrics.ascent + tgp->metrics.descent;
+
+ /* The X convention is to consider a character with an empty
+ * bounding box as undefined. This convention is broken. */
+
+ if(wd_actual <= 0) wd = 1;
+ else wd=wd_actual;
+ if(ht_actual <= 0) ht = 1;
+ else ht=ht_actual;
+
+ bpr = (((wd + (instance->bmfmt.glyph<<3) - 1) >> 3) &
+ -instance->bmfmt.glyph);
+ raster = (char*)xalloc(ht * bpr);
+ if(raster == NULL)
+ return AllocError;
+ memset(raster, 0, ht * bpr);
+
tgp->bits = raster;
+
+ /* If FT_GET_DUMMY is set, we return white space. */
+ if ( is_outline == -1 ) return Successful;
+
+ if ( wd_actual <= 0 || ht_actual <= 0 ) return Successful;
+
+ /*
+ * CALCULATE OFFSET, dx AND dy.
+ */
+
+ dx = face->face->glyph->bitmap_left - tgp->metrics.leftSideBearing;
+ dy = tgp->metrics.ascent - face->face->glyph->bitmap_top;
+
+ if(instance->ttcap.flags & TTCAP_MONO_CENTER)
+ dx += b_shift;
+
+ /* To prevent chipped bitmap, we correct dx and dy if needed. */
+ if( correct && is_outline==1 ){
+ int lsb, rsb, asc, des;
+ int chip_left,chip_right,chip_top,chip_bot;
+#ifdef USE_GET_CBOX
+ FT_Outline_Get_CBox(&face->face->glyph->outline, &bbox);
+ ftrc=0;
+#else
+ ftrc=FT_Outline_Get_BBox(&face->face->glyph->outline, &bbox);
+#endif
+ if( ftrc != 0 ) return FTtoXReturnCode(ftrc);
+ des = CEIL64(-bbox.yMin - 32) / 64;
+ lsb = FLOOR64(bbox.xMin + 32) / 64;
+ asc = FLOOR64(bbox.yMax + 32) / 64;
+ rsb = FLOOR64(bbox.xMax + 32) / 64;
+ rightSideBearing = tgp->metrics.rightSideBearing;
+ leftSideBearing = tgp->metrics.leftSideBearing;
+ if( instance->ttcap.flags & TTCAP_DOUBLE_STRIKE )
+ rightSideBearing -= instance->ttcap.doubleStrikeShift;
+ /* special case */
+ if(instance->ttcap.flags & TTCAP_MONO_CENTER){
+ leftSideBearing -= b_shift;
+ rightSideBearing -= b_shift;
+ }
+ chip_left = lsb - leftSideBearing;
+ chip_right = rightSideBearing - rsb;
+ if( flags & FT_FORCE_CONSTANT_SPACING ){
+ if( instance->ttcap.force_c_adjust_lsb_by_pixel != 0 ||
+ instance->ttcap.force_c_adjust_rsb_by_pixel != 0 ){
+ chip_left=0;
+ chip_right=0;
+ }
+ }
+ else{
+ if( instance->ttcap.adjustRightSideBearingByPixel != 0 ||
+ instance->ttcap.adjustLeftSideBearingByPixel != 0 ){
+ chip_left=0;
+ chip_right=0;
+ }
+ }
+ chip_top = tgp->metrics.ascent - asc;
+ chip_bot = tgp->metrics.descent - des;
+ if( chip_left < 0 && 0 < chip_right ) dx++;
+ else if( chip_right < 0 && 0 < chip_left ) dx--;
+ if( chip_top < 0 && 0 < chip_bot ) dy++;
+ else if( chip_bot < 0 && 0 < chip_top ) dy--;
+ }
+
+ /*
+ * COPY RASTER
+ */
+
+ {
+ int i, j;
+ unsigned char *current_raster;
+ unsigned char *current_buffer;
+ int mod_dx0,mod_dx1;
+ int div_dx;
+ if( 0 <= dx ){
+ div_dx = dx / 8;
+ mod_dx0 = dx % 8;
+ mod_dx1 = 8-mod_dx0;
+ }
+ else{
+ div_dx = dx / 8 -1;
+ mod_dx1 = -dx % 8;
+ mod_dx0 = 8-mod_dx1;
+ }
+ for( i = MAX(0, dy) ; i<ht ; i++ ){
+ int prev_jj,jj;
+ if( bitmap->rows <= i-dy ) break;
+ current_buffer=(unsigned char *)(bitmap->buffer+bitmap->pitch*(i-dy));
+ current_raster=(unsigned char *)(raster+i*bpr);
+ j = MAX(0,div_dx);
+ jj = j-div_dx;
+ prev_jj = jj-1;
+ if( j<bpr ){
+ if( 0 <= prev_jj && prev_jj < bitmap->pitch )
+ current_raster[j]|=current_buffer[prev_jj]<<mod_dx1;
+ if( 0 <= jj && jj < bitmap->pitch ){
+ current_raster[j]|=current_buffer[jj]>>mod_dx0;
+ j++; prev_jj++; jj++;
+ for( ; j<bpr ; j++,prev_jj++,jj++ ){
+ current_raster[j]|=current_buffer[prev_jj]<<mod_dx1;
+ if( bitmap->pitch <= jj ) break;
+ current_raster[j]|=current_buffer[jj]>>mod_dx0;
+ }
+ }
+ }
+ }
+ }
+
+ /* by TTCap */
+ if ( instance->ttcap.flags & TTCAP_DOUBLE_STRIKE ) {
+ int i;
+ for( i=0 ; i < instance->ttcap.doubleStrikeShift ; i++ )
+ ft_make_up_bold_bitmap( raster, bpr, ht, instance->ttcap.flags);
+ }
+ if ( is_outline == 0 &&
+ ( instance->ttcap.lsbShiftOfBitmapAutoItalic != 0 ||
+ instance->ttcap.rsbShiftOfBitmapAutoItalic != 0 ) ) {
+ ft_make_up_italic_bitmap( raster, bpr, ht,
+ - instance->ttcap.lsbShiftOfBitmapAutoItalic
+ + instance->ttcap.rsbShiftOfBitmapAutoItalic,
+ instance->charcellMetrics->ascent
+ + instance->charcellMetrics->descent,
+ instance->charcellMetrics->ascent
+ - tgp->metrics.ascent,
+ instance->ttcap.autoItalic);
+ }
if(instance->bmfmt.bit == LSBFirst) {
BitOrderInvert((unsigned char*)(tgp->bits), ht*bpr);
@@ -651,32 +1266,8 @@ FreeTypeRasteriseGlyph(CharInfoPtr tgp, FTInstancePtr instance,
;
}
}
-
-
- if(!hasMetrics) {
- leftSideBearing = TRANSFORM_X(metrics->horiBearingX);
- rightSideBearing = wd + TRANSFORM_X(metrics->horiBearingX);
-
- characterWidth = TRANSFORM_X(metrics->horiAdvance);
- rawCharacterWidth = TRANSFORM_X_RAW(metrics->horiAdvance);
-
- ascent = TRANSFORM_Y(metrics->horiBearingY);
- descent = ht - TRANSFORM_Y(metrics->horiBearingY);
-
- if(tgp) {
- /* Set the glyph metrics. */
- tgp->metrics.attributes = (unsigned short)((short)rawCharacterWidth);
- tgp->metrics.leftSideBearing = leftSideBearing;
- tgp->metrics.rightSideBearing = rightSideBearing;
- tgp->metrics.characterWidth = characterWidth;
- tgp->metrics.ascent = ascent;
- tgp->metrics.descent = descent;
- }
- }
+
return Successful;
-#undef TRANSFORM_X
-#undef TRANSFORM_Y
-#undef TRANSFORM_X_RAW
}
static void
@@ -725,14 +1316,12 @@ FreeTypeUnloadXFont(FontPtr pFont)
static int
FreeTypeAddProperties(FTFontPtr font, FontScalablePtr vals, FontInfoPtr info,
- char *fontname,
- int rawAverageWidth)
+ char *fontname, int rawAverageWidth)
{
int i, j, maxprops;
char *sp, *ep, val[MAXFONTNAMELEN], *vp;
FTFacePtr face;
FTInstancePtr instance;
- FT_Size_Metrics smetrics;
FTNormalisedTransformationPtr trans;
int upm;
TT_OS2 *os2;
@@ -743,9 +1332,12 @@ FreeTypeAddProperties(FTFontPtr font, FontScalablePtr vals, FontInfoPtr info,
instance = font->instance;
face = instance->face;
- smetrics = instance->size->metrics;
trans = &instance->transformation;
- upm = face->face->units_per_EM;
+ upm = face->face->units_per_EM;
+ if(upm == 0) {
+ /* Work around FreeType bug */
+ upm = WORK_AROUND_UPM;
+ }
os2 = FT_Get_Sfnt_Table(face->face, ft_sfnt_os2);
post = FT_Get_Sfnt_Table(face->face, ft_sfnt_post);
@@ -841,27 +1433,33 @@ FreeTypeAddProperties(FTFontPtr font, FontScalablePtr vals, FontInfoPtr info,
}
}
- info->props[i].name = MakeAtom("RAW_AVERAGE_WIDTH", 17, TRUE);
- info->props[i].value = rawAverageWidth;
- i++;
+ if(!face->bitmap) {
+ info->props[i].name = MakeAtom("RAW_AVERAGE_WIDTH", 17, TRUE);
+ info->props[i].value = rawAverageWidth;
+ i++;
+ }
info->props[i].name = MakeAtom("FONT_ASCENT", 11, TRUE);
info->props[i].value = info->fontAscent;
i++;
- info->props[i].name = MakeAtom("RAW_ASCENT", 15, TRUE);
- info->props[i].value =
- ((double)face->face->ascender/(double)upm*1000.0);
- i++;
+ if(!face->bitmap) {
+ info->props[i].name = MakeAtom("RAW_ASCENT", 15, TRUE);
+ info->props[i].value =
+ ((double)face->face->ascender/(double)upm*1000.0);
+ i++;
+ }
info->props[i].name = MakeAtom("FONT_DESCENT", 12, TRUE);
info->props[i].value = info->fontDescent;
i++;
- info->props[i].name = MakeAtom("RAW_DESCENT", 16, TRUE);
- info->props[i].value =
- -((double)face->face->descender/(double)upm*1000.0);
- i++;
+ if(!face->bitmap) {
+ info->props[i].name = MakeAtom("RAW_DESCENT", 16, TRUE);
+ info->props[i].value =
+ -((double)face->face->descender/(double)upm*1000.0);
+ i++;
+ }
j = FTGetEnglishName(face->face, TT_NAME_ID_COPYRIGHT,
val, MAXFONTNAMELEN);
@@ -915,15 +1513,11 @@ FreeTypeAddProperties(FTFontPtr font, FontScalablePtr vals, FontInfoPtr info,
FUnits into pixels. */
#define TRANSFORM_FUNITS_X(xval) \
((int) \
- floor((((double)(xval)/(double)upm) * \
- ((double)trans->matrix.xx/TWO_SIXTEENTH)*(double)smetrics.x_ppem)+\
- 0.5))
+ floor( ((double)(xval)/(double)upm) * (double)vals->pixel_matrix[0] + 0.5 ) )
#define TRANSFORM_FUNITS_Y(yval) \
((int) \
- floor((((double)(yval)/(double)upm) * \
- ((double)trans->matrix.yy/TWO_SIXTEENTH) * (double)smetrics.y_ppem)+\
- 0.5))
+ floor( ((double)(yval)/(double)upm) * (double)vals->pixel_matrix[3] + 0.5 ) )
/* In what follows, we assume the matrix is diagonal. In the rare
case when it is not, the values will be somewhat wrong. */
@@ -958,12 +1552,14 @@ FreeTypeAddProperties(FTFontPtr font, FontScalablePtr vals, FontInfoPtr info,
if(post || t1info) {
int underlinePosition, underlineThickness;
+ /* Raw underlineposition counts upwards,
+ but UNDERLINE_POSITION counts downwards. */
if(post) {
- underlinePosition = TRANSFORM_FUNITS_Y(post->underlinePosition);
+ underlinePosition = TRANSFORM_FUNITS_Y(-post->underlinePosition);
underlineThickness = TRANSFORM_FUNITS_Y(post->underlineThickness);
} else {
underlinePosition =
- TRANSFORM_FUNITS_Y(t1info->underline_position);
+ TRANSFORM_FUNITS_Y(-t1info->underline_position);
underlineThickness =
TRANSFORM_FUNITS_Y(t1info->underline_thickness);
}
@@ -975,7 +1571,9 @@ FreeTypeAddProperties(FTFontPtr font, FontScalablePtr vals, FontInfoPtr info,
i++;
info->props[i].name = MakeAtom("UNDERLINE_POSITION",18,TRUE);
+
info->props[i].value = underlinePosition;
+
i++;
/* The italic angle is often unreliable for Type 1 fonts */
@@ -1007,16 +1605,16 @@ FreeTypeAddProperties(FTFontPtr font, FontScalablePtr vals, FontInfoPtr info,
}
static int
-FreeTypeFontGetGlyph(unsigned code, CharInfoPtr *g, FTFontPtr font)
+ft_get_index(unsigned code, FTFontPtr font, unsigned *idx)
{
- unsigned idx;
- int i;
/* As a special case, we pass 0 even when it is not in the ranges;
this will allow for the default glyph, which should exist in any
TrueType font. */
+ /* This is not required...
if(code > 0 && font->nranges) {
+ int i;
for(i = 0; i < font->nranges; i++)
if((code >=
font->ranges[i].min_char_low+
@@ -1026,137 +1624,861 @@ FreeTypeFontGetGlyph(unsigned code, CharInfoPtr *g, FTFontPtr font)
(font->ranges[i].max_char_high<<8)))
break;
if(i == font->nranges) {
- *g = 0;
- return Successful;
+ *idx = font->zero_idx;
+ return -1;
}
}
+ */
+ if( font->info ) {
+ if( !( font->info->firstCol <= (code & 0x000ff) &&
+ (code & 0x000ff) <= font->info->lastCol &&
+ font->info->firstRow <= (code >> 8) &&
+ (code >> 8) <= font->info->lastRow ) ) {
+ *idx = font->zero_idx;
+ /* Error: The code has not been parsed in ft_compute_bounds()!
+ We should not return any metrics. */
+ return -1;
+ }
+ }
+
+ *idx = FTRemap(font->instance->face->face, &font->mapping, code);
- idx = FTRemap(font->instance->face->face, &font->mapping, code);
+ return 0;
+}
+
+static int
+FreeTypeFontGetGlyph(unsigned code, int flags, CharInfoPtr *g, FTFontPtr font)
+{
+ unsigned idx;
+ int xrc;
- /* Only pass the default glyph if there is no first index */
- if(idx == 0 &&
- (code != 0 ||
- (font->mapping.mapping &&
- (font->mapping.mapping->encoding->first != 0 ||
- font->mapping.mapping->encoding->first_col != 0)))) {
- *g = 0;
- return Successful;
- } else {
- return FreeTypeInstanceGetGlyph(idx, g, font->instance);
+ if( ft_get_index(code,font,&idx) ) {
+ *g = NULL;
+ flags &= ~FT_FORCE_CONSTANT_SPACING;
+#ifdef XAA_ACCEPTS_NO_SUCH_CHAR
+ /* if( font->instance->spacing != FT_CHARCELL ) */
+ return Successful;
+#endif
+ }
+
+ xrc = FreeTypeInstanceGetGlyph(idx, flags, g, font->instance);
+ if( xrc == Successful && *g != NULL )
+ return Successful;
+ if( font->zero_idx != idx ) {
+ xrc = FreeTypeInstanceGetGlyph(font->zero_idx, flags, g, font->instance);
+ if( xrc == Successful && *g != NULL )
+ return Successful;
}
+ return FreeTypeInstanceGetGlyph(font->zero_idx, flags|FT_GET_DUMMY, g, font->instance);
}
static int
-FreeTypeFontGetGlyphMetrics(unsigned code, xCharInfo **metrics, FTFontPtr font)
+FreeTypeFontGetGlyphMetrics(unsigned code, int flags, xCharInfo **metrics, FTFontPtr font)
{
unsigned idx;
- int i;
+ int xrc;
- /* As a special case, we pass 0 even when it is not in the ranges;
- this will allow for the default glyph, which should exist in any
- TrueType font. */
+ if( flags & FT_FORCE_CONSTANT_SPACING )
+ idx = 0; /* This is ignored in FreeTypeInstanceGetGlyphMetrics */
+ else {
+ if ( ft_get_index(code,font,&idx) ) {
+ /* The code has not been parsed! */
+ *metrics = NULL;
+ flags &= ~FT_FORCE_CONSTANT_SPACING;
+#ifdef XAA_ACCEPTS_NO_SUCH_CHAR
+ /* if( font->instance->spacing != FT_CHARCELL ) */
+ return Successful;
+#endif
+ }
+ }
- if(code>0 && font->nranges) {
- for(i = 0; i < font->nranges; i++)
- if((code >=
- font->ranges[i].min_char_low+
- (font->ranges[i].min_char_high<<8)) &&
- (code <=
- font->ranges[i].max_char_low+(font->ranges[i].max_char_high<<8)))
- break;
- if(i == font->nranges) {
- *metrics = 0;
- return Successful;
- }
+ xrc = FreeTypeInstanceGetGlyphMetrics(idx, flags, metrics, font->instance);
+ if( xrc == Successful && *metrics != NULL )
+ return Successful;
+ if( font->zero_idx != idx ) {
+ xrc = FreeTypeInstanceGetGlyphMetrics(font->zero_idx, flags,
+ metrics, font->instance);
+ if( xrc == Successful && *metrics != NULL )
+ return Successful;
}
-
- idx = FTRemap(font->instance->face->face, &font->mapping, code);
-
- if(idx == 0 &&
- (code != 0 ||
- (font->mapping.mapping &&
- (font->mapping.mapping->encoding->first != 0 ||
- font->mapping.mapping->encoding->first_col != 0)))) {
- *metrics = 0;
- return Successful;
- } else {
- return FreeTypeInstanceGetGlyphMetrics(idx, metrics, font->instance);
+ return FreeTypeInstanceGetGlyphMetrics(font->zero_idx, flags|FT_GET_DUMMY, metrics, font->instance);
+}
+
+/*
+ * restrict code range
+ *
+ * boolean for the numeric zone:
+ * results = results & (ranges[0] | ranges[1] | ... ranges[nranges-1])
+ */
+
+static void
+restrict_code_range(unsigned short *refFirstCol,
+ unsigned short *refFirstRow,
+ unsigned short *refLastCol,
+ unsigned short *refLastRow,
+ fsRange const *ranges, int nRanges)
+{
+ if (nRanges) {
+ int minCol = 256, minRow = 256, maxCol = -1, maxRow = -1;
+ fsRange const *r = ranges;
+ int i;
+
+ for (i=0; i<nRanges; i++) {
+ if (r->min_char_high != r->max_char_high) {
+ minCol = 0x00;
+ maxCol = 0xff;
+ } else {
+ if (minCol > r->min_char_low)
+ minCol = r->min_char_low;
+ if (maxCol < r->max_char_low)
+ maxCol = r->max_char_low;
+ }
+ if (minRow > r->min_char_high)
+ minRow = r->min_char_high;
+ if (maxRow < r->max_char_high)
+ maxRow = r->max_char_high;
+ r++;
+ }
+
+ if (minCol > *refLastCol)
+ *refFirstCol = *refLastCol;
+ else if (minCol > *refFirstCol)
+ *refFirstCol = minCol;
+
+ if (maxCol < *refFirstCol)
+ *refLastCol = *refFirstCol;
+ else if (maxCol < *refLastCol)
+ *refLastCol = maxCol;
+
+ if (minRow > *refLastRow) {
+ *refFirstRow = *refLastRow;
+ *refFirstCol = *refLastCol;
+ } else if (minRow > *refFirstRow)
+ *refFirstRow = minRow;
+
+ if (maxRow < *refFirstRow) {
+ *refLastRow = *refFirstRow;
+ *refLastCol = *refFirstCol;
+ } else if (maxRow < *refLastRow)
+ *refLastRow = maxRow;
}
}
+
static int
-FreeTypeFontGetDefaultGlyph(CharInfoPtr *g, FTFontPtr font)
+restrict_code_range_by_str(int count,unsigned short *refFirstCol,
+ unsigned short *refFirstRow,
+ unsigned short *refLastCol,
+ unsigned short *refLastRow,
+ char const *str)
{
- /* Disable default glyph generation if there is a first index */
- if(font->mapping.mapping &&
- (font->mapping.mapping->encoding->first ||
- font->mapping.mapping->encoding->first_col)) {
- *g = 0;
- return Successful;
+ int nRanges = 0;
+ int result = 0;
+ fsRange *ranges = NULL;
+ char const *p, *q;
+
+ p = q = str;
+ for (;;) {
+ int minpoint=0, maxpoint=65535;
+ long val;
+
+ /* skip comma and/or space */
+ while (',' == *p || isspace(*p))
+ p++;
+
+ /* begin point */
+ if ('-' != *p) {
+ val = strtol(p, (char **)&q, 0);
+ if (p == q)
+ /* end or illegal */
+ break;
+ if (val<0 || val>65535) {
+ /* out of zone */
+ break;
+ }
+ minpoint = val;
+ p=q;
+ }
+
+ /* skip space */
+ while (isspace(*p))
+ p++;
+
+ if (',' != *p && '\0' != *p) {
+ /* contiune */
+ if ('-' == *p)
+ /* hyphon */
+ p++;
+ else
+ /* end or illegal */
+ break;
+
+ /* skip space */
+ while (isspace(*p))
+ p++;
+
+ val = strtol(p, (char **)&q, 0);
+ if (p != q) {
+ if (val<0 || val>65535)
+ break;
+ maxpoint = val;
+ } else if (',' != *p && '\0' != *p)
+ /* end or illegal */
+ break;
+ p=q;
+ } else
+ /* comma - single code */
+ maxpoint = minpoint;
+
+ if ( count <= 0 && minpoint>maxpoint ) {
+ int tmp;
+ tmp = minpoint;
+ minpoint = maxpoint;
+ maxpoint = tmp;
+ }
+
+ /* add range */
+#if 0
+ fprintf(stderr, "zone: 0x%04X - 0x%04X\n", minpoint, maxpoint);
+ fflush(stderr);
+#endif
+ nRanges++;
+ ranges = (fsRange *)xrealloc(ranges, nRanges*sizeof(*ranges));
+ if (NULL == ranges)
+ break;
+ {
+ fsRange *r = ranges+nRanges-1;
+
+ r->min_char_low = minpoint & 0xff;
+ r->max_char_low = maxpoint & 0xff;
+ r->min_char_high = (minpoint>>8) & 0xff;
+ r->max_char_high = (maxpoint>>8) & 0xff;
+ }
}
-
- /* Using FreeTypeInstanceGetGlyph(0,...) would cause inconsistencies
- between metrics and glyphs in the unlikely case that 0 is not
- mapped to 0. */
- return FreeTypeFontGetGlyph(0, g, font);
+
+ if (ranges) {
+ if ( count <= 0 ) {
+ restrict_code_range(refFirstCol, refFirstRow, refLastCol, refLastRow,
+ ranges, nRanges);
+ }
+ else {
+ int i;
+ fsRange *r;
+ for ( i=0 ; i<nRanges ; i++ ) {
+ if ( count <= i ) break;
+ r = ranges+i;
+ refFirstCol[i] = r->min_char_low;
+ refLastCol[i] = r->max_char_low;
+ refFirstRow[i] = r->min_char_high;
+ refLastRow[i] = r->max_char_high;
+ }
+ result=i;
+ }
+ xfree(ranges);
+ }
+ return result;
}
-static int
-FreeTypeLoadFont(FTFontPtr *font_return, char *fileName,
- FontScalablePtr vals, FontEntryPtr entry,
- FontBitmapFormatPtr bmfmt)
+/* *face_number and *spacing are initialized but *load_flags is NOT. */
+static int
+FreeTypeSetUpTTCap( char *fileName, FontScalablePtr vals,
+ char **dynStrRealFileName, char **dynStrFTFileName,
+ struct TTCapInfo *ret, int *face_number,
+ FT_Int32 *load_flags, int *spacing, char **dynStrTTCapCodeRange )
{
- int xrc;
- FTFontPtr font;
- FTNormalisedTransformationRec trans;
- int charcell;
-
- font = (FTFontPtr)xalloc(sizeof(FTFontRec));
- if(font == NULL)
+ int result = Successful;
+ SDynPropRecValList listPropRecVal;
+ SPropRecValContainer contRecValue;
+ Bool hinting=True;
+ Bool isEmbeddedBitmap = True;
+ Bool alwaysEmbeddedBitmap = False;
+ int pixel = vals->pixel;
+
+ *dynStrRealFileName=NULL;
+ *dynStrFTFileName=NULL;
+ *dynStrTTCapCodeRange=NULL;
+
+ if (SPropRecValList_new(&listPropRecVal)) {
return AllocError;
+ }
+
+ {
+ int len = strlen(fileName);
+ char *capHead = NULL;
+ {
+ /* font cap */
+ char *p1=NULL, *p2=NULL;
+
+ p1=strrchr(fileName, '/');
+ if ( p1 == NULL ) p1 = fileName;
+ else p1++;
+ if (NULL != (p2=strrchr(p1, ':'))) {
+ /* colon exist in the right side of slash. */
+ int dirLen = p1-fileName;
+ int baseLen = fileName+len - p2 -1;
+
+ *dynStrRealFileName = (char *)xalloc(dirLen+baseLen+1);
+ if( *dynStrRealFileName == NULL ) {
+ result = AllocError;
+ goto quit;
+ }
+ if ( 0 < dirLen )
+ memcpy(*dynStrRealFileName, fileName, dirLen);
+ strcpy(*dynStrRealFileName+dirLen, p2+1);
+ capHead = p1;
+ } else {
+ *dynStrRealFileName = xstrdup(fileName);
+ if( *dynStrRealFileName == NULL ) {
+ result = AllocError;
+ goto quit;
+ }
+ }
+ }
+
+ /* font cap */
+ if (capHead) {
+ if (SPropRecValList_add_by_font_cap(&listPropRecVal,
+ capHead)) {
+ result = BadFontPath;
+ goto quit;
+ }
+ }
+ }
+
+ *face_number=0;
+ *spacing=0;
+ ret->autoItalic=0.0;
+ ret->scaleWidth=1.0;
+ ret->scaleBBoxWidth = 1.0;
+ ret->scaleBBoxHeight = 1.0;
+ ret->doubleStrikeShift = 1;
+ ret->adjustBBoxWidthByPixel = 0;
+ ret->adjustLeftSideBearingByPixel = 0;
+ ret->adjustRightSideBearingByPixel = 0;
+ ret->flags = 0;
+ ret->scaleBitmap = 0.0;
+ ret->forceConstantSpacingBegin = -1;
+ ret->forceConstantSpacingEnd = -1;
+ ret->force_c_representative_metrics_char_code = -2;
+ ret->force_c_scale_b_box_width = 1.0;
+ ret->force_c_scale_b_box_height = 1.0;
+ ret->force_c_adjust_width_by_pixel = 0;
+ ret->force_c_adjust_lsb_by_pixel = 0;
+ ret->force_c_adjust_rsb_by_pixel = 0;
+ ret->force_c_scale_lsb = 0.0;
+ ret->force_c_scale_rsb = 1.0;
+ /* */
+ ret->vl_slant=0;
+ ret->lsbShiftOfBitmapAutoItalic=0;
+ ret->rsbShiftOfBitmapAutoItalic=0;
+ /* face number */
+ {
+ char *beginptr=NULL,*endptr;
+ if ( SPropRecValList_search_record(&listPropRecVal,
+ &contRecValue,
+ "FaceNumber")) {
+ int lv;
+ beginptr = SPropContainer_value_str(contRecValue);
+ lv=strtol(beginptr, &endptr, 10);
+ if ( *beginptr != '\0' && *endptr == '\0' ) {
+ if ( 0 < lv ) *face_number = lv;
+ }
+ }
+ if( beginptr && 0 < *face_number ) {
+ char *slash;
+ *dynStrFTFileName = /* add -> ':'+strlen0+':'+strlen1+'\0' */
+ (char *)xalloc(1+strlen(beginptr)+1+strlen(*dynStrRealFileName)+1);
+ if( *dynStrFTFileName == NULL ){
+ result = AllocError;
+ goto quit;
+ }
+ **dynStrFTFileName = '\0';
+ slash = strrchr(*dynStrRealFileName,'/');
+ if( slash ) {
+ char *p;
+ strcat(*dynStrFTFileName,*dynStrRealFileName);
+ p = strrchr(*dynStrFTFileName,'/');
+ p[1] = '\0';
+ strcat(*dynStrFTFileName,":");
+ strcat(*dynStrFTFileName,beginptr);
+ strcat(*dynStrFTFileName,":");
+ strcat(*dynStrFTFileName,slash+1);
+ }
+ else{
+ strcat(*dynStrFTFileName,":");
+ strcat(*dynStrFTFileName,beginptr);
+ strcat(*dynStrFTFileName,":");
+ strcat(*dynStrFTFileName,*dynStrRealFileName);
+ }
+ }
+ else{
+ *dynStrFTFileName = (char *)xalloc(strlen(*dynStrRealFileName)+1);
+ if( *dynStrFTFileName == NULL ){
+ result = AllocError;
+ goto quit;
+ }
+ **dynStrFTFileName = '\0';
+ strcat(*dynStrFTFileName,*dynStrRealFileName);
+ }
+ }
+ /*
+ fprintf(stderr,"[Filename:%s]\n",fileName);
+ fprintf(stderr,"[RealFilename:%s]\n",*dynStrRealFileName);
+ fprintf(stderr,"[FTFilename:%s]\n",*dynStrFTFileName);
+ */
+ /* slant control */
+ if (SPropRecValList_search_record(&listPropRecVal,
+ &contRecValue,
+ "AutoItalic"))
+ ret->autoItalic = SPropContainer_value_dbl(contRecValue);
+ /* hinting control */
+ if (SPropRecValList_search_record(&listPropRecVal,
+ &contRecValue,
+ "Hinting"))
+ hinting = SPropContainer_value_bool(contRecValue);
+ /* scaling */
+ if (SPropRecValList_search_record(&listPropRecVal,
+ &contRecValue,
+ "ScaleWidth")) {
+ ret->scaleWidth = SPropContainer_value_dbl(contRecValue);
+ if (ret->scaleWidth<=0.0) {
+ fprintf(stderr, "ScaleWitdh needs plus.\n");
+ result = BadFontName;
+ goto quit;
+ }
+ }
+ /* bbox adjustment */
+ if (SPropRecValList_search_record(&listPropRecVal,
+ &contRecValue,
+ "ScaleBBoxWidth")) {
+ /* Scaling to Bounding Box Width */
+ int lv;
+ char *endptr,*beginptr;
+ double v,scaleBBoxWidth=1.0,scaleBBoxHeight=1.0;
+ beginptr = SPropContainer_value_str(contRecValue);
+ do {
+ if ( strlen(beginptr) < 1 ) break;
+ v=strtod(beginptr, &endptr);
+ if ( endptr!=beginptr ) {
+ scaleBBoxWidth = v;
+ }
+ if ( *endptr != ';' && *endptr != ',' ) break;
+ if ( *endptr == ',' ) {
+ beginptr=endptr+1;
+ v=strtod(beginptr, &endptr);
+ if ( endptr!=beginptr ) {
+ scaleBBoxHeight = v;
+ }
+ }
+ if ( *endptr != ';' && *endptr != ',' ) break;
+ beginptr=endptr+1;
+ lv=strtol(beginptr, &endptr, 10);
+ if ( endptr!=beginptr ) {
+ ret->adjustBBoxWidthByPixel = lv;
+ }
+ if ( *endptr != ',' ) break;
+ beginptr=endptr+1;
+ lv=strtol(beginptr, &endptr, 10);
+ if ( endptr!=beginptr ) {
+ ret->adjustLeftSideBearingByPixel = lv;
+ }
+ if ( *endptr != ',' ) break;
+ beginptr=endptr+1;
+ lv=strtol(beginptr, &endptr, 10);
+ if ( endptr!=beginptr ) {
+ ret->adjustRightSideBearingByPixel = lv;
+ }
+ } while ( 0 );
+ if (scaleBBoxWidth<=0.0) {
+ fprintf(stderr, "ScaleBBoxWitdh needs plus.\n");
+ result = BadFontName;
+ goto quit;
+ }
+ if (scaleBBoxHeight<=0.0) {
+ fprintf(stderr, "ScaleBBoxHeight needs plus.\n");
+ result = BadFontName;
+ goto quit;
+ }
+ ret->scaleBBoxWidth = scaleBBoxWidth;
+ ret->scaleBBoxHeight = scaleBBoxHeight;
+ }
+ /* spacing */
+ if (SPropRecValList_search_record(&listPropRecVal,
+ &contRecValue,
+ "ForceSpacing")) {
+ char *strSpace = SPropContainer_value_str(contRecValue);
+ Bool err = False;
+ if (1 != strlen(strSpace))
+ err = True;
+ else
+ switch (strSpace[0]) {
+ case 'M':
+ ret->flags |= TTCAP_MONO_CENTER;
+ *spacing = 'm';
+ break;
+ case 'm':
+ case 'p':
+ case 'c':
+ *spacing = strSpace[0];
+ break;
+ default:
+ err = True;
+ }
+ if (err) {
+ result = BadFontName;
+ goto quit;
+ }
+ }
+ /* doube striking */
+ if (SPropRecValList_search_record(&listPropRecVal,
+ &contRecValue,
+ "DoubleStrike")) {
+ /* Set or Reset Auto Bold Flag */
+ char *strDoubleStrike = SPropContainer_value_str(contRecValue);
+ Bool err = False;
+ if ( 0 < strlen(strDoubleStrike) ) {
+ switch (strDoubleStrike[0]) {
+ case 'm':
+ case 'M':
+ case 'l':
+ case 'L':
+ ret->flags |= TTCAP_DOUBLE_STRIKE;
+ ret->flags |= TTCAP_DOUBLE_STRIKE_MKBOLD_EDGE_LEFT;
+ break;
+ case 'y':
+ case 'Y':
+ ret->flags |= TTCAP_DOUBLE_STRIKE;
+ break;
+ case 'n':
+ case 'N':
+ ret->flags &= ~TTCAP_DOUBLE_STRIKE;
+ ret->flags &= ~TTCAP_DOUBLE_STRIKE_MKBOLD_EDGE_LEFT;
+ ret->flags &= ~TTCAP_DOUBLE_STRIKE_CORRECT_B_BOX_WIDTH;
+ break;
+ default:
+ err = True;
+ }
+ if ( err != True ) {
+ if ( strDoubleStrike[1] ) {
+ switch (strDoubleStrike[1]) {
+ case 'b':
+ case 'B':
+ case 'p':
+ case 'P':
+ case 'y':
+ case 'Y':
+ ret->flags |= TTCAP_DOUBLE_STRIKE_CORRECT_B_BOX_WIDTH;
+ break;
+ default:
+ break;
+ }
+ }
+ do {
+ char *comma_ptr=strchr(strDoubleStrike,';');
+ if ( !comma_ptr ) comma_ptr=strchr(strDoubleStrike,',');
+ if ( !comma_ptr ) break;
+ if ( comma_ptr[1] ) {
+ char *endptr;
+ int mkboldMaxPixel;
+ mkboldMaxPixel=strtol(comma_ptr+1, &endptr, 10);
+ if ( endptr != comma_ptr+1 && mkboldMaxPixel <= pixel ) {
+ ret->flags &= ~TTCAP_DOUBLE_STRIKE_MKBOLD_EDGE_LEFT;
+ }
+ }
+ comma_ptr=strchr(comma_ptr+1,',');
+ if ( !comma_ptr ) break;
+ if ( comma_ptr[1] ) {
+ char *endptr;
+ int max_pixel;
+ max_pixel=strtol(comma_ptr+1, &endptr, 10);
+ if ( endptr != comma_ptr+1 && max_pixel <= pixel ) {
+ if( ret->flags & TTCAP_DOUBLE_STRIKE )
+ ret->doubleStrikeShift += pixel / max_pixel;
+ }
+ }
+ } while(0);
+ }
+ }
+ else
+ err = True;
+ if (err) {
+ result = BadFontName;
+ goto quit;
+ }
+ }
+ /* very lazy metrics */
+ if (SPropRecValList_search_record(&listPropRecVal,
+ &contRecValue,
+ "VeryLazyMetrics")){
+ Bool isVeryLazy = SPropContainer_value_bool(contRecValue);
+ ret->flags |= TTCAP_DISABLE_DEFAULT_VERY_LAZY;
+ if( isVeryLazy == True )
+ ret->flags |= TTCAP_IS_VERY_LAZY;
+ else
+ ret->flags &= ~TTCAP_IS_VERY_LAZY;
+ }
+ /* embedded bitmap */
+ if (SPropRecValList_search_record(&listPropRecVal,
+ &contRecValue,
+ "EmbeddedBitmap")) {
+ char *strEmbeddedBitmap = SPropContainer_value_str(contRecValue);
+ Bool err = False;
+ if ( 1 == strlen(strEmbeddedBitmap) ) {
+ switch (strEmbeddedBitmap[0]) {
+ case 'y':
+ case 'Y':
+ isEmbeddedBitmap = True;
+ alwaysEmbeddedBitmap = True;
+ break;
+ case 'u':
+ case 'U':
+ isEmbeddedBitmap = True;
+ alwaysEmbeddedBitmap = False;
+ break;
+ case 'n':
+ case 'N':
+ isEmbeddedBitmap = False;
+ break;
+ default:
+ err = True;
+ }
+ }
+ else
+ err = True;
+ if (err) {
+ result = BadFontName;
+ goto quit;
+ }
+ }
+ /* scale bitmap */
+ if((ret->flags & TTCAP_IS_VERY_LAZY) &&
+ SPropRecValList_search_record(&listPropRecVal,
+ &contRecValue,
+ "VeryLazyBitmapWidthScale")) {
+ /* Scaling to Bitmap Bounding Box Width */
+ double scaleBitmapWidth = SPropContainer_value_dbl(contRecValue);
+
+ fprintf(stderr, "Warning: `bs' option is not required in X-TT version 2.\n");
+#if 0
+ if (scaleBitmapWidth<=0.0) {
+ fprintf(stderr, "ScaleBitmapWitdh needs plus.\n");
+ result = BadFontName;
+ goto quit;
+ }
+#endif
+ ret->scaleBitmap = scaleBitmapWidth;
+ }
+ /* restriction of the code range */
+ if (SPropRecValList_search_record(&listPropRecVal,
+ &contRecValue,
+ "CodeRange")) {
+ *dynStrTTCapCodeRange = xstrdup(SPropContainer_value_str(contRecValue));
+ if( *dynStrTTCapCodeRange == NULL ) {
+ result = AllocError;
+ goto quit;
+ }
+ }
+ /* forceConstantSpacing{Begin,End} */
+ if ( 1 /* ft->spacing == 'p' */ ){
+ unsigned short first_col=0,last_col=0x00ff;
+ unsigned short first_row=0,last_row=0x00ff;
+ if (SPropRecValList_search_record(&listPropRecVal,
+ &contRecValue,
+ "ForceConstantSpacingCodeRange")) {
+ if ( restrict_code_range_by_str(1,&first_col, &first_row,
+ &last_col, &last_row,
+ SPropContainer_value_str(contRecValue)) == 1 ) {
+ ret->forceConstantSpacingBegin = (int)( first_row<<8 | first_col );
+ ret->forceConstantSpacingEnd = (int)( last_row<<8 | last_col );
+ if ( ret->forceConstantSpacingBegin <= ret->forceConstantSpacingEnd )
+ ret->flags &= ~TTCAP_FORCE_C_OUTSIDE;
+ else ret->flags |= TTCAP_FORCE_C_OUTSIDE;
+ }
+ }
+ }
+ /* */
+ if ( 1 ){
+ unsigned short first_col=0, last_col=0x0ff;
+ unsigned short first_row=0, last_row=0x0ff;
+ if ( SPropRecValList_search_record(&listPropRecVal,
+ &contRecValue,
+ "ForceConstantSpacingMetrics")) {
+ char *strMetrics;
+ strMetrics = SPropContainer_value_str(contRecValue);
+ if ( strMetrics ) {
+ char *comma_ptr,*period_ptr,*semic_ptr;
+ semic_ptr=strchr(strMetrics,';');
+ comma_ptr=strchr(strMetrics,',');
+ period_ptr=strchr(strMetrics,'.');
+ if ( semic_ptr && comma_ptr )
+ if ( semic_ptr < comma_ptr ) comma_ptr=NULL;
+ if ( semic_ptr && period_ptr )
+ if ( semic_ptr < period_ptr ) period_ptr=NULL;
+ if ( !comma_ptr && !period_ptr && strMetrics != semic_ptr ) {
+ if ( restrict_code_range_by_str(1,&first_col, &first_row,
+ &last_col, &last_row,
+ SPropContainer_value_str(contRecValue)) == 1 ) {
+ ret->force_c_representative_metrics_char_code =
+ (int)( first_row<<8 | first_col );
+ }
+ }
+ else {
+ double v;
+ char *endptr,*beginptr=strMetrics;
+ do {
+ v=strtod(beginptr, &endptr);
+ if ( endptr!=beginptr ) {
+ ret->force_c_scale_b_box_width = v;
+ }
+ if ( *endptr != ',' ) break;
+ beginptr=endptr+1;
+ v=strtod(beginptr, &endptr);
+ if ( endptr!=beginptr ) {
+ ret->force_c_scale_lsb = v;
+ ret->flags |= TTCAP_FORCE_C_LSB_FLAG;
+ }
+ if ( *endptr != ',' ) break;
+ beginptr=endptr+1;
+ v=strtod(beginptr, &endptr);
+ if ( endptr!=beginptr ) {
+ ret->force_c_scale_rsb = v;
+ ret->flags |= TTCAP_FORCE_C_RSB_FLAG;
+ }
+ if ( *endptr != ',' ) break;
+ beginptr=endptr+1;
+ v=strtod(beginptr, &endptr);
+ if ( endptr!=beginptr ) {
+ ret->force_c_scale_b_box_height = v;
+ }
+ } while (0);
+ }
+ if ( semic_ptr ) {
+ int lv;
+ char *endptr,*beginptr=semic_ptr+1;
+ do {
+ lv=strtol(beginptr, &endptr, 10);
+ if ( endptr!=beginptr ) {
+ ret->force_c_adjust_width_by_pixel=lv;
+ }
+ if ( *endptr != ',' ) break;
+ beginptr=endptr+1;
+ lv=strtol(beginptr, &endptr, 10);
+ if ( endptr!=beginptr ) {
+ ret->force_c_adjust_lsb_by_pixel=lv;
+ }
+ if ( *endptr != ',' ) break;
+ beginptr=endptr+1;
+ lv=strtol(beginptr, &endptr, 10);
+ if ( endptr!=beginptr ) {
+ ret->force_c_adjust_rsb_by_pixel=lv;
+ }
+ } while (0);
+ }
+ }
+ }
+ }
+
+ ret->force_c_scale_b_box_width *= ret->scaleBBoxWidth;
+ ret->force_c_scale_b_box_height *= ret->scaleBBoxHeight;
+
+ ret->force_c_scale_b_box_width *= ret->scaleWidth;
+ ret->scaleBBoxWidth *= ret->scaleWidth;
+
+ ret->force_c_adjust_rsb_by_pixel += ret->adjustRightSideBearingByPixel;
+ ret->force_c_adjust_lsb_by_pixel += ret->adjustLeftSideBearingByPixel;
+ /* scaleWidth, scaleBBoxWidth, force_c_scale_b_box_width, force_c_scale_b_box_width */
+
+ /* by TTCap */
+ if( hinting == False ) *load_flags |= FT_LOAD_NO_HINTING;
+ if( isEmbeddedBitmap == False ) *load_flags |= FT_LOAD_NO_BITMAP;
+ if( ret->autoItalic != 0 && alwaysEmbeddedBitmap == False )
+ *load_flags |= FT_LOAD_NO_BITMAP;
+
+ quit:
+ return result;
+}
+
+static int
+ft_get_trans_from_vals( FontScalablePtr vals, FTNormalisedTransformationPtr trans )
+{
/* Compute the transformation matrix. We use floating-point
arithmetic for simplicity */
- trans.xres = vals->x;
- trans.yres = vals->y;
+ trans->xres = vals->x;
+ trans->yres = vals->y;
/* This value cannot be 0. */
- trans.scale = MAX(hypot(vals->point_matrix[0], vals->point_matrix[2]),
- hypot(vals->point_matrix[1], vals->point_matrix[3]));
- trans.nonIdentity = 0;
+ trans->scale = hypot(vals->point_matrix[2], vals->point_matrix[3]);
+ trans->nonIdentity = 0;
/* Try to round stuff. We want approximate zeros to be exact zeros,
and if the elements on the diagonal are approximately equal, we
want them equal. We do this to avoid breaking hinting. */
if(DIFFER(vals->point_matrix[0], vals->point_matrix[3])) {
- trans.nonIdentity = 1;
- trans.matrix.xx =
- (int)((vals->point_matrix[0]*(double)TWO_SIXTEENTH)/trans.scale);
- trans.matrix.yy =
- (int)((vals->point_matrix[3]*(double)TWO_SIXTEENTH)/trans.scale);
+ trans->nonIdentity = 1;
+ trans->matrix.xx =
+ (int)((vals->point_matrix[0]*(double)TWO_SIXTEENTH)/trans->scale);
+ trans->matrix.yy =
+ (int)((vals->point_matrix[3]*(double)TWO_SIXTEENTH)/trans->scale);
} else {
- trans.matrix.xx = trans.matrix.yy =
+ trans->matrix.xx = trans->matrix.yy =
((vals->point_matrix[0] + vals->point_matrix[3])/2*
- (double)TWO_SIXTEENTH)/trans.scale;
+ (double)TWO_SIXTEENTH)/trans->scale;
}
- if(DIFFER0(vals->point_matrix[1], trans.scale)) {
- trans.matrix.yx =
- (int)((vals->point_matrix[1]*(double)TWO_SIXTEENTH)/trans.scale);
- trans.nonIdentity = 1;
+ if(DIFFER0(vals->point_matrix[1], trans->scale)) {
+ trans->matrix.yx =
+ (int)((vals->point_matrix[1]*(double)TWO_SIXTEENTH)/trans->scale);
+ trans->nonIdentity = 1;
} else
- trans.matrix.yx = 0;
+ trans->matrix.yx = 0;
- if(DIFFER0(vals->point_matrix[2], trans.scale)) {
- trans.matrix.xy =
- (int)((vals->point_matrix[2]*(double)TWO_SIXTEENTH)/trans.scale);
- trans.nonIdentity = 1;
+ if(DIFFER0(vals->point_matrix[2], trans->scale)) {
+ trans->matrix.xy =
+ (int)((vals->point_matrix[2]*(double)TWO_SIXTEENTH)/trans->scale);
+ trans->nonIdentity = 1;
} else
- trans.matrix.xy=0;
-
+ trans->matrix.xy=0;
+ return 0;
+}
+
+
+static int
+is_fixed_width(FT_Face face)
+{
+ PS_FontInfoRec t1info_rec;
+ int ftrc;
+
+ if(FT_IS_FIXED_WIDTH(face)) {
+ return 1;
+ }
+
+ ftrc = FT_Get_PS_Font_Info(face, &t1info_rec);
+ if(ftrc == 0 && t1info_rec.is_fixed_pitch) {
+ return 1;
+ }
+
+ return 0;
+}
+
+static int
+FreeTypeLoadFont(FTFontPtr font, FontInfoPtr info, FTFacePtr face,
+ char *FTFileName, FontScalablePtr vals, FontEntryPtr entry,
+ FontBitmapFormatPtr bmfmt, FT_Int32 load_flags,
+ struct TTCapInfo *tmp_ttcap, char *dynStrTTCapCodeRange,
+ int ttcap_spacing )
+{
+ int xrc;
+ FTNormalisedTransformationRec trans;
+ int spacing, actual_spacing, zero_code;
+ long lastCode, firstCode;
+ TT_Postscript *post;
+
+ ft_get_trans_from_vals(vals,&trans);
+
/* Check for charcell in XLFD */
- charcell = 0;
+ spacing = FT_PROPORTIONAL;
if(entry->name.ndashes == 14) {
char *p;
int dashes = 0;
@@ -1167,242 +2489,53 @@ FreeTypeLoadFont(FTFontPtr *font_return, char *fileName,
dashes++;
if(dashes == 11) {
if(p[1]=='c' && p[2]=='-')
- charcell=1;
+ spacing=FT_CHARCELL;
+ else if(p[1]=='m' && p[2]=='-')
+ spacing=FT_MONOSPACED;
break;
}
}
}
}
-
- xrc = FreeTypeOpenInstance(&font->instance,
- fileName, &trans, charcell, bmfmt);
- if(xrc != Successful)
- return xrc;
-
+ /* by TTCap */
+ if( ttcap_spacing != 0 ) {
+ if( ttcap_spacing == 'c' ) spacing=FT_CHARCELL;
+ else if( ttcap_spacing == 'm' ) spacing=FT_MONOSPACED;
+ else spacing=FT_PROPORTIONAL;
+ }
+
+ actual_spacing = spacing;
+ if( spacing == FT_PROPORTIONAL ) {
+ if( is_fixed_width(face->face) )
+ actual_spacing = FT_MONOSPACED;
+ }
+
if(entry->name.ndashes == 14) {
- if(FTPickMapping(entry->name.name, entry->name.length, fileName,
- font->instance->face->face, &font->mapping))
- return BadFontFormat;
+ xrc = FTPickMapping(entry->name.name, entry->name.length, FTFileName,
+ face->face, &font->mapping);
+ if (xrc != Successful)
+ return xrc;
} else {
- if(FTPickMapping(0, 0, fileName,
- font->instance->face->face, &font->mapping))
- return BadFontFormat;
+ xrc = FTPickMapping(0, 0, FTFileName,
+ face->face, &font->mapping);
+ if (xrc != Successful)
+ return xrc;
}
-
font->nranges = vals->nranges;
font->ranges = 0;
if(font->nranges) {
font->ranges = (fsRange*)xalloc(vals->nranges*sizeof(fsRange));
- if(font->ranges == NULL) {
- FreeTypeFreeFont(font);
+ if(font->ranges == NULL)
return AllocError;
- }
memcpy((char*)font->ranges, (char*)vals->ranges,
vals->nranges*sizeof(fsRange));
}
- *font_return = font;
-
- return Successful;
-}
-/* Given a BBox in FUnits, return a transformed BBox in pixels */
-static void
-transformBBox(FTNormalisedTransformationPtr transformation,
- int upm, int x_ppem, int y_ppem,
- int x1, int y1, int x2, int y2,
- int *tx1p, int *ty1p, int *tx2p, int *ty2p)
-{
- double
- xx1, yy1, xx2, yy2,
- tx11, ty11, tx12, ty12, tx21, ty21, tx22, ty22,
- tx1, ty1, tx2, ty2;
-
- /* Convert arguments to EM units */
-
- xx1 = ((double)x1/(double)upm);
- yy1 = ((double)y1/(double)upm);
- xx2 = ((double)x2/(double)upm);
- yy2 = ((double)y2/(double)upm);
-
- /* Apply transformation matrix */
-
- if(!transformation->nonIdentity) {
- tx1 = xx1;
- ty1 = yy1;
- tx2 = xx2;
- ty2 = yy2;
- } else {
- /* Not an identity matrix, need to compute images of all corners */
- tx11 =
- (transformation->matrix.xx/TWO_SIXTEENTH)*xx1 +
- (transformation->matrix.xy/TWO_SIXTEENTH)*yy1;
- ty11 =
- (transformation->matrix.yx/TWO_SIXTEENTH)*xx1 +
- (transformation->matrix.yy/TWO_SIXTEENTH)*yy1;
- tx12 =
- (transformation->matrix.xx/TWO_SIXTEENTH)*xx1 +
- (transformation->matrix.xy/TWO_SIXTEENTH)*yy2;
- ty12 =
- (transformation->matrix.yx/TWO_SIXTEENTH)*xx1 +
- (transformation->matrix.yy/TWO_SIXTEENTH)*yy2;
- tx21 =
- (transformation->matrix.xx/TWO_SIXTEENTH)*xx2 +
- (transformation->matrix.xy/TWO_SIXTEENTH)*yy1;
- ty21 =
- (transformation->matrix.yx/TWO_SIXTEENTH)*xx2 +
- (transformation->matrix.yy/TWO_SIXTEENTH)*yy1;
- tx22 =
- (transformation->matrix.xx/TWO_SIXTEENTH)*xx2 +
- (transformation->matrix.xy/TWO_SIXTEENTH)*yy2;
- ty22 =
- (transformation->matrix.yx/TWO_SIXTEENTH)*xx2 +
- (transformation->matrix.yy/TWO_SIXTEENTH)*yy2;
-
- /* Compute the corners of the new bounding box */
-
- tx1 = MIN(MIN(tx11,tx12),MIN(tx21,tx22));
- ty1 = MIN(MIN(ty11,ty12),MIN(ty21,ty22));
- tx2 = MAX(MAX(tx11,tx12),MAX(tx21,tx22));
- ty2 = MAX(MAX(ty11,ty12),MAX(ty21,ty22));
- }
-
-
- /* Convert to device space */
- *tx1p = (int)floor(tx1*(double)x_ppem);
- *ty1p = (int)floor(ty1*(double)y_ppem);
- *tx2p = (int)ceil(tx2*(double)x_ppem);
- *ty2p = (int)ceil(ty2*(double)y_ppem);
-
- /* Ensure the resulting bounding box is not empty */
- if(*tx1p == *tx2p)
- (*tx2p)++;
- if(*ty1p == *ty2p)
- (*ty2p)++;
-}
-
-static int
-is_fixed_width(FT_Face face)
-{
- PS_FontInfoRec t1info_rec;
- int ftrc;
-
- if(FT_IS_FIXED_WIDTH(face)) {
- return 1;
- }
-
- ftrc = FT_Get_PS_Font_Info(face, &t1info_rec);
- if(ftrc == 0 && t1info_rec.is_fixed_pitch) {
- return 1;
- }
-
- return 0;
-}
-
-/* Do all the real work for OpenFont or FontInfo */
-/* xf->info is only accessed through info, and xf might be null */
-
-static int
-FreeTypeLoadXFont(char *fileName,
- FontScalablePtr vals, FontPtr xf, FontInfoPtr info,
- FontBitmapFormatPtr bmfmt, FontEntryPtr entry)
-{
-#define TRANSFORM_FUNITS_X(xval) \
- ((int) \
- floor((((double)(xval)/(double)upm) * \
- ((double)instance->transformation.matrix.xx/TWO_SIXTEENTH)*(double)smetrics.x_ppem)+0.5))
-#define TRANSFORM_FUNITS_X_DOWN(xval) \
- ((int) \
- floor((((double)(xval)/(double)upm) * \
- ((double)instance->transformation.matrix.xx/TWO_SIXTEENTH)*(double)smetrics.x_ppem)))
-#define TRANSFORM_FUNITS_X_UP(xval) \
- ((int) \
- ceil((((double)(xval)/(double)upm) * \
- ((double)instance->transformation.matrix.xx/TWO_SIXTEENTH)*(double)smetrics.x_ppem)))
-#define TRANSFORM_FUNITS_Y(yval) \
- ((int) \
- floor((((double)(yval)/(double)upm) * \
- ((double)instance->transformation.matrix.yy/TWO_SIXTEENTH)*(double)smetrics.x_ppem)+0.5))
-#define TRANSFORM_FUNITS_Y_DOWN(yval) \
- ((int) \
- floor((((double)(yval)/(double)upm) * \
- ((double)instance->transformation.matrix.yy/TWO_SIXTEENTH) * (double)smetrics.y_ppem)))
-#define TRANSFORM_FUNITS_Y_UP(yval) \
- ((int) \
- ceil((((double)(yval)/(double)upm) * \
- ((double)instance->transformation.matrix.yy/TWO_SIXTEENTH) * (double)smetrics.y_ppem)))
-#define TRANSFORM_FUNITS_RAW(value) \
- ((long) \
- floor(((double)(value)/(double)upm) * 1000.0 + 0.5))
-#define TRANSFORM_FUNITS_RAW_DOWN(value) \
- ((long) \
- floor(((double)(value)/(double)upm) * 1000.0))
-#define TRANSFORM_FUNITS_RAW_UP(value) \
- ((long) \
- ceil(((double)(value)/(double)upm) * 1000.0))
-
-
- FTFontPtr font;
- FTInstancePtr instance;
- FT_Size_Metrics smetrics;
- FTFacePtr face;
- int xrc, i;
- int charcell, constantWidth;
- long rawWidth, rawAverageWidth, aw, code, lastCode, firstCode;
- int upm, minLsb, maxRsb, ascent, descent, width, averageWidth;
-
-
- xrc = FreeTypeLoadFont(&font, fileName, vals, entry, bmfmt);
- if(xrc != Successful)
- return xrc;
-
- instance = font->instance;
- face = instance->face;
- smetrics = instance->size->metrics;
-
- upm = face->face->units_per_EM;
- charcell = (instance->monospaced == FT_CHARCELL);
- constantWidth = charcell || is_fixed_width(face->face);
- if(constantWidth && instance->monospaced == 0)
- instance->monospaced = FT_MONOSPACED;
-
- /* There's no way to get the average width right without rasterising
- all of the glyphs. We make a serious attempt at getting it right
- for monospaced fonts, and try to provide a reasonable
- approximation for others. */
-
- if(constantWidth)
- aw = face->face->max_advance_width;
- else
- aw = face->face->max_advance_width / 2;
-
- if(constantWidth)
- averageWidth = 10*TRANSFORM_FUNITS_X(aw);
- else
- averageWidth = TRANSFORM_FUNITS_X(aw*10L);
- rawAverageWidth = TRANSFORM_FUNITS_RAW(aw*10L);
-
- vals->width = averageWidth;
-
+ zero_code=-1;
if(info) {
- info->fontAscent =
- TRANSFORM_FUNITS_Y(face->face->ascender);
- info->fontDescent =
- -TRANSFORM_FUNITS_Y(face->face->descender);
firstCode = 0;
lastCode = 0xFFFFL;
- if(font->nranges) {
- lastCode = 0;
- /* The ranges information does not have an effect on firstCode,
- as we pass the default glyph at position 0. */
- for(i=0; i<font->nranges; i++) {
- code = font->ranges[i].max_char_low +
- (font->ranges[i].max_char_high<<8);
- if(lastCode < code)
- lastCode = code;
- }
- }
-
if(!font->mapping.mapping ||
font->mapping.mapping->encoding->row_size == 0) {
/* linear indexing */
@@ -1417,6 +2550,7 @@ FreeTypeLoadXFont(char *fileName,
info->firstCol =
(info->firstRow || info->lastRow) ? 0 : (firstCode & 0xFF);
info->lastCol = info->lastRow ? 0xFF : (lastCode & 0xFF);
+ if ( firstCode == 0 ) zero_code=0;
} else {
/* matrix indexing */
info->firstRow = font->mapping.mapping->encoding->first;
@@ -1425,66 +2559,767 @@ FreeTypeLoadXFont(char *fileName,
info->firstCol = font->mapping.mapping->encoding->first_col;
info->lastCol = MIN(font->mapping.mapping->encoding->row_size-1,
lastCode<0x100?lastCode:0xFF);
+ if( info->firstRow == 0 && info->firstCol == 0 ) zero_code=0;
}
/* firstCode and lastCode are not valid in case of a matrix
encoding */
- transformBBox(&instance->transformation, upm,
- smetrics.x_ppem, smetrics.y_ppem,
- charcell? 0 :
- face->face->bbox.xMin,
- face->face->bbox.yMin,
- charcell ?
- face->face->max_advance_width :
- face->face->bbox.xMax,
- face->face->bbox.yMax,
- &minLsb, &descent, &maxRsb, &ascent);
- descent = -descent;
-
- width = TRANSFORM_FUNITS_X(face->face->max_advance_width);
- rawWidth =
- TRANSFORM_FUNITS_RAW(face->face->max_advance_width);
- instance->width = width;
-
- info->constantWidth=constantWidth;
- info->constantMetrics=charcell;
-
- info->minbounds.leftSideBearing = minLsb;
- info->minbounds.rightSideBearing = charcell?maxRsb:minLsb;
- info->minbounds.characterWidth = constantWidth?width:-width;
- info->minbounds.ascent = charcell?ascent:-descent;
- info->minbounds.descent = charcell?descent:-ascent;
- info->minbounds.attributes =
- (unsigned short)(short)(constantWidth?rawWidth:-rawWidth);
-
- info->maxbounds.leftSideBearing = charcell?minLsb:maxRsb;
- info->maxbounds.rightSideBearing = maxRsb;
- info->maxbounds.characterWidth = width;
- info->maxbounds.ascent = ascent;
- info->maxbounds.descent = descent;
- info->maxbounds.attributes = (unsigned short)(short)rawWidth;
-
- if(charcell && instance->charcellMetrics == 0) {
- instance->charcellMetrics = (xCharInfo*)xalloc(sizeof(xCharInfo));
- if(instance->charcellMetrics == 0) {
- FreeTypeFreeFont(font);
- return AllocError;
+ if( dynStrTTCapCodeRange ) {
+ restrict_code_range_by_str(0,&info->firstCol, &info->firstRow,
+ &info->lastCol, &info->lastRow,
+ dynStrTTCapCodeRange);
+ }
+ restrict_code_range(&info->firstCol, &info->firstRow,
+ &info->lastCol, &info->lastRow,
+ font->ranges, font->nranges);
+ }
+ font->info = info;
+
+ /* zero code is frequently used. */
+ if ( zero_code < 0 ) {
+ /* The fontenc should have the information of DefaultCh.
+ But we do not have such a information.
+ So we cannot but set 0. */
+ font->zero_idx = 0;
+ }
+ else
+ font->zero_idx = FTRemap(face->face,
+ &font->mapping, zero_code);
+
+ post = FT_Get_Sfnt_Table(face->face, ft_sfnt_post);
+
+#ifdef DEFAULT_VERY_LAZY
+ if( !( tmp_ttcap->flags & TTCAP_DISABLE_DEFAULT_VERY_LAZY ) )
+ if( DEFAULT_VERY_LAZY <= 1 + info->lastRow - info->firstRow ) {
+ if( post ){
+ tmp_ttcap->flags |= TTCAP_IS_VERY_LAZY;
+ }
+ }
+#endif
+ /* We should always reset. */
+ tmp_ttcap->flags &= ~TTCAP_DISABLE_DEFAULT_VERY_LAZY;
+
+ if ( face->bitmap || actual_spacing == FT_CHARCELL )
+ tmp_ttcap->flags &= ~TTCAP_IS_VERY_LAZY;
+ /* "vl=y" is available when TrueType or OpenType only */
+ if ( !face->bitmap && !(FT_IS_SFNT( face->face )) )
+ tmp_ttcap->flags &= ~TTCAP_IS_VERY_LAZY;
+
+ if( post ) {
+ if( post->italicAngle != 0 )
+ tmp_ttcap->vl_slant = -sin( (post->italicAngle/1024./5760.)*1.57079632679489661923 );
+ /* fprintf(stderr,"angle=%g(%g)\n",tmp_ttcap->vl_slant,(post->italicAngle/1024./5760.)*90); */
+ }
+
+ xrc = FreeTypeOpenInstance(&font->instance, face,
+ FTFileName, &trans, actual_spacing, bmfmt,
+ tmp_ttcap, load_flags );
+ return xrc;
+}
+
+static void
+adjust_min_max(xCharInfo *minc, xCharInfo *maxc, xCharInfo *tmp)
+{
+#define MINMAX(field,ci) \
+ if (minc->field > (ci)->field) \
+ minc->field = (ci)->field; \
+ if (maxc->field < (ci)->field) \
+ maxc->field = (ci)->field;
+
+ MINMAX(ascent, tmp);
+ MINMAX(descent, tmp);
+ MINMAX(leftSideBearing, tmp);
+ MINMAX(rightSideBearing, tmp);
+ MINMAX(characterWidth, tmp);
+
+ if ((INT16)minc->attributes > (INT16)tmp->attributes)
+ minc->attributes = tmp->attributes;
+ if ((INT16)maxc->attributes < (INT16)tmp->attributes)
+ maxc->attributes = tmp->attributes;
+#undef MINMAX
+}
+
+static void
+ft_compute_bounds(FTFontPtr font, FontInfoPtr pinfo, FontScalablePtr vals )
+{
+ FTInstancePtr instance;
+ int row, col;
+ unsigned int c;
+ xCharInfo minchar, maxchar, *tmpchar = NULL;
+ int overlap, maxOverlap;
+ long swidth = 0;
+ long total_width = 0;
+ int num_cols, num_chars = 0;
+ int flags, skip_ok = 0;
+ int force_c_outside ;
+
+ instance = font->instance;
+ force_c_outside = instance->ttcap.flags & TTCAP_FORCE_C_OUTSIDE;
+
+ minchar.ascent = minchar.descent =
+ minchar.leftSideBearing = minchar.rightSideBearing =
+ minchar.characterWidth = minchar.attributes = 32767;
+ maxchar.ascent = maxchar.descent =
+ maxchar.leftSideBearing = maxchar.rightSideBearing =
+ maxchar.characterWidth = maxchar.attributes = -32767;
+ maxOverlap = -32767;
+
+ /* Parse all glyphs */
+ num_cols = 1 + pinfo->lastCol - pinfo->firstCol;
+ for (row = pinfo->firstRow; row <= pinfo->lastRow; row++) {
+ if ( skip_ok && tmpchar ) {
+ if ( !force_c_outside ) {
+ if ( instance->ttcap.forceConstantSpacingBegin < row<<8
+ && row<<8 < (instance->ttcap.forceConstantSpacingEnd & 0x0ff00) ) {
+ if (tmpchar->characterWidth) {
+ num_chars += num_cols;
+ swidth += ABS(tmpchar->characterWidth)*num_cols;
+ total_width += tmpchar->characterWidth*num_cols;
+ continue;
+ }
+ }
+ else skip_ok=0;
+ }
+ else { /* for GB18030 proportional */
+ if ( instance->ttcap.forceConstantSpacingBegin < row<<8
+ || row<<8 < (instance->ttcap.forceConstantSpacingEnd & 0x0ff00) ) {
+ if (tmpchar->characterWidth) {
+ num_chars += num_cols;
+ swidth += ABS(tmpchar->characterWidth)*num_cols;
+ total_width += tmpchar->characterWidth*num_cols;
+ continue;
}
- memcpy((char*)instance->charcellMetrics,
- (char*)&info->maxbounds, sizeof(xCharInfo));
+ }
+ else skip_ok=0;
}
+ }
+ for (col = pinfo->firstCol; col <= pinfo->lastCol; col++) {
+ c = row<<8|col;
+ flags=0;
+ if ( !force_c_outside ) {
+ if ( c <= instance->ttcap.forceConstantSpacingEnd
+ && instance->ttcap.forceConstantSpacingBegin <= c )
+ flags|=FT_FORCE_CONSTANT_SPACING;
+ }
+ else { /* for GB18030 proportional */
+ if ( c <= instance->ttcap.forceConstantSpacingEnd
+ || instance->ttcap.forceConstantSpacingBegin <= c )
+ flags|=FT_FORCE_CONSTANT_SPACING;
+ }
+#if 0
+ fprintf(stderr, "comp_bounds: %x ->", c);
+#endif
+ if ( skip_ok == 0 || flags == 0 ){
+ tmpchar=NULL;
+#if 0
+ fprintf(stderr, "%x\n", c);
+#endif
+ if( FreeTypeFontGetGlyphMetrics(c, flags, &tmpchar, font) != Successful )
+ continue;
+ }
+ if ( !tmpchar ) continue;
+ adjust_min_max(&minchar, &maxchar, tmpchar);
+ overlap = tmpchar->rightSideBearing - tmpchar->characterWidth;
+ if (maxOverlap < overlap)
+ maxOverlap = overlap;
+
+ if (!tmpchar->characterWidth)
+ continue;
+ num_chars++;
+ swidth += ABS(tmpchar->characterWidth);
+ total_width += tmpchar->characterWidth;
+
+ if ( flags & FT_FORCE_CONSTANT_SPACING ) skip_ok=1;
+ }
+ }
+
+#ifndef XAA_ACCEPTS_NO_SUCH_CHAR
+ /* Check code 0 */
+ if( FreeTypeInstanceGetGlyphMetrics(font->zero_idx, 0, &tmpchar, font->instance) != Successful || tmpchar == NULL)
+ if( FreeTypeInstanceGetGlyphMetrics(font->zero_idx, FT_GET_DUMMY, &tmpchar, font->instance) != Successful )
+ tmpchar = NULL;
+ if ( tmpchar ) {
+ adjust_min_max(&minchar, &maxchar, tmpchar);
+ overlap = tmpchar->rightSideBearing - tmpchar->characterWidth;
+ if (maxOverlap < overlap)
+ maxOverlap = overlap;
+ }
+#endif
+
+ /* AVERAGE_WIDTH ... 1/10 pixel unit */
+ if (num_chars > 0) {
+ swidth = (swidth * 10.0 + num_chars / 2.0) / num_chars;
+ if (total_width < 0)
+ swidth = -swidth;
+ vals->width = swidth;
+ } else
+ vals->width = 0;
+
+ /*
+ if (char_width.pixel) {
+ maxchar.characterWidth = char_width.pixel;
+ minchar.characterWidth = char_width.pixel;
+ }
+ */
+
+ pinfo->maxbounds = maxchar;
+ pinfo->minbounds = minchar;
+ pinfo->ink_maxbounds = maxchar;
+ pinfo->ink_minbounds = minchar;
+ pinfo->maxOverlap = maxOverlap;
+}
+
+static int
+compute_new_extents( FontScalablePtr vals, double scale, double lsb, double rsb, double desc, double asc,
+ int *lsb_result, int *rsb_result, int *desc_result, int *asc_result )
+{
+#define TRANSFORM_POINT(matrix, x, y, dest) \
+ ((dest)[0] = (matrix)[0] * (x) + (matrix)[2] * (y), \
+ (dest)[1] = (matrix)[1] * (x) + (matrix)[3] * (y))
+
+#define CHECK_EXTENT(lsb, rsb, desc, asc, data) \
+ ((lsb) > (data)[0] ? (lsb) = (data)[0] : 0 , \
+ (rsb) < (data)[0] ? (rsb) = (data)[0] : 0, \
+ (-desc) > (data)[1] ? (desc) = -(data)[1] : 0 , \
+ (asc) < (data)[1] ? (asc) = (data)[1] : 0)
+ double newlsb, newrsb, newdesc, newasc;
+ double point[2];
+
+ /* Compute new extents for this glyph */
+ TRANSFORM_POINT(vals->pixel_matrix, lsb, -desc, point);
+ newlsb = point[0];
+ newrsb = newlsb;
+ newdesc = -point[1];
+ newasc = -newdesc;
+ TRANSFORM_POINT(vals->pixel_matrix, lsb, asc, point);
+ CHECK_EXTENT(newlsb, newrsb, newdesc, newasc, point);
+ TRANSFORM_POINT(vals->pixel_matrix, rsb, -desc, point);
+ CHECK_EXTENT(newlsb, newrsb, newdesc, newasc, point);
+ TRANSFORM_POINT(vals->pixel_matrix, rsb, asc, point);
+ CHECK_EXTENT(newlsb, newrsb, newdesc, newasc, point);
+
+ /* ???: lsb = (int)floor(newlsb * scale); */
+ *lsb_result = (int)floor(newlsb * scale + 0.5);
+ *rsb_result = (int)floor(newrsb * scale + 0.5);
+ *desc_result = (int)ceil(newdesc * scale - 0.5);
+ *asc_result = (int)floor(newasc * scale + 0.5);
+
+ return 0;
+#undef CHECK_EXTENT
+#undef TRANSFORM_POINT
+}
+
+static int
+is_matrix_unit(FontScalablePtr vals)
+{
+ double base_size;
+ FT_Matrix m;
+
+ base_size = hypot(vals->point_matrix[2], vals->point_matrix[3]);
+
+ m.xx = vals->point_matrix[0] / base_size * 65536;
+ m.xy = vals->point_matrix[2] / base_size * 65536;
+ m.yx = vals->point_matrix[1] / base_size * 65536;
+ m.yy = vals->point_matrix[3] / base_size * 65536;
+
+ return (m.xx == 65536) && (m.yx == 0) &&
+ (m.xy == 0) && (m.yy == 65536);
+}
+
+/* Do all the real work for OpenFont or FontInfo */
+/* xf->info is only accessed through info, and xf might be null */
- /* Glyph metrics are accurate */
- info->inkMetrics=1;
+static int
+FreeTypeLoadXFont(char *fileName,
+ FontScalablePtr vals, FontPtr xf, FontInfoPtr info,
+ FontBitmapFormatPtr bmfmt, FontEntryPtr entry)
+{
+ FTFontPtr font = NULL;
+ FTFacePtr face = NULL;
+ FTInstancePtr instance;
+ FT_Size_Metrics *smetrics;
+ int xrc=Successful;
+ int charcell;
+ long rawWidth = 0, rawAverageWidth = 0;
+ int upm, minLsb, maxRsb, ascent, descent, width, averageWidth;
+ double scale, base_width, base_height;
+ Bool orig_is_matrix_unit;
+ int face_number, ttcap_spacing;
+ struct TTCapInfo tmp_ttcap;
+ struct TTCapInfo *ins_ttcap;
+ FT_Int32 load_flags = FT_LOAD_DEFAULT; /* orig: FT_LOAD_RENDER | FT_LOAD_MONOCHROME */
+ char *dynStrRealFileName = NULL; /* foo.ttc */
+ char *dynStrFTFileName = NULL; /* :1:foo.ttc */
+ char *dynStrTTCapCodeRange = NULL;
- memcpy((char *)&info->ink_maxbounds,
- (char *)&info->maxbounds, sizeof(xCharInfo));
- memcpy((char *)&info->ink_minbounds,
- (char *)&info->minbounds, sizeof(xCharInfo));
+ font = (FTFontPtr)xalloc(sizeof(FTFontRec));
+ if(font == NULL) {
+ xrc = AllocError;
+ goto quit;
+ }
+ memset(font, 0, sizeof(FTFontRec));
+
+ xrc = FreeTypeSetUpTTCap(fileName, vals,
+ &dynStrRealFileName, &dynStrFTFileName,
+ &tmp_ttcap, &face_number,
+ &load_flags, &ttcap_spacing,
+ &dynStrTTCapCodeRange);
+ if ( xrc != Successful ) {
+ goto quit;
+ }
- /* XXX - hack */
- info->defaultCh=0;
+ xrc = FreeTypeOpenFace(&face, dynStrFTFileName, dynStrRealFileName, face_number);
+ if(xrc != Successful) {
+ goto quit;
+ }
+
+ if( is_matrix_unit(vals) )
+ orig_is_matrix_unit = True;
+ else {
+ orig_is_matrix_unit = False;
+ /* Turn off EmbeddedBitmap when original matrix is not diagonal. */
+ load_flags |= FT_LOAD_NO_BITMAP;
+ }
+
+ if( face->bitmap ) load_flags &= ~FT_LOAD_NO_BITMAP;
+
+ /* Slant control by TTCap */
+ if(!face->bitmap) {
+ vals->pixel_matrix[2] +=
+ vals->pixel_matrix[0] * tmp_ttcap.autoItalic;
+ vals->point_matrix[2] +=
+ vals->point_matrix[0] * tmp_ttcap.autoItalic;
+ vals->pixel_matrix[3] +=
+ vals->pixel_matrix[1] * tmp_ttcap.autoItalic;
+ vals->point_matrix[3] +=
+ vals->point_matrix[1] * tmp_ttcap.autoItalic;
+ }
+
+ base_width=hypot(vals->pixel_matrix[0], vals->pixel_matrix[1]);
+ base_height=hypot(vals->pixel_matrix[2], vals->pixel_matrix[3]);
+ if(MAX(base_width, base_height) < 1.0 ) {
+ xrc = BadFontName;
+ goto quit;
+ }
+
+ xrc = FreeTypeLoadFont(font, info, face, dynStrFTFileName, vals, entry, bmfmt,
+ load_flags, &tmp_ttcap, dynStrTTCapCodeRange,
+ ttcap_spacing );
+ if(xrc != Successful) {
+ goto quit;
+ }
+
+ instance = font->instance;
+ smetrics = &instance->size->metrics;
+ ins_ttcap = &instance->ttcap;
+
+ upm = face->face->units_per_EM;
+ if(upm == 0) {
+ /* Work around FreeType bug */
+ upm = WORK_AROUND_UPM;
+ }
+ scale = 1.0 / upm;
+
+ charcell = (instance->spacing == FT_CHARCELL);
+
+ if( instance->charcellMetrics == NULL ) {
+
+ /* New instance */
+
+ long force_c_rawWidth = 0;
+ int force_c_lsb,force_c_rsb,force_c_width;
+ double unit_x=0,unit_y=0,advance;
+ CharInfoPtr tmpglyph;
+
+ /*
+ * CALCULATE HEADER'S METRICS
+ */
+
+ /* for OUTLINE fonts */
+ if(!face->bitmap) {
+ int new_width;
+ double ratio,force_c_ratio;
+ double b_width_diagonal;
+ double width_x=0,width_y=0;
+ double force_c_width_x, force_c_rsb_x, force_c_lsb_x;
+ double tmp_rsb,tmp_lsb,tmp_asc,tmp_des;
+ double max_advance_height;
+ tmp_asc = face->face->bbox.yMax;
+ tmp_des = -(face->face->bbox.yMin);
+ if ( tmp_asc < face->face->ascender ) tmp_asc = face->face->ascender;
+ if ( tmp_des < -(face->face->descender) ) tmp_des = -(face->face->descender);
+ tmp_lsb = face->face->bbox.xMin;
+ tmp_rsb = face->face->bbox.xMax;
+ if ( tmp_rsb < face->face->max_advance_width ) tmp_rsb = face->face->max_advance_width;
+ /* apply scaleBBoxWidth */
+ /* we should not ...???
+ tmp_lsb *= ins_ttcap->scaleBBoxWidth;
+ tmp_rsb *= ins_ttcap->scaleBBoxWidth;
+ */
+ /* transform and rescale */
+ compute_new_extents( vals, scale, tmp_lsb, tmp_rsb, tmp_des, tmp_asc,
+ &minLsb, &maxRsb, &descent, &ascent );
+ /* */
+ b_width_diagonal = (tmp_rsb - tmp_lsb) /* face->face->max_advance_width */
+ * vals->pixel_matrix[0] * scale;
+ /* Consider vertical layouts */
+ if( 0 < face->face->max_advance_height )
+ max_advance_height = face->face->max_advance_height;
+ else
+ max_advance_height = tmp_asc + tmp_des;
+ if( vals->pixel_matrix[1] == 0 ){
+ unit_x = fabs(vals->pixel_matrix[0]);
+ unit_y = 0;
+ width_x = face->face->max_advance_width * ins_ttcap->scaleBBoxWidth * unit_x;
+ }
+ else if( vals->pixel_matrix[3] == 0 ){
+ unit_y = fabs(vals->pixel_matrix[2]);
+ unit_x = 0;
+ width_x = max_advance_height * ins_ttcap->scaleBBoxHeight * unit_y;
+ }
+ else{
+ unit_x = fabs(vals->pixel_matrix[0] -
+ vals->pixel_matrix[1]*vals->pixel_matrix[2]/vals->pixel_matrix[3]);
+ unit_y = fabs(vals->pixel_matrix[2] -
+ vals->pixel_matrix[3]*vals->pixel_matrix[0]/vals->pixel_matrix[1]);
+ width_x = face->face->max_advance_width * ins_ttcap->scaleBBoxWidth * unit_x;
+ width_y = max_advance_height * ins_ttcap->scaleBBoxHeight * unit_y;
+ if( width_y < width_x ){
+ width_x = width_y;
+ unit_x = 0;
+ }
+ else{
+ unit_y = 0;
+ }
+ }
+ /* calculate correction ratio */
+ width = (int)floor( (advance = width_x * scale) + 0.5);
+ new_width = width;
+ if( ins_ttcap->flags & TTCAP_DOUBLE_STRIKE_CORRECT_B_BOX_WIDTH )
+ new_width += ins_ttcap->doubleStrikeShift;
+ new_width += ins_ttcap->adjustBBoxWidthByPixel;
+ ratio = (double)new_width/width;
+ width = new_width;
+ /* force constant */
+ if( unit_x != 0 ) {
+ force_c_width_x = face->face->max_advance_width
+ * ins_ttcap->force_c_scale_b_box_width * unit_x;
+ force_c_lsb_x = face->face->max_advance_width
+ * ins_ttcap->force_c_scale_lsb * unit_x;
+ force_c_rsb_x = face->face->max_advance_width
+ * ins_ttcap->force_c_scale_rsb * unit_x;
+ }
+ else {
+ force_c_width_x = max_advance_height
+ * ins_ttcap->force_c_scale_b_box_height * unit_y;
+ force_c_lsb_x = max_advance_height
+ * ins_ttcap->force_c_scale_lsb * unit_y;
+ force_c_rsb_x = max_advance_height
+ * ins_ttcap->force_c_scale_rsb * unit_y;
+ }
+ /* calculate correction ratio */
+ force_c_width = (int)floor(force_c_width_x * scale + 0.5);
+ new_width = force_c_width;
+ if( ins_ttcap->flags & TTCAP_DOUBLE_STRIKE_CORRECT_B_BOX_WIDTH )
+ force_c_width += ins_ttcap->doubleStrikeShift;
+ new_width += ins_ttcap->force_c_adjust_width_by_pixel;
+ force_c_ratio = (double)new_width/force_c_width;
+ force_c_width = new_width;
+ /* force_c_lsb, force_c_rsb */
+ if( ins_ttcap->flags & TTCAP_FORCE_C_LSB_FLAG )
+ force_c_lsb = (int)floor( force_c_lsb_x * scale + 0.5 );
+ else
+ force_c_lsb = minLsb;
+ if( ins_ttcap->flags & TTCAP_FORCE_C_RSB_FLAG )
+ force_c_rsb = (int)floor( force_c_rsb_x * scale + 0.5 );
+ else
+ force_c_rsb = maxRsb;
+ /* calculate shift of BitmapAutoItalic
+ (when diagonal matrix only) */
+ if( orig_is_matrix_unit == True ) {
+ if( ins_ttcap->autoItalic != 0 ) {
+ double ai;
+ int ai_lsb,ai_rsb,ai_total;
+ if( 0 < ins_ttcap->autoItalic ) ai=ins_ttcap->autoItalic;
+ else ai = -ins_ttcap->autoItalic;
+ ai_total = (int)( b_width_diagonal * ai + 0.5);
+ ai_rsb = (int)((double)ai_total * ascent / ( ascent + descent ) + 0.5 );
+ ai_lsb = -(ai_total - ai_rsb);
+ if( 0 < ins_ttcap->autoItalic ) {
+ ins_ttcap->lsbShiftOfBitmapAutoItalic = ai_lsb;
+ ins_ttcap->rsbShiftOfBitmapAutoItalic = ai_rsb;
+ }
+ else {
+ ins_ttcap->lsbShiftOfBitmapAutoItalic = -ai_rsb;
+ ins_ttcap->rsbShiftOfBitmapAutoItalic = -ai_lsb;
+ }
+ }
+ }
+ /* integer adjustment by TTCap */
+ if( ins_ttcap->flags & TTCAP_DOUBLE_STRIKE )
+ maxRsb += ins_ttcap->doubleStrikeShift;
+ maxRsb += ins_ttcap->adjustRightSideBearingByPixel;
+ minLsb += ins_ttcap->adjustLeftSideBearingByPixel;
+ /* */
+ if( ins_ttcap->flags & TTCAP_DOUBLE_STRIKE )
+ force_c_rsb += ins_ttcap->doubleStrikeShift;
+ force_c_rsb += ins_ttcap->force_c_adjust_rsb_by_pixel;
+ force_c_lsb += ins_ttcap->force_c_adjust_lsb_by_pixel;
+ /* apply to rawWidth */
+ averageWidth = (int)floor(10 * width_x * scale
+ * ratio + 0.5);
+ rawWidth = floor(width_x * scale
+ * ratio * 1000. / base_height + 0.5);
+ rawAverageWidth = floor(width_x * scale * ratio * 10.
+ * 1000. / base_height + 0.5);
+ force_c_rawWidth = floor(force_c_width_x * scale
+ * force_c_ratio * 1000. / base_height + 0.5);
+ /* */
+ }
+ /* for BITMAP fonts [if(face->bitmap)] */
+ else {
+ /* These values differ from actual when outline,
+ so we must use them ONLY FOR BITMAP. */
+ width = (int)floor(smetrics->max_advance * ins_ttcap->scaleBBoxWidth / 64.0 + .5);
+ descent = -smetrics->descender / 64;
+ ascent = smetrics->ascender / 64;
+ /* force constant */
+ force_c_width = (int)floor(smetrics->max_advance
+ * ins_ttcap->force_c_scale_b_box_width / 64.0 + .5);
+ /* Preserve average width for bitmap fonts */
+ if(vals->width != 0)
+ averageWidth = (int)floor(vals->width * ins_ttcap->scaleBBoxWidth +.5);
+ else
+ averageWidth = (int)floor(10.0 * smetrics->max_advance
+ * ins_ttcap->scaleBBoxWidth / 64.0 + .5);
+ rawWidth = 0;
+ rawAverageWidth = 0;
+ force_c_rawWidth = 0;
+ /* We don't consider vertical layouts */
+ advance = (int)floor(smetrics->max_advance / 64.0 +.5);
+ unit_x = vals->pixel_matrix[0];
+ unit_y = 0;
+ /* We can use 'width' only when bitmap.
+ This should not be set when outline. */
+ minLsb = 0;
+ maxRsb = width;
+ /* force constant */
+ if( ins_ttcap->flags & TTCAP_FORCE_C_LSB_FLAG )
+ force_c_lsb = (int)floor(smetrics->max_advance
+ * ins_ttcap->force_c_scale_lsb / 64.0 + .5);
+ else
+ force_c_lsb = minLsb;
+ if( ins_ttcap->flags & TTCAP_FORCE_C_RSB_FLAG )
+ force_c_rsb = (int)floor(smetrics->max_advance
+ * ins_ttcap->force_c_scale_rsb / 64.0 + .5);
+ else
+ force_c_rsb = maxRsb;
+ /* calculate shift of BitmapAutoItalic */
+ if( ins_ttcap->autoItalic != 0 ) {
+ double ai;
+ int ai_lsb,ai_rsb,ai_total;
+ if( 0 < ins_ttcap->autoItalic ) ai=ins_ttcap->autoItalic;
+ else ai = -ins_ttcap->autoItalic;
+ ai_total = (int)( ai * smetrics->max_advance / 64.0 + 0.5);
+ ai_rsb = (int)((double)ai_total * ascent / ( ascent + descent ) + 0.5 );
+ ai_lsb = -(ai_total - ai_rsb);
+ if( 0 < ins_ttcap->autoItalic ) {
+ ins_ttcap->lsbShiftOfBitmapAutoItalic = ai_lsb;
+ ins_ttcap->rsbShiftOfBitmapAutoItalic = ai_rsb;
+ }
+ else {
+ ins_ttcap->lsbShiftOfBitmapAutoItalic = -ai_rsb;
+ ins_ttcap->rsbShiftOfBitmapAutoItalic = -ai_lsb;
+ }
+ }
+ /* integer adjustment by TTCap */
+ if( ins_ttcap->flags & TTCAP_DOUBLE_STRIKE_CORRECT_B_BOX_WIDTH )
+ width += ins_ttcap->doubleStrikeShift;
+ if( ins_ttcap->flags & TTCAP_DOUBLE_STRIKE )
+ maxRsb += ins_ttcap->doubleStrikeShift;
+ maxRsb += ins_ttcap->adjustRightSideBearingByPixel;
+ minLsb += ins_ttcap->adjustLeftSideBearingByPixel;
+ /* We have not carried out matrix calculation, so this is done. */
+ maxRsb += ins_ttcap->rsbShiftOfBitmapAutoItalic;
+ minLsb += ins_ttcap->lsbShiftOfBitmapAutoItalic;
+ /* force constant */
+ if( ins_ttcap->flags & TTCAP_DOUBLE_STRIKE )
+ force_c_rsb += ins_ttcap->doubleStrikeShift;
+ force_c_rsb += ins_ttcap->force_c_adjust_rsb_by_pixel;
+ force_c_lsb += ins_ttcap->force_c_adjust_lsb_by_pixel;
+ force_c_rsb += ins_ttcap->rsbShiftOfBitmapAutoItalic;
+ force_c_lsb += ins_ttcap->lsbShiftOfBitmapAutoItalic;
+ }
+
+ /* SET CALCULATED VALUES TO INSTANCE */
+
+ /* Set actual height and cosine */
+ instance->pixel_size = base_height;
+ instance->advance = advance;
+ if ( unit_x != 0 ){
+ instance->pixel_width_unit_x = unit_x/base_height;
+ instance->pixel_width_unit_y = 0;
+ }
+ else{
+ instance->pixel_width_unit_x = 0;
+ instance->pixel_width_unit_y = unit_y/base_height;
+ }
+
+ /* header's metrics */
+ instance->charcellMetrics = (xCharInfo*)xalloc(sizeof(xCharInfo));
+ if(instance->charcellMetrics == NULL) {
+ xrc = AllocError;
+ goto quit;
+ }
+ instance->charcellMetrics->ascent = ascent;
+ instance->charcellMetrics->descent = descent;
+ instance->charcellMetrics->attributes = rawWidth;
+ instance->charcellMetrics->rightSideBearing = maxRsb;
+ instance->charcellMetrics->leftSideBearing = minLsb;
+ instance->charcellMetrics->characterWidth = width;
+ instance->averageWidth = averageWidth;
+ instance->rawAverageWidth = rawAverageWidth;
+
+ /* Check code 0 */
+ if( FreeTypeInstanceGetGlyph(font->zero_idx, 0, &tmpglyph, font->instance) != Successful
+ || tmpglyph == NULL)
+ if( FreeTypeInstanceGetGlyph(font->zero_idx, FT_GET_DUMMY, &tmpglyph, font->instance)
+ != Successful )
+ tmpglyph = NULL;
+ if ( !tmpglyph ) {
+ xrc = AllocError;
+ goto quit;
+ }
+
+ /* FORCE CONSTANT METRICS */
+ if( 0 <= ins_ttcap->forceConstantSpacingEnd ) {
+ xCharInfo *tmpchar = NULL;
+ int c = ins_ttcap->force_c_representative_metrics_char_code;
+ /* header's metrics */
+ if( instance->forceConstantMetrics == NULL ){
+ instance->forceConstantMetrics = (xCharInfo*)xalloc(sizeof(xCharInfo));
+ if(instance->forceConstantMetrics == NULL) {
+ xrc = AllocError;
+ goto quit;
+ }
+ }
+ /* Get Representative Metrics */
+ if ( 0 <= c ) {
+ if( FreeTypeFontGetGlyphMetrics(c, 0, &tmpchar, font) != Successful )
+ tmpchar = NULL;
+ }
+ if ( tmpchar && 0 < tmpchar->characterWidth ) {
+ instance->forceConstantMetrics->leftSideBearing = tmpchar->leftSideBearing;
+ instance->forceConstantMetrics->rightSideBearing = tmpchar->rightSideBearing;
+ instance->forceConstantMetrics->characterWidth = tmpchar->characterWidth;
+ instance->forceConstantMetrics->ascent = tmpchar->ascent;
+ instance->forceConstantMetrics->descent = tmpchar->descent;
+ instance->forceConstantMetrics->attributes = tmpchar->attributes;
+ }
+ else {
+ instance->forceConstantMetrics->leftSideBearing = force_c_lsb;
+ instance->forceConstantMetrics->rightSideBearing = force_c_rsb;
+ instance->forceConstantMetrics->characterWidth = force_c_width;
+ instance->forceConstantMetrics->ascent = ascent;
+ instance->forceConstantMetrics->descent = descent;
+ instance->forceConstantMetrics->attributes = force_c_rawWidth;
+ }
+ /* Check code 0 */
+ if( FreeTypeInstanceGetGlyph(font->zero_idx, FT_FORCE_CONSTANT_SPACING,
+ &tmpglyph, font->instance) != Successful
+ || tmpglyph == NULL)
+ if( FreeTypeInstanceGetGlyph(font->zero_idx, FT_FORCE_CONSTANT_SPACING | FT_GET_DUMMY,
+ &tmpglyph, font->instance)
+ != Successful )
+ tmpglyph = NULL;
+ if ( !tmpglyph ) {
+ xrc = AllocError;
+ goto quit;
+ }
+ }
+ }
+ else{
+
+ /*
+ * CACHED VALUES
+ */
+
+ width = instance->charcellMetrics->characterWidth;
+ ascent = instance->charcellMetrics->ascent;
+ descent = instance->charcellMetrics->descent;
+ rawWidth = instance->charcellMetrics->attributes;
+ maxRsb = instance->charcellMetrics->rightSideBearing;
+ minLsb = instance->charcellMetrics->leftSideBearing;
+ averageWidth = instance->averageWidth;
+ rawAverageWidth = instance->rawAverageWidth;
+
+ }
+
+ /*
+ * SET maxbounds, minbounds ...
+ */
+
+ if( !charcell ) { /* NOT CHARCELL */
+ if( info ){
+ /*
+ Calculate all glyphs' metrics.
+ maxbounds.ascent and maxbounds.descent are quite important values
+ for XAA. If ascent/descent of each glyph exceeds
+ maxbounds.ascent/maxbounds.descent, XAA causes SERVER CRASH.
+ Therefore, THIS MUST BE DONE.
+ */
+ ft_compute_bounds(font,info,vals);
+ }
+ }
+ else{ /* CHARCELL */
+
+ /*
+ * SET CALCULATED OR CACHED VARIABLES
+ */
+
+ vals->width = averageWidth;
+
+ if( info ){
+
+ info->maxbounds.leftSideBearing = minLsb;
+ info->maxbounds.rightSideBearing = maxRsb;
+ info->maxbounds.characterWidth = width;
+ info->maxbounds.ascent = ascent;
+ info->maxbounds.descent = descent;
+ info->maxbounds.attributes =
+ (unsigned short)(short)rawWidth;
+
+ info->minbounds = info->maxbounds;
+ }
+ }
+
+ /* set info */
+
+ if( info ){
+ info->fontAscent = ascent;
+ info->fontDescent = descent;
+ /* Glyph metrics are accurate */
+ info->inkMetrics=1;
+
+ memcpy((char *)&info->ink_maxbounds,
+ (char *)&info->maxbounds, sizeof(xCharInfo));
+ memcpy((char *)&info->ink_minbounds,
+ (char *)&info->minbounds, sizeof(xCharInfo));
+
+ /* XXX - hack */
+ info->defaultCh=0;
+
+ /* Set the pInfo flags */
+ /* Properties set by FontComputeInfoAccelerators:
+ pInfo->noOverlap;
+ pInfo->terminalFont;
+ pInfo->constantMetrics;
+ pInfo->constantWidth;
+ pInfo->inkInside;
+ */
+ /* from lib/font/util/fontaccel.c */
+ FontComputeInfoAccelerators(info);
}
if(xf)
@@ -1494,21 +3329,21 @@ FreeTypeLoadXFont(char *fileName,
xrc = FreeTypeAddProperties(font, vals, info, entry->name.name,
rawAverageWidth);
if (xrc != Successful) {
- FreeTypeFreeFont(font);
- return xrc;
+ goto quit;
}
}
- return Successful;
-#undef TRANSFORM_FUNITS_X
-#undef TRANSFORM_FUNITS_X_DOWN
-#undef TRANSFORM_FUNITS_X_UP
-#undef TRANSFORM_FUNITS_Y
-#undef TRANSFORM_FUNITS_Y_DOWN
-#undef TRANSFORM_FUNITS_Y_UP
-#undef TRANSFORM_FUNITS_RAW
-#undef TRANSFORM_FUNITS_RAW_DOWN
-#undef TRANSFORM_FUNITS_RAW_UP
+ quit:
+ if ( dynStrTTCapCodeRange ) xfree(dynStrTTCapCodeRange);
+ if ( dynStrFTFileName ) xfree(dynStrFTFileName);
+ if ( dynStrRealFileName ) xfree(dynStrRealFileName);
+ if ( xrc != Successful ) {
+ if( font ){
+ if( face && font->instance == NULL ) FreeTypeFreeFace(face);
+ FreeTypeFreeFont(font);
+ }
+ }
+ return xrc;
}
/* Routines used by X11 to get info and glyphs from the font. */
@@ -1519,16 +3354,15 @@ FreeTypeGetMetrics(FontPtr pFont, unsigned long count, unsigned char *chars,
xCharInfo **metrics)
{
unsigned int code = 0;
+ int flags = 0;
FTFontPtr tf;
+ struct TTCapInfo *ttcap;
xCharInfo **mp, *m;
-
- /* The compiler is supposed to initialise all the fields to 0 */
- static xCharInfo noSuchChar;
-
/* MUMBLE1("Get metrics for %ld characters\n", count);*/
tf = (FTFontPtr)pFont->fontPrivate;
+ ttcap = &tf->instance->ttcap;
mp = metrics;
while (count-- > 0) {
@@ -1541,13 +3375,28 @@ FreeTypeGetMetrics(FontPtr pFont, unsigned long count, unsigned char *chars,
case TwoD16Bit:
code = (*chars++ << 8);
code |= *chars++;
+ /* */
+ if ( !(ttcap->flags & TTCAP_FORCE_C_OUTSIDE) ) {
+ if ( (int)code <= ttcap->forceConstantSpacingEnd
+ && ttcap->forceConstantSpacingBegin <= (int)code )
+ flags|=FT_FORCE_CONSTANT_SPACING;
+ else flags=0;
+ }
+ else { /* for GB18030 proportional */
+ if ( (int)code <= ttcap->forceConstantSpacingEnd
+ || ttcap->forceConstantSpacingBegin <= (int)code )
+ flags|=FT_FORCE_CONSTANT_SPACING;
+ else flags=0;
+ }
break;
}
- if(FreeTypeFontGetGlyphMetrics(code, &m, tf) == Successful && m!=0) {
+ if(FreeTypeFontGetGlyphMetrics(code, flags, &m, tf) == Successful && m!=NULL) {
*mp++ = m;
- } else
- *mp++ = &noSuchChar;
+ }
+#ifdef XAA_ACCEPTS_NO_SUCH_CHAR
+ else *mp++ = &noSuchChar.metrics;
+#endif
}
*metricCount = mp - metrics;
@@ -1560,11 +3409,14 @@ FreeTypeGetGlyphs(FontPtr pFont, unsigned long count, unsigned char *chars,
CharInfoPtr *glyphs)
{
unsigned int code = 0;
+ int flags = 0;
FTFontPtr tf;
CharInfoPtr *gp;
CharInfoPtr g;
+ struct TTCapInfo *ttcap;
tf = (FTFontPtr)pFont->fontPrivate;
+ ttcap = &tf->instance->ttcap;
gp = glyphs;
while (count-- > 0) {
@@ -1575,14 +3427,28 @@ FreeTypeGetGlyphs(FontPtr pFont, unsigned long count, unsigned char *chars,
case Linear16Bit: case TwoD16Bit:
code = *chars++ << 8;
code |= *chars++;
+ /* */
+ if ( !(ttcap->flags & TTCAP_FORCE_C_OUTSIDE) ) {
+ if ( (int)code <= ttcap->forceConstantSpacingEnd
+ && ttcap->forceConstantSpacingBegin <= (int)code )
+ flags|=FT_FORCE_CONSTANT_SPACING;
+ else flags=0;
+ }
+ else { /* for GB18030 proportional */
+ if ( (int)code <= ttcap->forceConstantSpacingEnd
+ || ttcap->forceConstantSpacingBegin <= (int)code )
+ flags|=FT_FORCE_CONSTANT_SPACING;
+ else flags=0;
+ }
break;
}
- if(FreeTypeFontGetGlyph(code, &g, tf) == Successful && g!=0) {
+ if(FreeTypeFontGetGlyph(code, flags, &g, tf) == Successful && g!=NULL) {
*gp++ = g;
- } else
- if(FreeTypeFontGetDefaultGlyph(&g, tf) == Successful && g!=0)
- *gp++ = g;
+ }
+#ifdef XAA_ACCEPTS_NO_SUCH_CHAR
+ else *gp++ = &noSuchChar;
+#endif
}
*glyphCount = gp - glyphs;
@@ -1658,13 +3524,6 @@ FreeTypeOpenScalable(FontPathElementPtr fpe, FontPtr *ppFont, int flags,
#endif
MUMBLE("\n");
- /* Reject ridiculously small values. Singular matrices are okay. */
- if(MAX(hypot(vals->pixel_matrix[0], vals->pixel_matrix[1]),
- hypot(vals->pixel_matrix[2], vals->pixel_matrix[3]))
- <1.0)
- return BadFontName;
-
- /* Create an X11 server-side font. */
xf = CreateFontRec();
if (xf == NULL)
return AllocError;
@@ -1674,16 +3533,13 @@ FreeTypeOpenScalable(FontPathElementPtr fpe, FontPtr *ppFont, int flags,
DestroyFontRec(xf);
return xrc;
}
- /* Load the font and fill its info structure. */
xrc = FreeTypeLoadXFont(fileName, vals, xf, &xf->info, &bmfmt, entry);
if(xrc != Successful) {
- /* Free everything up at this level and return the error code. */
MUMBLE1("Error during load: %d\n",xrc);
DestroyFontRec(xf);
return xrc;
}
- /* Set the font and return. */
*ppFont = xf;
return xrc;
@@ -1705,10 +3561,6 @@ FreeTypeGetInfoScalable(FontPathElementPtr fpe, FontInfoPtr info,
#endif
MUMBLE("\n");
- if(MAX(hypot(vals->pixel_matrix[0], vals->pixel_matrix[1]),
- hypot(vals->pixel_matrix[2], vals->pixel_matrix[3])) < 1.0)
- return BadFontName;
-
xrc = FreeTypeSetUpFont(fpe, 0, info, 0, 0, &bmfmt);
if(xrc != Successful) {
return xrc;
@@ -1760,6 +3612,21 @@ static FontRendererRec renderers[] = {
};
static int num_renderers = sizeof(renderers) / sizeof(renderers[0]);
+static FontRendererRec alt_renderers[] = {
+ {".bdf", 4, 0, FreeTypeOpenScalable, 0,
+ FreeTypeGetInfoScalable, 0, CAPABILITIES},
+ {".BDF", 4, 0, FreeTypeOpenScalable, 0,
+ FreeTypeGetInfoScalable, 0, CAPABILITIES},
+ {".pcf", 4, 0, FreeTypeOpenScalable, 0,
+ FreeTypeGetInfoScalable, 0, CAPABILITIES},
+ {".PCF", 4, 0, FreeTypeOpenScalable, 0,
+ FreeTypeGetInfoScalable, 0, CAPABILITIES},
+};
+
+static int num_alt_renderers =
+sizeof(alt_renderers) / sizeof(alt_renderers[0]);
+
+
void
FreeTypeRegisterFontFileFunctions(void)
{
@@ -1767,4 +3634,7 @@ FreeTypeRegisterFontFileFunctions(void)
for (i = 0; i < num_renderers; i++)
FontFileRegisterRenderer(&renderers[i]);
+
+ for (i = 0; i < num_alt_renderers; i++)
+ FontFilePriorityRegisterRenderer(&alt_renderers[i], -10);
}
diff --git a/src/FreeType/ftfuncs.h b/src/FreeType/ftfuncs.h
index 6d57abe..a08d521 100644
--- a/src/FreeType/ftfuncs.h
+++ b/src/FreeType/ftfuncs.h
@@ -1,5 +1,6 @@
/*
Copyright (c) 1998-2002 by Juliusz Chroboczek
+Copyright (c) 2003 After X-TT Project, All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -19,7 +20,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
-/* $XFree86: xc/lib/font/FreeType/ftfuncs.h,v 1.12 2002/10/01 00:02:10 alanh Exp $ */
+/* $XFree86: xc/lib/font/FreeType/ftfuncs.h,v 1.16 2003/11/02 04:30:56 dawes Exp $ */
/* Number of buckets in the hashtable holding faces */
#define NUMFACEBUCKETS 32
@@ -45,6 +46,7 @@ struct FTSize_s;
typedef struct _FTFace {
char *filename;
FT_Face face;
+ int bitmap;
struct _FTInstance *instances;
struct _FTInstance *active_instance;
struct _FTFace *next; /* link to next face in bucket */
@@ -58,14 +60,58 @@ typedef struct _FTNormalisedTransformation {
int xres, yres;
} FTNormalisedTransformationRec, *FTNormalisedTransformationPtr;
+#define FT_PROPORTIONAL 0
#define FT_MONOSPACED 1
#define FT_CHARCELL 2
#define FT_AVAILABLE_UNKNOWN 0
#define FT_AVAILABLE_NO 1
-#define FT_AVAILABLE_YES 2
+#define FT_AVAILABLE_METRICS 2
#define FT_AVAILABLE_RASTERISED 3
+#define FT_GET_GLYPH_BOTH 0x01
+#define FT_GET_GLYPH_METRICS_ONLY 0x02
+#define FT_GET_DUMMY 0x04
+#define FT_FORCE_CONSTANT_SPACING 0x08
+
+#define TTCAP_DOUBLE_STRIKE 0x0001
+#define TTCAP_DOUBLE_STRIKE_MKBOLD_EDGE_LEFT 0x0002
+#define TTCAP_DOUBLE_STRIKE_CORRECT_B_BOX_WIDTH 0x0008
+#define TTCAP_IS_VERY_LAZY 0x0010
+#define TTCAP_DISABLE_DEFAULT_VERY_LAZY 0x0020
+#define TTCAP_FORCE_C_LSB_FLAG 0x0100
+#define TTCAP_FORCE_C_RSB_FLAG 0x0200
+#define TTCAP_FORCE_C_OUTSIDE 0x0400
+#define TTCAP_MONO_CENTER 0x0800
+
+/* TTCap */
+struct TTCapInfo {
+ long flags;
+ double autoItalic;
+ double scaleWidth;
+ double scaleBBoxWidth;
+ double scaleBBoxHeight;
+ int doubleStrikeShift;
+ int adjustBBoxWidthByPixel;
+ int adjustLeftSideBearingByPixel;
+ int adjustRightSideBearingByPixel;
+ double scaleBitmap;
+ int forceConstantSpacingBegin;
+ int forceConstantSpacingEnd;
+ /* We don't compare */
+ int force_c_adjust_width_by_pixel;
+ int force_c_adjust_lsb_by_pixel;
+ int force_c_adjust_rsb_by_pixel;
+ int force_c_representative_metrics_char_code;
+ double force_c_scale_b_box_width;
+ double force_c_scale_b_box_height;
+ double force_c_scale_lsb;
+ double force_c_scale_rsb;
+ double vl_slant;
+ int lsbShiftOfBitmapAutoItalic;
+ int rsbShiftOfBitmapAutoItalic;
+};
+
/* An instance builds on a face by specifying the transformation
matrix. Multiple fonts may share the same instance. */
@@ -74,13 +120,21 @@ typedef struct _FTInstance {
FTFacePtr face; /* the associated face */
FT_Size size;
FTNormalisedTransformationRec transformation;
- int monospaced;
- int width; /* the width of all glyphs if monospaced */
- xCharInfo *charcellMetrics; /* the metrics if charcell is 1 */
+ FT_Int32 load_flags;
+ int spacing; /* actual spacing */
+ double pixel_size; /* to calc attributes (actual height) */
+ double pixel_width_unit_x; /* to calc horiz. width (cosine) */
+ double pixel_width_unit_y; /* to calc vert. width (cosine) */
+ xCharInfo *charcellMetrics; /* the header's metrics */
+ int averageWidth; /* the header's metrics */
+ long rawAverageWidth; /* the header's metrics */
+ double advance; /* the header's metrics */
+ xCharInfo *forceConstantMetrics;
FontBitmapFormatRec bmfmt;
unsigned nglyphs;
CharInfoPtr *glyphs; /* glyphs and available are used in parallel */
int **available;
+ struct TTCapInfo ttcap;
int refcount;
struct _FTInstance *next; /* link to next instance */
} FTInstanceRec, *FTInstancePtr;
@@ -90,23 +144,30 @@ typedef struct _FTInstance {
typedef struct _FTFont{
FTInstancePtr instance;
FTMappingRec mapping;
+ unsigned zero_idx;
+ FontInfoPtr info;
int nranges;
fsRange *ranges;
} FTFontRec, *FTFontPtr;
/* Prototypes for some local functions */
-static int FreeTypeOpenFace(FTFacePtr *facep, char *fileName);
+static int FreeTypeOpenFace(FTFacePtr *facep, char *FTFileName, char *realFileName, int faceNumber);
static void FreeTypeFreeFace(FTFacePtr face);
static int
- FreeTypeOpenInstance(FTInstancePtr *instancep,
- char *fileName, FTNormalisedTransformationPtr trans,
- int charcell, FontBitmapFormatPtr bmfmt);
+FreeTypeOpenInstance(FTInstancePtr *instancep, FTFacePtr face,
+ char *FTFileName, FTNormalisedTransformationPtr trans,
+ int spacing, FontBitmapFormatPtr bmfmt,
+ struct TTCapInfo *tmp_ttcap, FT_Int32 load_flags);
static void FreeTypeFreeInstance(FTInstancePtr instance);
static int
- FreeTypeInstanceGetGlyph(unsigned idx, CharInfoPtr *g, FTInstancePtr instance);
+FreeTypeInstanceGetGlyph(unsigned idx, int flags, CharInfoPtr *g, FTInstancePtr instance);
+static int
+FreeTypeInstanceGetGlyphMetrics(unsigned idx, int flags,
+ xCharInfo **metrics, FTInstancePtr instance );
static int
-FreeTypeRasteriseGlyph(CharInfoPtr tgp, FTInstancePtr instance, int hasMetrics);
+FreeTypeRasteriseGlyph(unsigned idx, int flags, CharInfoPtr tgp,
+ FTInstancePtr instance, int hasMetrics );
static void FreeTypeFreeFont(FTFontPtr font);
static void FreeTypeFreeXFont(FontPtr pFont, int freeProps);
static void FreeTypeUnloadXFont(FontPtr pFont);
@@ -114,9 +175,10 @@ static int
FreeTypeAddProperties(FTFontPtr font, FontScalablePtr vals, FontInfoPtr info,
char *fontname,
int rawAverageWidth);
-static int FreeTypeFontGetGlyph(unsigned code, CharInfoPtr *g, FTFontPtr font);
-static int FreeTypeFontGetDefaultGlyph(CharInfoPtr *g, FTFontPtr font);
+static int FreeTypeFontGetGlyph(unsigned code, int flags, CharInfoPtr *g, FTFontPtr font);
static int
-FreeTypeLoadFont(FTFontPtr *fontp, char *fileName,
- FontScalablePtr vals, FontEntryPtr entry,
- FontBitmapFormatPtr bmfmt);
+FreeTypeLoadFont(FTFontPtr font, FontInfoPtr info, FTFacePtr face,
+ char *FTFileName, FontScalablePtr vals, FontEntryPtr entry,
+ FontBitmapFormatPtr bmfmt, FT_Int32 load_flags,
+ struct TTCapInfo *tmp_ttcap, char *dynStrTTCapCodeRange,
+ int ttcap_spacing );
diff --git a/src/FreeType/fttools.c b/src/FreeType/fttools.c
index f6510af..33c3e26 100644
--- a/src/FreeType/fttools.c
+++ b/src/FreeType/fttools.c
@@ -21,7 +21,7 @@
THE SOFTWARE.
*/
-/* $XFree86: xc/lib/font/FreeType/fttools.c,v 1.4 2003/02/25 21:36:54 dawes Exp $ */
+/* $XFree86: xc/lib/font/FreeType/fttools.c,v 1.7 2003/11/20 22:36:37 dawes Exp $ */
#include "fontmisc.h"
#ifndef FONTMODULE
@@ -34,9 +34,10 @@
#endif
#include "font.h"
-#include "freetype/freetype.h"
-#include "freetype/ftsnames.h"
-#include "freetype/ttnameid.h"
+#include <ft2build.h>
+#include FT_FREETYPE_H
+#include FT_SFNT_NAMES_H
+#include FT_TRUETYPE_IDS_H
#include "ft.h"
#ifndef LSBFirst
@@ -51,14 +52,16 @@ int FTtoXReturnCode(int rc)
{
if(rc == 0x40)
return AllocError;
- else return BadFontFormat;
+ /* Anything else stops the font matching mechanism */
+ else return BadFontName;
+
}
/* Convert slen bytes from UCS-2 to ISO 8859-1. Byte specifies the
endianness of the string, max the maximum number of bytes written into
to. */
-int
-FTu2a(int slen, char *from, char *to, int byte, int max)
+static int
+FTu2a(int slen, FT_Byte *from, char *to, int byte, int max)
{
int i, n;
@@ -132,7 +135,7 @@ FTGetEnglishName(FT_Face face, int nid, char *name_return, int name_len)
len = name.string_len;
if(len > name_len)
len = name_len;
- memcpy(name_return, name.string, name_len);
+ memcpy(name_return, name.string, len);
return len;
}
diff --git a/src/Speedo/set_trns.c b/src/Speedo/set_trns.c
index b7f0e31..18d87ec 100644
--- a/src/Speedo/set_trns.c
+++ b/src/Speedo/set_trns.c
@@ -21,7 +21,7 @@ INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
*/
-/* $XFree86: xc/lib/font/Speedo/set_trns.c,v 1.5 2002/09/18 17:11:44 tsi Exp $ */
+/* $XFree86: xc/lib/font/Speedo/set_trns.c,v 1.6 2003/05/27 22:26:44 tsi Exp $ */
@@ -152,7 +152,6 @@ ufix8 format) /* Character format byte */
{
fix15 i,n;
ufix16 tmpufix16;
-fix15 constr;
n = sp_globals.no_X_orus + sp_globals.no_Y_orus - 2;
for (i = 0; i < n; i++) /* For each entry in control table ... */
@@ -162,7 +161,7 @@ for (i = 0; i < n; i++) /* For each entry in control table ... */
else
pointer += 2; /* Skip FROM and TO fields */
/* skip constraints field */
- constr = NEXT_BYTES (pointer, tmpufix16);
+ NEXT_BYTES (pointer, tmpufix16);
}
return pointer;
@@ -936,8 +935,10 @@ fix15 no_Y_ctrl_zones) /* Number of Y control zones */
{
fix15 i, j, n;
fix31 ppo;
+#if INCL_SQUEEZING || INCL_ISW
fix31 xppo0; /* top level pixels per oru */
fix31 yppo0; /* top level pixels per oru */
+#endif
ufix8 edge_org;
ufix8 edge;
ufix8 start_edge;
@@ -975,9 +976,9 @@ constr_org = 0;
sp_globals.rnd_xmin = 0; /* initialize the error for chars with no zone */
n = no_X_ctrl_zones;
ppo = sp_globals.tcb.xppo;
+#if INCL_SQUEEZING || INCL_ISW
xppo0 = sp_globals.tcb0.xppo;
yppo0 = sp_globals.tcb0.yppo;
-#if INCL_SQUEEZING || INCL_ISW
squeezed_x = FALSE;
#endif
diff --git a/src/Speedo/spfont.c b/src/Speedo/spfont.c
index 61ec6d4..7799eef 100644
--- a/src/Speedo/spfont.c
+++ b/src/Speedo/spfont.c
@@ -21,7 +21,7 @@
*
* Author: Dave Lemke, Network Computing Devices Inc
*/
-/* $XFree86: xc/lib/font/Speedo/spfont.c,v 3.12 2001/12/14 19:56:41 dawes Exp $ */
+/* $XFree86: xc/lib/font/Speedo/spfont.c,v 3.13 2003/05/27 22:26:44 tsi Exp $ */
/*
@@ -106,7 +106,9 @@ sp_get_glyphs(
unsigned int r;
CharInfoPtr encoding;
CharInfoPtr pDefault;
+#ifdef notyet
int itemSize;
+#endif
int err = Successful;
spf = (SpeedoFontPtr) pFont->fontPrivate;
@@ -119,12 +121,12 @@ sp_get_glyphs(
/* XXX - this should be much smarter */
/* make sure the glyphs are there */
+#ifdef notyet
if (charEncoding == Linear8Bit || charEncoding == TwoD8Bit)
itemSize = 1;
else
itemSize = 2;
-#ifdef notyet
if (!fsd->complete)
err = fs_load_glyphs(NULL, pFont, count, itemSize, chars);
#endif
diff --git a/src/Type1/arith.c b/src/Type1/arith.c
index 693b970..6caaa3f 100644
--- a/src/Type1/arith.c
+++ b/src/Type1/arith.c
@@ -26,7 +26,7 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
-/* $XFree86: xc/lib/font/Type1/arith.c,v 1.6 2002/02/18 20:51:57 herrb Exp $ */
+/* $XFree86: xc/lib/font/Type1/arith.c,v 1.7 2003/05/27 22:26:45 tsi Exp $ */
/* ARITH CWEB V0006 ******** */
/*
@@ -382,14 +382,12 @@ FPmult(fractpel u, fractpel v)
DLrightshift(w, FRACTBITS);
#ifndef LONG64
if (w.high != 0 || SIGNBITON(w.low)) {
- IfTrace2(TRUE,"FPmult: overflow, %px%p\n", u, v);
w.low = TOFRACTPEL(MAXSHORT);
}
return ((negative) ? -w.low : w.low);
#else
if (w & 0xffffffff80000000L ) {
- IfTrace2(TRUE,"FPmult: overflow, %px%p\n", u, v);
ret = TOFRACTPEL(MAXSHORT);
}
else
@@ -427,7 +425,6 @@ FPdiv(fractpel dividend, fractpel divisor)
w.high = dividend >> (LONGSIZE - FRACTBITS);
DLdiv(&w, divisor);
if (w.high != 0 || SIGNBITON(w.low)) {
- IfTrace2(TRUE,"FPdiv: overflow, %p/%p\n", dividend, divisor);
w.low = TOFRACTPEL(MAXSHORT);
}
return( (negative) ? -w.low : w.low);
@@ -435,7 +432,6 @@ FPdiv(fractpel dividend, fractpel divisor)
w = ((long)dividend) << FRACTBITS;
DLdiv(&w, divisor);
if (w & 0xffffffff80000000L ) {
- IfTrace2(TRUE,"FPdiv: overflow, %p/%p\n", dividend, divisor);
ret = TOFRACTPEL(MAXSHORT);
}
else
@@ -471,13 +467,11 @@ FPstarslash(fractpel a, /* result = a * b / c */
DLdiv(&w, c);
#ifndef LONG64
if (w.high != 0 || SIGNBITON(w.low)) {
- IfTrace3(TRUE,"FPstarslash: overflow, %p*%p/%p\n", a, b, c);
w.low = TOFRACTPEL(MAXSHORT);
}
return((negative) ? -w.low : w.low);
#else
if (w & 0xffffffff80000000L ) {
- IfTrace3(TRUE,"FPstarslash: overflow, %p*%p/%p\n", a, b, c);
ret = TOFRACTPEL(MAXSHORT);
}
else
diff --git a/src/Type1/cidchar.c b/src/Type1/cidchar.c
index e70d371..593337e 100644
--- a/src/Type1/cidchar.c
+++ b/src/Type1/cidchar.c
@@ -15,7 +15,7 @@
* The Original Software is CID font code that was developed by Silicon
* Graphics, Inc.
*/
-/* $XFree86: xc/lib/font/Type1/cidchar.c,v 1.9 2001/10/28 03:32:44 tsi Exp $ */
+/* $XFree86: xc/lib/font/Type1/cidchar.c,v 1.10 2003/05/27 22:26:45 tsi Exp $ */
#ifdef BUILDCID
#ifndef FONTMODULE
@@ -487,7 +487,6 @@ CIDGetCharMetrics(FontPtr pFont, FontInfo *fi, unsigned int charcode, double sxm
int
CIDGetAFM(FontPtr pFont, unsigned long count, unsigned char *chars, FontEncoding charEncoding, unsigned long *glyphCount, CharInfoPtr *glyphs, char *cidafmfile)
{
- int rc;
FILE *fp;
FontInfo *fi = NULL;
cidglyphs *cid;
@@ -496,7 +495,7 @@ CIDGetAFM(FontPtr pFont, unsigned long count, unsigned char *chars, FontEncoding
register CharInfoPtr pci;
CharInfoPtr pDefault;
- unsigned int firstRow, firstCol, numRows, code, char_row, char_col;
+ unsigned int firstCol, code, char_row, char_col;
double sxmult;
cid = (cidglyphs *)pFont->fontPrivate;
@@ -505,7 +504,7 @@ CIDGetAFM(FontPtr pFont, unsigned long count, unsigned char *chars, FontEncoding
if (!(fp = fopen(cidafmfile, "rb")))
return(BadFontName);
- if ((rc = CIDAFM(fp, &fi)) != 0) {
+ if (CIDAFM(fp, &fi) != 0) {
fprintf(stderr,
"There is something wrong with Adobe Font Metric file %s.\n",
cidafmfile);
@@ -579,8 +578,6 @@ CIDGetAFM(FontPtr pFont, unsigned long count, unsigned char *chars, FontEncoding
break;
case TwoD16Bit:
- firstRow = pFont->info.firstRow;
- numRows = pFont->info.lastRow - firstRow + 1;
while (count--) {
char_row = (*chars++);
char_col = (*chars++);
diff --git a/src/Type1/hints.c b/src/Type1/hints.c
index 5150647..81b8a2c 100644
--- a/src/Type1/hints.c
+++ b/src/Type1/hints.c
@@ -26,7 +26,7 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
-/* $XFree86: xc/lib/font/Type1/hints.c,v 1.7 2002/02/18 20:51:57 herrb Exp $ */
+/* $XFree86: xc/lib/font/Type1/hints.c,v 1.8 2003/05/27 22:26:45 tsi Exp $ */
/* HINTS CWEB V0006 ******** */
/*
@@ -113,9 +113,6 @@ CloseHints(struct fractpoint *hintP)
hintP->y -= oldHint[i].hint.y;
oldHint[i].inuse = FALSE;
-
- IfTrace3((HintDebug > 1)," Hint %d was open, hint=(%p,%p)\n",
- i, hintP->x, hintP->y);
}
}
}
@@ -143,16 +140,13 @@ multiple of 90 degrees.
if (hP->width.y == 0)
{
orientation = 'v'; /* vertical */
- IfTrace0((HintDebug > 0)," vertical hint\n");
}
else if (hP->width.x == 0)
{
orientation = 'h'; /* horizontal */
- IfTrace0((HintDebug > 0)," horizontal hint\n");
}
else
{
- IfTrace0((HintDebug > 0)," hint not vertical or horizontal\n");
hintP->x = hintP->y = 0;
return;
}
@@ -173,11 +167,6 @@ multiple of 90 degrees.
Abort("ComputeHint: invalid orientation");
}
- IfTrace4((HintDebug > 1),
- " currX=%p, currY=%p, currRef=%p, currWidth=%p\n",
- currX, currY,
- currRef, currWidth);
-
if ((hP->hinttype == 'b') /* Bar or stem */
|| (hP->hinttype == 's')) /* Serif */
{
@@ -193,9 +182,6 @@ multiple of 90 degrees.
/* align "ref" on pel boundary */
hintValue = FPROUND(currRef) - currRef;
}
- if (HintDebug > 2) {
- IfTrace1(TRUE," idealWidth=%d, ", idealWidth);
- }
}
else if (hP->hinttype == 'c') /* Curve extrema */
{
@@ -207,8 +193,6 @@ multiple of 90 degrees.
Abort("ComputeHint: invalid hinttype");
}
- IfTrace1((HintDebug > 1)," hintValue=%p", hintValue);
-
if (orientation == 'v') /* vertical */
{
hintP->x = hintValue;
@@ -236,14 +220,6 @@ ProcessHint(struct hintsegment *hP,
{
struct fractpoint thisHint;
- IfTrace4((HintDebug > 1)," ref=(%p,%p), width=(%p,%p)",
- hP->ref.x, hP->ref.y,
- hP->width.x, hP->width.y);
- IfTrace4((HintDebug > 1),", %c %c %c %c",
- hP->orientation, hP->hinttype,
- hP->adjusttype, hP->direction);
- IfTrace1((HintDebug > 1),", label=%d\n", hP->label);
-
if ((hP->adjusttype == 'm') /* Move */
|| (hP->adjusttype == 'a')) /* Adjust */
{
@@ -299,14 +275,9 @@ ProcessHint(struct hintsegment *hP,
{
Abort("ProcessHint: invalid adjusttype");
}
- IfTrace3((HintDebug > 1)," label=%d, thisHint=(%p,%p)\n",
- hP->label, thisHint.x, thisHint.y);
hintP->x += thisHint.x;
hintP->y += thisHint.y;
-
- IfTrace2((HintDebug > 1)," hint=(%p,%p)\n",
- hintP->x, hintP->y);
}
/*
@@ -643,28 +614,19 @@ DumpSubPaths(struct edgelist *anchor)
for (edge = anchor; VALIDEDGE(edge); edge = edge->link) {
if (ISPERMANENT(edge->flag))
continue;
- IfTrace0(TRUE, "BEGIN Subpath\n");
for (e2 = edge; !ISPERMANENT(e2->flag);) {
if (ISDOWN(e2->flag)) {
- IfTrace1(TRUE, ". Downgoing edge's top at %x\n", e2);
for (e = e2;; e = e->subpath) {
- IfTrace4(TRUE, ". . [%5d] %5d @ %x[%x]\n",
- e->ymin, *e->xvalues, e, e->flag);
for (y=e->ymin+1; y < e->ymax; y++)
- IfTrace2(TRUE, ". . [%5d] %5d \"\n", y, e->xvalues[y-e->ymin]);
e->flag |= ISPERMANENT(ON);
if (ISBREAK(e, e->subpath))
break;
}
}
else {
- IfTrace1(TRUE, ". Upgoing edge's top at %x\n", e2);
for (e = e2; !ISBREAK(e, e->subpath); e = e->subpath) { ; }
for (;; e=before(e)) {
- IfTrace4(TRUE, ". . [%5d] %5d @ %x[%x]\n",
- e->ymax-1, e->xvalues[e->ymax-1-e->ymin], e, e->flag);
for (y=e->ymax-2; y >= e->ymin; y--)
- IfTrace2(TRUE, ". . [%5d] %5d \"\n", y, e->xvalues[y-e->ymin]);
e->flag |= ISPERMANENT(ON);
if (e == e2)
break;
diff --git a/src/Type1/lines.c b/src/Type1/lines.c
index dec3f08..197943f 100644
--- a/src/Type1/lines.c
+++ b/src/Type1/lines.c
@@ -26,7 +26,7 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
-/* $XFree86: xc/lib/font/Type1/lines.c,v 1.4 2001/01/17 19:43:22 dawes Exp $ */
+/* $XFree86: xc/lib/font/Type1/lines.c,v 1.5 2003/05/27 22:26:45 tsi Exp $ */
/* LINES CWEB V0003 ******** */
/*
@@ -80,9 +80,6 @@ void StepLine(R, x1, y1, x2, y2)
{
register fractpel dy;
- IfTrace4((LineDebug > 0), ".....StepLine: (%p,%p) to (%p,%p)\n",
- x1, y1, x2, y2);
-
dy = y2 - y1;
/*
diff --git a/src/Type1/objects.c b/src/Type1/objects.c
index 57168b4..2f2d30a 100644
--- a/src/Type1/objects.c
+++ b/src/Type1/objects.c
@@ -26,7 +26,7 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
-/* $XFree86: xc/lib/font/Type1/objects.c,v 1.10 2002/02/18 20:51:57 herrb Exp $ */
+/* $XFree86: xc/lib/font/Type1/objects.c,v 1.11 2003/05/27 22:26:45 tsi Exp $ */
/* OBJECTS CWEB V0025 ******** */
/*
:h1.OBJECTS Module - TYPE1IMAGER Objects Common Routines
@@ -311,8 +311,6 @@ t1_Allocate(int size, /* number of bytes to allocate & initialize */
while (r == NULL) {
if (!GimeSpace()) {
- IfTrace1(TRUE, "malloc attempted %d bytes.\n",
- size + extra);
Abort("We have REALLY run out of memory");
}
r = (struct xobject *) xiMalloc(size + extra);
@@ -339,12 +337,6 @@ t1_Allocate(int size, /* number of bytes to allocate & initialize */
*p1++ = NULL;
}
- if (MemoryDebug > 1) {
- register long *L;
- L = (long *) r;
- IfTrace4(TRUE, "Allocating at %x: %x %x %x\n",
- L, L[-1], L[0], L[1]);
- }
return(r);
}
@@ -369,12 +361,6 @@ Free(pointer objPtr)
Abort("Free of already freed object?");
obj->type = INVALIDTYPE;
- if (MemoryDebug > 1) {
- register long *L;
- L = (long *) obj;
- IfTrace4(TRUE,"Freeing at %x: %x %x %x\n", L, L[-1], L[0], L[1]);
- }
-
xiFree((long *)obj);
}
@@ -407,8 +393,6 @@ t1_Permanent(pointer objPtr)
{
struct xobject *obj = (struct xobject *)objPtr; /* object to be made permanent */
- IfTrace1((MustTraceCalls),"Permanent(%z)\n", obj);
-
if ( (obj != NULL) && ( !(ISPERMANENT(obj->flag)) ) )
{
/* there is a non-NULL, temporary object to be made permanent.
@@ -454,8 +438,6 @@ xiTemporary(pointer objPtr)
{
register struct xobject *obj
= (struct xobject *)objPtr; /* object to be made permanent */
- IfTrace1((MustTraceCalls),"Temporary(%z)\n", obj);
-
if (obj != NULL) {
/* if it's already temporary, there's nothing to do. */
if ISPERMANENT(obj->flag)
@@ -504,8 +486,6 @@ t1_Dup(pointer objPtr)
= (struct xobject *)objPtr; /* object to be duplicated */
register char oldflag; /* copy of original object's flag byte */
- IfTrace1((MustTraceCalls),"Dup(%z)\n", obj);
-
if (obj == NULL)
return(NULL);
/* An immortal object must be Copy'ed, so that we get a mortal
@@ -592,12 +572,9 @@ Destroy(pointer objPtr)
{
register struct xobject *obj
= (struct xobject *)objPtr; /* object to be destroyed */
- IfTrace1((MustTraceCalls),"Destroy(%z)\n", obj);
-
if (obj == NULL)
return(NULL);
if (ISIMMORTAL(obj->flag)) {
- IfTrace1(TRUE,"Destroy of immortal object %z ignored\n", obj);
return(NULL);
}
if (ISPATHTYPE(obj->type))
@@ -937,24 +914,6 @@ Consume(int n, ...)
Destroy(obj);
}
}
-/*
-:h4.ObjectPostMortem() - Prints as Much as We Can About a Bad Object
-
-This is a subroutine of TypeErr() and ArgErr().
-*/
-
-/*ARGSUSED*/
-static void
-ObjectPostMortem(struct xobject *obj)
-{
-
- Pragmatics("Debug", 10);
- IfTrace2(TRUE,"Bad object is of %s type %z\n", TypeFmt(obj->type), obj);
-
- IfTrace0((obj == (struct xobject *) USER),
- "Suspect that InitImager() was omitted.\n");
- Pragmatics("Debug", 0);
-}
/*
:h3.TypeErr() - Handles "Invalid Object Type" Errors
@@ -981,9 +940,6 @@ TypeErr(char *name, /* Name of routine (for error message) */
sprintf(typemsg, "Wrong object type in %s. Expected %s; was %s.\n",
name, TypeFmt(expect), TypeFmt(obj->type));
- IfTrace0(TRUE,typemsg);
-
- ObjectPostMortem(obj);
if (MustCrash)
Abort("Terminating because of CrashOnUserError...");
@@ -1055,14 +1011,11 @@ ArgErr(char *string, /* description of error */
pointer objPtr, /* object, if any, that was in error */
pointer retPtr) /* object returned to caller or NULL */
{
- struct xobject *obj = (struct xobject *)objPtr;
struct xobject *ret = (struct xobject *)retPtr;
if (MustCrash)
LineIOTrace = TRUE;
- IfTrace1(TRUE,"ARGUMENT ERROR-- %s.\n", string);
- if (obj != NULL)
- ObjectPostMortem(obj);
+
if (MustCrash)
Abort("Terminating because of CrashOnUserError...");
else
diff --git a/src/Type1/objects.h b/src/Type1/objects.h
index 984ccbd..e64d00e 100644
--- a/src/Type1/objects.h
+++ b/src/Type1/objects.h
@@ -43,7 +43,7 @@
* The Original Software is CID font code that was developed by Silicon
* Graphics, Inc.
*/
-/* $XFree86: xc/lib/font/Type1/objects.h,v 1.14 2002/12/24 17:42:59 tsi Exp $ */
+/* $XFree86: xc/lib/font/Type1/objects.h,v 1.15 2003/05/27 22:26:45 tsi Exp $ */
/*SHARED*/
/*END SHARED*/
@@ -285,18 +285,6 @@ struct xobject {
/*END SHARED*/
/*SHARED*/
-#define IfTrace0(condition,model)
-#define IfTrace1(condition,model,arg0)
-#define IfTrace2(condition,model,arg0,arg1)
-#define IfTrace3(condition,model,arg0,arg1,arg2)
-#define IfTrace4(condition,model,arg0,arg1,arg2,arg3)
-#define IfTrace5(condition,model,arg0,arg1,arg2,arg3,arg4)
-#define IfTrace6(condition,model,arg0,arg1,arg2,arg3,arg4,arg5)
-
-#if 0
-void Trace0();
-char *Trace1(),*Trace2(),*Trace3(),*Trace4(),*Trace5(),*Trace6();
-#endif
#ifdef GLOBALS
diff --git a/src/Type1/paths.c b/src/Type1/paths.c
index 6291d68..3fec84e 100644
--- a/src/Type1/paths.c
+++ b/src/Type1/paths.c
@@ -26,7 +26,7 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
-/* $XFree86: xc/lib/font/Type1/paths.c,v 1.7 2002/02/18 20:51:57 herrb Exp $ */
+/* $XFree86: xc/lib/font/Type1/paths.c,v 1.8 2003/05/27 22:26:46 tsi Exp $ */
/* PATHS CWEB V0021 ******** */
/*
@@ -211,8 +211,6 @@ t1_Loc(struct XYspace *S, /* coordinate space to interpret X,Y */
register struct segment *r;
- IfTrace3((MustTraceCalls),"..Loc(S=%z, x=%f, y=%f)\n", S, &x, &y);
-
r = (struct segment *)Allocate(sizeof(struct segment), &movetemplate, 0);
TYPECHECK("Loc", S, SPACETYPE, r, (0), struct segment *);
@@ -232,8 +230,6 @@ ILoc(struct XYspace *S, /* coordinate space to interpret X,Y */
{
register struct segment *r;
- IfTrace3((MustTraceCalls),"..ILoc(S=%z, x=%d, y=%d)\n",
- S, (long) x, (long) y);
r = (struct segment *)Allocate(sizeof(struct segment), &movetemplate, 0);
TYPECHECK("Loc", S, SPACETYPE, r, (0), struct segment *);
@@ -257,8 +253,6 @@ so it is not provided.
struct segment *
SubLoc(struct segment *p1, struct segment *p2)
{
- IfTrace2((MustTraceCalls),"SubLoc(%z, %z)\n", p1, p2);
-
ARGCHECK(!ISLOCATION(p1), "SubLoc: bad first arg", p1, NULL, (0), struct segment *);
ARGCHECK(!ISLOCATION(p2), "SubLoc: bad second arg", p2, NULL, (0), struct segment *);
p1 = UniquePath(p1);
@@ -301,8 +295,6 @@ This involves just creating and filling out a segment structure:
struct segment *
Line(struct segment *P) /* relevant coordinate space */
{
-
- IfTrace1((MustTraceCalls),"..Line(%z)\n", P);
ARGCHECK(!ISLOCATION(P), "Line: arg not a location", P, NULL, (0), struct segment *);
P = UniquePath(P);
@@ -345,7 +337,6 @@ Bezier(struct segment *B, /* second control point */
register struct beziersegment *r; /* output segment */
- IfTrace3((MustTraceCalls),"..Bezier(%z, %z, %z)\n", B, C, D);
ARGCHECK(!ISLOCATION(B), "Bezier: bad B", B, NULL, (2,C,D), struct beziersegment *);
ARGCHECK(!ISLOCATION(C), "Bezier: bad C", C, NULL, (2,B,D), struct beziersegment *);
ARGCHECK(!ISLOCATION(D), "Bezier: bad D", D, NULL, (2,B,C), struct beziersegment *);
@@ -447,8 +438,6 @@ rules.
struct segment *
Join(struct segment *p1, struct segment *p2)
{
- IfTrace2((MustTraceCalls && PathDebug > 1),"..Join(%z, %z)\n", p1, p2);
- IfTrace2((MustTraceCalls && PathDebug <=1),"..Join(%x, %x)\n", p1, p2);
/*
We start with a whole bunch of very straightforward argument tests:
*/
@@ -603,7 +592,6 @@ t1_ClosePath(struct segment *p0, /* path to close */
register fractpel firstx = 0,firsty = 0; /* start position of sub path */
register struct segment *lastnonhint = NULL; /* last non-hint segment in path */
- IfTrace1((MustTraceCalls),"ClosePath(%z)\n", p0);
if (p0 != NULL && p0->type == TEXTTYPE)
return(UniquePath(p0));
if (p0->type == STROKEPATHTYPE)
@@ -650,9 +638,6 @@ At each break, we insert a close segment.
if (r->dest.x != 0 || r->dest.y != 0) {
if (r->dest.x <= CLOSEFUDGE && r->dest.x >= -CLOSEFUDGE
&& r->dest.y <= CLOSEFUDGE && r->dest.y >= -CLOSEFUDGE) {
- IfTrace2((PathDebug),
- "ClosePath forced closed by (%p,%p)\n",
- r->dest.x, r->dest.y);
lastnonhint->dest.x += r->dest.x;
lastnonhint->dest.y += r->dest.y;
r->dest.x = r->dest.y = 0;
@@ -707,8 +692,6 @@ Reverse(struct segment *p) /* full path to reverse */
register struct segment *r; /* output path built here */
register struct segment *nextp; /* contains next sub-path */
- IfTrace1((MustTraceCalls),"Reverse(%z)\n", p);
-
if (p == NULL)
return(NULL);
@@ -883,8 +866,6 @@ ReverseSubPaths(struct segment *p) /* input path */
register struct segment *nomove; /* the part of sub-path without move segment */
struct fractpoint delta;
- IfTrace1((MustTraceCalls),"ReverseSubPaths(%z)\n", p);
-
if (p == NULL)
return(NULL);
@@ -1024,7 +1005,6 @@ PathTransform(struct segment *p0, /* path to transform */
}
default:
- IfTrace1(TRUE,"path = %z\n", p);
Abort("PathTransform: invalid segment");
}
oldx += savex;
@@ -1091,8 +1071,6 @@ QueryLoc(struct segment *P, /* location to query, not consumed */
struct XYspace *S, /* XY space to return coordinates in */
double *xP, double *yP) /* coordinates returned here */
{
- IfTrace4((MustTraceCalls),"QueryLoc(P=%z, S=%z, (%x, %x))\n",
- P, S, xP, yP);
if (!ISLOCATION(P)) {
ArgErr("QueryLoc: first arg not a location", P, NULL);
return;
@@ -1124,8 +1102,6 @@ QueryPath(struct segment *path, /* path to check */
{
register int coerced = FALSE; /* did I coerce a text path? */
- IfTrace3((MustTraceCalls), "QueryPath(%z, %x, %x, ...)\n",
- path, typeP, Bp);
if (path == NULL) {
*typeP = -1;
return;
@@ -1204,9 +1180,6 @@ QueryBounds(struct segment *p0, /* object to check for bound */
int coerced = FALSE; /* we have coerced the path from another object */
double x1,y1,x2,y2,x3,y3,x4,y4; /* corners of rectangle in space X */
- IfTrace2((MustTraceCalls), "QueryBounds(%z, %z,", p0, S);
- IfTrace4((MustTraceCalls), " %x, %x, %x, %x)\n",
- xminP, yminP, xmaxP, ymaxP);
if (S->type != SPACETYPE) {
ArgErr("QueryBounds: bad XYspace", S, NULL);
return;
@@ -1379,7 +1352,6 @@ to ask about an entire path.
struct segment *
DropSegment(struct segment *path)
{
- IfTrace1((MustTraceCalls),"DropSegment(%z)\n", path);
if (path != NULL && path->type == STROKEPATHTYPE)
path = CoercePath(path);
ARGCHECK((path == NULL || !ISPATHANCHOR(path)),
@@ -1401,7 +1373,6 @@ first segment only.
struct segment *
HeadSegment(struct segment *path) /* input path */
{
- IfTrace1((MustTraceCalls),"HeadSegment(%z)\n", path);
if (path == NULL)
return(NULL);
if (path->type == STROKEPATHTYPE)
@@ -1427,79 +1398,4 @@ HeadSegment(struct segment *path) /* input path */
void
DumpPath(struct segment *p)
{
- register fractpel x,y;
- register fractpel lastx,lasty;
- double roundness;
-
- IfTrace1(TRUE,"Dumping path, anchor=%x:\n", p);
- lastx = lasty = 0;
-
- for (;p != NULL; p=p->link) {
-
- IfTrace0(TRUE,". ");
- x = p->dest.x;
- y = p->dest.y;
- switch (p->type) {
-
- case LINETYPE:
- IfTrace1(TRUE,". line<%x> to", (long) p->flag);
- IfTrace4(TRUE," (%p,%p), delta=(%p,%p)",
- x + lastx, y + lasty, x, y);
- break;
-
- case MOVETYPE:
- IfTrace1(TRUE,"MOVE<%x> to", (long) p->flag);
- IfTrace4(TRUE,"(%p,%p), delta=(%p,%p)",
- x + lastx, y + lasty, x, y);
- break;
-
- case CONICTYPE:
- {
- register struct conicsegment *cp = (struct conicsegment *) p;
-
- roundness = cp->roundness;
- IfTrace2(TRUE, ". conic to (%p,%p),",
- x + lastx, y + lasty);
- IfTrace3(TRUE," M=(%p,%p), r=%f", cp->M.x + lastx,
- cp->M.y + lasty, &roundness);
- }
- break;
-
- case BEZIERTYPE:
- {
- IfTrace4(TRUE,". bezier to (%p,%p), B=(%p,%p)",
- x + lastx, y + lasty,
- bp->B.x + lastx, bp->B.y + lasty);
- IfTrace2(TRUE, ", C=(%p,%p)",
- bp->C.x + lastx, bp->C.y + lasty);
- }
- break;
-
- case HINTTYPE:
- {
- IfTrace4(TRUE,". hint ref=(%p,%p), width=(%p,%p)",
- hp->ref.x + lastx, hp->ref.y + lasty,
- hp->width.x, hp->width.y);
- IfTrace4(TRUE, ", %c %c %c %c",
- hp->orientation, hp->hinttype,
- hp->adjusttype, hp->direction);
- IfTrace1(TRUE, ", %ld", (long) hp->label);
- }
- break;
-
- case TEXTTYPE:
-#ifdef notyet
- DumpText(p);
-#endif
- break;
-
- default:
- IfTrace0(TRUE, "bad path segment?");
- }
- IfTrace1(TRUE," at %x\n", p);
- lastx += x;
- lasty += y;
- }
}
-
-
diff --git a/src/Type1/regions.c b/src/Type1/regions.c
index 724d3f5..e24bacc 100644
--- a/src/Type1/regions.c
+++ b/src/Type1/regions.c
@@ -26,7 +26,7 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
-/* $XFree86: xc/lib/font/Type1/regions.c,v 3.8 2002/02/18 20:51:57 herrb Exp $ */
+/* $XFree86: xc/lib/font/Type1/regions.c,v 3.9 2003/05/27 22:26:46 tsi Exp $ */
/* REGIONS CWEB V0023 LOTS */
/*
:h1 id=regions.REGIONS Module - Regions Operator Handler
@@ -297,8 +297,6 @@ NewEdge(pel xmin, pel xmax, /* X extent of edge */
register struct edgelist *r; /* returned structure */
register int iy; /* ymin adjusted for 'long' alignment purposes */
- IfTrace2((RegionDebug),"....new edge: ymin=%d, ymax=%d ",
- (long)ymin, (long) ymax);
if (ymin >= ymax)
Abort("newedge: height not positive");
/*
@@ -332,7 +330,6 @@ Allocate() makes everything it allocates be in multiples of longs.
*/
LONGCOPY(&r[1], xvalues, (ymax - iy) * sizeof(pel) + sizeof(long) - 1);
- IfTrace1((RegionDebug),"result=%x\n", r);
return(r);
}
@@ -358,8 +355,6 @@ discard(struct edgelist *left, /* all edges between here exclusive */
{
register struct edgelist *beg,*end,*p;
- IfTrace2((RegionDebug > 0),"discard: l=%x, r=%x\n", left, right);
-
beg = left->link;
if (beg == right)
return;
@@ -367,7 +362,6 @@ discard(struct edgelist *left, /* all edges between here exclusive */
for (p = beg; p != right; p = p->link) {
if (p->link == NULL && right != NULL)
Abort("discard(): ran off end");
- IfTrace1((RegionDebug > 0),"discarding %x\n", p);
p->ymin = p->ymax = 32767;
end = p;
}
@@ -400,8 +394,6 @@ Unwind(struct edgelist *area) /* input area modified in place */
register int y; /* ymin of current swath */
register int count,newcount; /* winding count registers */
- IfTrace1((RegionDebug>0),"...Unwind(%z)\n", area);
-
while (VALIDEDGE(area)) {
count = 0;
@@ -469,8 +461,6 @@ Interior(struct segment *p, /* take interior of this path */
char tempflag; /* flag; is path temporary? */
char Cflag; /* flag; should we apply continuity? */
- IfTrace2((MustTraceCalls),". INTERIOR(%z, %d)\n", p, (long) fillrule);
-
if (p == NULL)
return(NULL);
/*
@@ -547,8 +537,6 @@ The hints data structure must be initialized once for each path.
x = lastx + p->dest.x;
y = lasty + p->dest.y;
- IfTrace2((HintDebug > 0),"Ending point = (%p,%p)\n", x, y);
-
nextP = p->link;
/*
@@ -567,8 +555,6 @@ the first on the path), we need to close (reverse) any open hints.
if (ProcessHints)
if ((p->type == MOVETYPE) && (p->last == NULL)) {
CloseHints(&hint);
- IfTrace2((HintDebug>0),"Closed point= (%p,%p)\n",
- x+hint.x, y+hint.y);
}
/*
@@ -599,8 +585,6 @@ We now apply the full hint value to the ending point of the path segment.
x += hint.x;
y += hint.y;
- IfTrace2((HintDebug>0),"Hinted ending point = (%p,%p)\n", x, y);
-
switch(p->type) {
case LINETYPE:
@@ -706,27 +690,19 @@ ChangeDirection(int type, /* CD_FIRST, CD_CONTINUE, or CD_LAST */
fractpel dy) /* direction and magnitude of change in y */
{
register fractpel ymin,ymax; /* minimum and maximum Y since last call */
- register fractpel x_at_ymin,x_at_ymax; /* their respective X's */
register pel iy; /* nearest integer pel to 'y' */
register pel idy; /* nearest integer pel to 'dy' */
register int ydiff; /* allowed Y difference in 'currentworkarea' */
- IfTrace4((RegionDebug>0),"Change Y direction (%d) from (%p,%p), dy=%p\n",
- (long) type, x, y, dy);
-
if (type != CD_FIRST) {
if (R->lastdy > 0) {
ymin = R->firsty;
- x_at_ymin = R->firstx;
ymax = y;
- x_at_ymax = x;
}
else {
ymin = y;
- x_at_ymin = x;
ymax = R->firsty;
- x_at_ymax = R->firstx;
}
if (ymax < ymin)
@@ -850,16 +826,6 @@ SortSwath(struct edgelist *anchor, /* list being built */
register struct edgelist *before,*after;
struct edgelist base;
- if (RegionDebug > 0) {
- if (RegionDebug > 2) {
- IfTrace3(TRUE,"SortSwath(anchor=%z, edge=%z, fcn=%x)\n",
- anchor, edge, swathfcn);
- }
- else {
- IfTrace3(TRUE,"SortSwath(anchor=%x, edge=%x, fcn=%x)\n",
- anchor, edge, swathfcn);
- }
- }
if (anchor == NULL)
return(edge);
@@ -904,8 +870,6 @@ If the bottom of 'after' is above the bottom of the swath,
break;
}
else if (TOP(after) > TOP(edge)) {
- IfTrace0((BOTTOM(edge) < TOP(after) && RegionDebug > 0),
- "SortSwath: disjoint edges\n");
if (BOTTOM(edge) > TOP(after)) {
after = SortSwath(after,
splitedge(edge, TOP(after)), swathfcn);
@@ -934,13 +898,9 @@ contains all the edges before. Whew! A simple matter now of adding
*/
before->link = edge;
if (RegionDebug > 1) {
- IfTrace3(TRUE,"SortSwath: in between %x and %x are %x",
- before, after, edge);
while (edge->link != NULL) {
edge = edge->link;
- IfTrace1(TRUE," and %x", edge);
}
- IfTrace0(TRUE,"\n");
}
else
for (; edge->link != NULL; edge = edge->link) { ; }
@@ -966,8 +926,6 @@ splitedge(struct edgelist *list, /* area to split */
register struct edgelist *r; /* temp pointer to new structure */
register struct edgelist *lastlist; /* temp pointer to last 'list' value */
- IfTrace2((RegionDebug > 1),"splitedge of %x at %d ", list, (long) y);
-
lastlist = new = NULL;
while (list != NULL) {
@@ -1019,7 +977,6 @@ Then, we return the caller a pointer to 'new':
Abort("null splitedge");
lastlist->link = NULL;
last->link = list;
- IfTrace1((RegionDebug > 1),"yields %x\n", new);
return(new);
}
@@ -1099,7 +1056,6 @@ recursively with the part of the edge that is below the crossing point:
y -= TOP(edge);
if (h0 <= 0) {
- IfTrace0((RegionDebug>0),"swathxsort: exactly equal edges\n");
return(before);
}
@@ -1136,9 +1092,6 @@ SwathUnion(struct edgelist *before0, /* edge before the swath */
register struct edgelist *before,*after; /* edge before and after */
int h0; /* saves initial height */
- IfTrace2((RegionDebug > 1),"SwathUnion entered, before=%x, edge=%x\n",
- before0, edge);
-
h0 = h = edge->ymax - edge->ymin;
if (h <= 0)
Abort("SwathUnion: 0 height swath?");
@@ -1176,9 +1129,6 @@ the height by that amount.
if (after == NULL || TOP(after) != TOP(edge) ||
after->xvalues[0] > rightedge->xvalues[0]) {
- IfTrace2((RegionDebug > 1),
- "SwathUnion starts disjoint: before=%x after=%x\n",
- before, after);
/*
On this side of the the above 'if', the new edge is disjoint from the
existing edges in the swath. This is the picture:
@@ -1243,9 +1193,6 @@ out the new situation:
h -= touches(h, rightedge->xvalues, after->xvalues);
- IfTrace3((RegionDebug > 1),
- "SwathUnion is overlapped until %d: before=%x after=%x\n",
- (long) TOP(edge) + h, before, after);
/*
OK, if we touched either of our neighbors we need to split at that point
and recursively sort the split edge onto the list. One tricky part
@@ -1520,7 +1467,6 @@ MoreWorkArea(struct region *R, /* region we are generating */
* need to store:
*/
if (++idy > currentsize) {
- IfTrace1((RegionDebug > 0),"Allocating edge of %d pels\n", idy);
if (currentworkarea != workedge)
NonObjectFree(currentworkarea);
currentworkarea = (pel *)Allocate(0, NULL, idy * sizeof(pel));
@@ -1545,29 +1491,19 @@ BoxClip(struct region *R, /* region to clip */
struct edgelist anchor; /* pretend edgelist to facilitate discards */
register struct edgelist *e,*laste;
- IfTrace1((OffPageDebug),"BoxClip of %z:\n", R);
-
R = UniqueRegion(R);
if (xmin > R->xmin) {
- IfTrace2((OffPageDebug),"BoxClip: left clip old %d new %d\n",
- (long) R->xmin, (long) xmin);
R->xmin = xmin;
}
if (xmax < R->xmax) {
- IfTrace2((OffPageDebug),"BoxClip: right clip old %d new %d\n",
- (long) R->xmax, (long) xmax);
R->xmax = xmax;
}
if (ymin > R->ymin) {
- IfTrace2((OffPageDebug),"BoxClip: top clip old %d new %d\n",
- (long) R->ymin, (long) ymin);
R->ymin = ymin;
}
if (ymax < R->ymax) {
- IfTrace2((OffPageDebug),"BoxClip: bottom clip old %d new %d\n",
- (long) R->ymax, (long) ymax);
R->ymax = ymax;
}
@@ -1653,11 +1589,6 @@ RegionBounds(struct region *R)
void
DumpArea(struct region *area)
{
- IfTrace1(TRUE,"Dumping area %x,", area);
- IfTrace4(TRUE," X %d:%d Y %d:%d;", (long) area->xmin,
- (long) area->xmax, (long) area->ymin,(long) area->ymax);
- IfTrace4(TRUE," origin=(%p,%p), ending=(%p,%p)\n",
- area->origin.x, area->origin.y, area->ending.x, area->ending.y);
DumpEdges(area->anchor);
}
@@ -1684,30 +1615,20 @@ out:
Abort("EDGE ERROR: overlapping swaths"); */
}
-static pel RegionDebugYMin = MINPEL;
-static pel RegionDebugYMax = MAXPEL;
-
void
DumpEdges(struct edgelist *edges)
{
register struct edgelist *p,*p2;
register pel ymin = MINPEL;
register pel ymax = MINPEL;
- register int y;
if (edges == NULL) {
- IfTrace0(TRUE," NULL area.\n");
return;
}
if (RegionDebug <= 1) {
for (p=edges; p != NULL; p = p->link) {
edgecheck(p, ymin, ymax);
ymin = p->ymin; ymax = p->ymax;
- IfTrace3(TRUE,". at %x type=%d flag=%x",
- p, (long) p->type,(long) p->flag);
- IfTrace4(TRUE," bounding box HxW is %dx%d at (%d,%d)\n",
- (long) ymax - ymin, (long) p->xmax - p->xmin,
- (long) p->xmin, (long) ymin);
}
}
else {
@@ -1718,27 +1639,8 @@ DumpEdges(struct edgelist *edges)
ymin = p2->ymin;
ymax = p2->ymax;
- if (RegionDebug > 3 || (ymax > RegionDebugYMin
- && ymin < RegionDebugYMax)) {
- IfTrace2 (TRUE,". Swath from %d to %d:\n",
- ymin, ymax);
- for (p=p2; INSWATH(p,ymin,ymax); p = p->link) {
- IfTrace4(TRUE,". . at %x[%x] range %d:%d, ",
- p, (long) p->flag,
- (long) p->xmin, (long)p->xmax);
- IfTrace1(TRUE, "subpath=%x,\n", p->subpath);
- }
- }
- for (y=MAX(ymin,RegionDebugYMin); y < MIN(ymax, RegionDebugYMax); y++) {
- IfTrace1(TRUE,". . . Y[%5d] ", (long) y);
- for (p=p2; INSWATH(p,ymin,ymax); p = p->link)
- IfTrace1(TRUE,"%5d ",
- (long) p->xvalues[y - ymin]);
- IfTrace0(TRUE,"\n");
- }
while (INSWATH(p2, ymin, ymax))
p2 = p2->link;
}
}
}
-
diff --git a/src/Type1/scanfont.c b/src/Type1/scanfont.c
index b8aff94..7b2db30 100644
--- a/src/Type1/scanfont.c
+++ b/src/Type1/scanfont.c
@@ -45,7 +45,7 @@
* The Original Software is CID font code that was developed by Silicon
* Graphics, Inc.
*/
-/* $XFree86: xc/lib/font/Type1/scanfont.c,v 1.15 2001/07/25 15:04:55 dawes Exp $ */
+/* $XFree86: xc/lib/font/Type1/scanfont.c,v 1.16 2003/05/27 22:26:46 tsi Exp $ */
#ifndef FONTMODULE
#include <string.h>
@@ -74,7 +74,6 @@ static cidrange *notdefrangeP;
static cidrange *cidrangeP;
extern int FDArrayIndex;
static boolean CIDWantFontInfo;
-static boolean InFDArray;
static psobj inputFile1;
#endif
@@ -1621,14 +1620,11 @@ scan_cidfont(cidfont *CIDFontP, cmapres *CMapP)
FILE *fileP;
FILE *fileP1;
char *nameP;
- char *p;
int namelen;
int i, j;
int cread, rangecnt;
unsigned int char_row, char_col;
- InFDArray = FALSE;
-
filetype[0] = 'r';
filetype[1] = 'b';
filetype[2] = '\0';
@@ -1657,7 +1653,7 @@ scan_cidfont(cidfont *CIDFontP, cmapres *CMapP)
fclose(fileP);
if (cread > 17) {
if (strncmp(buf, "%!", 2) ||
- (p = strstr(buf, "Resource-CIDFont")) == NULL)
+ strstr(buf, "Resource-CIDFont") == NULL)
return(SCAN_FILE_OPEN_ERROR);
} else
return(SCAN_FILE_OPEN_ERROR);
@@ -1687,7 +1683,7 @@ scan_cidfont(cidfont *CIDFontP, cmapres *CMapP)
fclose(fileP1);
if (cread > 17) {
if (strncmp(buf, "%!", 2) ||
- (p = strstr(buf, "Resource-CMap")) == NULL)
+ strstr(buf, "Resource-CMap") == NULL)
return(SCAN_FILE_OPEN_ERROR);
} else
return(SCAN_FILE_OPEN_ERROR);
@@ -1984,8 +1980,6 @@ scan_cidfont(cidfont *CIDFontP, cmapres *CMapP)
case TOKEN_LITERAL_NAME:
/* Look up the name */
tokenStartP[tokenLength] = '\0';
- if (0 == strncmp(tokenStartP,"FDArray",7))
- InFDArray = TRUE;
if (CIDWantFontInfo) {
rc = FindDictValue(CIDFontP->CIDfontInfoP);
diff --git a/src/Type1/spaces.c b/src/Type1/spaces.c
index 8eb4b52..9c79954 100644
--- a/src/Type1/spaces.c
+++ b/src/Type1/spaces.c
@@ -26,7 +26,7 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
-/* $XFree86: xc/lib/font/Type1/spaces.c,v 3.10 2002/02/18 20:51:57 herrb Exp $ */
+/* $XFree86: xc/lib/font/Type1/spaces.c,v 3.11 2003/05/27 22:26:47 tsi Exp $ */
/* SPACES CWEB V0021 ******** */
/*
:h1 id=spaces.SPACES Module - Handles Coordinate Spaces
@@ -282,8 +282,6 @@ Context(pointer device, /* device token */
register int n; /* will hold device context number */
register struct XYspace *S; /* XYspace constructed */
- IfTrace2((MustTraceCalls),"Context(%x, %f)\n", device, &units);
-
ARGCHECK((device == NULL), "Context of NULLDEVICE not allowed",
NULL, IDENTITY, (0), struct XYspace *);
ARGCHECK((units == 0.0), "Context: bad units", NULL, IDENTITY, (0), struct XYspace *);
@@ -751,9 +749,6 @@ t1_Transform(struct xobject *obj,
{
double M[2][2];
- IfTrace1((MustTraceCalls),"Transform(%z,", obj);
- IfTrace4((MustTraceCalls)," %f %f %f %f)\n", &cxx, &cyx, &cxy, &cyy);
-
M[0][0] = cxx;
M[0][1] = cyx;
M[1][0] = cxy;
@@ -772,7 +767,7 @@ t1_Scale(struct xobject *obj, /* object to scale */
double sx, double sy) /* scale factors in x and y */
{
double M[2][2];
- IfTrace3((MustTraceCalls),"Scale(%z, %f, %f)\n", obj, &sx, &sy);
+
M[0][0] = sx;
M[1][1] = sy;
M[1][0] = M[0][1] = 0.0;
@@ -794,9 +789,6 @@ xiRotate(struct xobject *obj, /* object to be transformed */
{
double M[2][2];
-
- IfTrace2((MustTraceCalls),"Rotate(%z, %f)\n", obj, &degrees);
-
M[0][0] = M[1][1] = DegreeCos(degrees);
M[1][0] = - (M[0][1] = DegreeSin(degrees));
ConsiderContext(obj, M);
@@ -1000,12 +992,4 @@ FormatFP(char *string, /* output string */
void
DumpSpace(struct XYspace *S)
{
- IfTrace4(TRUE,"--Coordinate space at %x,ID=%d,convert=%x,iconvert=%x\n",
- S, S->ID, S->convert, S->iconvert);
- IfTrace2(TRUE," | %12.3f %12.3f |",
- &S->tofract.normal[0][0], &S->tofract.normal[0][1]);
- IfTrace2(TRUE," [ %p %p ]\n", S->itofract[0][0], S->itofract[0][1]);
- IfTrace2(TRUE," | %12.3f %12.3f |",
- &S->tofract.normal[1][0], &S->tofract.normal[1][1]);
- IfTrace2(TRUE," [ %p %p ]\n", S->itofract[1][0], S->itofract[1][1]);
}
diff --git a/src/Type1/t1funcs.c b/src/Type1/t1funcs.c
index 20b7b66..70da203 100644
--- a/src/Type1/t1funcs.c
+++ b/src/Type1/t1funcs.c
@@ -71,7 +71,7 @@
* The Original Software is CID font code that was developed by Silicon
* Graphics, Inc.
*/
-/* $XFree86: xc/lib/font/Type1/t1funcs.c,v 3.30 2002/12/09 17:29:59 dawes Exp $ */
+/* $XFree86: xc/lib/font/Type1/t1funcs.c,v 3.33 2003/07/19 13:16:40 tsi Exp $ */
/*
@@ -204,7 +204,6 @@ CIDOpenScalable (FontPathElementPtr fpe,
glyph,
scan,
image;
- int pad,wordsize; /* scan & image in bits */
long *pool; /* memory pool for ximager objects */
int size; /* for memory size calculations */
struct XYspace *S; /* coordinate space for character */
@@ -227,8 +226,9 @@ CIDOpenScalable (FontPathElementPtr fpe,
#endif
#if defined(CID_ALL_CHARS)
char *cf;
-#endif
+#else
long sAscent, sDescent;
+#endif
/* check the font name */
len = strlen(fileName);
@@ -325,9 +325,6 @@ CIDOpenScalable (FontPathElementPtr fpe,
if (rc != Successful)
return rc;
- pad = glyph * 8;
- wordsize = scan * 8;
-
#define PAD(bits, pad) (((bits)+(pad)-1)&-(pad))
if (!(pFont = CreateFontRec()))
@@ -461,8 +458,10 @@ CIDOpenScalable (FontPathElementPtr fpe,
/* CID-keyed are not constant-width fonts. */
pFont->info.constantWidth = 0;
+#ifndef CID_ALL_CHARS
sAscent = CIDFontP->CIDfontInfoP[CIDFONTBBOX].value.data.arrayP[3].data.integer;
sDescent = -CIDFontP->CIDfontInfoP[CIDFONTBBOX].value.data.arrayP[1].data.integer;
+#endif
if (strncmp(entry->name.name, "-bogus", 6)) {
#ifdef CID_ALL_CHARS
@@ -508,8 +507,7 @@ Type1OpenScalable (FontPathElementPtr fpe,
struct XYspace *S; /* coordinate space for character */
struct region *area;
CharInfoRec *glyphs;
- register int i;
- int len, rc, count = 0;
+ int len, rc, count = 0, i = 0;
struct type1font *type1;
char *p;
FontMapPtr mapping = NULL;
@@ -617,6 +615,9 @@ Type1OpenScalable (FontPathElementPtr fpe,
no_mapping=1; /* font's native encoding vector */
}
+ pFont->info.firstCol = 255;
+ pFont->info.lastCol = 0;
+
if(!no_mapping) {
mapping = FontEncMapFind(p,
FONT_ENCODING_POSTSCRIPT, -1, -1,
@@ -626,14 +627,11 @@ Type1OpenScalable (FontPathElementPtr fpe,
FONT_ENCODING_UNICODE, -1, -1,
fileName);
if(!mapping)
- no_mapping=2;
+ goto NoEncoding;
else
no_mapping=0;
}
- pFont->info.firstCol = 255;
- pFont->info.lastCol = 0;
-
for (i=0; i < 256; i++) {
long h,w;
long paddedW;
@@ -757,7 +755,8 @@ Type1OpenScalable (FontPathElementPtr fpe,
Destroy(area);
}
-
+ NoEncoding:
+
delmemory();
xfree(pool);
@@ -948,7 +947,7 @@ CIDGetGlyphs(FontPtr pFont,
unsigned long *glyphCount, /* RETURN */
CharInfoPtr *glyphs) /* RETURN */
{
- unsigned int firstRow, numRows, code, char_row, char_col;
+ unsigned int code, char_row, char_col;
CharInfoPtr *glyphsBase;
register unsigned int c;
CharInfoPtr pci;
@@ -1040,8 +1039,6 @@ CIDGetGlyphs(FontPtr pFont,
break;
case TwoD16Bit:
- firstRow = pFont->info.firstRow;
- numRows = pFont->info.lastRow - firstRow + 1;
while (count--) {
char_row = (*chars++);
char_col = (*chars++);
diff --git a/src/Type1/t1info.c b/src/Type1/t1info.c
index 0ee137f..c1ef5f6 100644
--- a/src/Type1/t1info.c
+++ b/src/Type1/t1info.c
@@ -99,7 +99,7 @@ from The Open Group.
* The Original Software is CID font code that was developed by Silicon
* Graphics, Inc.
*/
-/* $XFree86: xc/lib/font/Type1/t1info.c,v 1.18 2002/09/10 16:14:33 tsi Exp $ */
+/* $XFree86: xc/lib/font/Type1/t1info.c,v 1.19 2003/05/27 22:26:47 tsi Exp $ */
#include "fntfilst.h"
#include "fontutil.h"
@@ -386,7 +386,7 @@ ComputeBoundsAllChars(FontPtr pFont, char *cfmfilename, double sxmult)
k <= cidrangeP->range[j].srcCodeHi; k++) {
ccode[0] = (k >> 8) & 0xff;
ccode[1] = k & 0xff;
- ret = CIDGetMetrics(pFont, 1, ccode, 2, &ccount, &pmetrics);
+ ret = CIDGetMetrics(pFont, 1, ccode, Linear16Bit, &ccount, &pmetrics);
if (ret != Successful || (ret == Successful && pmetrics == NULL))
continue;
total_width += pmetrics->attributes;
@@ -505,7 +505,7 @@ ComputeBoundsAll(FontPtr pFont)
k <= cidrangeP->range[j].srcCodeHi; k++) {
ccode[0] = (k >> 8) & 0xff;
ccode[1] = k & 0xff;
- ret = CIDGetMetrics(pFont, 1, ccode, 2, &ccount, (xCharInfo **)cinfo);
+ ret = CIDGetMetrics(pFont, 1, ccode, Linear16Bit, &ccount, (xCharInfo **)cinfo);
if (ret != Successful || cinfo == NULL)
continue;
pmetrics = &cinfo[0]->metrics;
diff --git a/src/Type1/token.c b/src/Type1/token.c
index ef28990..6fb4109 100644
--- a/src/Type1/token.c
+++ b/src/Type1/token.c
@@ -27,7 +27,7 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
-/* $XFree86: xc/lib/font/Type1/token.c,v 1.5 2001/01/17 19:43:24 dawes Exp $ */
+/* $XFree86: xc/lib/font/Type1/token.c,v 1.6 2003/05/27 22:26:47 tsi Exp $ */
/* Authors: Sig Nin & Carol Thompson IBM Almaden Research Laboratory */
#include "t1stdio.h"
#include "util.h"
@@ -186,7 +186,7 @@ isWHITE_SPACE(ch)\
)
#define save_ch_no_inc(ch) \
-((tokenCharP < tokenMaxP) && (*tokenCharP = ch))
+if (tokenCharP < tokenMaxP) *tokenCharP = ch
/*
* -------------------------------------------------------------------
@@ -253,7 +253,6 @@ static long m_scale;
/* real number exponent */
static int e_sign;
static long e_value;
-static long e_scale;
/* radix number */
static long r_base;
@@ -362,7 +361,6 @@ add_digits(int ch)
/* Initialize for possible real */
e_sign = '+';
e_value = 0;
- e_scale = 0;
return(ch);
}
@@ -476,7 +474,6 @@ add_fraction(int ch)
/* Initialize for possible real */
e_sign = '+';
e_value = 0;
- e_scale = 0;
return(ch);
}
@@ -554,7 +551,6 @@ add_exponent(int ch)
/* Store results */
e_value = value;
- e_scale = scale;
return(ch);
}
@@ -693,10 +689,6 @@ REAL(int ch)
back_ch_not_white(ch);
- /* NOTE: ignore e_scale, since e_value alone will cause
- * exponent overflow if e_scale > 0.
- */
-
/* HAZARD: exponent overflow of intermediate result
* (e.g., in 370 floating point); this should not be a problem
* with IEEE floating point. Reduce exponent overflow hazard by
diff --git a/src/Type1/type1.c b/src/Type1/type1.c
index 5b83dd0..9bb8d00 100644
--- a/src/Type1/type1.c
+++ b/src/Type1/type1.c
@@ -45,7 +45,7 @@
* The Original Software is CID font code that was developed by Silicon
* Graphics, Inc.
*/
-/* $XFree86: xc/lib/font/Type1/type1.c,v 1.9 2001/01/17 19:43:24 dawes Exp $ */
+/* $XFree86: xc/lib/font/Type1/type1.c,v 1.10 2003/05/27 22:26:47 tsi Exp $ */
/*********************************************************************/
/* */
@@ -150,11 +150,6 @@ typedef struct xobject xobject;
#define Error {errflag = TRUE; return;}
#define ErrorRet(ret) {errflag = TRUE; return (ret);}
-#define Error0(errmsg) {IfTrace0(TRUE, errmsg); Error;}
-#define Error0Ret(errmsg, ret) {IfTrace0(TRUE, errmsg); ErrorRet(ret);}
-
-#define Error1(errmsg,arg) {IfTrace1(TRUE, errmsg, arg); Error;}
-
/********************/
/* global variables */
/********************/
@@ -187,8 +182,7 @@ static int errflag;
/*************************************************/
static char *Environment;
static struct XYspace *CharSpace;
-static psobj *CharStringP, *SubrsP, *OtherSubrsP;
-static int *ModeP;
+static psobj *CharStringP, *SubrsP;
/************************/
/* Forward declarations */
@@ -772,7 +766,7 @@ static void
Push(double Num)
{
if (++Top < MAXSTACK) Stack[Top] = Num;
- else Error0("Push: Stack full\n");
+ else Error;
}
static void
@@ -789,7 +783,7 @@ PushCall(psobj *CurrStrP, int CurrIndex, unsigned short CurrKey)
CallStack[CallTop].currindex = CurrIndex; /* save CharString index */
CallStack[CallTop].currkey = CurrKey; /* save decryption key */
}
- else Error0("PushCall: Stack full\n");
+ else Error;
}
static void
@@ -800,7 +794,7 @@ PopCall(psobj **CurrStrPP, int *CurrIndexP, unsigned short *CurrKeyP)
*CurrIndexP = CallStack[CallTop].currindex; /* restore CharString index */
*CurrKeyP = CallStack[CallTop--].currkey; /* restore decryption key */
}
- else Error0("PopCall: Stack empty\n");
+ else Error;
}
static void
@@ -814,7 +808,7 @@ static void
PSFakePush(double Num)
{
if (++PSFakeTop < MAXPSFAKESTACK) PSFakeStack[PSFakeTop] = Num;
- else Error0("PSFakePush: Stack full\n");
+ else Error;
}
/* PSFakePop: Removes a number from the top of the fake PostScript stack */
@@ -822,7 +816,7 @@ static double
PSFakePop (void)
{
if (PSFakeTop >= 0) return(PSFakeStack[PSFakeTop--]);
- else Error0Ret("PSFakePop : Stack empty\n", 0.0);
+ else ErrorRet(0.0);
/*NOTREACHED*/
}
@@ -929,7 +923,7 @@ StartDecrypt(void)
r = KEY; /* Initial key (seed) for CharStrings decryption */
for (strindex = 0; strindex < blues->lenIV;)
if (!DoRead(&Code)) /* Read a byte and update decryption key */
- Error0("StartDecrypt: Premature end of CharString\n");
+ Error;
}
static void
@@ -958,7 +952,7 @@ Decode(int Code)
}
return;
-ended: Error0("Decode: Premature end of Type 1 CharString");
+ended: Error;
}
/* Interpret a command code */
@@ -968,37 +962,37 @@ DoCommand(int Code)
switch(Code) {
case HSTEM: /* |- y dy HSTEM |- */
/* Vertical range of a horizontal stem zone */
- if (Top < 1) Error0("DoCommand: Stack low\n");
+ if (Top < 1) Error;
HStem(Stack[0], Stack[1]);
ClearStack();
break;
case VSTEM: /* |- x dx VSTEM |- */
/* Horizontal range of a vertical stem zone */
- if (Top < 1) Error0("DoCommand: Stack low\n");
+ if (Top < 1) Error;
VStem(Stack[0], Stack[1]);
ClearStack();
break;
case VMOVETO: /* |- dy VMOVETO |- */
/* Vertical MOVETO, equivalent to 0 dy RMOVETO */
- if (Top < 0) Error0("DoCommand: Stack low\n");
+ if (Top < 0) Error;
RMoveTo(0.0, Stack[0]);
ClearStack();
break;
case RLINETO: /* |- dx dy RLINETO |- */
/* Like RLINETO in PostScript */
- if (Top < 1) Error0("DoCommand: Stack low\n");
+ if (Top < 1) Error;
RLineTo(Stack[0], Stack[1]);
ClearStack();
break;
case HLINETO: /* |- dx HLINETO |- */
/* Horizontal LINETO, equivalent to dx 0 RLINETO */
- if (Top < 0) Error0("DoCommand: Stack low\n");
+ if (Top < 0) Error;
RLineTo(Stack[0], 0.0);
ClearStack();
break;
case VLINETO: /* |- dy VLINETO |- */
/* Vertical LINETO, equivalent to 0 dy RLINETO */
- if (Top < 0) Error0("DoCommand: Stack low\n");
+ if (Top < 0) Error;
RLineTo(0.0, Stack[0]);
ClearStack();
break;
@@ -1007,7 +1001,7 @@ DoCommand(int Code)
/* Relative RCURVETO, equivalent to dx1 dy1 */
/* (dx1+dx2) (dy1+dy2) (dx1+dx2+dx3) */
/* (dy1+dy2+dy3) RCURVETO in PostScript */
- if (Top < 5) Error0("DoCommand: Stack low\n");
+ if (Top < 5) Error;
RRCurveTo(Stack[0], Stack[1], Stack[2], Stack[3],
Stack[4], Stack[5]);
ClearStack();
@@ -1021,7 +1015,7 @@ DoCommand(int Code)
case CALLSUBR: /* subr# CALLSUBR - */
/* Calls a CharString subroutine with index */
/* subr# from the Subrs array */
- if (Top < 0) Error0("DoCommand: Stack low\n");
+ if (Top < 0) Error;
CallSubr((int)Stack[Top--]);
break;
case RETURN: /* - RETURN - */
@@ -1030,7 +1024,7 @@ DoCommand(int Code)
Return();
break;
case ESCAPE: /* ESCAPE to two-byte command code */
- if (!DoRead(&Code)) Error0("DoCommand: ESCAPE is last byte\n");
+ if (!DoRead(&Code)) Error;
Escape(Code);
break;
case HSBW: /* |- sbx wx HSBW |- */
@@ -1038,7 +1032,7 @@ DoCommand(int Code)
/* set the character width vector to (wx,0). */
/* Equivalent to sbx 0 wx 0 SBW. Space */
/* character should have sbx = 0 */
- if (Top < 1) Error0("DoCommand: Stack low\n");
+ if (Top < 1) Error;
Sbw(Stack[0], 0.0, Stack[1], 0.0);
ClearStack();
break;
@@ -1049,20 +1043,20 @@ DoCommand(int Code)
break;
case RMOVETO: /* |- dx dy RMOVETO |- */
/* Behaves like RMOVETO in PostScript */
- if (Top < 1) Error0("DoCommand: Stack low\n");
+ if (Top < 1) Error;
RMoveTo(Stack[0], Stack[1]);
ClearStack();
break;
case HMOVETO: /* |- dx HMOVETO |- */
/* Horizontal MOVETO. Equivalent to dx 0 RMOVETO */
- if (Top < 0) Error0("DoCommand: Stack low\n");
+ if (Top < 0) Error;
RMoveTo(Stack[0], 0.0);
ClearStack();
break;
case VHCURVETO: /* |- dy1 dx2 dy2 dx3 VHCURVETO |- */
/* Vertical-Horizontal CURVETO, equivalent to */
/* 0 dy1 dx2 dy2 dx3 0 RRCURVETO */
- if (Top < 3) Error0("DoCommand: Stack low\n");
+ if (Top < 3) Error;
RRCurveTo(0.0, Stack[0], Stack[1], Stack[2],
Stack[3], 0.0);
ClearStack();
@@ -1070,13 +1064,13 @@ DoCommand(int Code)
case HVCURVETO: /* |- dx1 dx2 dy2 dy3 HVCURVETO |- */
/* Horizontal-Vertical CURVETO, equivalent to */
/* dx1 0 dx2 dy2 0 dy3 RRCURVETO */
- if (Top < 3) Error0("DoCommand: Stack low\n");
+ if (Top < 3) Error;
RRCurveTo(Stack[0], 0.0, Stack[1], Stack[2], 0.0, Stack[3]);
ClearStack();
break;
default: /* Unassigned command code */
ClearStack();
- Error1("DoCommand: Unassigned code %d\n", Code);
+ Error;
}
}
@@ -1097,7 +1091,7 @@ Escape(int Code)
/* Declares the horizontal ranges of three */
/* vertical stem zones between x0 and x0+dx0, */
/* x1 and x1+dx1, and x2 and x2+dx2. */
- if (Top < 5) Error0("DoCommand: Stack low\n");
+ if (Top < 5) Error;
if (!wsset && ProcessHints) {
/* Shift the whole character so that the middle stem is centered. */
p = CenterStem(Stack[2] + sidebearingX, Stack[3]);
@@ -1114,7 +1108,7 @@ Escape(int Code)
/* Declares the vertical ranges of three hori- */
/* zontal stem zones between y0 and y0+dy0, */
/* y1 and y1+dy1, and y2 and y2+dy2. */
- if (Top < 5) Error0("DoCommand: Stack low\n");
+ if (Top < 5) Error;
HStem(Stack[0], Stack[1]);
HStem(Stack[2], Stack[3]);
HStem(Stack[4], Stack[5]);
@@ -1122,7 +1116,7 @@ Escape(int Code)
break;
case SEAC: /* |- asb adx ady bchar achar SEAC |- */
/* Standard Encoding Accented Character. */
- if (Top < 4) Error0("DoCommand: Stack low\n");
+ if (Top < 4) Error;
Seac(Stack[0], Stack[1], Stack[2],
(unsigned char) Stack[3],
(unsigned char) Stack[4]);
@@ -1131,22 +1125,22 @@ Escape(int Code)
case SBW: /* |- sbx sby wx wy SBW |- */
/* Set the left sidebearing point to (sbx,sby), */
/* set the character width vector to (wx,wy). */
- if (Top < 3) Error0("DoCommand: Stack low\n");
+ if (Top < 3) Error;
Sbw(Stack[0], Stack[1], Stack[2], Stack[3]);
ClearStack();
break;
case DIV: /* num1 num2 DIV quotient */
/* Behaves like DIV in the PostScript language */
- if (Top < 1) Error0("DoCommand: Stack low\n");
+ if (Top < 1) Error;
Stack[Top-1] = Div(Stack[Top-1], Stack[Top]);
Top--;
break;
case CALLOTHERSUBR:
/* arg1 ... argn n othersubr# CALLOTHERSUBR - */
/* Make calls on the PostScript interpreter */
- if (Top < 1) Error0("DoCommand: Stack low\n");
+ if (Top < 1) Error;
Num = Stack[Top-1];
- if (Top < Num+1) Error0("DoCommand: Stack low\n");
+ if (Top < Num+1) Error;
for (i = 0; i < Num; i++) PSFakePush(Stack[Top - i - 2]);
Top -= Num + 2;
#ifdef BUILDCID
@@ -1168,13 +1162,13 @@ Escape(int Code)
/* Sets the current point to (x,y) in absolute */
/* character space coordinates without per- */
/* forming a CharString MOVETO command */
- if (Top < 1) Error0("DoCommand: Stack low\n");
+ if (Top < 1) Error;
SetCurrentPoint(Stack[0], Stack[1]);
ClearStack();
break;
default: /* Unassigned escape code command */
ClearStack();
- Error1("Escape: Unassigned code %d\n", Code);
+ Error;
}
}
@@ -1185,9 +1179,8 @@ Escape(int Code)
static void
HStem(double y, double dy)
{
- IfTrace2((FontDebug), "Hstem %f %f\n", &y, &dy);
if (ProcessHints) {
- if (numstems >= MAXSTEMS) Error0("HStem: Too many hints\n");
+ if (numstems >= MAXSTEMS) Error;
if (dy < 0.0) {y += dy; dy = -dy;}
stems[numstems].vertical = FALSE;
stems[numstems].x = 0.0;
@@ -1207,9 +1200,8 @@ HStem(double y, double dy)
static void
VStem(double x, double dx)
{
- IfTrace2((FontDebug), "Vstem %f %f\n", &x, &dx);
if (ProcessHints) {
- if (numstems >= MAXSTEMS) Error0("VStem: Too many hints\n");
+ if (numstems >= MAXSTEMS) Error;
if (dx < 0.0) {x += dx; dx = -dx;}
stems[numstems].vertical = TRUE;
stems[numstems].x = sidebearingX + x + wsoffsetX;
@@ -1228,8 +1220,6 @@ RLineTo(double dx, double dy)
{
struct segment *B;
- IfTrace2((FontDebug), "RLineTo %f %f\n", &dx, &dy);
-
B = Loc(CharSpace, dx, dy);
if (ProcessHints) {
@@ -1252,9 +1242,6 @@ RRCurveTo(double dx1, double dy1, double dx2, double dy2,
{
struct segment *B, *C, *D;
- IfTrace4((FontDebug), "RRCurveTo %f %f %f %f ", &dx1, &dy1, &dx2, &dy2);
- IfTrace2((FontDebug), "%f %f\n", &dx3, &dy3);
-
B = Loc(CharSpace, dx1, dy1);
C = Loc(CharSpace, dx2, dy2);
D = Loc(CharSpace, dx3, dy3);
@@ -1285,7 +1272,6 @@ DoClosePath(void)
{
struct segment *CurrentPoint;
- IfTrace0((FontDebug), "DoClosePath\n");
CurrentPoint = Phantom(path);
path = ClosePath(path);
path = Join(Snap(path), CurrentPoint);
@@ -1297,9 +1283,8 @@ DoClosePath(void)
static void
CallSubr(int subrno)
{
- IfTrace1((FontDebug), "CallSubr %d\n", subrno);
if ((subrno < 0) || (subrno >= SubrsP->len))
- Error0("CallSubr: subrno out of range\n");
+ Error;
PushCall(CharStringP, strindex, r);
CharStringP = &SubrsP->data.arrayP[subrno];
StartDecrypt();
@@ -1311,7 +1296,6 @@ CallSubr(int subrno)
static void
Return(void)
{
- IfTrace0((FontDebug), "Return\n");
PopCall(&CharStringP, &strindex, &r);
}
@@ -1326,8 +1310,6 @@ Return(void)
static void
EndChar(void)
{
- IfTrace0((FontDebug), "EndChar\n");
-
/* There is no need to compute and set bounding box for
the cache, since XIMAGER does that on the fly. */
@@ -1346,8 +1328,6 @@ RMoveTo(double dx, double dy)
{
struct segment *B;
- IfTrace2((FontDebug), "RMoveTo %f %f\n", &dx, &dy);
-
B = Loc(CharSpace, dx, dy);
if (ProcessHints) {
@@ -1366,7 +1346,6 @@ RMoveTo(double dx, double dy)
static void
DotSection(void)
{
- IfTrace0((FontDebug), "DotSection\n");
InDotSection = !InDotSection;
}
@@ -1379,9 +1358,6 @@ Seac(double asb, double adx, double ady,
int Code;
struct segment *mypath;
- IfTrace4((FontDebug), "SEAC %f %f %f %d ", &asb, &adx, &ady, bchar);
- IfTrace1((FontDebug), "%d\n", achar);
-
/* Move adx - asb, ady over and up from base char's sbpoint. */
/* (We use adx - asb to counteract the accents sb shift.) */
/* The variables accentoffsetX/Y modify sidebearingX/Y in Sbw(). */
@@ -1439,8 +1415,6 @@ Seac(double asb, double adx, double ady,
static void
Sbw(double sbx, double sby, double wx, double wy)
{
- IfTrace4((FontDebug), "SBW %f %f %f %f\n", &sbx, &sby, &wx, &wy);
-
escapementX = wx; /* Character width vector */
escapementY = wy;
@@ -1457,7 +1431,6 @@ Sbw(double sbx, double sby, double wx, double wy)
static double
Div(double num1, double num2)
{
- IfTrace2((FontDebug), "Div %f %f\n", &num1, &num2);
return(num1 / num2);
}
@@ -1757,11 +1730,9 @@ HintReplace(void)
static void
CallOtherSubr(int othersubrno)
{
- IfTrace1((FontDebug), "CallOtherSubr %d\n", othersubrno);
-
switch(othersubrno) {
case 0: /* OtherSubrs[0]; Main part of Flex */
- if (PSFakeTop < 16) Error0("CallOtherSubr: PSFakeStack low");
+ if (PSFakeTop < 16) Error;
ClearPSFakeStack();
FlxProc(
PSFakeStack[0], PSFakeStack[1], PSFakeStack[2], PSFakeStack[3],
@@ -1792,8 +1763,6 @@ CallOtherSubr(int othersubrno)
static void
SetCurrentPoint(double x, double y)
{
- IfTrace2((FontDebug), "SetCurrentPoint %f %f\n", &x, &y);
-
currx = x;
curry = y;
}
@@ -1816,8 +1785,6 @@ Type1Char(char *env, struct XYspace *S, psobj *charstrP, psobj *subrsP,
CharSpace = S; /* used when creating path elements */
CharStringP = charstrP;
SubrsP = subrsP;
- OtherSubrsP = osubrsP;
- ModeP = modeP;
blues = bluesP;
@@ -1876,8 +1843,6 @@ CIDChar(char *env, struct XYspace *S,
CharSpace = S; /* used when creating path elements */
CharStringP = charstrP;
SubrsP = subrsP;
- OtherSubrsP = osubrsP;
- ModeP = modeP;
blues = bluesP;
diff --git a/src/bitmap/bdfread.c b/src/bitmap/bdfread.c
index 67e4252..813975a 100644
--- a/src/bitmap/bdfread.c
+++ b/src/bitmap/bdfread.c
@@ -50,7 +50,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
-/* $XFree86: xc/lib/font/bitmap/bdfread.c,v 1.12 2002/09/10 16:14:34 tsi Exp $ */
+/* $XFree86: xc/lib/font/bitmap/bdfread.c,v 1.13 2003/05/27 22:26:48 tsi Exp $ */
#ifndef FONTMODULE
#include <ctype.h>
@@ -82,7 +82,6 @@ bdfReadBitmap(CharInfoPtr pCI, FontFilePtr file, int bit, int byte,
int i,
inLineLen,
nextByte;
- Bool badbits;
unsigned char *pInBits,
*picture,
*line = NULL;
@@ -106,7 +105,6 @@ bdfReadBitmap(CharInfoPtr pCI, FontFilePtr file, int bit, int byte,
for (i = 0; i < GLYPHPADOPTIONS; i++)
sizes[i] += BYTES_PER_ROW(widthBits, (1 << i)) * height;
}
- badbits = FALSE;
nextByte = 0;
widthHexChars = BYTES_PER_ROW(widthBits, 1);
@@ -149,9 +147,7 @@ bdfReadBitmap(CharInfoPtr pCI, FontFilePtr file, int bit, int byte,
mask = 0xff << (8 - (widthBits & 0x7));
if (mask && picture[nextByte - 1] & ~mask) {
picture[nextByte - 1] &= mask;
- badbits = TRUE;
- } else if (inLineLen > widthHexChars)
- badbits = TRUE;
+ }
}
if (widthBytes > widthHexChars) {
diff --git a/src/bitmap/bdfutils.c b/src/bitmap/bdfutils.c
index 94a9ff6..c1340af 100644
--- a/src/bitmap/bdfutils.c
+++ b/src/bitmap/bdfutils.c
@@ -49,7 +49,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
-/* $XFree86: xc/lib/font/bitmap/bdfutils.c,v 1.10 2001/12/14 19:56:45 dawes Exp $ */
+/* $XFree86: xc/lib/font/bitmap/bdfutils.c,v 1.11 2003/09/13 21:33:02 dawes Exp $ */
#ifndef FONTMODULE
#include <ctype.h>
@@ -130,7 +130,6 @@ Atom
bdfForceMakeAtom(char *str, int *size)
{
register int len = strlen(str);
- extern Atom MakeAtom(); /* Added this line to be consistent with X.org code */
Atom the_atom;
if (size != NULL)
diff --git a/src/bitmap/bitscale.c b/src/bitmap/bitscale.c
index 287bd5c..3966c0f 100644
--- a/src/bitmap/bitscale.c
+++ b/src/bitmap/bitscale.c
@@ -26,7 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
-/* $XFree86: xc/lib/font/bitmap/bitscale.c,v 3.29 2003/01/12 03:55:46 tsi Exp $ */
+/* $XFree86: xc/lib/font/bitmap/bitscale.c,v 3.30 2003/05/27 22:26:48 tsi Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -900,12 +900,10 @@ ScaleFont(FontPtr opf, /* originating font */
opci;
int nchars = 0; /* how many characters in the font */
int i;
- int glyph;
int firstCol, lastCol, firstRow, lastRow;
double xform[4], inv_xform[4];
double xmult, ymult;
int totalwidth = 0, totalchars = 0;
- int inkindex1, inkindex2;
#define OLDINDEX(i) (((i)/(lastCol - firstCol + 1) + \
firstRow - opf->info.firstRow) * \
(opf->info.lastCol - opf->info.firstCol + 1) + \
@@ -915,7 +913,6 @@ ScaleFont(FontPtr opf, /* originating font */
*sWidth = 0;
opfi = &opf->info;
- glyph = opf->glyph;
obitmapFont = (BitmapFontPtr) opf->fontPrivate;
bitmapFont = 0;
@@ -1056,11 +1053,9 @@ ScaleFont(FontPtr opf, /* originating font */
/* Compute the transformation and inverse transformation matrices.
Can fail if the determinant is zero. */
- inkindex1 = 0;
pci = bitmapFont->metrics;
for (i = 0; i < nchars; i++)
{
- inkindex2 = OLDINDEX(i);
if ((opci = ACCESSENCODING(obitmapFont->encoding,OLDINDEX(i))))
{
double newlsb, newrsb, newdesc, newasc, point[2];
@@ -1693,8 +1688,7 @@ PrinterScaleBitmaps(FontPtr pf, /* scaled font */
char *glyphBytes;
BitmapFontPtr bitmapFont,
obitmapFont;
- CharInfoPtr pci,
- opci;
+ CharInfoPtr pci;
FontInfoPtr pfi;
int glyph;
unsigned bytestoalloc = 0;
@@ -1739,7 +1733,7 @@ PrinterScaleBitmaps(FontPtr pf, /* scaled font */
for (i = 0; i < nchars; i++)
{
if ((pci = ACCESSENCODING(bitmapFont->encoding, i)) &&
- (opci = ACCESSENCODING(obitmapFont->encoding, OLDINDEX(i))))
+ (ACCESSENCODING(obitmapFont->encoding, OLDINDEX(i))))
{
pci->bits = glyphBytes;
}
diff --git a/src/bitmap/pcfread.c b/src/bitmap/pcfread.c
index 1e07b09..a7843cb 100644
--- a/src/bitmap/pcfread.c
+++ b/src/bitmap/pcfread.c
@@ -26,7 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
-/* $XFree86: xc/lib/font/bitmap/pcfread.c,v 1.20 2003/01/12 03:55:46 tsi Exp $ */
+/* $XFree86: xc/lib/font/bitmap/pcfread.c,v 1.22 2003/11/18 01:17:04 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -40,28 +40,14 @@ from The Open Group.
#define MAX(a,b) (((a)>(b)) ? a : b)
#endif
-#if NeedVarargsPrototypes
#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
void
-#if NeedVarargsPrototypes
-pcfError(char* message, ...)
-#else
-pcfError (message, va_alist)
- char* message;
- va_dcl
-#endif
+pcfError(const char* message, ...)
{
va_list args;
-#if NeedVarargsPrototypes
va_start(args, message);
-#else
- va_start(args);
-#endif
fprintf(stderr, "PCF Error: ");
vfprintf(stderr, message, args);
diff --git a/src/bitmap/pcfwrite.c b/src/bitmap/pcfwrite.c
index 74b099e..c02f433 100644
--- a/src/bitmap/pcfwrite.c
+++ b/src/bitmap/pcfwrite.c
@@ -26,7 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
-/* $XFree86: xc/lib/font/bitmap/pcfwrite.c,v 1.10 2003/01/12 03:55:46 tsi Exp $ */
+/* $XFree86: xc/lib/font/bitmap/pcfwrite.c,v 1.12 2003/11/18 01:17:04 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -37,12 +37,6 @@ from The Open Group.
#include "bitmap.h"
#include "pcf.h"
-extern void pcfError(
-#if NeedVarargsPrototypes
- char* message, ...
-#endif
- );
-
/* Write PCF font files */
static CARD32 current_position;
diff --git a/src/bitmap/snfread.c b/src/bitmap/snfread.c
index 375fa5a..848db90 100644
--- a/src/bitmap/snfread.c
+++ b/src/bitmap/snfread.c
@@ -49,7 +49,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
-/* $XFree86: xc/lib/font/bitmap/snfread.c,v 1.11 2003/01/12 03:55:46 tsi Exp $ */
+/* $XFree86: xc/lib/font/bitmap/snfread.c,v 1.13 2003/11/18 01:17:04 dawes Exp $ */
#ifndef FONTMODULE
#include <ctype.h>
@@ -59,28 +59,14 @@ from The Open Group.
#include "bitmap.h"
#include "snfstr.h"
-#if NeedVarargsPrototypes
#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
void
-#if NeedVarargsPrototypes
-snfError(char* message, ...)
-#else
-snfError (message, va_alist)
- char* message;
- va_dcl
-#endif
+snfError(const char* message, ...)
{
va_list args;
-#if NeedVarargsPrototypes
va_start(args, message);
-#else
- va_start(args);
-#endif
fprintf(stderr, "SNF Error: ");
vfprintf(stderr, message, args);
diff --git a/src/bitmap/snfstr.h b/src/bitmap/snfstr.h
index 09ecf8a..85f75f2 100644
--- a/src/bitmap/snfstr.h
+++ b/src/bitmap/snfstr.h
@@ -49,7 +49,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
-/* $XFree86: xc/lib/font/bitmap/snfstr.h,v 1.5 2001/12/14 19:56:47 dawes Exp $ */
+/* $XFree86: xc/lib/font/bitmap/snfstr.h,v 1.6 2003/11/18 01:17:04 dawes Exp $ */
#ifndef SNFSTR_H
#define SNFSTR_H 1
@@ -180,5 +180,6 @@ extern void SnfSetFormat ( int bit, int byte, int glyph, int scan );
extern int snfReadFont ( FontPtr pFont, FontFilePtr file,
int bit, int byte, int glyph, int scan );
extern int snfReadFontInfo ( FontInfoPtr pFontInfo, FontFilePtr file );
+extern void snfError( const char* message, ... );
#endif /* SNFSTR_H */
diff --git a/src/fc/fsconvert.c b/src/fc/fsconvert.c
index 47239cf..6b694fd 100644
--- a/src/fc/fsconvert.c
+++ b/src/fc/fsconvert.c
@@ -22,7 +22,7 @@
*
* Author: Dave Lemke, Network Computing Devices, Inc
*/
-/* $XFree86: xc/lib/font/fc/fsconvert.c,v 1.11 2002/09/10 16:14:35 tsi Exp $ */
+/* $XFree86: xc/lib/font/fc/fsconvert.c,v 1.15 2003/09/01 20:50:43 herrb Exp $ */
/*
* FS data conversion
*/
@@ -36,6 +36,7 @@
#include "fontstruct.h"
#include "fservestr.h"
#include "fontutil.h"
+#include "fslibos.h"
extern char _fs_glyph_undefined;
extern char _fs_glyph_requested;
@@ -102,6 +103,10 @@ _fs_convert_props(fsPropInfo *pi, fsPropOffset *po, pointer pd,
nprops = pfi->nprops = pi->num_offsets;
+ if (nprops < 0
+ || nprops > SIZE_MAX/(sizeof(FontPropRec) + sizeof(char)))
+ return -1;
+
dprop = (FontPropPtr) xalloc(sizeof(FontPropRec) * nprops +
sizeof (char) * nprops);
if (!dprop)
@@ -351,11 +356,9 @@ _fs_clean_aborted_loadglyphs(FontPtr pfont, int num_expected_ranges,
fsRange *expected_ranges)
{
register FSFontPtr fsfont;
- register FSFontDataRec *fsd;
register int i;
fsfont = (FSFontPtr) pfont->fontPrivate;
- fsd = (FSFontDataRec *) pfont->fpePrivate;
if (fsfont->encoding)
{
fsRange full_range[1];
@@ -446,7 +449,6 @@ _fs_get_glyphs(FontPtr pFont, unsigned long count, unsigned char *chars,
CharInfoPtr encoding;
CharInfoPtr pDefault;
FSFontDataPtr fsd = (FSFontDataPtr) pFont->fpePrivate;
- int itemSize;
int err = Successful;
fsdata = (FSFontPtr) pFont->fontPrivate;
@@ -456,12 +458,6 @@ _fs_get_glyphs(FontPtr pFont, unsigned long count, unsigned char *chars,
numCols = pFont->info.lastCol - firstCol + 1;
glyphsBase = glyphs;
-
- if (charEncoding == Linear8Bit || charEncoding == TwoD8Bit)
- itemSize = 1;
- else
- itemSize = 2;
-
/* In this age of glyph caching, any glyphs gotten through this
procedure should already be loaded. If they are not, we are
dealing with someone (perhaps a ddx driver optimizing a font)
@@ -563,7 +559,6 @@ _fs_get_metrics(FontPtr pFont, unsigned long count, unsigned char *chars,
unsigned int r;
CharInfoPtr encoding;
CharInfoPtr pDefault;
- int itemSize;
fsdata = (FSFontPtr) pFont->fontPrivate;
encoding = fsdata->inkMetrics;
@@ -578,11 +573,6 @@ _fs_get_metrics(FontPtr pFont, unsigned long count, unsigned char *chars,
/* XXX - this should be much smarter */
/* make sure the glyphs are there */
- if (charEncoding == Linear8Bit || charEncoding == TwoD8Bit)
- itemSize = 1;
- else
- itemSize = 2;
-
switch (charEncoding) {
case Linear8Bit:
diff --git a/src/fc/fserve.c b/src/fc/fserve.c
index f21233c..c9fccc4 100644
--- a/src/fc/fserve.c
+++ b/src/fc/fserve.c
@@ -24,7 +24,7 @@ used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
-/* $XFree86: xc/lib/font/fc/fserve.c,v 3.22 2002/05/31 18:45:49 dawes Exp $ */
+/* $XFree86: xc/lib/font/fc/fserve.c,v 3.25 2003/11/20 18:16:34 dawes Exp $ */
/*
* Copyright 1990 Network Computing Devices
@@ -87,13 +87,13 @@ in this Software without prior written authorization from The Open Group.
(pci)->descent || \
(pci)->characterWidth)
+extern void ErrorF(const char *f, ...);
static int fs_read_glyphs ( FontPathElementPtr fpe, FSBlockDataPtr blockrec );
static int fs_read_list ( FontPathElementPtr fpe, FSBlockDataPtr blockrec );
static int fs_read_list_info ( FontPathElementPtr fpe,
FSBlockDataPtr blockrec );
-static int fs_font_type;
extern fd_set _fs_fd_mask;
static void fs_block_handler ( pointer data, OSTimePtr wt,
@@ -952,6 +952,7 @@ fs_read_extent_info(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
CharInfoPtr ci, pCI;
char *fsci;
fsXCharInfo fscilocal;
+ FontInfoRec *fi = &bfont->pfont->info;
rep = (fsQueryXExtents16Reply *) fs_get_reply (conn, &ret);
if (!rep || rep->type == FS_Error)
@@ -997,6 +998,21 @@ fs_read_extent_info(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
{
memcpy(&fscilocal, fsci, SIZEOF(fsXCharInfo)); /* align it */
_fs_convert_char_info(&fscilocal, &ci->metrics);
+ /* Bounds check. */
+ if (ci->metrics.ascent > fi->maxbounds.ascent)
+ {
+ ErrorF("fserve: warning: %s %s ascent (%d) > maxascent (%d)\n",
+ fpe->name, fsd->name,
+ ci->metrics.ascent, fi->maxbounds.ascent);
+ ci->metrics.ascent = fi->maxbounds.ascent;
+ }
+ if (ci->metrics.descent > fi->maxbounds.descent)
+ {
+ ErrorF("fserve: warning: %s %s descent (%d) > maxdescent (%d)\n",
+ fpe->name, fsd->name,
+ ci->metrics.descent, fi->maxbounds.descent);
+ ci->metrics.descent = fi->maxbounds.descent;
+ }
fsci = fsci + SIZEOF(fsXCharInfo);
/* Initialize the bits field for later glyph-caching use */
if (NONZEROMETRICS(&ci->metrics))
@@ -1022,7 +1038,6 @@ fs_read_extent_info(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
/* build bitmap metrics, ImageRectMax style */
if (haveInk)
{
- FontInfoRec *fi = &bfont->pfont->info;
CharInfoPtr ii;
ci = fsfont->encoding;
@@ -1037,10 +1052,44 @@ fs_read_extent_info(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
ci->metrics.descent = FONT_MAX_DESCENT(fi);
ci->metrics.characterWidth = FONT_MAX_WIDTH(fi);
ci->metrics.attributes = ii->metrics.attributes;
+ /* Bounds check. */
+ if (ci->metrics.ascent > fi->maxbounds.ascent)
+ {
+ ErrorF("fserve: warning: %s %s ascent (%d) "
+ "> maxascent (%d)\n",
+ fpe->name, fsd->name,
+ ci->metrics.ascent, fi->maxbounds.ascent);
+ ci->metrics.ascent = fi->maxbounds.ascent;
+ }
+ if (ci->metrics.descent > fi->maxbounds.descent)
+ {
+ ErrorF("fserve: warning: %s %s descent (%d) "
+ "> maxdescent (%d)\n",
+ fpe->name, fsd->name,
+ ci->metrics.descent, fi->maxbounds.descent);
+ ci->metrics.descent = fi->maxbounds.descent;
+ }
}
else
{
ci->metrics = ii->metrics;
+ /* Bounds check. */
+ if (ci->metrics.ascent > fi->maxbounds.ascent)
+ {
+ ErrorF("fserve: warning: %s %s ascent (%d) "
+ "> maxascent (%d)\n",
+ fpe->name, fsd->name,
+ ci->metrics.ascent, fi->maxbounds.ascent);
+ ci->metrics.ascent = fi->maxbounds.ascent;
+ }
+ if (ci->metrics.descent > fi->maxbounds.descent)
+ {
+ ErrorF("fserve: warning: %s %s descent (%d) "
+ "> maxdescent (%d)\n",
+ fpe->name, fsd->name,
+ ci->metrics.descent, fi->maxbounds.descent);
+ ci->metrics.descent = fi->maxbounds.descent;
+ }
}
}
}
@@ -1498,7 +1547,6 @@ fs_send_open_font(pointer client, FontPathElementPtr fpe, Mask flags,
FSBlockDataPtr blockrec = NULL;
FSBlockedFontPtr bfont;
FSFontDataPtr fsd;
- FSFontPtr fsfont;
fsOpenBitmapFontReq openreq;
fsQueryXInfoReq inforeq;
fsQueryXExtents16Req extreq;
@@ -1507,8 +1555,8 @@ fs_send_open_font(pointer client, FontPathElementPtr fpe, Mask flags,
if (conn->blockState & FS_GIVE_UP)
return BadFontName;
-
- if (namelen > sizeof (buf) - 1)
+
+ if (namelen <= 0 || namelen > sizeof (buf) - 1)
return BadFontName;
/*
@@ -1522,7 +1570,6 @@ fs_send_open_font(pointer client, FontPathElementPtr fpe, Mask flags,
font = *ppfont;
fsd = (FSFontDataPtr)font->fpePrivate;
- fsfont = (FSFontPtr)font->fontPrivate;
/* This is an attempt to reopen a font. Did the font have a
NAME property? */
if ((nameatom = MakeAtom("FONT", 4, 0)) != None)
@@ -1550,7 +1597,6 @@ fs_send_open_font(pointer client, FontPathElementPtr fpe, Mask flags,
return AllocError;
fsd = (FSFontDataPtr)font->fpePrivate;
- fsfont = (FSFontPtr)font->fontPrivate;
}
/* make a new block record, and add it to the end of the list */
@@ -1793,7 +1839,7 @@ fs_read_glyphs(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
err;
int nranges = 0;
int ret;
- fsRange *ranges, *nextrange = 0;
+ fsRange *nextrange = 0;
unsigned long minchar, maxchar;
rep = (fsQueryXBitmaps16Reply *) fs_get_reply (conn, &ret);
@@ -1818,7 +1864,7 @@ fs_read_glyphs(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
if (blockrec->type == FS_LOAD_GLYPHS)
{
nranges = bglyph->num_expected_ranges;
- nextrange = ranges = bglyph->expected_ranges;
+ nextrange = bglyph->expected_ranges;
}
/* place the incoming glyphs */
@@ -2291,7 +2337,6 @@ fs_list_fonts(pointer client, FontPathElementPtr fpe,
{
FSFpePtr conn = (FSFpePtr) fpe->private;
FSBlockDataPtr blockrec;
- FSBlockedListPtr blockedlist;
int err;
/* see if the result is already there */
@@ -2302,7 +2347,6 @@ fs_list_fonts(pointer client, FontPathElementPtr fpe,
err = blockrec->errcode;
if (err == StillWorking)
return Suspended;
- blockedlist = (FSBlockedListPtr) blockrec->data;
_fs_remove_block_rec(conn, blockrec);
return err;
}
@@ -3143,21 +3187,21 @@ _fs_free_conn (FSFpePtr conn)
void
fs_register_fpe_functions(void)
{
- fs_font_type = RegisterFPEFunctions(fs_name_check,
- fs_init_fpe,
- fs_free_fpe,
- fs_reset_fpe,
- fs_open_font,
- fs_close_font,
- fs_list_fonts,
- fs_start_list_with_info,
- fs_next_list_with_info,
- (WakeupFpeFunc)fs_wakeup,
- fs_client_died,
- _fs_load_glyphs,
- NULL,
- NULL,
- NULL);
+ RegisterFPEFunctions(fs_name_check,
+ fs_init_fpe,
+ fs_free_fpe,
+ fs_reset_fpe,
+ fs_open_font,
+ fs_close_font,
+ fs_list_fonts,
+ fs_start_list_with_info,
+ fs_next_list_with_info,
+ fs_wakeup,
+ fs_client_died,
+ _fs_load_glyphs,
+ NULL,
+ NULL,
+ NULL);
}
static int
@@ -3210,19 +3254,19 @@ check_fs_next_list_with_info(pointer client, FontPathElementPtr fpe,
void
check_fs_register_fpe_functions(void)
{
- fs_font_type = RegisterFPEFunctions(fs_name_check,
- fs_init_fpe,
- fs_free_fpe,
- fs_reset_fpe,
- check_fs_open_font,
- fs_close_font,
- check_fs_list_fonts,
- check_fs_start_list_with_info,
- check_fs_next_list_with_info,
- (WakeupFpeFunc)fs_wakeup,
- fs_client_died,
- _fs_load_glyphs,
- NULL,
- NULL,
- NULL);
+ RegisterFPEFunctions(fs_name_check,
+ fs_init_fpe,
+ fs_free_fpe,
+ fs_reset_fpe,
+ check_fs_open_font,
+ fs_close_font,
+ check_fs_list_fonts,
+ check_fs_start_list_with_info,
+ check_fs_next_list_with_info,
+ fs_wakeup,
+ fs_client_died,
+ _fs_load_glyphs,
+ NULL,
+ NULL,
+ NULL);
}
diff --git a/src/fc/fsio.c b/src/fc/fsio.c
index b5d9de0..6f589c8 100644
--- a/src/fc/fsio.c
+++ b/src/fc/fsio.c
@@ -23,7 +23,7 @@
*
* Author: Dave Lemke, Network Computing Devices, Inc
*/
-/* $XFree86: xc/lib/font/fc/fsio.c,v 3.16 2002/05/31 18:45:49 dawes Exp $ */
+/* $XFree86: xc/lib/font/fc/fsio.c,v 3.17 2003/05/27 22:26:49 tsi Exp $ */
/*
* font server i/o routines
*/
@@ -146,7 +146,7 @@ _fs_connect(char *servername, int *err)
int
_fs_fill (FSFpePtr conn)
{
- long avail, need;
+ long avail;
long bytes_read;
Bool waited = FALSE;
@@ -156,8 +156,7 @@ _fs_fill (FSFpePtr conn)
* Don't go overboard here; stop reading when we've
* got enough to satisfy the pending request
*/
- while ((need = conn->inNeed - (conn->inBuf.insert -
- conn->inBuf.remove)) > 0)
+ while ((conn->inNeed - (conn->inBuf.insert - conn->inBuf.remove)) > 0)
{
avail = conn->inBuf.size - conn->inBuf.insert;
/*
diff --git a/src/fc/fslibos.h b/src/fc/fslibos.h
index 8ca2a8a..09f1ade 100644
--- a/src/fc/fslibos.h
+++ b/src/fc/fslibos.h
@@ -31,7 +31,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
-/* $XFree86: xc/lib/font/fc/fslibos.h,v 3.7 2002/05/31 18:45:49 dawes Exp $ */
+/* $XFree86: xc/lib/font/fc/fslibos.h,v 3.9 2003/09/01 20:50:44 herrb Exp $ */
/*
* FSlib networking & os include file
@@ -48,13 +48,20 @@ from The Open Group.
#ifndef FONT_OPEN_MAX
#ifndef X_NOT_POSIX
-#ifdef _POSIX_SOURCE
-#include <limits.h>
-#else
-#define _POSIX_SOURCE
-#include <limits.h>
-#undef _POSIX_SOURCE
-#endif
+# ifdef _POSIX_SOURCE
+# include <limits.h>
+# else
+# define _POSIX_SOURCE
+# include <limits.h>
+# undef _POSIX_SOURCE
+# endif
+#endif
+#ifndef SIZE_MAX
+# ifdef ULONG_MAX
+# define SIZE_MAX ULONG_MAX
+# else
+# define SIZE_MAX UINT_MAX
+# endif
#endif
#ifndef OPEN_MAX
#if defined(SVR4) || defined(__UNIXOS2__)
diff --git a/src/fontfile/dirfile.c b/src/fontfile/dirfile.c
index 5f90501..bb7c339 100644
--- a/src/fontfile/dirfile.c
+++ b/src/fontfile/dirfile.c
@@ -25,7 +25,7 @@ used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
-/* $XFree86: xc/lib/font/fontfile/dirfile.c,v 3.15 2002/05/31 18:45:50 dawes Exp $ */
+/* $XFree86: xc/lib/font/fontfile/dirfile.c,v 3.16 2003/04/07 16:23:31 eich Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -90,6 +90,8 @@ FontFileReadDirectory (char *directory, FontDirectoryPtr *pdir)
strcat(dir_file, FontDirFile);
file = fopen(dir_file, "r");
if (file) {
+ Bool found_font = FALSE;
+
if (fstat (fileno(file), &statb) == -1)
return BadFontPath;
count = fscanf(file, "%d\n", &i);
@@ -106,6 +108,7 @@ FontFileReadDirectory (char *directory, FontDirectoryPtr *pdir)
if (format[0] == '\0')
sprintf(format, "%%%ds %%%d[^\n]\n",
MAXFONTFILENAMELEN-1, MAXFONTNAMELEN-1);
+
while ((count = fscanf(file, format, file_name, font_name)) != EOF) {
#ifdef __UNIXOS2__
/* strip any existing trailing CR */
@@ -118,14 +121,16 @@ FontFileReadDirectory (char *directory, FontDirectoryPtr *pdir)
fclose(file);
return BadFontPath;
}
- if (!FontFileAddFontFile (dir, font_name, file_name))
- {
- FontFileFreeDir (dir);
- fclose(file);
- return BadFontPath;
- }
+ if (FontFileAddFontFile (dir, font_name, file_name))
+ found_font = TRUE;
+ }
+ if (!found_font) {
+ FontFileFreeDir (dir);
+ fclose(file);
+ return BadFontPath;
}
fclose(file);
+
} else if (errno != ENOENT) {
return BadFontPath;
}
diff --git a/src/fontfile/ffcheck.c b/src/fontfile/ffcheck.c
index 4de2a4b..5289b7f 100644
--- a/src/fontfile/ffcheck.c
+++ b/src/fontfile/ffcheck.c
@@ -25,7 +25,7 @@ used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
-/* $XFree86: xc/lib/font/fontfile/ffcheck.c,v 1.15 2001/12/14 19:56:51 dawes Exp $ */
+/* $XFree86: xc/lib/font/fontfile/ffcheck.c,v 1.16 2003/05/27 22:26:49 tsi Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -115,9 +115,6 @@ FontFileCheckListNextFontOrAlias(pointer client, FontPathElementPtr fpe,
return BadFontName;
}
-typedef int (*IntFunc) (void);
-static int font_file_check_type;
-
void
FontFileCheckRegisterFpeFunctions (void)
{
@@ -160,19 +157,19 @@ FontFileCheckRegisterFpeFunctions (void)
}
#endif
- font_file_check_type = RegisterFPEFunctions(FontFileNameCheck,
- FontFileInitFPE,
- FontFileFreeFPE,
- FontFileResetFPE,
- FontFileCheckOpenFont,
- FontFileCloseFont,
- FontFileCheckListFonts,
- FontFileCheckStartListFontsWithInfo,
- FontFileCheckListNextFontWithInfo,
- NULL,
- NULL,
- NULL,
- FontFileCheckStartListFontsAndAliases,
- FontFileCheckListNextFontOrAlias,
- FontFileEmptyBitmapSource);
+ RegisterFPEFunctions(FontFileNameCheck,
+ FontFileInitFPE,
+ FontFileFreeFPE,
+ FontFileResetFPE,
+ FontFileCheckOpenFont,
+ FontFileCloseFont,
+ FontFileCheckListFonts,
+ FontFileCheckStartListFontsWithInfo,
+ FontFileCheckListNextFontWithInfo,
+ NULL,
+ NULL,
+ NULL,
+ FontFileCheckStartListFontsAndAliases,
+ FontFileCheckListNextFontOrAlias,
+ FontFileEmptyBitmapSource);
}
diff --git a/src/fontfile/fontdir.c b/src/fontfile/fontdir.c
index a2bd411..28e58b6 100644
--- a/src/fontfile/fontdir.c
+++ b/src/fontfile/fontdir.c
@@ -25,7 +25,7 @@ used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
-/* $XFree86: xc/lib/font/fontfile/fontdir.c,v 3.19 2002/05/31 18:45:50 dawes Exp $ */
+/* $XFree86: xc/lib/font/fontfile/fontdir.c,v 3.22 2003/07/07 16:40:11 eich Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -678,11 +678,10 @@ FontFileAddFontFile (FontDirectoryPtr dir, char *fontName, char *fileName)
#endif
if (!isscale || (vals.values_supplied & SIZE_SPECIFY_MASK))
{
- /* If the fontname says it is nonScalable, make sure that the
- * renderer supports OpenBitmap and GetInfoBitmap.
+ /*
+ * If the renderer doesn't support OpenBitmap, FontFileOpenFont
+ * will still do the right thing.
*/
- if (renderer->OpenBitmap && renderer->GetInfoBitmap)
- {
entry.type = FONT_ENTRY_BITMAP;
entry.u.bitmap.renderer = renderer;
entry.u.bitmap.pFont = NullFont;
@@ -693,7 +692,6 @@ FontFileAddFontFile (FontDirectoryPtr dir, char *fontName, char *fileName)
xfree (entry.u.bitmap.fileName);
return FALSE;
}
- }
}
/*
* Parse out scalable fields from XLFD names - a scalable name
@@ -701,11 +699,6 @@ FontFileAddFontFile (FontDirectoryPtr dir, char *fontName, char *fileName)
*/
if (isscale)
{
- /* If the fontname says it is scalable, make sure that the
- * renderer supports OpenScalable and GetInfoScalable.
- */
- if (renderer->OpenScalable && renderer->GetInfoScalable)
- {
if (vals.values_supplied & SIZE_SPECIFY_MASK)
{
bzero((char *)&zeroVals, sizeof(zeroVals));
@@ -728,10 +721,13 @@ FontFileAddFontFile (FontDirectoryPtr dir, char *fontName, char *fileName)
if (!(existing->u.scalable.fileName = FontFileSaveString (fileName)))
return FALSE;
}
- FontFileCompleteXLFD(&vals, &vals);
- FontFileAddScaledInstance (existing, &vals, NullFont,
- bitmap->name.name);
- return TRUE;
+ if(bitmap)
+ {
+ FontFileCompleteXLFD(&vals, &vals);
+ FontFileAddScaledInstance (existing, &vals, NullFont,
+ bitmap->name.name);
+ return TRUE;
+ }
}
}
if (!(entry.u.scalable.fileName = FontFileSaveString (fileName)))
@@ -795,11 +791,13 @@ FontFileAddFontFile (FontDirectoryPtr dir, char *fontName, char *fileName)
}
if (vals.values_supplied & SIZE_SPECIFY_MASK)
{
- FontFileCompleteXLFD(&vals, &vals);
- FontFileAddScaledInstance (scalable, &vals, NullFont,
- bitmap->name.name);
+ if(bitmap)
+ {
+ FontFileCompleteXLFD(&vals, &vals);
+ FontFileAddScaledInstance (scalable, &vals, NullFont,
+ bitmap->name.name);
+ }
}
- }
}
return TRUE;
}
diff --git a/src/fontfile/fontfile.c b/src/fontfile/fontfile.c
index 1e39413..6378c39 100644
--- a/src/fontfile/fontfile.c
+++ b/src/fontfile/fontfile.c
@@ -25,7 +25,7 @@ used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
-/* $XFree86: xc/lib/font/fontfile/fontfile.c,v 3.16 2002/05/31 18:45:50 dawes Exp $ */
+/* $XFree86: xc/lib/font/fontfile/fontfile.c,v 3.19 2003/11/08 02:02:03 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -331,8 +331,7 @@ FontFileOpenFont (pointer client, FontPathElementPtr fpe, Mask flags,
if (!FontParseXLFDName (lowerName, &vals, FONT_XLFD_REPLACE_ZERO) ||
!(tmpName.length = strlen (lowerName),
entry = FontFileFindNameInScalableDir (&dir->scalable, &tmpName,
- &vals)))
- {
+ &vals))) {
CopyISOLatin1Lowered (lowerName, name, namelen);
lowerName[namelen] = '\0';
tmpName.name = lowerName;
@@ -497,6 +496,8 @@ FontFileOpenBitmapNCF (FontPathElementPtr fpe, FontPtr *pFont,
dir = (FontDirectoryPtr) fpe->private;
bitmap = &entry->u.bitmap;
+ if(!bitmap || !bitmap->renderer->OpenBitmap)
+ return BadFontName;
strcpy (fileName, dir->directory);
strcat (fileName, bitmap->fileName);
ret = (*bitmap->renderer->OpenBitmap)
@@ -811,26 +812,112 @@ FontFileListOneFontWithInfo (pointer client, FontPathElementPtr fpe,
FontScalableEntryPtr scalable;
FontScaledPtr scaled;
FontBitmapEntryPtr bitmap;
- FontAliasEntryPtr alias;
int ret;
+ Bool noSpecificSize;
+ int nranges;
+ fsRange *ranges;
+
char *name = *namep;
int namelen = *namelenp;
- Bool noSpecificSize;
if (namelen >= MAXFONTNAMELEN)
return AllocError;
dir = (FontDirectoryPtr) fpe->private;
+
+ /* Match non-scalable pattern */
CopyISOLatin1Lowered (lowerName, name, namelen);
lowerName[namelen] = '\0';
+ ranges = FontParseRanges(lowerName, &nranges);
tmpName.name = lowerName;
tmpName.length = namelen;
tmpName.ndashes = FontFileCountDashes (lowerName, namelen);
- /* Match XLFD patterns */
- if (tmpName.ndashes == 14 &&
+ if (!FontParseXLFDName(lowerName, &vals, FONT_XLFD_REPLACE_NONE))
+ bzero(&vals, sizeof(vals));
+ if (!(entry = FontFileFindNameInDir (&dir->nonScalable, &tmpName)) &&
+ tmpName.ndashes == 14 &&
FontParseXLFDName (lowerName, &vals, FONT_XLFD_REPLACE_ZERO))
{
- tmpName.length = strlen (lowerName);
+ tmpName.length = strlen(lowerName);
+ entry = FontFileFindNameInDir (&dir->nonScalable, &tmpName);
+ }
+
+ if (entry)
+ {
+ switch (entry->type) {
+ case FONT_ENTRY_BITMAP:
+ bitmap = &entry->u.bitmap;
+ if (bitmap->pFont)
+ {
+ *pFontInfo = &bitmap->pFont->info;
+ ret = Successful;
+ }
+ else
+ {
+ ret = FontFileGetInfoBitmap (fpe, *pFontInfo, entry);
+ }
+ break;
+ case FONT_ENTRY_ALIAS:
+ vals.nranges = nranges;
+ vals.ranges = ranges;
+ transfer_values_to_alias(entry->name.name, entry->name.length,
+ entry->u.alias.resolved, namep, &vals);
+ *namelenp = strlen (*namep);
+ ret = FontNameAlias;
+ break;
+#ifdef NOTYET
+ case FONT_ENTRY_BC:
+ /* no LFWI for this yet */
+ bc = &entry->u.bc;
+ entry = bc->entry;
+ /* Make a new scaled instance */
+ strcpy (fileName, dir->directory);
+ strcat (fileName, scalable->fileName);
+ ret = (*scalable->renderer->GetInfoScalable)
+ (fpe, *pFontInfo, entry, tmpName, fileName, &bc->vals);
+ break;
+#endif
+ default:
+ ret = BadFontName;
+ }
+ }
+ else
+ {
+ ret = BadFontName;
+ }
+
+ if (ret != BadFontName)
+ {
+ if (ranges) xfree(ranges);
+ return ret;
+ }
+
+ /* Match XLFD patterns */
+ CopyISOLatin1Lowered (lowerName, name, namelen);
+ lowerName[namelen] = '\0';
+ tmpName.name = lowerName;
+ tmpName.length = namelen;
+ tmpName.ndashes = FontFileCountDashes (lowerName, namelen);
+ if (!FontParseXLFDName (lowerName, &vals, FONT_XLFD_REPLACE_ZERO) ||
+ !(tmpName.length = strlen (lowerName),
+ entry = FontFileFindNameInScalableDir (&dir->scalable, &tmpName,
+ &vals))) {
+ CopyISOLatin1Lowered (lowerName, name, namelen);
+ lowerName[namelen] = '\0';
+ tmpName.name = lowerName;
+ tmpName.length = namelen;
+ tmpName.ndashes = FontFileCountDashes (lowerName, namelen);
entry = FontFileFindNameInScalableDir (&dir->scalable, &tmpName, &vals);
+ if (entry)
+ {
+ strcpy(lowerName, entry->name.name);
+ tmpName.name = lowerName;
+ tmpName.length = entry->name.length;
+ tmpName.ndashes = entry->name.ndashes;
+ }
+ }
+
+ if (entry)
+ {
noSpecificSize = FALSE; /* TRUE breaks XLFD enhancements */
if (entry && entry->type == FONT_ENTRY_SCALABLE &&
FontFileCompleteXLFD (&vals, &entry->u.scalable.extra->defaults))
@@ -883,13 +970,13 @@ FontFileListOneFontWithInfo (pointer client, FontPathElementPtr fpe,
#endif
{
char origName[MAXFONTNAMELEN];
- fsRange *ranges;
CopyISOLatin1Lowered (origName, name, namelen);
origName[namelen] = '\0';
vals.xlfdName = origName;
- vals.ranges = FontParseRanges(origName, &vals.nranges);
- ranges = vals.ranges;
+ vals.ranges = ranges;
+ vals.nranges = nranges;
+
/* Make a new scaled instance */
strcpy (fileName, dir->directory);
strcat (fileName, scalable->fileName);
@@ -903,48 +990,11 @@ FontFileListOneFontWithInfo (pointer client, FontPathElementPtr fpe,
CopyISOLatin1Lowered (lowerName, name, namelen);
tmpName.length = namelen;
}
- /* Match non XLFD pattern */
- if ((entry = FontFileFindNameInDir (&dir->nonScalable, &tmpName)))
- {
- switch (entry->type) {
- case FONT_ENTRY_BITMAP:
- bitmap = &entry->u.bitmap;
- if (bitmap->pFont)
- {
- *pFontInfo = &bitmap->pFont->info;
- ret = Successful;
- }
- else
- {
- ret = FontFileGetInfoBitmap (fpe, *pFontInfo, entry);
- }
- break;
- case FONT_ENTRY_ALIAS:
- alias = &entry->u.alias;
- *(char **)pFontInfo = name;
- *namelenp = strlen (*namep = alias->resolved);
- ret = FontNameAlias;
- break;
-#ifdef NOTYET
- case FONT_ENTRY_BC:
- /* no LFWI for this yet */
- bc = &entry->u.bc;
- entry = bc->entry;
- /* Make a new scaled instance */
- strcpy (fileName, dir->directory);
- strcat (fileName, scalable->fileName);
- ret = (*scalable->renderer->GetInfoScalable)
- (fpe, *pFontInfo, entry, tmpName, fileName, &bc->vals);
- break;
-#endif
- default:
- ret = BadFontName;
- }
- }
else
- {
ret = BadFontName;
- }
+
+ if (ranges)
+ xfree(ranges);
return ret;
}
@@ -1048,26 +1098,22 @@ FontFileListNextFontOrAlias(pointer client, FontPathElementPtr fpe,
return ret;
}
-
-typedef int (*IntFunc) (void);
-static int font_file_type;
-
void
FontFileRegisterLocalFpeFunctions (void)
{
- font_file_type = RegisterFPEFunctions(FontFileNameCheck,
- FontFileInitFPE,
- FontFileFreeFPE,
- FontFileResetFPE,
- FontFileOpenFont,
- FontFileCloseFont,
- FontFileListFonts,
- FontFileStartListFontsWithInfo,
- FontFileListNextFontWithInfo,
- NULL,
- NULL,
- NULL,
- FontFileStartListFontsAndAliases,
- FontFileListNextFontOrAlias,
- FontFileEmptyBitmapSource);
+ RegisterFPEFunctions(FontFileNameCheck,
+ FontFileInitFPE,
+ FontFileFreeFPE,
+ FontFileResetFPE,
+ FontFileOpenFont,
+ FontFileCloseFont,
+ FontFileListFonts,
+ FontFileStartListFontsWithInfo,
+ FontFileListNextFontWithInfo,
+ NULL,
+ NULL,
+ NULL,
+ FontFileStartListFontsAndAliases,
+ FontFileListNextFontOrAlias,
+ FontFileEmptyBitmapSource);
}
diff --git a/src/fontfile/printerfont.c b/src/fontfile/printerfont.c
index 6759e91..112b1bc 100644
--- a/src/fontfile/printerfont.c
+++ b/src/fontfile/printerfont.c
@@ -25,7 +25,7 @@ used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
-/* $XFree86: xc/lib/font/fontfile/printerfont.c,v 1.5 2001/12/14 19:56:52 dawes Exp $ */
+/* $XFree86: xc/lib/font/fontfile/printerfont.c,v 1.6 2003/05/27 22:26:49 tsi Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -154,26 +154,22 @@ PrinterFontListNextFontOrAlias(pointer client, FontPathElementPtr fpe,
return BadFontName;
}
-typedef int (*IntFunc) (void);
-static int printer_font_type;
-
void
PrinterFontRegisterFpeFunctions (void)
{
- /* what is the use of printer font type? */
- printer_font_type = RegisterFPEFunctions(PrinterFontNameCheck,
- PrinterFontInitFPE,
- FontFileFreeFPE,
- FontFileResetFPE,
- PrinterFontOpenFont,
- FontFileCloseFont,
- PrinterFontListFonts,
- PrinterFontStartListFontsWithInfo,
- PrinterFontListNextFontWithInfo,
- NULL,
- NULL,
- NULL,
- PrinterFontStartListFontsAndAliases,
- PrinterFontListNextFontOrAlias,
- FontFileEmptyBitmapSource);
+ RegisterFPEFunctions(PrinterFontNameCheck,
+ PrinterFontInitFPE,
+ FontFileFreeFPE,
+ FontFileResetFPE,
+ PrinterFontOpenFont,
+ FontFileCloseFont,
+ PrinterFontListFonts,
+ PrinterFontStartListFontsWithInfo,
+ PrinterFontListNextFontWithInfo,
+ NULL,
+ NULL,
+ NULL,
+ PrinterFontStartListFontsAndAliases,
+ PrinterFontListNextFontOrAlias,
+ FontFileEmptyBitmapSource);
}
diff --git a/src/stubs/errorf.c b/src/stubs/errorf.c
index 44d675c..7fdd1d5 100644
--- a/src/stubs/errorf.c
+++ b/src/stubs/errorf.c
@@ -1,9 +1,9 @@
-/* $XFree86: xc/lib/font/stubs/errorf.c,v 1.1 1999/01/11 05:13:19 dawes Exp $ */
+/* $XFree86: xc/lib/font/stubs/errorf.c,v 1.2 2003/09/13 21:33:02 dawes Exp $ */
#include "stubs.h"
void
-ErrorF(char *f)
+ErrorF(const char *f, ...)
{
}
diff --git a/src/stubs/fatalerror.c b/src/stubs/fatalerror.c
index 62f571c..dbbfdd4 100644
--- a/src/stubs/fatalerror.c
+++ b/src/stubs/fatalerror.c
@@ -1,9 +1,9 @@
-/* $XFree86: xc/lib/font/stubs/fatalerror.c,v 1.1 1999/01/11 05:13:19 dawes Exp $ */
+/* $XFree86: xc/lib/font/stubs/fatalerror.c,v 1.2 2003/09/13 21:33:02 dawes Exp $ */
#include "stubs.h"
void
-FatalError(char *f)
+FatalError(const char *f, ...)
{
}
diff --git a/src/stubs/initfshdl.c b/src/stubs/initfshdl.c
index 13d2230..7a7f024 100644
--- a/src/stubs/initfshdl.c
+++ b/src/stubs/initfshdl.c
@@ -1,10 +1,10 @@
-/* $XFree86: xc/lib/font/stubs/initfshdl.c,v 1.1 1999/01/11 05:13:20 dawes Exp $ */
+/* $XFree86: xc/lib/font/stubs/initfshdl.c,v 1.2 2003/09/13 21:33:02 dawes Exp $ */
#include "stubs.h"
int
init_fs_handlers(FontPathElementPtr fpe,
- void (*block_handler)())
+ BlockHandlerProcPtr block_handler)
{
return Successful;
}
diff --git a/src/stubs/rmfshdl.c b/src/stubs/rmfshdl.c
index 4e6d1da..1c6f650 100644
--- a/src/stubs/rmfshdl.c
+++ b/src/stubs/rmfshdl.c
@@ -1,10 +1,10 @@
-/* $XFree86: xc/lib/font/stubs/rmfshdl.c,v 1.1 1999/01/11 05:13:21 dawes Exp $ */
+/* $XFree86: xc/lib/font/stubs/rmfshdl.c,v 1.2 2003/09/13 21:33:03 dawes Exp $ */
#include "stubs.h"
void
remove_fs_handlers(FontPathElementPtr fpe,
- void (*block_handler) (),
+ BlockHandlerProcPtr blockHandler,
Bool all)
{
}
diff --git a/src/stubs/stubs.h b/src/stubs/stubs.h
index e88dc39..097b60c 100644
--- a/src/stubs/stubs.h
+++ b/src/stubs/stubs.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/font/stubs/stubs.h,v 1.3 1999/12/15 01:14:36 robin Exp $ */
+/* $XFree86: xc/lib/font/stubs/stubs.h,v 1.4 2003/09/13 21:33:03 dawes Exp $ */
/* This directory includes dummy entry for bdftopcf and mkfontdir */
@@ -15,15 +15,13 @@
#endif
extern FontPtr find_old_font ( FSID id );
-extern FontResolutionPtr GetClientResolutions ( int *num );
-extern int GetDefaultPointSize ( void );
extern int set_font_authorizations ( char **authorizations,
int *authlen,
ClientPtr client );
-extern Bool XpClientIsBitmapClient ( ClientPtr client );
-extern Bool XpClientIsPrintClient ( ClientPtr client,
- FontPathElementPtr fpe );
extern unsigned long GetTimeInMillis (void);
+extern void ErrorF(const char *format, ...);
+extern void FatalError(const char *format, ...);
+
/* end of file */
diff --git a/src/util/fontxlfd.c b/src/util/fontxlfd.c
index 3a2c93d..593f84c 100644
--- a/src/util/fontxlfd.c
+++ b/src/util/fontxlfd.c
@@ -27,7 +27,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
-/* $XFree86: xc/lib/font/util/fontxlfd.c,v 3.15 2002/05/31 18:45:50 dawes Exp $ */
+/* $XFree86: xc/lib/font/util/fontxlfd.c,v 3.17 2003/10/24 16:11:52 tsi Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -197,7 +197,8 @@ xlfd_round_double(double x)
defined(ia64) || defined(__ia64__) || \
defined(__alpha__) || defined(__alpha) || \
defined(__hppa__) || \
- defined(__x86_64__) || defined(__x86_64)
+ defined(__AMD64__) || defined(__AMD64) || \
+ defined(sgi)
#if !defined(__UNIXOS2__)
#include <float.h>
@@ -214,27 +215,27 @@ xlfd_round_double(double x)
/* convert # of decimal digits to # of binary digits */
#define XLFD_NDIGITS_2 ((int)(XLFD_NDIGITS * M_LN10 / M_LN2 + 0.5))
-
+
union conv_d {
double d;
unsigned char b[8];
} d;
int i,j,k,d_exp;
-
- if (x == 0)
+
+ if (x == 0)
return x;
/* do minor sanity check for IEEE 754 fp and correct byte order */
d.d = 1.0;
if (sizeof(double) == 8 && d.b[7] == 0x3f && d.b[6] == 0xf0) {
-
- /*
+
+ /*
* this code will round IEEE 754 double to XLFD_NDIGITS_2 binary digits
*/
-
+
d.d = x;
d_exp = (d.b[7] << 4) | (d.b[6] >> 4);
-
+
i = (DBL_MANT_DIG-XLFD_NDIGITS_2) >> 3;
j = 1 << ((DBL_MANT_DIG-XLFD_NDIGITS_2) & 0x07);
for (; i<7; i++) {
@@ -249,25 +250,25 @@ xlfd_round_double(double x)
d.b[7] = d_exp >> 4;
d.b[6] = (d.b[6] & 0x0f) | (d_exp << 4);
}
-
+
i = (DBL_MANT_DIG-XLFD_NDIGITS_2) >> 3;
- j = 1 << ((DBL_MANT_DIG-XLFD_NDIGITS_2) & 0x07);
+ j = 1 << ((DBL_MANT_DIG-XLFD_NDIGITS_2) & 0x07);
d.b[i] &= ~(j-1);
for (;--i>=0;) d.b[i] = 0;
return d.d;
}
- else
+ else
#endif
#endif /* !__UNIXOS2__ */
#endif /* i386 || __i386__ */
{
/*
- * If not IEEE 754: Let printf() do it for you.
+ * If not IEEE 754: Let printf() do it for you.
*/
-
+
char formatbuf[40], buffer[40];
-
+
sprintf(formatbuf, "%%.%dlg", XLFD_NDIGITS);
sprintf(buffer, formatbuf, x);
return atof(buffer);
@@ -352,7 +353,7 @@ GetMatrix(char *ptr, FontScalablePtr vals, int which)
}
-static void
+static void
append_ranges(char *fname, int nranges, fsRange *ranges)
{
if (nranges)
@@ -366,9 +367,9 @@ append_ranges(char *fname, int nranges, fsRange *ranges)
sprintf(fname + strlen(fname), "%d",
minchar(ranges[i]));
if (ranges[i].min_char_low ==
- ranges[i].max_char_low &&
- ranges[i].min_char_high ==
- ranges[i].max_char_high) continue;
+ ranges[i].max_char_low &&
+ ranges[i].min_char_high ==
+ ranges[i].max_char_high) continue;
sprintf(fname + strlen(fname), "_%d",
maxchar(ranges[i]));
}
diff --git a/src/util/private.c b/src/util/private.c
index ef7d48b..729d41a 100644
--- a/src/util/private.c
+++ b/src/util/private.c
@@ -25,7 +25,7 @@ used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
-/* $XFree86: xc/lib/font/util/private.c,v 1.8 2001/12/14 19:56:57 dawes Exp $ */
+/* $XFree86: xc/lib/font/util/private.c,v 1.9 2003/02/27 22:19:20 tsi Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -51,9 +51,9 @@ CreateFontRec (void)
size = sizeof(FontRec) + (sizeof(pointer) * _FontPrivateAllocateIndex);
pFont = (FontPtr)xalloc(size);
- bzero((char*)pFont, size);
if(pFont) {
+ bzero((char*)pFont, size);
pFont->maxPrivate = _FontPrivateAllocateIndex - 1;
if(_FontPrivateAllocateIndex)
pFont->devPrivates = (pointer)(&pFont[1]);
@@ -62,7 +62,8 @@ CreateFontRec (void)
return pFont;
}
-void DestroyFontRec (FontPtr pFont)
+void
+DestroyFontRec (FontPtr pFont)
{
if (pFont->devPrivates && pFont->devPrivates != (pointer)(&pFont[1]))
xfree(pFont->devPrivates);