Hello,
Following the objections to my previous patch, here's a version that
sports three build-time and two runtime mechanisms for configuring the
bitmap scaling code in or out. Say wow.
By default, bitmap scaling is compiled in; naked FPEs do not scale
bitmaps, the ``:scaled'' attribute can be used to enable bitmap
scaling. I understand this is the behaviour that Keith and Mike
condone.
The bitmap scaler can be compiled out with -DNO_BITMAP_SCALER; in
order to remove the ``:foo'' parsing code, don't -DFONTDIRATTRIB.
Both flags are controlled by the NoBitmapScaler Imake flag.
At runtime, the default for naked FPEs is controlled by the global
variable ``defaultScaleBitmaps''. This variable is initialised to
DEFAULT_SCALE_BITMAPS, which defaults to false. There is currently no
way to change its value at runtime other than by using a debugger. If
defaultScaleBitmaps is true, it can be overridden by using
``:unscaled''.
(Somebody could write an extension to control the value of
defaultScaleBitmaps at runtime. After all, that's no more ridiculous
than the FontCache extension.)
Juliusz
? xc/lib/font/fontfile/DONE
? xc/lib/font/fontfile/Makefile
Index: xc/lib/font/fontfile/Imakefile
===================================================================
RCS file: /cvs/xc/lib/font/fontfile/Imakefile,v
retrieving revision 3.21
diff -c -r3.21 Imakefile
*** xc/lib/font/fontfile/Imakefile 2002/02/13 21:32:48 3.21
--- xc/lib/font/fontfile/Imakefile 2002/06/03 06:32:02
***************
*** 49,58 ****
GZIP_DEFS = -DX_GZIP_FONT_COMPRESSION
#endif
ATTRIBDEFS = -DFONTDIRATTRIB
FONTENCDEFS = -DFONT_ENCODINGS_DIRECTORY=\"$(FONTDIR)/encodings/encodings.dir\"
! DEFINES = StrcasecmpDefines $(ATTRIBDEFS) \
$(SPEEDO_DEFINES) $(TYPE1_DEFINES) $(CID_DEFINES) \
$(FREETYPE_DEFINES) $(XTRUETYPE_DEFINES) $(FONTENCDEFS) \
$(GZIP_DEFS)
--- 49,69 ----
GZIP_DEFS = -DX_GZIP_FONT_COMPRESSION
#endif
+ #if NoBitmapScaler
+ #if ForceFontDirAttrib
ATTRIBDEFS = -DFONTDIRATTRIB
+ #endif
+ #else
+ ATTRIBDEFS = -DFONTDIRATTRIB
+ #endif
+
+ #if NoBitmapScaler
+ BITSCALE_DEFS = -DNO_BITMAP_SCALER
+ #endif
+
FONTENCDEFS = -DFONT_ENCODINGS_DIRECTORY=\"$(FONTDIR)/encodings/encodings.dir\"
! DEFINES = StrcasecmpDefines $(ATTRIBDEFS) $(BITSCALE_DEFS)\
$(SPEEDO_DEFINES) $(TYPE1_DEFINES) $(CID_DEFINES) \
$(FREETYPE_DEFINES) $(XTRUETYPE_DEFINES) $(FONTENCDEFS) \
$(GZIP_DEFS)
Index: xc/lib/font/fontfile/fontdir.c
===================================================================
RCS file: /cvs/xc/lib/font/fontfile/fontdir.c,v
retrieving revision 3.18
diff -c -r3.18 fontdir.c
*** xc/lib/font/fontfile/fontdir.c 2001/12/14 19:56:51 3.18
--- xc/lib/font/fontfile/fontdir.c 2002/06/03 06:32:02
***************
*** 34,39 ****
--- 34,49 ----
#include "fntfilst.h"
#include <X11/keysym.h>
+ /* Whether to scale bitmap fonts when neither :unscaled nor :scaled
+ * are present. If a different default is desired, the command-line
+ * parsing code should set this. */
+
+ #ifndef DEFAULT_SCALE_BITMAPS
+ #define DEFAULT_SCALE_BITMAPS 0
+ #endif
+
+ int defaultScaleBitmaps = DEFAULT_SCALE_BITMAPS;
+
Bool
FontFileInitTable (FontTablePtr table, int size)
{
***************
*** 654,681 ****
(vals.values_supplied & PIXELSIZE_MASK) != PIXELSIZE_ARRAY &&
(vals.values_supplied & POINTSIZE_MASK) != POINTSIZE_ARRAY &&
!(vals.values_supplied & ENHANCEMENT_SPECIFY_MASK);
#ifdef FONTDIRATTRIB
#define UNSCALED_ATTRIB "unscaled"
! /* For scalable fonts, check if the "unscaled" attribute is present */
! if (isscale && dir->attributes && dir->attributes[0] == ':') {
! char *ptr1 = dir->attributes + 1;
! char *ptr2;
! int length;
! int uslength = strlen(UNSCALED_ATTRIB);
!
! do {
! ptr2 = strchr(ptr1, ':');
! if (ptr2)
! length = ptr2 - ptr1;
! else
! length = dir->attributes + strlen(dir->attributes) - ptr1;
! if (length == uslength && !strncmp(ptr1, UNSCALED_ATTRIB, uslength))
! isscale = FALSE;
! if (ptr2)
! ptr1 = ptr2 + 1;
! } while (ptr2);
! }
#endif
if (!isscale || (vals.values_supplied & SIZE_SPECIFY_MASK))
{
/* If the fontname says it is nonScalable, make sure that the
--- 664,710 ----
(vals.values_supplied & PIXELSIZE_MASK) != PIXELSIZE_ARRAY &&
(vals.values_supplied & POINTSIZE_MASK) != POINTSIZE_ARRAY &&
!(vals.values_supplied & ENHANCEMENT_SPECIFY_MASK);
+
+ if (isscale) {
+ int surelyScale = FALSE;
+
#ifdef FONTDIRATTRIB
#define UNSCALED_ATTRIB "unscaled"
! #define SCALED_ATTRIB "scaled"
! /* For scalable fonts, check if the "unscaled" or "scaled" attribute
! * is present */
!
! if(dir->attributes && dir->attributes[0] == ':') {
! char *ptr1 = dir->attributes + 1;
! char *ptr2;
! int length;
! int uslength = strlen(UNSCALED_ATTRIB);
! int slength = strlen(SCALED_ATTRIB);
!
! /* Yuck. */
! do {
! ptr2 = strchr(ptr1, ':');
! if (ptr2)
! length = ptr2 - ptr1;
! else
! length = dir->attributes + strlen(dir->attributes) - ptr1;
! if (length == uslength &&
! strncmp(ptr1, UNSCALED_ATTRIB, uslength) == 0)
! isscale = FALSE;
! else if (length == slength &&
! strncmp(ptr1, SCALED_ATTRIB, slength) == 0)
! surelyScale = TRUE;
! if (ptr2)
! ptr1 = ptr2 + 1;
! } while (ptr2);
! }
#endif
+
+ if(!surelyScale)
+ if(!defaultScaleBitmaps)
+ isscale = FALSE;
+ }
+
if (!isscale || (vals.values_supplied & SIZE_SPECIFY_MASK))
{
/* If the fontname says it is nonScalable, make sure that the
Index: xc/lib/font/fontfile/fontfile.c
===================================================================
RCS file: /cvs/xc/lib/font/fontfile/fontfile.c,v
retrieving revision 3.15
diff -c -r3.15 fontfile.c
*** xc/lib/font/fontfile/fontfile.c 2001/12/14 19:56:51 3.15
--- xc/lib/font/fontfile/fontfile.c 2002/06/03 06:32:03
***************
*** 381,386 ****
--- 381,387 ----
(*pFont)->fpe = fpe;
ret = Successful;
}
+ #ifndef NO_BITMAP_SCALER
else if (scaled->bitmap)
{
entry = scaled->bitmap;
***************
*** 400,405 ****
--- 401,407 ----
(*pFont)->fpe = fpe;
}
}
+ #endif
else /* "cannot" happen */
{
ret = BadFontName;
***************
*** 407,413 ****
}
else
{
! ret = FontFileMatchBitmapSource (fpe, pFont, flags, entry, &tmpName,
&vals, format, fmask, noSpecificSize);
if (ret != Successful)
{
char origName[MAXFONTNAMELEN];
--- 409,418 ----
}
else
{
! ret =
! FontFileMatchBitmapSource (fpe, pFont, flags, entry,
! &tmpName, &vals,
! format, fmask, noSpecificSize);
if (ret != Successful)
{
char origName[MAXFONTNAMELEN];
? xc/lib/font/bitmap/DONE
? xc/lib/font/bitmap/Makefile
Index: xc/lib/font/bitmap/Imakefile
===================================================================
RCS file: /cvs/xc/lib/font/bitmap/Imakefile,v
retrieving revision 1.13
diff -c -r1.13 Imakefile
*** xc/lib/font/bitmap/Imakefile 2002/01/18 16:27:19 1.13
--- xc/lib/font/bitmap/Imakefile 2002/06/03 06:32:10
***************
*** 35,41 ****
#if GzipFontCompression
GZIP_DEFS = -DX_GZIP_FONT_COMPRESSION
#endif
! DEFINES = $(BDFDEFS) $(PCFDEFS) $(SNFDEFS)
SRCS = $(BDFSRCS) bitmap.c bitmaputil.c bitscale.c \
bitmapfunc.c $(PCFSRCS) $(SNFSRCS) \
--- 35,44 ----
#if GzipFontCompression
GZIP_DEFS = -DX_GZIP_FONT_COMPRESSION
#endif
! #if NoBitmapScaler
! BITSCALE_DEFS = -DNO_BITMAP_SCALER
! #endif
! DEFINES = $(BDFDEFS) $(PCFDEFS) $(SNFDEFS) $(BITSCALE_DEFS)
SRCS = $(BDFSRCS) bitmap.c bitmaputil.c bitscale.c \
bitmapfunc.c $(PCFSRCS) $(SNFSRCS) \
Index: xc/lib/font/bitmap/bitscale.c
===================================================================
RCS file: /cvs/xc/lib/font/bitmap/bitscale.c,v
retrieving revision 3.22
diff -c -r3.22 bitscale.c
*** xc/lib/font/bitmap/bitscale.c 2001/12/14 19:56:46 3.22
--- xc/lib/font/bitmap/bitscale.c 2002/06/03 06:32:11
***************
*** 49,54 ****
--- 49,80 ----
#define MAX(a,b) (((a)>(b)) ? a : b)
#endif
+ #ifdef NO_BITMAP_SCALER
+
+ /* ARGSUSED */
+ int
+ BitmapOpenScalable (FontPathElementPtr fpe,
+ FontPtr *pFont,
+ int flags,
+ FontEntryPtr entry,
+ char *fileName,
+ FontScalablePtr vals,
+ fsBitmapFormat format,
+ fsBitmapFormatMask fmask,
+ FontPtr non_cachable_font)
+ {
+ return BadFontName;
+ }
+
+ /* ARGSUSED */
+ static void
+ bitmapUnloadScalable (FontPtr pFont)
+ {
+ return BadFontName;
+ }
+
+ #else
+
/* Should get this from elsewhere */
extern int serverGeneration;
***************
*** 1952,1954 ****
--- 1978,1982 ----
xfree (pFont->fontPrivate);
DestroyFontRec (pFont);
}
+
+ #endif