diff --git a/configure.ac b/configure.ac index a7c97e3..0c39f22 100644 --- a/configure.ac +++ b/configure.ac @@ -39,10 +39,10 @@ PKG_CHECK_EXISTS([SDL2_mixer], [ STARFIGHTER_CFLAGS="$STARFIGHTER_CFLAGS -DNOSOUND" echo "Note: SDL_mixer not found; audio will not be supported." ]) -PKG_CHECK_MODULES([UTF8PROC], [libutf8proc], [ +PKG_CHECK_MODULES([PANGO], [pango], [ ], [ STARFIGHTER_CFLAGS="$STARFIGHTER_CFLAGS -DNOFONT" - echo "Note: utf8proc not found; Unicode will not be supported." + echo "Note: Pango not found; Unicode will not be supported." ]) AC_ARG_VAR([SF_SCREEN_WIDTH], [The width of the game window in pixels]) diff --git a/src/Makefile.am b/src/Makefile.am index fffb858..5ca6f5b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -6,8 +6,8 @@ bin_PROGRAMS = starfighter starfighter_CPPFLAGS = $(STARFIGHTER_CFLAGS) -DDATADIR=\"$(pkgdatadir)\" -Wall -starfighter_CFLAGS = $(SDL_CFLAGS) $(UTF8PROC_CFLAGS) -lm -starfighter_LDADD = $(SDL_LIBS) $(UTF8PROC_LIBS) +starfighter_CFLAGS = $(SDL_CFLAGS) $(PANGO_CFLAGS) -lm +starfighter_LDADD = $(SDL_LIBS) $(PANGO_LIBS) starfighter_SOURCES = \ Starfighter.c \ diff --git a/src/gfx.c b/src/gfx.c index 2a9f975..b1dea87 100644 --- a/src/gfx.c +++ b/src/gfx.c @@ -26,7 +26,7 @@ along with this program. If not, see . #ifndef NOFONT #include "SDL_ttf.h" -#include "utf8proc.h" +#include "pango.h" #endif #include "defs.h" @@ -236,12 +236,12 @@ int gfx_renderUnicodeBase(const char *in, int x, int y, int fontColor, int wrap, SDL_Color color; int w, h; int changed; - utf8proc_int32_t buf; - utf8proc_int32_t prev; int breakPoints[STRMAX]; int nBreakPoints; - char testStr[STRMAX]; + const char testStr[STRMAX]; char remainingStr[STRMAX]; + PangoLogAttr logAttrs[STRMAX]; + int nLogAttrs; int state; int i, j; SDL_Rect area; @@ -261,29 +261,17 @@ int gfx_renderUnicodeBase(const char *in, int x, int y, int fontColor, int wrap, changed = 1; while (changed && (w > dest->w)) { - i = 0; - j = 0; - prev = '\0'; - state = 0; + nLogAttrs = strlen(remainingStr) + 1; + pango_get_log_attrs(remainingStr, strlen(remainingStr), -1, NULL, logAttrs, nLogAttrs); + nBreakPoints = 0; - while (i < strlen(remainingStr)) + for (i = 0; i < nLogAttrs; i++) { - j = utf8proc_iterate((utf8proc_uint8_t*)(&remainingStr[i]), -1, &buf); - if (buf < 0) + if (logAttrs[i].is_line_break) { - printf("WARNING: Unicode string \"%s\" contains an invalid character!\n", remainingStr); - break; + breakPoints[nBreakPoints] = i; + nBreakPoints++; } - else - { - if (utf8proc_grapheme_break_stateful(prev, buf, &state)) - { - breakPoints[nBreakPoints] = i + 1; - nBreakPoints++; - } - } - i += j; - prev = buf; } changed = 0;