[stsf-commit] stsf/STFontServer/dropins/freetype2 ft2_glue.c, 1.3,
1.4 ftrenderglyph.inc, 1.1.1.1, 1.2 makefile, 1.1.1.1,
1.2 testft2.c, 1.1.1.1, 1.2
Alexander Gelfenbain
stsf-commit at pdx.freedesktop.org
Thu Jul 1 22:00:16 PDT 2004
- Previous message: [stsf-commit] stsf/STFontServer/dropins/dummy makefile, 1.1.1.1,
1.2 scalerglue.c, 1.1.1.1, 1.2
- Next message: [stsf-commit] stsf/STFontServer/loader client.c, 1.1.1.1,
1.2 makefile, 1.2, 1.3 stfsloader.c, 1.2, 1.3 stfsloader.x,
1.1.1.1, 1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Committed by: adg
Index: ft2_glue.c
===================================================================
RCS file: /cvs/stsf/stsf/STFontServer/dropins/freetype2/ft2_glue.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- ft2_glue.c 5 Jun 2004 05:23:03 -0000 1.3
+++ ft2_glue.c 2 Jul 2004 05:00:13 -0000 1.4
@@ -31,10 +31,6 @@
* THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE
* SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
- * You acknowledge that this software is not designed, licensed or intended
- * for use in the design, construction, operation or maintenance of any
- * nuclear facility.
- *
*/
/* $Id$ */
@@ -44,7 +40,7 @@
* @brief Scaler glue for FreeType 2 engine
* @author Alexander Gelfenbain
* @author Jay Hobson
- * @version 0.8
+ * @version 0.11
*
*/
@@ -111,6 +107,9 @@
// 1 - gray-scale
// 2 - LCD Optimized
// 3 - bit-swapped B&W
+ unsigned int aconv; // algorithmic conversion
+ // bit flags: 0x1 - embolden 0x2 - italicize
+
} ScalerCacheRecord, *ScalerCacheRecordPtr;
typedef struct {
@@ -275,6 +274,14 @@
res->gmode = 0;
}
+ res->aconv = 0;
+ if (instance->flags & FS_RF_EMBOLDEN) {
+ res->aconv |= 0x01;
+ }
+ if (instance->flags & FS_RF_ITALICISE) {
+ res->aconv |= 0x02;
+ }
+
DebugStr(3, "scale: [%f %f], Det(scale): %f; ras: [%f %f %f %f], Det(ras): %f",
F16DOT16_TO_FLOAT(res->scale.xx),
F16DOT16_TO_FLOAT(res->scale.yy),
@@ -289,7 +296,7 @@
// Set the width and height
h = (F16DOT16_TO_FLOAT(res->scale.yy) * (double) instance->yres) / 72.0;
w = (F16DOT16_TO_FLOAT(res->scale.xx) * (double) instance->xres) / 72.0;
- FT_Set_Pixel_Sizes(res->face, (FT_UInt) ceil(w), (FT_UInt) ceil(h));
+ FT_Set_Pixel_Sizes(res->face, (FT_UInt) floor(w), (FT_UInt) floor(h));
if (res->ras.xy != 0 || res->ras.yx != 0) {
FT_Set_Transform(res->face, &res->matrix, 0);
@@ -645,6 +652,7 @@
ret = FTRenderGlyphPrim(p->library, p->face, ftglyphID, p->loadFlags, p->renderMode, &p->matrix, 1 /* pad32 */,
+ p->aconv,
metrics, &tbuf, &tbufsize);
if (p->gmode == 3) {
@@ -664,7 +672,6 @@
if (tbufsize > *buffersize) {
-// *buffersize = tbufsize;
ret = ST_FSG_BUFFER;
} else {
memcpy(buffer, tbuf, tbufsize);
@@ -702,8 +709,22 @@
/* const char *longname; */ "FreeType Engine",
/* const char *notice; */ "",
- /* uint32_t flags; */ ST_SF_BITMAP | ST_SF_AUTOHINTING | ST_SF_GRAYSCALE | ST_SF_LCDOPTIMIZED,
- /* uint32_t fontflags; */ ST_FM_TRUETYPE | ST_FM_TTC | ST_FM_TYPE1 | ST_FM_OPENTYPE_TTF | ST_FM_OPENTYPE_OTF | ST_FM_TRUETYPE_GX | ST_FM_PCF,
+ /* uint32_t flags; */ ST_SF_BITMAP |
+ ST_SF_AUTOHINTING |
+ ST_SF_GRAYSCALE |
+ ST_SF_LCDOPTIMIZED |
+ ST_SF_SBITS |
+ ST_SF_EMBOLDEN |
+ ST_SF_OBLIQUE,
+
+ /* uint32_t fontflags; */
+ ST_FM_TRUETYPE |
+ ST_FM_TTC |
+ ST_FM_TYPE1 |
+ ST_FM_OPENTYPE_TTF |
+ ST_FM_OPENTYPE_OTF |
+ ST_FM_TRUETYPE_GX |
+ ST_FM_PCF,
/* StartF Init; */ Start,
/* StopF Stop; */ Stop,
Index: ftrenderglyph.inc
===================================================================
RCS file: /cvs/stsf/stsf/STFontServer/dropins/freetype2/ftrenderglyph.inc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- ftrenderglyph.inc 26 Mar 2004 19:19:56 -0000 1.1.1.1
+++ ftrenderglyph.inc 2 Jul 2004 05:00:13 -0000 1.2
@@ -2,11 +2,82 @@
* For testing purposes it is a separate file for now
*/
+#define PCONV_NONE 0
+#define PCONV_LCD_TO_ALPHAMASK 1
+#define PCONV_EMBOLDEN_BITMAP 2
+#define PCONV_MASK 0x7F
+#define PCONV_PAD_FLAG 0x80
+
+#if X_DEBUG
+void X_DumpData(const byte *p, int len)
+{
+ int i;
+
+ if (p == NULL) {
+ printf("(nil)");
+ return;
+ }
+
+ for (i=0; i<len; i++) {
+ if (isprint(p[i])) {
+ printf("%c", p[i]);
+ } else {
+ printf(".");
+ }
+ }
+}
+#endif
+
+/* adopted from a patch submitted by Firefly (firefly at firefly.idv.tw) to Xft */
+static void EmboldenBitmap(byte *s, byte *d, int height, int sbpr, int dbpr, int mode)
+{
+ byte lsb, tmp;
+ int i, x, y;
+
+ for (y=0; y<height; y++) {
+ lsb = 0;
+ for (x=0; x<sbpr; x++) {
+ switch (mode) {
+ case FT_PIXEL_MODE_GRAY:
+ tmp = s[x];
+ d[x] = s[x] | lsb;
+ break;
+ case FT_PIXEL_MODE_MONO:
+ tmp = s[x] << 7;
+ d[x] = s[x] | (s[x] >> 1) | lsb;
+ break;
+ }
+ lsb = tmp;
+ }
+ s += sbpr;
+ d += dbpr;
+ }
+}
+
+static void CopyBitmap(byte *s, byte *d, int height, int sbpr, int dbpr)
+{
+ int i;
+ for (i=0; i<height; i++) {
+ memmove(d, s, sbpr);
+ s += sbpr;
+ d += dbpr;
+ }
+}
+
+static void ConvertLCDBitmap(byte *s, byte *d, int height, int sbpr, int dbpr, int width)
+{
+ int i, j;
+
+ for (i=0; i<height; i++) {
+ for (j=0; j<width/3; j++) {
+ d[j] = AlphaMasksToLookupIndex(s[j*3], s[j*3 + 1], s[j*3 + 2]);
+ }
+ d += dbpr;
+ s += sbpr;
+
+ }
+}
-enum pconv {
- PCONV_NONE = 0,
- PCONV_LCD_TO_ALPHAMASK = 1
-};
/*
@@ -24,6 +95,7 @@
FT_Render_Mode renderMode,
FT_Matrix *matrix,
int pad32,
+ unsigned int aconv,
ScaledGlyphData *sgd,
byte **buffer,
unsigned *bufsize
@@ -34,7 +106,7 @@
FT_GlyphSlotRec *slotr;
FT_Bitmap *ftbit;
int advx, advy;
- int width, height, bytesPerRow;
+ int width, height, bytesPerRow, sourceBytesPerRow;
FT_Glyph glyph;
FT_BitmapGlyph bglyph;
FT_Vector delta;
@@ -42,14 +114,33 @@
unsigned n;
int pwidth = 0; /* bitmap width in "real" pixels */
int pconv = PCONV_NONE;
+ int emboldenhack = 0;
+ byte *s, *d;
errcode = FT_Load_Glyph(face, glyphID, loadFlags);
slot = face->glyph;
+
+ if (aconv & 0x01) {
+ if (((FT_GlyphSlotRec *) slot)->format == FT_GLYPH_FORMAT_BITMAP) {
+ emboldenhack = 1;
+ } else {
+ FT_GlyphSlot_Embolden(slot);
+ }
+ }
+ if (aconv & 0x02) {
+ FT_GlyphSlot_Oblique(slot);
+ }
+
slotr = (FT_GlyphSlotRec *) slot;
advx = ((FT_GlyphSlotRec *) slot)->advance.x;
advy = ((FT_GlyphSlotRec *) slot)->advance.y;
+#if X_DEBUG
+ printf("GlyphSlot format: [");
+ X_DumpData((const byte *) &((FT_GlyphSlotRec *)slot)->format, 4);
+ printf("]\n");
+#endif
#ifdef X_DEBUG
#if 0 /* Horizontal and vertical */
@@ -106,15 +197,27 @@
printf(" width: %d, height: %d\n", width, height);
#endif
- if (FT_Get_Glyph(face->glyph, &glyph)) return -1;
+ if (FT_Get_Glyph(face->glyph, &glyph)) {
+ DebugStr(1, "%s: FT_Get_Glyph error", __func__);
+ return -1;
+ }
+
+ DebugStr(1, "*** FT_Glyph_Format: %d", ((FT_GlyphRec *) glyph)->format);
delta.x = delta.y = 0;
- if (face->face_flags & FT_FACE_FLAG_SCALABLE) {
- if (FT_Glyph_Transform(glyph, matrix, 0)) return -1;
+
+ if (((FT_GlyphRec *) glyph)->format != FT_GLYPH_FORMAT_BITMAP) {
+ if (FT_Glyph_Transform(glyph, matrix, 0)) {
+ DebugStr(1, "%s: FT_Glyph_Transfrom error", __func__);
+ return -1;
+ }
}
- if (FT_Glyph_To_Bitmap(&glyph, renderMode, 0, 1)) return -1;
+ if ((errcode = FT_Glyph_To_Bitmap(&glyph, renderMode, 0, 1)) != 0) {
+ DebugStr(1, "%s: FT_Glyph_To_Bitmap error: %d", __func__, errcode);
+ return -1;
+ }
bglyph = (FT_BitmapGlyph) glyph;
ftbit = &bglyph->bitmap;
@@ -127,57 +230,48 @@
sgd->topH = bglyph->top << 16;
sgd->leftH = bglyph->left << 16;
-#if 0
-#ifdef STSF_PAD32
- if (renderMode == FT_RENDER_MODE_MONO) {
- bytesPerRow = 4 * ((ftbit->width + 31) >> 5);
- } else {
- bytesPerRow = (ftbit->width + 3) & ~3;
- }
-#else
- if (renderMode == FT_RENDER_MODE_MONO) {
- bytesPerRow = (ftbit->width + 7) >> 3;
- } else {
- bytesPerRow = ftbit->width;
- }
-#endif
-#endif // 0
switch (ftbit->pixel_mode) {
- case FT_PIXEL_MODE_LCD:
- pwidth = ftbit->width / 3;
- pconv = PCONV_LCD_TO_ALPHAMASK;
- break;
+ case FT_PIXEL_MODE_LCD:
+ pwidth = ftbit->width / 3;
+ pconv = PCONV_LCD_TO_ALPHAMASK;
+ bytesPerRow = pad32 ? ((pwidth + 3) >> 2) << 2 : pwidth;
+
+ break;
- case FT_PIXEL_MODE_MONO:
- case FT_PIXEL_MODE_GRAY:
- pwidth = ftbit->width;
- pconv = PCONV_NONE;
- break;
+ case FT_PIXEL_MODE_MONO:
+ pwidth = emboldenhack ? ftbit->width + 1 : ftbit->width;
+ pconv = emboldenhack ? PCONV_EMBOLDEN_BITMAP : PCONV_NONE;
+ bytesPerRow = pad32 ? 4 * ((pwidth + 31) >> 5) : (pwidth + 7) >> 3;
+
+ break;
+
+ case FT_PIXEL_MODE_GRAY:
+ pwidth = emboldenhack ? ftbit->width + 1 : ftbit->width;
+ pconv = emboldenhack ? PCONV_EMBOLDEN_BITMAP : PCONV_NONE;
+ bytesPerRow = pad32 ? (pwidth + 3) & ~3 : pwidth;
+
+ break;
}
if (pad32) {
- if (ftbit->pixel_mode == FT_PIXEL_MODE_MONO) {
- bytesPerRow = 4 * ((pwidth + 31) >> 5);
- } else {
- bytesPerRow = (pwidth + 3) & ~3;
- }
- } else {
- bytesPerRow = abs(ftbit->pitch);
+ pconv |= PCONV_PAD_FLAG;
}
n = bytesPerRow * ftbit->rows;
+ sourceBytesPerRow = abs(ftbit->pitch);
- sgd->width = ftbit->width;
+ sgd->width = pwidth;
sgd->height = ftbit->rows;
sgd->bytesPerRow = bytesPerRow;
-
- if (bytesPerRow != abs(ftbit->pitch)) {
- byte *s, *d;
- int i, j;
-
- /* 1: check and allocate the buffer */
+ /* figure out if we need to allocate the buffer and
+ set up source (s) and destination (d) pointers */
+
+ s = ftbit->buffer;
+
+ if (bytesPerRow > abs(ftbit->pitch)) {
+ /* check and allocate the buffer */
if (*bufsize == 0) {
if ((p = calloc(1, n)) == NULL) {
ret = -3;
@@ -193,50 +287,41 @@
p = *buffer;
}
- /* 2: copy out the buffer */
- s = ftbit->buffer;
d = p;
-
- if (ftbit->pixel_mode != FT_PIXEL_MODE_LCD) {
- /* either row by row */
- for (i=0; i<ftbit->rows; i++) {
- memcpy(d, s, abs(ftbit->pitch));
- s += abs(ftbit->pitch);
- d += bytesPerRow;
- }
- } else {
- /* or by converting 3 LCD pixels to a single indexed color value */
- for (i=0; i<ftbit->rows; i++) {
- for (j=0; j<ftbit->width/3; j++) {
- d[j] = AlphaMasksToLookupIndex(s[j*3], s[j*3 + 1], s[j*3 + 2]);
- }
- d += bytesPerRow;
- s += abs(ftbit->pitch);
-
- }
- sgd->width /= 3;
- if (pad32) {
- sgd->bytesPerRow = ((sgd->width + 3) >> 2) << 2;
- } else {
- sgd->bytesPerRow = sgd->width;
- }
- }
} else {
if (*bufsize >= n) {
- /* copy out the entire buffer */
- memcpy(*buffer, ftbit->buffer, n);
+ d = *buffer;
} else if (*bufsize != 0) {
ret = -2;
+ *bufsize = n;
+ goto cleanup;
} else {
/* assign buffer */
-
- *buffer = ftbit->buffer;
+ d = *buffer = ftbit->buffer;
*bufsize = n;
-
ftbit->buffer = 0; /* XXX so that FT_Done_Glyph() does not deallocate memory */
+
}
}
+ /* figure out how to copy source to destination */
+ switch (pconv & PCONV_MASK) {
+ case PCONV_NONE: /* copy row by row */
+ if (pconv & PCONV_PAD_FLAG) {
+ CopyBitmap(s, d, ftbit->rows, sourceBytesPerRow, bytesPerRow);
+ } else if (s != d) {
+ memmove(d, s, n);
+ }
+ break;
+ case PCONV_LCD_TO_ALPHAMASK:
+ ConvertLCDBitmap(s, d, ftbit->rows, sourceBytesPerRow, bytesPerRow, ftbit->width);
+ break;
+ case PCONV_EMBOLDEN_BITMAP:
+ EmboldenBitmap(s, d, ftbit->rows, sourceBytesPerRow, bytesPerRow, ftbit->pixel_mode);
+ break;
+ }
+
+
cleanup:
FT_Done_Glyph(glyph);
Index: makefile
===================================================================
RCS file: /cvs/stsf/stsf/STFontServer/dropins/freetype2/makefile,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- makefile 26 Mar 2004 19:19:56 -0000 1.1.1.1
+++ makefile 2 Jul 2004 05:00:13 -0000 1.2
@@ -30,11 +30,6 @@
# THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE
# SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
#
-# You acknowledge that this software is not designed, licensed or intended
-# for use in the design, construction, operation or maintenance of any
-# nuclear facility.
-#
-#
# $Id$
TOP= ../../..
Index: testft2.c
===================================================================
RCS file: /cvs/stsf/stsf/STFontServer/dropins/freetype2/testft2.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- testft2.c 26 Mar 2004 19:19:56 -0000 1.1.1.1
+++ testft2.c 2 Jul 2004 05:00:13 -0000 1.2
@@ -45,6 +45,7 @@
#include <math.h> // XXX
#include "sttypes.h"
#include "fontserver.h"
+#include "stsfutil.h"
#include <ft2build.h>
#include FT_FREETYPE_H
@@ -66,24 +67,6 @@
-#if 0
-void RenderGlyph(byte *buffer, int width, int height, int rowbytes)
-{
- int i,j,k;
- k = 0;
- for (i = 0; i < height; i++) {
- for (j=0; j<width; j++) {
- if (buffer[k + (j>>3)] & (0x80 >> (j & 7))) {
- printf("X");
- } else {
- printf(".");
- }
- }
- printf("\n");
- k += rowbytes;
- }
-}
-#endif
char agrayscale[] = {' ', '*', 'O', '@'};
@@ -121,247 +104,8 @@
return 0;
}
-#define X_DEBUG
-
-#if 0
-enum pconv {
- PCONV_NONE = 0,
- PCONV_LCD_TO_ALPHAMASK = 1
-};
-
-
-/*
- * Returns:
- * 0: OK
- * -1: FreeType error
- * -2: memory buffer passed in is not big enough
- * -3: memory allocation error
- *
- */
-int FTRenderGlyphPrim(FT_Library library,
- FT_Face face,
- STGlyph glyphID,
- FT_Int loadFlags,
- FT_Render_Mode renderMode,
- FT_Matrix *matrix,
- int pad32,
- ScaledGlyphData *sgd,
- byte **buffer,
- int *bufsize
- )
-{
- int errcode, ret = 0;
- FT_GlyphSlot slot;
- FT_GlyphSlotRec *slotr;
- FT_Bitmap *ftbit;
- int advx, advy;
- int width, height, bytesPerRow;
- FT_Glyph glyph;
- FT_BitmapGlyph bglyph;
- FT_Vector delta;
- byte *p = 0;
- int n;
- int pwidth; /* bitmap width in "real" pixels */
- int spbits; /* bits per pixel in the source bitmap */
- int tpbits; /* bits per pixel in the target bitmap */
- int pconv = PCONV_NONE;
-
-
- errcode = FT_Load_Glyph(face, glyphID, loadFlags);
- slot = face->glyph;
- slotr = (FT_GlyphSlotRec *) slot;
- advx = ((FT_GlyphSlotRec *) slot)->advance.x;
- advy = ((FT_GlyphSlotRec *) slot)->advance.y;
-
-
-#ifdef X_DEBUG
-#if 0 /* Horizontal and vertical */
-
- printf(">> %d\n"
- " LOAD: metrics: [w: %f h: %f, hBX: %f hBY: %f, hAdv: %f, vBX: %f, vBY: %f, vAdv: %f]\n"
- " lHAdv: %f, lVAdv: %f, advance: [%f %f]\n",
- glyphID,
- F26DOT6_TO_FLOAT(slotr->metrics.width),
- F26DOT6_TO_FLOAT(slotr->metrics.height),
- F26DOT6_TO_FLOAT(slotr->metrics.horiBearingX),
- F26DOT6_TO_FLOAT(slotr->metrics.horiBearingY),
- F26DOT6_TO_FLOAT(slotr->metrics.horiAdvance),
- F26DOT6_TO_FLOAT(slotr->metrics.vertBearingX),
- F26DOT6_TO_FLOAT(slotr->metrics.vertBearingY),
- F26DOT6_TO_FLOAT(slotr->metrics.vertAdvance),
- F16DOT16_TO_FLOAT(slotr->linearHoriAdvance),
- F16DOT16_TO_FLOAT(slotr->linearVertAdvance),
- F26DOT6_TO_FLOAT(advx),
- F26DOT6_TO_FLOAT(advy));
-#else /* Horizontal only */
- printf(">> %d\n"
- " LOAD: metrics: [w: %f h: %f, bx: %f by: %f, adv: %f]\n"
- " linearAdv: %f, advance: [%f %f]\n",
- glyphID,
- F26DOT6_TO_FLOAT(slotr->metrics.width),
- F26DOT6_TO_FLOAT(slotr->metrics.height),
- F26DOT6_TO_FLOAT(slotr->metrics.horiBearingX),
- F26DOT6_TO_FLOAT(slotr->metrics.horiBearingY),
- F26DOT6_TO_FLOAT(slotr->metrics.horiAdvance),
- F16DOT16_TO_FLOAT(slotr->linearHoriAdvance),
- F26DOT6_TO_FLOAT(advx),
- F26DOT6_TO_FLOAT(advy));
-
-#endif
-#endif
-
- if (loadFlags & FT_LOAD_VERTICAL_LAYOUT) {
- sgd->xAdvV = advx << 10;
- sgd->yAdvV = advy << 10;
- sgd->xAdvH = sgd->yAdvH = 0;
- sgd->flags &= fVerticalMetrics;
- } else {
- sgd->xAdvH = advx << 10;
- sgd->yAdvH = advy << 10;
- sgd->xAdvV = sgd->yAdvV = 0;
- sgd->flags &= fHorisontalMetrics;
- }
-
- width = slotr->metrics.width >> 6;
- height = slotr->metrics.height >> 6;
-
-
-#ifdef X_DEBUG
- printf(" width: %d, height: %d\n", width, height);
-#endif
-
-
-
- if (FT_Get_Glyph(face->glyph, &glyph)) return -1;
-
- delta.x = delta.y = 0;
-
- if (FT_Glyph_Transform(glyph, matrix, 0)) return -1;
-
- if (FT_Glyph_To_Bitmap(&glyph, renderMode, 0, 1)) return -1;
-
- bglyph = (FT_BitmapGlyph) glyph;
- ftbit = &bglyph->bitmap;
-
-#ifdef X_DEBUG
- printf(" RNDR: left: %d top: %d, width: %d, rows: %d\n",
- bglyph->left, bglyph->top, ftbit->width, ftbit->rows);
-#endif
-
-#if 0
-#ifdef STSF_PAD32
- if (renderMode == FT_RENDER_MODE_MONO) {
- bytesPerRow = 4 * ((ftbit->width + 31) >> 5);
- } else {
- bytesPerRow = (ftbit->width + 3) & ~3;
- }
-#else
- if (renderMode == FT_RENDER_MODE_MONO) {
- bytesPerRow = (ftbit->width + 7) >> 3;
- } else {
- bytesPerRow = ftbit->width;
- }
-#endif
-#endif // 0
-
- switch (ftbit->pixel_mode) {
- case FT_PIXEL_MODE_LCD:
- pwidth = ftbit->width / 3;
- pconv = PCONV_LCD_TO_ALPHAMASK;
- break;
-
- case FT_PIXEL_MODE_MONO:
- case FT_PIXEL_MODE_GRAY:
- pwidth = ftbit->width;
- pconv = PCONV_NONE;
- break;
- }
-
- if (pad32) {
- if (ftbit->pixel_mode == FT_PIXEL_MODE_MONO) {
- bytesPerRow = 4 * ((pwidth + 31) >> 5);
- } else {
- bytesPerRow = (pwidth + 3) & ~3;
- }
- } else {
- bytesPerRow = abs(ftbit->pitch);
- }
-
- n = bytesPerRow * ftbit->rows;
-
- sgd->width = ftbit->width;
- sgd->height = ftbit->rows;
- sgd->bytesPerRow = bytesPerRow;
-
-
- if (bytesPerRow != abs(ftbit->pitch)) {
- byte *s, *d;
- int i, j;
-
- /* 1: check and allocate the buffer */
- if (*bufsize == 0) {
- if ((p = malloc(n)) == NULL) {
- ret = -3;
- goto cleanup;
- }
- *buffer = p;
- *bufsize = n;
- } else if (*bufsize < n) {
- ret = -2;
- goto cleanup;
- } else {
- p = *buffer;
- }
-
- /* 2: copy out the buffer */
- s = ftbit->buffer;
- d = p;
-
- if (ftbit->pixel_mode != FT_PIXEL_MODE_LCD) {
- /* either row by row */
-
- for (i=0; i<ftbit->rows; i++) {
- memcpy(d, s, abs(ftbit->pitch));
- s += abs(ftbit->pitch);
- d += bytesPerRow;
- }
- } else {
- /* or by converting 3 LCD pixels to a single indexed color value */
- for (i=0; i<ftbit->rows; i++) {
- for (j=0; j<ftbit->width/3; j++) {
- d[j] = AlphaMasksToLookupIndex(s[j*3], s[j*3 + 1], s[j*3 + 2]);
- }
- d += bytesPerRow;
- s += abs(ftbit->pitch);
-
- }
- }
- } else {
- if (*bufsize >= n) {
- /* copy out the entire buffer */
- memcpy(*buffer, ftbit->buffer, n);
- } else if (*bufsize != 0) {
- ret = -2;
- } else {
- /* assign buffer */
-
- *buffer = ftbit->buffer;
- *bufsize = n;
-
- ftbit->buffer = 0; /* XXX so that FT_Done_Glyph() does not deallocate memory */
- }
- }
-
- cleanup:
- FT_Done_Glyph(glyph);
-
-#ifdef X_DEBUG
- printf("\n");
-#endif
- return ret;
-}
+#define X_DEBUG 1
-#endif
#include "ftrenderglyph.inc"
@@ -370,7 +114,9 @@
{
FT_Library library;
FT_Face face;
+ FT_Glyph glyph;
FT_GlyphSlot slot;
+ FT_GlyphSlotRec *slotrec;
FT_Matrix matrix;
FT_Vector delta;
byte *buffer;
@@ -378,12 +124,20 @@
int error;
char *ff;
long i, j, nglyphs;
-
byte bbb[2048];
+ char *debuglevel = getenv("STDEBUG");
+ int dl = 0;
bufsize = 2048;
buffer = bbb;
+ if (debuglevel) {
+ dl = atoi(debuglevel);
+ }
+ if (dl < 0 || dl > 10) {
+ dl = 0;
+ }
+ STSFSetDebugLevel(&dl);
if (ac < 2) {
ff = FONT;
@@ -426,13 +180,17 @@
slot = face->glyph;
+#if 0
if (face->face_flags & FT_FACE_FLAG_FIXED_SIZES) {
-// error = FT_Set_Pixel_Sizes(face,
-// face->available_sizes[0].height,
-// face->available_sizes[0].width);
+ error = FT_Set_Pixel_Sizes(face,
+ face->available_sizes[5].height,
+ face->available_sizes[5].width);
} else {
error = FT_Set_Pixel_Sizes(face, 0, 20);
}
+#endif
+
+ error = FT_Set_Pixel_Sizes(face, 0, 20);
if (error) {
printf("FT_Set_Pixel_Sizes: error %d.\n", error);
@@ -456,80 +214,49 @@
nglyphs = ((FT_FaceRec *) face)->num_glyphs;
- delta.x = 32;
- delta.y = 32;
+ delta.x = 0;
+ delta.y = 0;
-#undef DO_GLYPHS
+#define DO_GLYPHS 1
#if DO_GLYPHS
- for (i=0; i<nglyphs; i++) {
+ for (i=0; i<1000; i++) {
printf("glyph: %X.\n", i);
#else
for (j=' '; j<0x7F; j++) {
i = FT_Get_Char_Index(face, j);
printf("Char: %X (%c) => glyph %d.\n", j, j, i);
#endif
- FT_Int loadFlags = FT_LOAD_TARGET_NORMAL;
+ FT_Int loadFlags = FT_LOAD_DEFAULT ; // | FT_LOAD_NO_BITMAP;
//FT_Render_Mode renderMode = FT_RENDER_MODE_NORMAL;
FT_Render_Mode renderMode = FT_RENDER_MODE_MONO;
ScaledGlyphData metrics;
-
- if (!FTRenderGlyphPrim(library, face, i, loadFlags, renderMode, &matrix, 1, &metrics, &buffer, &bufsize)) {
- printglyph(buffer, metrics.width, metrics.height, metrics.bytesPerRow, 1, 256);
- } else {
- printf("[][][][][][][]>>> FTRenderGlyphPrim() returned an error!\n");
- }
- printf("\n\n");
-
-
-// if (bufsize) {
-// free(buffer);
-// bufsize = 0;
-// }
-
-
#if 0
- int w, h, r;
- FT_Glyph glyph;
- FT_BitmapGlyph bit;
- FT_Glyph_Metrics metrics = ((FT_GlyphSlotRec *) slot)->metrics;
- FT_Bitmap *bitmap;
-
-// if ((error = FT_Load_Glyph(face, i, FT_LOAD_TARGET_NORMAL))) {
- if ((error = FT_Load_Glyph(face, i, FT_LOAD_TARGET_LCD))) {
- printf("FT_Load_Glyph(%ld): error %d.\n", i, error);
- break;
- }
-
- if ((error = FT_Get_Glyph(face->glyph, &glyph))) {
- printf("FT_Get_Glyph: error %d.\n", error);
+ if ((error = FT_Load_Glyph(face, i, loadFlags)) != 0) {
+ printf("FT_Load_Glyph: %d\n", error);
+ return 1;
}
-
- if ((error = FT_Glyph_Transform(glyph, 0, &delta))) {
- printf("FT_Glyph_Transform: error %d.\n", error);
+ if ((error = FT_Render_Glyph(face->glyph, FT_RENDER_MODE_MONO)) != 0) {
+ printf("FT_Render_Glyph: %d\n", error);
}
- if ((error = FT_Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_NORMAL, 0, 1))) {
-// if ((error = FT_Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_LCD, 0, 1))) {
- printf("FT_Glyph_To_Bitmap: error %d.\n", error);
- }
- bit = (FT_BitmapGlyph) glyph;
- bitmap = &bit->bitmap;
-
+ slotrec = (FT_GlyphSlotRec *)face->glyph;
- w = metrics.width / 64;
- h = metrics.height /64;
- r = ((w + 3) / 4) * 4;
+ printglyph(face->glyph->bitmap.buffer, face->glyph->bitmap.width, face->glyph->bitmap.rows, face->glyph->bitmap.pitch, 1, 256);
#endif
+
+#if 1
+
+ if (!FTRenderGlyphPrim(library, face, i, loadFlags, renderMode, &matrix, 1, 0, &metrics, &buffer, &bufsize)) {
+ printglyph(buffer, metrics.width, metrics.height, metrics.bytesPerRow, 1, 256);
+ } else {
+ printf("[][][][][][][]>>> FTRenderGlyphPrim() returned an error!\n");
+ }
+ printf("\n\n");
+#endif
-
-// printf("Glyph: %d (w: %d h: %d), AdvX: (%f %f).\n", i, w, h, F16DOT16_TO_FLOAT(metrics.horiBearingX), F16DOT16_TO_FLOAT(metrics.horiBearingY));
-// printglyph(bitmap->buffer, bitmap->width, bitmap->rows, bitmap->pitch, 8, 256);
-
-
-
}
- Previous message: [stsf-commit] stsf/STFontServer/dropins/dummy makefile, 1.1.1.1,
1.2 scalerglue.c, 1.1.1.1, 1.2
- Next message: [stsf-commit] stsf/STFontServer/loader client.c, 1.1.1.1,
1.2 makefile, 1.2, 1.3 stfsloader.c, 1.2, 1.3 stfsloader.x,
1.1.1.1, 1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the stsf-commit
mailing list