From: Matthew Fernandez Date: Sun, 16 Jan 2022 00:16:40 +0000 (-0800) Subject: API BREAK: return a C99 bool from 'gvtextlayout_engine_t.textlayout' X-Git-Tag: 3.0.0~64^2~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1dc9e7b9b72399cd09fb0a460ea7500ef535f7d6;p=graphviz API BREAK: return a C99 bool from 'gvtextlayout_engine_t.textlayout' --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bdfb3a64..267808735 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - **Breaking**: The `loadimage` member of the `gvloadimage_engine_t` struct must now accept a C99 `bool` parameter instead of a former Graphviz-specific `boolean` parameter. +- **Breaking**: The `textlayout` member of the `gvtextlayout_engine_t` struct + must now return a C99 `bool` instead of a Graphviz-specific `boolean`. - **Breaking**: 1-bit fields of the `obj_state_s` struct are now unsigned instead of signed. - **Breaking**: Graphviz headers no longer define the constant `MAXSHORT`. A diff --git a/lib/gvc/gvplugin_textlayout.h b/lib/gvc/gvplugin_textlayout.h index 47c40c543..45fe2f72e 100644 --- a/lib/gvc/gvplugin_textlayout.h +++ b/lib/gvc/gvplugin_textlayout.h @@ -14,13 +14,14 @@ #include "gvplugin.h" #include "gvcjob.h" #include "gvcommon.h" +#include #ifdef __cplusplus extern "C" { #endif struct gvtextlayout_engine_s { - boolean (*textlayout) (textspan_t *span, char** fontpath); + bool (*textlayout) (textspan_t *span, char** fontpath); }; #ifdef __cplusplus diff --git a/lib/gvc/gvtextlayout.c b/lib/gvc/gvtextlayout.c index 584dd1a45..c436bc5de 100644 --- a/lib/gvc/gvtextlayout.c +++ b/lib/gvc/gvtextlayout.c @@ -39,6 +39,6 @@ bool gvtextlayout(GVC_t *gvc, textspan_t *span, char **fontpath) gvtextlayout_engine_t *gvte = gvc->textlayout.engine; if (gvte && gvte->textlayout) - return gvte->textlayout(span, fontpath) != FALSE; + return gvte->textlayout(span, fontpath); return false; } diff --git a/plugin/gd/gvtextlayout_gd.c b/plugin/gd/gvtextlayout_gd.c index 727aab928..7fdbfd770 100644 --- a/plugin/gd/gvtextlayout_gd.c +++ b/plugin/gd/gvtextlayout_gd.c @@ -10,6 +10,7 @@ #include "config.h" +#include #include #include #include @@ -110,7 +111,7 @@ char* gd_psfontResolve (PostscriptAlias* pa) return buf; } -static boolean gd_textlayout(textspan_t * span, char **fontpath) +static bool gd_textlayout(textspan_t * span, char **fontpath) { char *err, *fontlist, *fontname; double fontsize; @@ -143,7 +144,7 @@ static boolean gd_textlayout(textspan_t * span, char **fontpath) if (fontname) { if (fontsize <= FONTSIZE_MUCH_TOO_SMALL) { - return TRUE; /* OK, but ignore text entirely */ + return true; /* OK, but ignore text entirely */ } else if (fontsize <= FONTSIZE_TOO_SMALL) { /* draw line in place of text */ /* fake a finite fontsize so that line length is calculated */ @@ -166,7 +167,7 @@ static boolean gd_textlayout(textspan_t * span, char **fontpath) if (err) { agerr(AGERR,"%s\n", err); - return FALSE; /* indicate error */ + return false; /* indicate error */ } if (fontpath) @@ -183,7 +184,7 @@ static boolean gd_textlayout(textspan_t * span, char **fontpath) span->size.y = (int)(fontsize * 1.2); } } - return TRUE; + return true; } static gvtextlayout_engine_t gd_textlayout_engine = { diff --git a/plugin/gdiplus/gvtextlayout_gdiplus.cpp b/plugin/gdiplus/gvtextlayout_gdiplus.cpp index e0fa0b47e..3f863ce91 100644 --- a/plugin/gdiplus/gvtextlayout_gdiplus.cpp +++ b/plugin/gdiplus/gvtextlayout_gdiplus.cpp @@ -63,7 +63,7 @@ void gdiplus_free_layout(void *layout) delete reinterpret_cast(layout); }; -boolean gdiplus_textlayout(textspan_t *span, char **) +bool gdiplus_textlayout(textspan_t *span, char **) { /* ensure GDI+ is started up: since we get called outside of a job, we can't rely on GDI+ startup then */ UseGdiplus(); @@ -94,7 +94,7 @@ boolean gdiplus_textlayout(textspan_t *span, char **) span->size.y = layout->font->GetHeight(&measureGraphics); span->yoffset_layout = fontFamily.GetCellAscent(style) * span->font->size / fontFamily.GetEmHeight(style); /* convert design units to pixels */ span->yoffset_centerline = 0; - return TRUE; + return true; }; static gvtextlayout_engine_t gdiplus_textlayout_engine = { diff --git a/plugin/pango/gvtextlayout_pango.c b/plugin/pango/gvtextlayout_pango.c index 8abf1e53d..5ac08bfac 100644 --- a/plugin/pango/gvtextlayout_pango.c +++ b/plugin/pango/gvtextlayout_pango.c @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -75,7 +76,7 @@ static int agxbput_int(void *buffer, const char *s) { return (int)len; } -static boolean pango_textlayout(textspan_t * span, char **fontpath) +static bool pango_textlayout(textspan_t * span, char **fontpath) { static char buf[1024]; /* returned in fontpath, only good until next call */ static PangoFontMap *fontmap; @@ -117,7 +118,7 @@ static boolean pango_textlayout(textspan_t * span, char **fontpath) /* check if the conversion to Pango units below will overflow */ if ((double)(G_MAXINT / PANGO_SCALE) < span->font->size) { - return FALSE; + return false; } free(fontname); @@ -288,9 +289,7 @@ static boolean pango_textlayout(textspan_t * span, char **fontpath) /* The distance below midline for y centering of text strings */ span->yoffset_centerline = 0.2 * span->font->size; - if (logical_rect.width == 0) - return FALSE; - return TRUE; + return logical_rect.width != 0; } static gvtextlayout_engine_t pango_textlayout_engine = { diff --git a/plugin/quartz/gvtextlayout_quartz.c b/plugin/quartz/gvtextlayout_quartz.c index 8fc775cd8..b9a2e6547 100644 --- a/plugin/quartz/gvtextlayout_quartz.c +++ b/plugin/quartz/gvtextlayout_quartz.c @@ -10,6 +10,7 @@ #include "config.h" +#include #include #include @@ -86,7 +87,7 @@ void quartz_free_layout(void *layout) #endif -boolean quartz_textlayout(textspan_t *para, char **fontpath) +bool quartz_textlayout(textspan_t *para, char **fontpath) { void *line = quartz_new_layout(para->font->name, para->font->size, para->str); if (line) @@ -96,10 +97,10 @@ boolean quartz_textlayout(textspan_t *para, char **fontpath) para->free_layout = &quartz_free_layout; quartz_size_layout((void*)line, ¶->size.x, ¶->size.y, ¶->yoffset_layout); para->yoffset_centerline = 0.2 * para->font->size; - return TRUE; + return true; } else - return FALSE; + return false; }; static gvtextlayout_engine_t quartz_textlayout_engine = {