"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/gdft.c" between
libgd-2.3.0.tar.gz and libgd-2.3.1.tar.gz

About: LibGD is a library for the dynamic creation of images by programmers (PNG, JPEG, GIF, WebP, XPM, BMP support).

gdft.c  (libgd-2.3.0):gdft.c  (libgd-2.3.1)
skipping to change at line 442 skipping to change at line 442
#endif #endif
typedef struct { typedef struct {
unsigned int index; unsigned int index;
FT_Pos x_advance; FT_Pos x_advance;
FT_Pos x_offset; FT_Pos x_offset;
FT_Pos y_offset; FT_Pos y_offset;
uint32_t cluster; uint32_t cluster;
} glyphInfo; } glyphInfo;
static size_t static ssize_t
textLayout(uint32_t *text, int len, textLayout(uint32_t *text, int len,
FT_Face face, gdFTStringExtraPtr strex, FT_Face face, gdFTStringExtraPtr strex,
glyphInfo **glyph_info) glyphInfo **glyph_info)
{ {
size_t count; size_t count;
glyphInfo *info; glyphInfo *info;
if (!len) {
return 0;
}
#ifdef HAVE_LIBRAQM #ifdef HAVE_LIBRAQM
size_t i; size_t i;
raqm_glyph_t *glyphs; raqm_glyph_t *glyphs;
raqm_t *rq = raqm_create (); raqm_t *rq = raqm_create ();
if (!rq || !raqm_set_text (rq, text, len) || if (!rq || !raqm_set_text (rq, text, len) ||
!raqm_set_freetype_face (rq, face) || !raqm_set_freetype_face (rq, face) ||
!raqm_set_par_direction (rq, RAQM_DIRECTION_DEFAULT) || !raqm_set_par_direction (rq, RAQM_DIRECTION_DEFAULT) ||
!raqm_layout (rq)) { !raqm_layout (rq)) {
raqm_destroy (rq); raqm_destroy (rq);
return 0; return -1;
} }
glyphs = raqm_get_glyphs (rq, &count); glyphs = raqm_get_glyphs (rq, &count);
if (!glyphs) { if (!glyphs) {
raqm_destroy (rq); raqm_destroy (rq);
return 0; return -1;
} }
info = (glyphInfo*) gdMalloc (sizeof (glyphInfo) * count); info = (glyphInfo*) gdMalloc (sizeof (glyphInfo) * count);
if (!info) { if (!info) {
raqm_destroy (rq); raqm_destroy (rq);
return 0; return -1;
} }
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
info[i].index = glyphs[i].index; info[i].index = glyphs[i].index;
info[i].x_offset = glyphs[i].x_offset; info[i].x_offset = glyphs[i].x_offset;
info[i].y_offset = glyphs[i].y_offset; info[i].y_offset = glyphs[i].y_offset;
info[i].x_advance = glyphs[i].x_advance; info[i].x_advance = glyphs[i].x_advance;
info[i].cluster = glyphs[i].cluster; info[i].cluster = glyphs[i].cluster;
} }
raqm_destroy (rq); raqm_destroy (rq);
#else #else
FT_UInt glyph_index = 0, previous = 0; FT_UInt glyph_index = 0, previous = 0;
FT_Vector delta; FT_Vector delta;
FT_Error err; FT_Error err;
info = (glyphInfo*) gdMalloc (sizeof (glyphInfo) * len); info = (glyphInfo*) gdMalloc (sizeof (glyphInfo) * len);
if (!info) { if (!info) {
return 0; return -1;
} }
for (count = 0; count < len; count++) { for (count = 0; count < len; count++) {
/* Convert character code to glyph index */ /* Convert character code to glyph index */
glyph_index = FT_Get_Char_Index (face, text[count]); glyph_index = FT_Get_Char_Index (face, text[count]);
/* retrieve kerning distance */ /* retrieve kerning distance */
if (! (strex && (strex->flags & gdFTEX_DISABLE_KERNING)) if (! (strex && (strex->flags & gdFTEX_DISABLE_KERNING))
&& ! FT_IS_FIXED_WIDTH(face) && ! FT_IS_FIXED_WIDTH(face)
&& FT_HAS_KERNING(face) && FT_HAS_KERNING(face)
&& previous && previous
&& glyph_index) && glyph_index)
FT_Get_Kerning (face, previous, glyph_index, ft_kerning_d efault, &delta); FT_Get_Kerning (face, previous, glyph_index, ft_kerning_d efault, &delta);
else else
delta.x = delta.y = 0; delta.x = delta.y = 0;
err = FT_Load_Glyph (face, glyph_index, FT_LOAD_DEFAULT); err = FT_Load_Glyph (face, glyph_index, FT_LOAD_DEFAULT);
if (err) { if (err) {
gdFree (info); gdFree (info);
return 0; return -1;
} }
info[count].index = glyph_index; info[count].index = glyph_index;
info[count].x_offset = 0; info[count].x_offset = 0;
info[count].y_offset = 0; info[count].y_offset = 0;
if (delta.x != 0) if (delta.x != 0)
info[count - 1].x_advance += delta.x; info[count - 1].x_advance += delta.x;
info[count].x_advance = face->glyph->metrics.horiAdvance; info[count].x_advance = face->glyph->metrics.horiAdvance;
info[count].cluster = count; info[count].cluster = count;
/* carriage returns or newlines */ /* carriage returns or newlines */
if (text[count] == '\r' || text[count] == '\n') if (text[count] == '\r' || text[count] == '\n')
previous = 0; /* clear kerning flag */ previous = 0; /* clear kerning flag */
else else
previous = glyph_index; previous = glyph_index;
} }
#endif #endif
*glyph_info = info; *glyph_info = info;
return count; return count <= SSIZE_MAX ? count : -1;
} }
/********************************************************************/ /********************************************************************/
/* font cache functions */ /* font cache functions */
static int static int
fontTest (void *element, void *key) fontTest (void *element, void *key)
{ {
font_t *a = (font_t *) element; font_t *a = (font_t *) element;
fontkey_t *b = (fontkey_t *) key; fontkey_t *b = (fontkey_t *) key;
skipping to change at line 1109 skipping to change at line 1113
FT_UInt glyph_index; FT_UInt glyph_index;
double sin_a = sin (angle); double sin_a = sin (angle);
double cos_a = cos (angle); double cos_a = cos (angle);
int i, ch; int i, ch;
font_t *font; font_t *font;
fontkey_t fontkey; fontkey_t fontkey;
const char *next; const char *next;
char *tmpstr = 0; char *tmpstr = 0;
uint32_t *text; uint32_t *text;
glyphInfo *info = NULL; glyphInfo *info = NULL;
size_t count; ssize_t count;
int render = (im && (im->trueColor || (fg <= 255 && fg >= -255))); int render = (im && (im->trueColor || (fg <= 255 && fg >= -255)));
FT_BitmapGlyph bm; FT_BitmapGlyph bm;
/* 2.0.13: Bob Ostermann: don't force autohint, that's just for testing /* 2.0.13: Bob Ostermann: don't force autohint, that's just for testing
freetype and doesn't look as good */ freetype and doesn't look as good */
int render_mode = FT_LOAD_DEFAULT; int render_mode = FT_LOAD_DEFAULT;
int encoding, encodingfound; int encoding, encodingfound;
/* Now tuneable thanks to Wez Furlong */ /* Now tuneable thanks to Wez Furlong */
double linespace = LINESPACE; double linespace = LINESPACE;
/* 2.0.6: put this declaration with the other declarations! */ /* 2.0.6: put this declaration with the other declarations! */
/* /*
skipping to change at line 1410 skipping to change at line 1414
break; break;
} }
text[i] = ch; text[i] = ch;
i++; i++;
} }
FT_Activate_Size (platform_independent); FT_Activate_Size (platform_independent);
count = textLayout (text , i, face, strex, &info); count = textLayout (text , i, face, strex, &info);
if (!count) { if (count < 0) {
gdFree (text); gdFree (text);
gdFree (tmpstr); gdFree (tmpstr);
gdCacheDelete (tc_cache); gdCacheDelete (tc_cache);
gdMutexUnlock (gdFontCacheMutex); gdMutexUnlock (gdFontCacheMutex);
return "Problem doing text layout"; return "Problem doing text layout";
} }
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
FT_Activate_Size (platform_independent); FT_Activate_Size (platform_independent);
skipping to change at line 1566 skipping to change at line 1570
(int)(x + (pen_x * cos_a + pen_y * sin_ a)*hdpi/(METRIC_RES*64) + bm->left), (int)(x + (pen_x * cos_a + pen_y * sin_ a)*hdpi/(METRIC_RES*64) + bm->left),
(int)(y - (pen_x * sin_a - pen_y * cos_ a)*vdpi/(METRIC_RES*64) - bm->top)); (int)(y - (pen_x * sin_a - pen_y * cos_ a)*vdpi/(METRIC_RES*64) - bm->top));
FT_Done_Glyph (image); FT_Done_Glyph (image);
} }
penf.x += horiAdvance; penf.x += horiAdvance;
} }
gdFree(text); gdFree(text);
gdFree(info); if (info) {
gdFree(info);
}
/* Save the (unkerned) advance from the last character in the xshow vecto r */ /* Save the (unkerned) advance from the last character in the xshow vecto r */
if (strex && (strex->flags & gdFTEX_XSHOW) && strex->xshow) { if (strex && (strex->flags & gdFTEX_XSHOW) && strex->xshow) {
sprintf(strex->xshow + xshow_pos, "%g", sprintf(strex->xshow + xshow_pos, "%g",
(double)(penf.x - oldpenf.x) * hdpi / (64 * METRIC_RES) ) ; (double)(penf.x - oldpenf.x) * hdpi / (64 * METRIC_RES) ) ;
} }
if (brect) { if (brect) {
/* only if need brect */ /* only if need brect */
double scalex = (double)hdpi / (64 * METRIC_RES); double scalex = (double)hdpi / (64 * METRIC_RES);
 End of changes. 11 change blocks. 
10 lines changed or deleted 16 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)