diff -r 514e61338063 -r 5603e0f23f9c Makefile.am --- a/Makefile.am Fri Jun 26 19:05:28 2015 -0700 +++ b/Makefile.am Mon Dec 21 14:24:39 2015 +0400 @@ -9,6 +9,11 @@ libSDL2_ttf_la_SOURCES = \ SDL_ttf.c +if HAVE_CTL +libSDL2_ttf_la_SOURCES += raqm.c +libSDL2_ttfinclude_HEADERS += raqm.h +endif + EXTRA_DIST = \ Android.mk \ debian \ diff -r 514e61338063 -r 5603e0f23f9c SDL_ttf.c --- a/SDL_ttf.c Fri Jun 26 19:05:28 2015 -0700 +++ b/SDL_ttf.c Mon Dec 21 14:24:39 2015 +0400 @@ -35,6 +35,12 @@ #include "SDL_endian.h" #include "SDL_ttf.h" +#ifdef HAVE_CTL +#include "raqm.h" +#define SHAPE_TEXT(text, textlen, font, info) \ + raqm_shape(text, textlen, font->face, RAQM_DIRECTION_DEFAULT, info); +#endif + /* FIXME: Right now we assume the gray-scale renderer Freetype is using supports 256 shades of gray, but we should instead key off of num_grays in the result FT_Bitmap after the FT_Render_Glyph() call. */ @@ -331,6 +337,67 @@ #endif /* USE_FREETYPE_ERRORS */ } +static FT_Error Find_Glyph( TTF_Font* font, Uint16 ch, int want ); +static Uint32 UTF8_getch(const char **src, size_t *srclen); + +#ifndef HAVE_CTL +#define SHAPE_TEXT(text, textlen, font, info) \ + fallback_shape(text, textlen, font, info); + +typedef struct { + int index; + int x_offset; + int x_advance; + int y_offset; +} raqm_glyph_info_t; + +int fallback_shape(const char *text, size_t textlen, TTF_Font *font, raqm_glyph_info_t **info) +{ + int xstart, count; + c_glyph *glyph; + FT_Error error; + FT_Long use_kerning; + FT_UInt prev_index = 0; + raqm_glyph_info_t *g_info; + + /* check kerning */ + use_kerning = FT_HAS_KERNING( font->face ) && font->kerning; + + g_info = (raqm_glyph_info_t*) malloc(sizeof(raqm_glyph_info_t) * (textlen)); + + xstart = 0; + for ( count = 0; textlen > 0; count++ ) { + Uint16 c = UTF8_getch(&text, &textlen); + if ( c == UNICODE_BOM_NATIVE || c == UNICODE_BOM_SWAPPED ) { + continue; + } + + error = Find_Glyph(font, c, CACHED_METRICS|CACHED_BITMAP); + if ( error ) { + TTF_SetFTError("Couldn't find glyph", error); + exit(-1); + } + glyph = font->current; + + g_info[count].index = glyph->index; + g_info[count].y_offset = 0; + g_info[count].x_offset = 0; + g_info[count].x_advance = glyph->advance; + + /* do kerning, if possible AC-Patch */ + if ( use_kerning && prev_index && glyph->index ) { + FT_Vector delta; + FT_Get_Kerning( font->face, prev_index, g_info->index, ft_kerning_default, &delta ); + xstart += delta.x >> 6; + g_info[count].x_offset = delta.x; + } + } + + *info = g_info; + return count; +} +#endif + int TTF_Init( void ) { int status = 0; @@ -618,7 +685,7 @@ cached->maxy = FT_FLOOR(metrics->horiBearingY); cached->miny = cached->maxy - FT_CEIL(metrics->height); cached->yoffset = font->ascent - cached->maxy; - cached->advance = FT_CEIL(metrics->horiAdvance); + cached->advance = metrics->horiAdvance; } else { /* Get the bounding box for non-scalable format. * Again, freetype2 fills in many of the font metrics @@ -631,7 +698,7 @@ cached->maxy = FT_FLOOR(metrics->horiBearingY); cached->miny = cached->maxy - FT_CEIL(face->available_sizes[font->font_size_family].height); cached->yoffset = 0; - cached->advance = FT_CEIL(metrics->horiAdvance); + cached->advance = metrics->horiAdvance; } /* Adjust for bold and italic text */ @@ -912,6 +979,24 @@ return retval; } +static FT_Error Find_GlyphByIndex( TTF_Font* font, Uint16 idx, int want ) +{ + int retval = 0; + int hsize = sizeof( font->cache ) / sizeof( font->cache[0] ); + + int h = idx % hsize; + font->current = &font->cache[h]; + + if (font->current->cached != idx) + Flush_Glyph( font->current ); + + if ( (font->current->stored & want) != want ) { + font->current->index = idx; + retval = Load_Glyph( font, idx, font->current, want ); + } + return retval; +} + void TTF_CloseFont( TTF_Font* font ) { if ( font ) { @@ -1158,7 +1243,7 @@ *maxy = font->current->maxy; } if ( advance ) { - *advance = font->current->advance; + *advance = FT_CEIL(font->current->advance); if ( TTF_HANDLE_STYLE_BOLD(font) ) { *advance += font->glyph_overhang; } @@ -1184,7 +1269,7 @@ return status; } -int TTF_SizeUTF8(TTF_Font *font, const char *text, int *w, int *h) +static int CalculateSize(TTF_Font *font, raqm_glyph_info_t *g_info, int glyph_count, int *w, int*h) { int status; int x, z; @@ -1192,69 +1277,31 @@ int miny, maxy; c_glyph *glyph; FT_Error error; - FT_Long use_kerning; FT_UInt prev_index = 0; int outline_delta = 0; - size_t textlen; - - TTF_CHECKPOINTER(text, -1); + int i; /* Initialize everything to 0 */ status = 0; minx = maxx = 0; miny = maxy = 0; - /* check kerning */ - use_kerning = FT_HAS_KERNING( font->face ) && font->kerning; - /* Init outline handling */ if ( font->outline > 0 ) { outline_delta = font->outline * 2; } /* Load each character and sum it's bounding box */ - textlen = SDL_strlen(text); x= 0; - while ( textlen > 0 ) { - Uint16 c = UTF8_getch(&text, &textlen); - if ( c == UNICODE_BOM_NATIVE || c == UNICODE_BOM_SWAPPED ) { - continue; - } - - error = Find_Glyph(font, c, CACHED_METRICS); + for (i = 0; i < glyph_count; i++) { + error = Find_GlyphByIndex(font, g_info[i].index, CACHED_METRICS); if ( error ) { TTF_SetFTError("Couldn't find glyph", error); return -1; } glyph = font->current; - /* handle kerning */ - if ( use_kerning && prev_index && glyph->index ) { - FT_Vector delta; - FT_Get_Kerning( font->face, prev_index, glyph->index, ft_kerning_default, &delta ); - x += delta.x >> 6; - } - -#if 0 - if ( (ch == text) && (glyph->minx < 0) ) { - /* Fixes the texture wrapping bug when the first letter - * has a negative minx value or horibearing value. The entire - * bounding box must be adjusted to be bigger so the entire - * letter can fit without any texture corruption or wrapping. - * - * Effects: First enlarges bounding box. - * Second, xstart has to start ahead of its normal spot in the - * negative direction of the negative minx value. - * (pushes everything to the right). - * - * This will make the memory copy of the glyph bitmap data - * work out correctly. - * */ - z -= glyph->minx; - } -#endif - - z = x + glyph->minx; + z = x + FT_FLOOR(g_info[i].x_offset) + glyph->minx; if ( minx > z ) { minx = z; } @@ -1262,14 +1309,14 @@ x += font->glyph_overhang; } if ( glyph->advance > glyph->maxx ) { - z = x + glyph->advance; + z = x + FT_FLOOR(g_info[i].x_advance); } else { - z = x + glyph->maxx; + z = x + FT_FLOOR(g_info[i].x_offset) + glyph->maxx; } if ( maxx < z ) { maxx = z; } - x += glyph->advance; + x += FT_FLOOR(g_info[i].x_advance); if ( glyph->miny < miny ) { miny = glyph->miny; @@ -1277,7 +1324,7 @@ if ( glyph->maxy > maxy ) { maxy = glyph->maxy; } - prev_index = glyph->index; + prev_index = g_info[i].index; } /* Fill the bounds rectangle */ @@ -1303,6 +1350,23 @@ return status; } +int TTF_SizeUTF8(TTF_Font *font, const char *text, int *w, int *h) +{ + raqm_glyph_info_t *info; + size_t textlen; + int glyph_count; + + TTF_CHECKPOINTER(text, -1); + + textlen = SDL_strlen(text); + + /* Shape text */ + glyph_count = SHAPE_TEXT(text, textlen, font, &info); + + /* Calculate the size */ + return CalculateSize(font, info, glyph_count, w, h); +} + int TTF_SizeUNICODE(TTF_Font *font, const Uint16 *text, int *w, int *h) { int status = -1; @@ -1353,18 +1417,24 @@ Uint8* dst; Uint8 *dst_check; int row, col; + int i; c_glyph *glyph; - + raqm_glyph_info_t *g_info; + int glyph_count; FT_Bitmap *current; FT_Error error; - FT_Long use_kerning; FT_UInt prev_index = 0; size_t textlen; TTF_CHECKPOINTER(text, NULL); + textlen = SDL_strlen(text); + + /* Shape text */ + glyph_count = SHAPE_TEXT(text, textlen, font, &g_info); + /* Get the dimensions of the text surface */ - if ( ( TTF_SizeUTF8(font, text, &width, &height) < 0 ) || !width ) { + if ( ( CalculateSize(font, g_info, glyph_count, &width, &height) < 0 ) || !width ) { TTF_SetError( "Text has zero width" ); return NULL; } @@ -1389,26 +1459,19 @@ palette->colors[1].b = fg.b; SDL_SetColorKey( textbuf, SDL_TRUE, 0 ); - /* check kerning */ - use_kerning = FT_HAS_KERNING( font->face ) && font->kerning; - - /* Load and render each character */ - textlen = SDL_strlen(text); + /* Load and render each glyph */ first = SDL_TRUE; xstart = 0; - while ( textlen > 0 ) { - Uint16 c = UTF8_getch(&text, &textlen); - if ( c == UNICODE_BOM_NATIVE || c == UNICODE_BOM_SWAPPED ) { - continue; - } - - error = Find_Glyph(font, c, CACHED_METRICS|CACHED_BITMAP); + for (i = 0; i < glyph_count; i++) { + int y_offset; + error = Find_GlyphByIndex(font, g_info[i].index, CACHED_METRICS|CACHED_BITMAP); if ( error ) { TTF_SetFTError("Couldn't find glyph", error); SDL_FreeSurface( textbuf ); return NULL; } glyph = font->current; + y_offset = glyph->yoffset - FT_FLOOR(g_info[i].y_offset); current = &glyph->bitmap; /* Ensure the width of the pixmap is correct. On some cases, * freetype may report a larger pixmap than possible.*/ @@ -1416,12 +1479,6 @@ if (font->outline <= 0 && width > glyph->maxx - glyph->minx) { width = glyph->maxx - glyph->minx; } - /* do kerning, if possible AC-Patch */ - if ( use_kerning && prev_index && glyph->index ) { - FT_Vector delta; - FT_Get_Kerning( font->face, prev_index, glyph->index, ft_kerning_default, &delta ); - xstart += delta.x >> 6; - } /* Compensate for wrap around bug with negative minx's */ if ( first && (glyph->minx < 0) ) { xstart -= glyph->minx; @@ -1431,15 +1488,15 @@ for ( row = 0; row < current->rows; ++row ) { /* Make sure we don't go either over, or under the * limit */ - if ( row+glyph->yoffset < 0 ) { + if ( row+y_offset < 0 ) { continue; } - if ( row+glyph->yoffset >= textbuf->h ) { + if ( row+y_offset >= textbuf->h ) { continue; } dst = (Uint8*) textbuf->pixels + - (row+glyph->yoffset) * textbuf->pitch + - xstart + glyph->minx; + (row+y_offset) * textbuf->pitch + + xstart + FT_FLOOR(g_info[i].x_offset) + glyph->minx; src = current->buffer + row * current->pitch; for ( col=width; col>0 && dst < dst_check; --col ) { @@ -1447,11 +1504,11 @@ } } - xstart += glyph->advance; + xstart += FT_FLOOR(g_info[i].x_advance); if ( TTF_HANDLE_STYLE_BOLD(font) ) { xstart += font->glyph_overhang; } - prev_index = glyph->index; + prev_index = g_info[i].index; } /* Handle the underline style */ @@ -1465,6 +1522,7 @@ row = TTF_strikethrough_top_row(font); TTF_drawLine_Solid(font, textbuf, row); } + free(g_info); return textbuf; } @@ -1524,6 +1582,7 @@ int xstart; int width; int height; + int i; SDL_Surface* textbuf; SDL_Palette* palette; int index; @@ -1536,15 +1595,20 @@ int row, col; FT_Bitmap* current; c_glyph *glyph; + raqm_glyph_info_t *g_info; + int glyph_count; + size_t textlen; FT_Error error; - FT_Long use_kerning; FT_UInt prev_index = 0; - size_t textlen; TTF_CHECKPOINTER(text, NULL); + textlen = SDL_strlen(text); + /* Shape text */ + glyph_count = SHAPE_TEXT(text, textlen, font, &g_info); + /* Get the dimensions of the text surface */ - if ( ( TTF_SizeUTF8(font, text, &width, &height) < 0 ) || !width ) { + if ( ( CalculateSize(font, g_info, glyph_count, &width, &height) < 0 ) || !width ) { TTF_SetError("Text has zero width"); return NULL; } @@ -1571,38 +1635,25 @@ palette->colors[index].b = bg.b + (index*bdiff) / (NUM_GRAYS-1); } - /* check kerning */ - use_kerning = FT_HAS_KERNING( font->face ) && font->kerning; - - /* Load and render each character */ - textlen = SDL_strlen(text); + /* Load and render each glyph */ first = SDL_TRUE; xstart = 0; - while ( textlen > 0 ) { - Uint16 c = UTF8_getch(&text, &textlen); - if ( c == UNICODE_BOM_NATIVE || c == UNICODE_BOM_SWAPPED ) { - continue; - } - - error = Find_Glyph(font, c, CACHED_METRICS|CACHED_PIXMAP); + for (i = 0; i < glyph_count; i++) { + int y_offset; + error = Find_GlyphByIndex(font, g_info[i].index, CACHED_METRICS|CACHED_PIXMAP); if ( error ) { TTF_SetFTError("Couldn't find glyph", error); SDL_FreeSurface( textbuf ); return NULL; } glyph = font->current; + y_offset = glyph->yoffset - FT_FLOOR(g_info[i].y_offset); /* Ensure the width of the pixmap is correct. On some cases, * freetype may report a larger pixmap than possible.*/ width = glyph->pixmap.width; if (font->outline <= 0 && width > glyph->maxx - glyph->minx) { width = glyph->maxx - glyph->minx; } - /* do kerning, if possible AC-Patch */ - if ( use_kerning && prev_index && glyph->index ) { - FT_Vector delta; - FT_Get_Kerning( font->face, prev_index, glyph->index, ft_kerning_default, &delta ); - xstart += delta.x >> 6; - } /* Compensate for the wrap around with negative minx's */ if ( first && (glyph->minx < 0) ) { xstart -= glyph->minx; @@ -1613,26 +1664,26 @@ for ( row = 0; row < current->rows; ++row ) { /* Make sure we don't go either over, or under the * limit */ - if ( row+glyph->yoffset < 0 ) { + if ( row+ y_offset < 0 ) { continue; } - if ( row+glyph->yoffset >= textbuf->h ) { + if ( row+ y_offset >= textbuf->h ) { continue; } dst = (Uint8*) textbuf->pixels + - (row+glyph->yoffset) * textbuf->pitch + - xstart + glyph->minx; + (row+y_offset) * textbuf->pitch + + xstart + FT_FLOOR(g_info[i].x_offset) + glyph->minx; src = current->buffer + row * current->pitch; for ( col=width; col>0 && dst < dst_check; --col ) { *dst++ |= *src++; } } - xstart += glyph->advance; + xstart += FT_FLOOR(g_info[i].x_advance); if ( TTF_HANDLE_STYLE_BOLD(font) ) { xstart += font->glyph_overhang; } - prev_index = glyph->index; + prev_index = g_info[i].index; } /* Handle the underline style */ @@ -1646,6 +1697,7 @@ row = TTF_strikethrough_top_row(font); TTF_drawLine_Shaded(font, textbuf, row); } + free(g_info); return textbuf; } @@ -1715,15 +1767,21 @@ Uint32 *dst_check; int row, col; c_glyph *glyph; + raqm_glyph_info_t *g_info; + int glyph_count; + int i; FT_Error error; - FT_Long use_kerning; FT_UInt prev_index = 0; size_t textlen; TTF_CHECKPOINTER(text, NULL); + textlen = SDL_strlen(text); + /* Shape text */ + glyph_count = SHAPE_TEXT(text, textlen, font, &g_info); + /* Get the dimensions of the text surface */ - if ( ( TTF_SizeUTF8(font, text, &width, &height) < 0 ) || !width ) { + if ( ( CalculateSize(font, g_info, glyph_count, &width, &height) < 0 ) || !width ) { TTF_SetError("Text has zero width"); return(NULL); } @@ -1739,40 +1797,28 @@ that may occur. */ dst_check = (Uint32*)textbuf->pixels + textbuf->pitch/4 * textbuf->h; - /* check kerning */ - use_kerning = FT_HAS_KERNING( font->face ) && font->kerning; - - /* Load and render each character */ - textlen = SDL_strlen(text); + /* Load and render each glyph */ first = SDL_TRUE; xstart = 0; pixel = (fg.r<<16)|(fg.g<<8)|fg.b; SDL_FillRect(textbuf, NULL, pixel); /* Initialize with fg and 0 alpha */ - while ( textlen > 0 ) { - Uint16 c = UTF8_getch(&text, &textlen); - if ( c == UNICODE_BOM_NATIVE || c == UNICODE_BOM_SWAPPED ) { - continue; - } - error = Find_Glyph(font, c, CACHED_METRICS|CACHED_PIXMAP); + for (i = 0; i < glyph_count; i++) { + int y_offset; + error = Find_GlyphByIndex(font, g_info[i].index, CACHED_METRICS|CACHED_PIXMAP); if ( error ) { TTF_SetFTError("Couldn't find glyph", error); SDL_FreeSurface( textbuf ); return NULL; } glyph = font->current; + y_offset = glyph->yoffset - FT_FLOOR(g_info[i].y_offset); /* Ensure the width of the pixmap is correct. On some cases, * freetype may report a larger pixmap than possible.*/ width = glyph->pixmap.width; if (font->outline <= 0 && width > glyph->maxx - glyph->minx) { width = glyph->maxx - glyph->minx; } - /* do kerning, if possible AC-Patch */ - if ( use_kerning && prev_index && glyph->index ) { - FT_Vector delta; - FT_Get_Kerning( font->face, prev_index, glyph->index, ft_kerning_default, &delta ); - xstart += delta.x >> 6; - } /* Compensate for the wrap around bug with negative minx's */ if ( first && (glyph->minx < 0) ) { @@ -1783,15 +1829,15 @@ for ( row = 0; row < glyph->pixmap.rows; ++row ) { /* Make sure we don't go either over, or under the * limit */ - if ( row+glyph->yoffset < 0 ) { + if ( row+y_offset < 0 ) { continue; } - if ( row+glyph->yoffset >= textbuf->h ) { + if ( row+y_offset >= textbuf->h ) { continue; } dst = (Uint32*) textbuf->pixels + - (row+glyph->yoffset) * textbuf->pitch/4 + - xstart + glyph->minx; + (row+y_offset) * textbuf->pitch/4 + + xstart + FT_FLOOR(g_info[i].x_offset) + glyph->minx; /* Added code to adjust src pointer for pixmaps to * account for pitch. @@ -1803,11 +1849,11 @@ } } - xstart += glyph->advance; + xstart += FT_FLOOR(g_info[i].x_advance); if ( TTF_HANDLE_STYLE_BOLD(font) ) { xstart += font->glyph_overhang; } - prev_index = glyph->index; + prev_index = g_info[i].index; } /* Handle the underline style */ @@ -1821,6 +1867,7 @@ row = TTF_strikethrough_top_row(font); TTF_drawLine_Blended(font, textbuf, row, pixel); } + free(g_info); return(textbuf); } @@ -1878,6 +1925,7 @@ { SDL_bool first; int xstart; + int i; int width, height; SDL_Surface *textbuf; Uint32 alpha; @@ -1887,8 +1935,9 @@ Uint32 *dst_check; int row, col; c_glyph *glyph; + raqm_glyph_info_t *g_info; + int glyph_count; FT_Error error; - FT_Long use_kerning; FT_UInt prev_index = 0; const int lineSpace = 2; int line, numLines, rowSize; @@ -1897,8 +1946,12 @@ TTF_CHECKPOINTER(text, NULL); - /* Get the dimensions of the text surface */ - if ( (TTF_SizeUTF8(font, text, &width, &height) < 0) || !width ) { + textlen = SDL_strlen(text); + /* Shape text */ + glyph_count = SHAPE_TEXT(text, textlen, font, &g_info); + + /* Get the dimensions of the text surface */ + if ( ( CalculateSize(font, g_info, glyph_count, &width, &height) < 0 ) || !width ) { TTF_SetError("Text has zero width"); return(NULL); } @@ -2002,10 +2055,7 @@ that may occur. */ dst_check = (Uint32*)textbuf->pixels + textbuf->pitch/4 * textbuf->h; - /* check kerning */ - use_kerning = FT_HAS_KERNING( font->face ) && font->kerning; - - /* Load and render each character */ + /* Load and render each glyph */ pixel = (fg.r<<16)|(fg.g<<8)|fg.b; SDL_FillRect(textbuf, NULL, pixel); /* Initialize with fg and 0 alpha */ @@ -2013,35 +2063,24 @@ if ( strLines ) { text = strLines[line]; } - textlen = SDL_strlen(text); first = SDL_TRUE; xstart = 0; - while ( textlen > 0 ) { - Uint16 c = UTF8_getch(&text, &textlen); - if ( c == UNICODE_BOM_NATIVE || c == UNICODE_BOM_SWAPPED ) { - continue; - } - - error = Find_Glyph(font, c, CACHED_METRICS|CACHED_PIXMAP); + for (i = 0; i < glyph_count; i++) { + int y_offset; + error = Find_GlyphByIndex(font, g_info[i].index, CACHED_METRICS|CACHED_PIXMAP); if ( error ) { TTF_SetFTError("Couldn't find glyph", error); SDL_FreeSurface( textbuf ); return NULL; } glyph = font->current; + y_offset = glyph->yoffset - FT_FLOOR(g_info[i].y_offset); /* Ensure the width of the pixmap is correct. On some cases, * freetype may report a larger pixmap than possible.*/ width = glyph->pixmap.width; if ( font->outline <= 0 && width > glyph->maxx - glyph->minx ) { width = glyph->maxx - glyph->minx; } - /* do kerning, if possible AC-Patch */ - if ( use_kerning && prev_index && glyph->index ) { - FT_Vector delta; - FT_Get_Kerning( font->face, prev_index, glyph->index, ft_kerning_default, &delta ); - xstart += delta.x >> 6; - } - /* Compensate for the wrap around bug with negative minx's */ if ( first && (glyph->minx < 0) ) { xstart -= glyph->minx; @@ -2051,15 +2090,15 @@ for ( row = 0; row < glyph->pixmap.rows; ++row ) { /* Make sure we don't go either over, or under the * limit */ - if ( row+glyph->yoffset < 0 ) { + if ( row+y_offset < 0 ) { continue; } - if ( row+glyph->yoffset >= textbuf->h ) { + if ( row+y_offset >= textbuf->h ) { continue; } dst = ((Uint32*)textbuf->pixels + rowSize * line) + - (row+glyph->yoffset) * textbuf->pitch/4 + - xstart + glyph->minx; + (row+y_offset) * textbuf->pitch/4 + + xstart + FT_FLOOR(g_info[i].x_offset) + glyph->minx; /* Added code to adjust src pointer for pixmaps to * account for pitch. @@ -2071,11 +2110,11 @@ } } - xstart += glyph->advance; + xstart += FT_FLOOR(g_info[i].x_advance); if ( TTF_HANDLE_STYLE_BOLD(font) ) { xstart += font->glyph_overhang; } - prev_index = glyph->index; + prev_index = g_info[i].index; } /* Handle the underline style * @@ -2097,6 +2136,7 @@ SDL_free(strLines); SDL_stack_free(str); } + free(g_info); return(textbuf); } diff -r 514e61338063 -r 5603e0f23f9c configure.in --- a/configure.in Fri Jun 26 19:05:28 2015 -0700 +++ b/configure.in Mon Dec 21 14:24:39 2015 +0400 @@ -120,6 +120,26 @@ LIBS="$LIBS `$FREETYPE_CONFIG $freetypeconf_args --libs`" fi +dnl Check for the CTL_FLAGS +AC_ARG_ENABLE(ctl, + [AS_HELP_STRING([--disable-ctl], + [disable complex text layout support])], + [enable_ctl=$enableval], + [enable_ctl='yes']) + +have_ctl="" +if test "x$enable_ctl" != 'xno'; then + PKG_CHECK_MODULES(CTL, [fribidi harfbuzz], have_ctl="yes", []) +fi + +if test "x$have_ctl" == "xyes"; then + AC_DEFINE(HAVE_CTL) + CFLAGS="$CFLAGS $CTL_CFLAGS" + LIBS="$LIBS $CTL_LIBS" + AC_CHECK_FUNC(fribidi_reorder_runs, AC_DEFINE(HAVE_FRIBIDI_REORDER_RUNS), []) +fi +AM_CONDITIONAL(HAVE_CTL, test "x$have_ctl" == "xyes") + dnl Check for SDL SDL_VERSION=2.0.0 AC_SUBST(SDL_VERSION)