SDL_ttf: Switched to C++ style comments and C99 style code.

From 9d29468644c7a0f73e9c52506f59b3b17aa90247 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 30 Sep 2024 08:14:10 -0700
Subject: [PATCH] Switched to C++ style comments and C99 style code.

---
 src/SDL_renderer_textengine.c |  77 +++---
 src/SDL_surface_textengine.c  |  78 +++---
 src/SDL_ttf.c                 | 441 +++++++++++++++++-----------------
 3 files changed, 302 insertions(+), 294 deletions(-)

diff --git a/src/SDL_renderer_textengine.c b/src/SDL_renderer_textengine.c
index dccb9d01..282949a8 100644
--- a/src/SDL_renderer_textengine.c
+++ b/src/SDL_renderer_textengine.c
@@ -56,14 +56,16 @@ typedef struct TTF_RendererTextEngineData
 
 static void DestroyGlyphData(TTF_RendererTextEngineGlyphData *data)
 {
-    if (data) {
-        --data->refcount;
-        if (data->refcount == 0) {
-            if (data->texture) {
-                SDL_DestroyTexture(data->texture);
-            }
-            SDL_free(data);
+    if (!data) {
+        return;
+    }
+
+    --data->refcount;
+    if (data->refcount == 0) {
+        if (data->texture) {
+            SDL_DestroyTexture(data->texture);
         }
+        SDL_free(data);
     }
 }
 
@@ -113,26 +115,27 @@ static TTF_RendererTextEngineGlyphData *GetGlyphData(SDL_Renderer *renderer, TTF
 
 static void DestroyTextData(TTF_RendererTextEngineTextData *data)
 {
-    if (data) {
-        if (data->ops) {
-            int i;
-
-            for (i = 0; i < data->num_ops; ++i) {
-                const TTF_DrawOperation *op = &data->ops[i];
-                if (op->cmd == TTF_DRAW_COMMAND_COPY) {
-                    TTF_RendererTextEngineGlyphData *glyph = (TTF_RendererTextEngineGlyphData *)op->copy.reserved;
-                    DestroyGlyphData(glyph);
-                }
+    if (!data) {
+        return;
+    }
+
+    if (data->ops) {
+        int i;
+
+        for (i = 0; i < data->num_ops; ++i) {
+            const TTF_DrawOperation *op = &data->ops[i];
+            if (op->cmd == TTF_DRAW_COMMAND_COPY) {
+                TTF_RendererTextEngineGlyphData *glyph = (TTF_RendererTextEngineGlyphData *)op->copy.reserved;
+                DestroyGlyphData(glyph);
             }
-            SDL_free(data->ops);
         }
-        SDL_free(data);
+        SDL_free(data->ops);
     }
+    SDL_free(data);
 }
 
 static TTF_RendererTextEngineTextData *CreateTextData(SDL_Renderer *renderer, TTF_RendererTextEngineFontData *fontdata, const TTF_DrawOperation *ops, int num_ops)
 {
-    int i;
     TTF_RendererTextEngineTextData *data = (TTF_RendererTextEngineTextData *)SDL_calloc(1, sizeof(*data));
     if (!data) {
         return NULL;
@@ -146,7 +149,7 @@ static TTF_RendererTextEngineTextData *CreateTextData(SDL_Renderer *renderer, TT
     SDL_memcpy(data->ops, ops, num_ops * sizeof(*data->ops));
     data->num_ops = num_ops;
 
-    for (i = 0; i < data->num_ops; ++i) {
+    for (int i = 0; i < data->num_ops; ++i) {
         TTF_DrawOperation *op = &data->ops[i];
         if (op->cmd == TTF_DRAW_COMMAND_COPY) {
             TTF_RendererTextEngineGlyphData *glyph = GetGlyphData(renderer, fontdata, op->copy.glyph_index);
@@ -163,12 +166,14 @@ static TTF_RendererTextEngineTextData *CreateTextData(SDL_Renderer *renderer, TT
 
 static void DestroyFontData(TTF_RendererTextEngineFontData *data)
 {
-    if (data) {
-        if (data->glyphs) {
-            SDL_DestroyHashTable(data->glyphs);
-        }
-        SDL_free(data);
+    if (!data) {
+        return;
+    }
+
+    if (data->glyphs) {
+        SDL_DestroyHashTable(data->glyphs);
     }
+    SDL_free(data);
 }
 
 static void NukeGlyphData(const void *key, const void *value, void *unused)
@@ -203,12 +208,14 @@ static TTF_RendererTextEngineFontData *CreateFontData(TTF_RendererTextEngineData
 
 static void DestroyEngineData(TTF_RendererTextEngineData *data)
 {
-    if (data) {
-        if (data->fonts) {
-            SDL_DestroyHashTable(data->fonts);
-        }
-        SDL_free(data);
+    if (!data) {
+        return;
+    }
+
+    if (data->fonts) {
+        SDL_DestroyHashTable(data->fonts);
     }
+    SDL_free(data);
 }
 
 static void NukeFontData(const void *key, const void *value, void *unused)
@@ -288,11 +295,10 @@ TTF_TextEngine *TTF_CreateRendererTextEngine(SDL_Renderer *renderer)
 static void DrawFill(SDL_Renderer *renderer, TTF_Text *text, const TTF_FillOperation *op, float x, float y)
 {
     SDL_FColor color;
-    SDL_FRect dst;
-
     SDL_GetRenderDrawColorFloat(renderer, &color.r, &color.g, &color.b, &color.a);
     SDL_SetRenderDrawColorFloat(renderer, text->color.r, text->color.g, text->color.b, text->color.a);
 
+    SDL_FRect dst;
     SDL_RectToFRect(&op->rect, &dst);
     dst.x += x;
     dst.y += y;
@@ -304,7 +310,6 @@ static void DrawFill(SDL_Renderer *renderer, TTF_Text *text, const TTF_FillOpera
 static void DrawCopy(SDL_Renderer *renderer, TTF_Text *text, const TTF_CopyOperation *op, float x, float y)
 {
     TTF_RendererTextEngineGlyphData *glyph = (TTF_RendererTextEngineGlyphData *)op->reserved;
-    SDL_FRect src, dst;
 
     if (text->color.r != glyph->color.r ||
         text->color.g != glyph->color.g ||
@@ -315,6 +320,7 @@ static void DrawCopy(SDL_Renderer *renderer, TTF_Text *text, const TTF_CopyOpera
         SDL_copyp(&glyph->color, &text->color);
     }
 
+    SDL_FRect src, dst;
     SDL_RectToFRect(&op->src, &src);
     SDL_RectToFRect(&op->dst, &dst);
     dst.x += x;
@@ -326,7 +332,6 @@ bool TTF_DrawRendererText(TTF_Text *text, float x, float y)
 {
     TTF_RendererTextEngineTextData *data;
     SDL_Renderer *renderer;
-    int i;
 
     if (!text || !text->engine || text->engine->CreateText != CreateText) {
         return SDL_InvalidParamError("text");
@@ -335,7 +340,7 @@ bool TTF_DrawRendererText(TTF_Text *text, float x, float y)
     renderer = ((TTF_RendererTextEngineData *)text->engine->userdata)->renderer;
     data = (TTF_RendererTextEngineTextData *)text->internal;
 
-    for (i = 0; i < data->num_ops; ++i) {
+    for (int i = 0; i < data->num_ops; ++i) {
         const TTF_DrawOperation *op = &data->ops[i];
         switch (op->cmd) {
         case TTF_DRAW_COMMAND_FILL:
diff --git a/src/SDL_surface_textengine.c b/src/SDL_surface_textengine.c
index 317ba8fc..06a290a4 100644
--- a/src/SDL_surface_textengine.c
+++ b/src/SDL_surface_textengine.c
@@ -54,14 +54,16 @@ typedef struct TTF_SurfaceTextEngineData
 
 static void DestroyGlyphData(TTF_SurfaceTextEngineGlyphData *data)
 {
-    if (data) {
-        --data->refcount;
-        if (data->refcount == 0) {
-            if (data->surface) {
-                SDL_DestroySurface(data->surface);
-            }
-            SDL_free(data);
+    if (!data) {
+        return;
+    }
+
+    --data->refcount;
+    if (data->refcount == 0) {
+        if (data->surface) {
+            SDL_DestroySurface(data->surface);
         }
+        SDL_free(data);
     }
 }
 
@@ -104,26 +106,25 @@ static TTF_SurfaceTextEngineGlyphData *GetGlyphData(TTF_SurfaceTextEngineFontDat
 
 static void DestroyTextData(TTF_SurfaceTextEngineTextData *data)
 {
-    if (data) {
-        if (data->ops) {
-            int i;
-
-            for (i = 0; i < data->num_ops; ++i) {
-                const TTF_DrawOperation *op = &data->ops[i];
-                if (op->cmd == TTF_DRAW_COMMAND_COPY) {
-                    TTF_SurfaceTextEngineGlyphData *glyph = (TTF_SurfaceTextEngineGlyphData *)op->copy.reserved;
-                    DestroyGlyphData(glyph);
-                }
+    if (!data) {
+        return;
+    }
+
+    if (data->ops) {
+        for (int i = 0; i < data->num_ops; ++i) {
+            const TTF_DrawOperation *op = &data->ops[i];
+            if (op->cmd == TTF_DRAW_COMMAND_COPY) {
+                TTF_SurfaceTextEngineGlyphData *glyph = (TTF_SurfaceTextEngineGlyphData *)op->copy.reserved;
+                DestroyGlyphData(glyph);
             }
-            SDL_free(data->ops);
         }
-        SDL_free(data);
+        SDL_free(data->ops);
     }
+    SDL_free(data);
 }
 
 static TTF_SurfaceTextEngineTextData *CreateTextData(TTF_SurfaceTextEngineFontData *fontdata, const TTF_DrawOperation *ops, int num_ops)
 {
-    int i;
     TTF_SurfaceTextEngineTextData *data = (TTF_SurfaceTextEngineTextData *)SDL_calloc(1, sizeof(*data));
     if (!data) {
         return NULL;
@@ -137,7 +138,7 @@ static TTF_SurfaceTextEngineTextData *CreateTextData(TTF_SurfaceTextEngineFontDa
     SDL_memcpy(data->ops, ops, num_ops * sizeof(*data->ops));
     data->num_ops = num_ops;
 
-    for (i = 0; i < data->num_ops; ++i) {
+    for (int i = 0; i < data->num_ops; ++i) {
         TTF_DrawOperation *op = &data->ops[i];
         if (op->cmd == TTF_DRAW_COMMAND_COPY) {
             TTF_SurfaceTextEngineGlyphData *glyph = GetGlyphData(fontdata, op->copy.glyph_index);
@@ -154,12 +155,14 @@ static TTF_SurfaceTextEngineTextData *CreateTextData(TTF_SurfaceTextEngineFontDa
 
 static void DestroyFontData(TTF_SurfaceTextEngineFontData *data)
 {
-    if (data) {
-        if (data->glyphs) {
-            SDL_DestroyHashTable(data->glyphs);
-        }
-        SDL_free(data);
+    if (!data) {
+        return;
+    }
+
+    if (data->glyphs) {
+        SDL_DestroyHashTable(data->glyphs);
     }
+    SDL_free(data);
 }
 
 static void NukeGlyphData(const void *key, const void *value, void *unused)
@@ -176,6 +179,7 @@ static TTF_SurfaceTextEngineFontData *CreateFontData(TTF_SurfaceTextEngineData *
     if (!data) {
         return NULL;
     }
+
     data->font = font;
     data->generation = font_generation;
     data->glyphs = SDL_CreateHashTable(NULL, 4, SDL_HashID, SDL_KeyMatchID, NukeGlyphData, false);
@@ -194,12 +198,14 @@ static TTF_SurfaceTextEngineFontData *CreateFontData(TTF_SurfaceTextEngineData *
 
 static void DestroyEngineData(TTF_SurfaceTextEngineData *data)
 {
-    if (data) {
-        if (data->fonts) {
-            SDL_DestroyHashTable(data->fonts);
-        }
-        SDL_free(data);
+    if (!data) {
+        return;
+    }
+
+    if (data->fonts) {
+        SDL_DestroyHashTable(data->fonts);
     }
+    SDL_free(data);
 }
 
 static void NukeFontData(const void *key, const void *value, void *unused)
@@ -287,11 +293,10 @@ static void UpdateColor(TTF_SurfaceTextEngineTextData *data, const SDL_FColor *c
 static void DrawFill(TTF_Text *text, const TTF_FillOperation *op, int x, int y, SDL_Surface *surface)
 {
     TTF_SurfaceTextEngineTextData *data = (TTF_SurfaceTextEngineTextData *)text->internal;
-    Uint32 color;
-    SDL_Rect dst;
 
-    color = SDL_MapSurfaceRGBA(surface, data->color.r, data->color.g, data->color.b, data->color.a);
+    Uint32 color = SDL_MapSurfaceRGBA(surface, data->color.r, data->color.g, data->color.b, data->color.a);
 
+    SDL_Rect dst;
     SDL_copyp(&dst, &op->rect);
     dst.x += x;
     dst.y += y;
@@ -302,7 +307,6 @@ static void DrawCopy(TTF_Text *text, const TTF_CopyOperation *op, int x, int y,
 {
     TTF_SurfaceTextEngineTextData *data = (TTF_SurfaceTextEngineTextData *)text->internal;
     TTF_SurfaceTextEngineGlyphData *glyph = (TTF_SurfaceTextEngineGlyphData *)op->reserved;
-    SDL_Rect dst;
 
     if (data->color.r != glyph->color.r ||
         data->color.g != glyph->color.g ||
@@ -313,6 +317,7 @@ static void DrawCopy(TTF_Text *text, const TTF_CopyOperation *op, int x, int y,
         SDL_copyp(&glyph->color, &data->color);
     }
 
+    SDL_Rect dst;
     SDL_copyp(&dst, &op->dst);
     dst.x += x;
     dst.y += y;
@@ -322,7 +327,6 @@ static void DrawCopy(TTF_Text *text, const TTF_CopyOperation *op, int x, int y,
 bool TTF_DrawSurfaceText(TTF_Text *text, int x, int y, SDL_Surface *surface)
 {
     TTF_SurfaceTextEngineTextData *data;
-    int i;
 
     if (!text || !text->engine || text->engine->CreateText != CreateText) {
         return SDL_InvalidParamError("text");
@@ -340,7 +344,7 @@ bool TTF_DrawSurfaceText(TTF_Text *text, int x, int y, SDL_Surface *surface)
         UpdateColor(data, &text->color);
     }
 
-    for (i = 0; i < data->num_ops; ++i) {
+    for (int i = 0; i < data->num_ops; ++i) {
         const TTF_DrawOperation *op = &data->ops[i];
         switch (op->cmd) {
         case TTF_DRAW_COMMAND_FILL:
diff --git a/src/SDL_ttf.c b/src/SDL_ttf.c
index aa646962..4224992a 100644
--- a/src/SDL_ttf.c
+++ b/src/SDL_ttf.c
@@ -39,7 +39,7 @@
 #  define TTF_USE_COLOR 0
 #endif
 
-/* Enable Signed Distance Field rendering (requires latest FreeType version) */
+// Enable Signed Distance Field rendering (requires latest FreeType version)
 #if defined(FT_RASTER_FLAG_SDF)
 #  define TTF_USE_SDF 1
 #else
@@ -71,7 +71,7 @@ SDL_COMPILE_TIME_ASSERT(SDL_BUILD_MICRO_VERSION,
                         SDL_TTF_MICRO_VERSION == SDL_BUILD_MICRO_VERSION);
 #endif
 
-/* Limited by its encoding in SDL_VERSIONNUM */
+// Limited by its encoding in SDL_VERSIONNUM
 SDL_COMPILE_TIME_ASSERT(SDL_TTF_MAJOR_VERSION_min, SDL_TTF_MAJOR_VERSION >= 0);
 SDL_COMPILE_TIME_ASSERT(SDL_TTF_MAJOR_VERSION_max, SDL_TTF_MAJOR_VERSION <= 10);
 SDL_COMPILE_TIME_ASSERT(SDL_TTF_MINOR_VERSION_min, SDL_TTF_MINOR_VERSION >= 0);
@@ -83,24 +83,24 @@ SDL_COMPILE_TIME_ASSERT(SDL_TTF_MICRO_VERSION_max, SDL_TTF_MICRO_VERSION <= 999)
 #include <hb.h>
 #include <hb-ft.h>
 
-/* Default configuration */
+// Default configuration
 static hb_direction_t g_hb_direction = HB_DIRECTION_LTR;
 static hb_script_t    g_hb_script = HB_SCRIPT_UNKNOWN;
 #endif
 
-/* Round glyph to 16 bytes width and use SSE2 instructions */
+// Round glyph to 16 bytes width and use SSE2 instructions
 #if defined(__SSE2__)
 #  define HAVE_SSE2_INTRINSICS 1
 #include <emmintrin.h>
 #endif
 
-/* Round glyph width to 16 bytes use NEON instructions */
+// Round glyph width to 16 bytes use NEON instructions
 #if defined(__ARM_NEON)
 #  define HAVE_NEON_INTRINSICS 1
 #include <arm_neon.h>
 #endif
 
-/* Round glyph width to 8 bytes */
+// Round glyph width to 8 bytes
 #define HAVE_BLIT_GLYPH_64
 
 /* Android armeabi-v7a doesn't like int64 (Maybe all other __ARM_ARCH < 7 ?),
@@ -113,10 +113,10 @@ static hb_script_t    g_hb_script = HB_SCRIPT_UNKNOWN;
 #  endif
 #endif
 
-/* Default: round glyph width to 4 bytes to copy them faster */
+// Default: round glyph width to 4 bytes to copy them faster
 #define HAVE_BLIT_GLYPH_32
 
-/* Use Duff's device to unroll loops */
+// Use Duff's device to unroll loops
 //#define USE_DUFFS_LOOP
 
 #if defined(HAVE_SSE2_INTRINSICS)
@@ -149,14 +149,14 @@ static SDL_INLINE int hasNEON(void)
 #define NUM_GRAYS       256
 
 /* x offset = cos(((90.0-12)/360) * 2 * M_PI), or 12 degree angle */
-/* same value as in FT_GlyphSlot_Oblique, fixed point 16.16 */
+// same value as in FT_GlyphSlot_Oblique, fixed point 16.16
 #define GLYPH_ITALICS  0x0366AL
 
-/* Handy routines for converting from fixed point 26.6 */
+// Handy routines for converting from fixed point 26.6
 #define FT_FLOOR(X) (int)(((X) & -64) / 64)
 #define FT_CEIL(X)  FT_FLOOR((X) + 63)
 
-/* Handy routine for converting to fixed point 26.6 */
+// Handy routine for converting to fixed point 26.6
 #define F26Dot6(X)  ((X) << 6)
 
 /* Faster divide by 255, with same result
@@ -164,7 +164,7 @@ static SDL_INLINE int hasNEON(void)
  * in range [-255; 0]: (x + 255 + (x >> 8)) >> 8 */
 #define DIVIDE_BY_255_SIGNED(x, sign_val)  (((x) + (sign_val) + ((x)>>8)) >> 8)
 
-/* When x positive */
+// When x positive
 #define DIVIDE_BY_255(x)    DIVIDE_BY_255_SIGNED(x, 1)
 
 
@@ -177,7 +177,7 @@ static SDL_INLINE int hasNEON(void)
 
 
 typedef struct {
-    unsigned char *buffer; /* aligned */
+    unsigned char *buffer; // aligned
     int            left;
     int            top;
     int            width;
@@ -186,7 +186,7 @@ typedef struct {
     int            is_color;
 } TTF_Image;
 
-/* Cached glyph information */
+// Cached glyph information
 typedef struct cached_glyph {
     int stored;
     FT_UInt index;
@@ -197,12 +197,12 @@ typedef struct cached_glyph {
     int sz_rows;
     int advance;
     union {
-        /* TTF_HINTING_LIGHT_SUBPIXEL (only pixmap) */
+        // TTF_HINTING_LIGHT_SUBPIXEL (only pixmap)
         struct {
             int lsb_minus_rsb;
             int translation;
         } subpixel;
-        /* Other hinting */
+        // Other hinting
         struct {
             int rsb_delta;
             int lsb_delta;
@@ -218,47 +218,47 @@ typedef struct PosBuf {
     int y;
 } PosBuf_t;
 
-/* The structure used to hold internal font information */
+// The structure used to hold internal font information
 struct TTF_Font {
-    /* Freetype2 maintains all sorts of useful info itself */
+    // Freetype2 maintains all sorts of useful info itself
     FT_Face face;
 
-    /* Properties exposed to the application */
+    // Properties exposed to the application
     SDL_PropertiesID props;
 
-    /* The current font generation, changes when glyphs need to be rebuilt */
+    // The current font generation, changes when glyphs need to be rebuilt
     Uint32 generation;
 
-    /* We'll cache these ourselves */
+    // We'll cache these ourselves
     int height;
     int ascent;
     int descent;
     int lineskip;
 
-    /* The font style */
+    // The font style
     int style;
     int outline_val;
     FT_Stroker stroker;
 
-    /* Whether kerning is desired */
+    // Whether kerning is desired
     bool enable_kerning;
 #if !TTF_USE_HARFBUZZ
     bool use_kerning;
 #endif
 
-    /* Extra width in glyph bounds for text styles */
+    // Extra width in glyph bounds for text styles
     int glyph_overhang;
 
-    /* Information in the font for underlining */
+    // Information in the font for underlining
     int line_thickness;
     int underline_top_row;
     int strikethrough_top_row;
 
-    /* Cache for style-transformed glyphs */
+    // Cache for style-transformed glyphs
     c_glyph cache[256];
     FT_UInt cache_index[128];
 
-    /* We are responsible for closing the font stream */
+    // We are responsible for closing the font stream
     SDL_IOStream *src;
     Sint64 src_offset;
     bool closeio;
@@ -270,20 +270,20 @@ struct TTF_Font {
     int pos_len;
     int pos_max;
 
-    /* Hinting modes */
+    // Hinting modes
     int ft_load_target;
     int render_subpixel;
 #if TTF_USE_HARFBUZZ
     hb_font_t *hb_font;
-    /* If HB_SCRIPT_INVALID, use global default script */
+    // If HB_SCRIPT_INVALID, use global default script
     hb_script_t hb_script;
-    /* If HB_DIRECTION_INVALID, use global default direction */
+    // If HB_DIRECTION_INVALID, use global default direction
     hb_direction_t hb_direction;
     hb_language_t hb_language;
 #endif
     bool render_sdf;
 
-    /* Extra layout setting for wrapped text */
+    // Extra layout setting for wrapped text
     TTF_HorizontalAlignment horizontal_align;
 };
 
@@ -293,16 +293,16 @@ typedef struct
     size_t length;
 } TTF_Line;
 
-/* Tell if SDL_ttf has to handle the style */
+// Tell if SDL_ttf has to handle the style
 #define TTF_HANDLE_STYLE_BOLD(font)          ((font)->style & TTF_STYLE_BOLD)
 #define TTF_HANDLE_STYLE_ITALIC(font)        ((font)->style & TTF_STYLE_ITALIC)
 #define TTF_HANDLE_STYLE_UNDERLINE(font)     ((font)->style & TTF_STYLE_UNDERLINE)
 #define TTF_HANDLE_STYLE_STRIKETHROUGH(font) ((font)->style & TTF_STYLE_STRIKETHROUGH)
 
-/* Font styles that does not impact glyph drawing */
+// Font styles that does not impact glyph drawing
 #define TTF_STYLE_NO_GLYPH_CHANGE   (TTF_STYLE_UNDERLINE | TTF_STYLE_STRIKETHROUGH)
 
-/* The FreeType font engine/library */
+// The FreeType font engine/library
 static struct
 {
     SDL_InitState init;
@@ -341,7 +341,7 @@ static bool Find_GlyphByIndex(TTF_Font *font, FT_UInt idx, int want_pixmap, int
 
 #if defined(USE_DUFFS_LOOP)
 
-/* 4-times unrolled loop */
+// 4-times unrolled loop
 #define DUFFS_LOOP4(pixel_copy_increment, width)                        \
 { int n = (width+3)/4;                                                  \
     switch (width & 3) {                                                \
@@ -355,7 +355,7 @@ static bool Find_GlyphByIndex(TTF_Font *font, FT_UInt idx, int want_pixmap, int
 
 #else
 
-/* Don't use Duff's device to unroll loops */
+// Don't use Duff's device to unroll loops
 #define DUFFS_LOOP(pixel_copy_increment, width)                         \
 { int n;                                                                \
     for ( n=width; n > 0; --n ) {                                       \
@@ -369,7 +369,7 @@ static bool Find_GlyphByIndex(TTF_Font *font, FT_UInt idx, int want_pixmap, int
 #endif
 
 
-/* Blend colored glyphs */
+// Blend colored glyphs
 static void BG_Blended_Color(const TTF_Image *image, Uint32 *destination, Sint32 srcskip, Uint32 dstskip, Uint8 fg_alpha)
 {
     const Uint32 *src   = (Uint32 *)image->buffer;
@@ -395,7 +395,7 @@ static void BG_Blended_Color(const TTF_Image *image, Uint32 *destination, Sint32
             /* *INDENT-OFF* */
             DUFFS_LOOP4(
                     /* prevent misaligned load: tmp = *src++; */
-                    /* eventually, we can expect the compiler to replace the memcpy call with something optimized */
+                    // eventually, we can expect the compiler to replace the memcpy call with something optimized
                     SDL_memcpy(&tmp, src++, sizeof(tmp));
                     alpha = tmp >> 24;
                     tmp &= ~0xFF000000;
@@ -410,7 +410,7 @@ static void BG_Blended_Color(const TTF_Image *image, Uint32 *destination, Sint32
     }
 }
 
-/* Blend with LCD rendering */
+// Blend with LCD rendering
 static void BG_Blended_LCD(const TTF_Image *image, Uint32 *destination, Sint32 srcskip, Uint32 dstskip, SDL_Color *fg)
 {
     const Uint32 *src   = (Uint32 *)image->buffer;
@@ -473,7 +473,7 @@ static void BG_Blended_LCD(const TTF_Image *image, Uint32 *destination, Sint32 s
 
 #if TTF_USE_SDF
 
-/* Blended Opaque SDF */
+// Blended Opaque SDF
 static void BG_Blended_Opaque_SDF(const TTF_Image *image, Uint32 *destination, Sint32 srcskip, Uint32 dstskip)
 {
     const Uint8 *src    = image->buffer;
@@ -500,7 +500,7 @@ static void BG_Blended_Opaque_SDF(const TTF_Image *image, Uint32 *destination, S
     }
 }
 
-/* Blended non-opaque SDF */
+// Blended non-opaque SDF
 static void BG_Blended_SDF(const TTF_Image *image, Uint32 *destination, Sint32 srcskip, Uint32 dstskip, Uint8 fg_alpha)
 {
     const Uint8 *src    = image->buffer;
@@ -529,9 +529,9 @@ static void BG_Blended_SDF(const TTF_Image *image, Uint32 *destination, Sint32 s
     }
 }
 
-#endif /* TTF_USE_SDF */
+#endif // TTF_USE_SDF
 
-/* Blended Opaque */
+// Blended Opaque
 static void BG_Blended_Opaque(const TTF_Image *image, Uint32 *destination, Sint32 srcskip, Uint32 dstskip)
 {
     const Uint8 *src    = image->buffer;
@@ -550,7 +550,7 @@ static void BG_Blended_Opaque(const TTF_Image *image, Uint32 *destination, Sint3
     }
 }
 
-/* Blended non-opaque */
+// Blended non-opaque
 static void BG_Blended(const TTF_Image *image, Uint32 *destination, Sint32 srcskip, Uint32 dstskip, Uint8 fg_alpha)
 {
     const Uint8 *src    = image->buffer;
@@ -623,7 +623,7 @@ static void BG_Blended_32(const TTF_Image *image, Uint32 *destination, Sint32 sr
 #endif
 
 #if defined(HAVE_SSE2_INTRINSICS)
-/* Apply: alpha_table[i] = i << 24; */
+// Apply: alpha_table[i] = i << 24;
 static void BG_Blended_Opaque_SSE(const TTF_Image *image, Uint32 *destination, Sint32 srcskip, Uint32 dstskip)
 {
     const __m128i *src    = (__m128i *)image->buffer;
@@ -637,7 +637,7 @@ static void BG_Blended_Opaque_SSE(const TTF_Image *image, Uint32 *destination, S
     while (height--) {
         /* *INDENT-OFF* */
         DUFFS_LOOP4(
-            /* Read 16 Uint8 at once and put into 4 __m128i */
+            // Read 16 Uint8 at once and put into 4 __m128i
             s  = _mm_loadu_si128(src);          // load unaligned
             d0 = _mm_load_si128(dst);           // load
             d1 = _mm_load_si128(dst + 1);       // load
@@ -686,7 +686,7 @@ static void BG_Blended_SSE(const TTF_Image *image, Uint32 *destination, Sint32 s
     while (height--) {
         /* *INDENT-OFF* */
         DUFFS_LOOP4(
-            /* Read 16 Uint8 at once and put into 4 __m128i */
+            // Read 16 Uint8 at once and put into 4 __m128i
             s  = _mm_loadu_si128(src);          // load unaligned
             d0 = _mm_load_si128(dst);           // load
             d1 = _mm_load_si128(dst + 1);       // load
@@ -697,7 +697,7 @@ static void BG_Blended_SSE(const TTF_Image *image, Uint32 *destination, Sint32 s
             H  = _mm_unpackhi_epi8(s, zero);    // enough room to multiply
 
             /* Apply: alpha_table[i] = ((i * fg.a / 255) << 24; */
-            /* Divide by 255 is done as:    (x + 1 + (x >> 8)) >> 8 */
+            // Divide by 255 is done as:    (x + 1 + (x >> 8)) >> 8
 
             L  = _mm_mullo_epi16(L, alpha);     // x := i * fg.a
             H  = _mm_mullo_epi16(H, alpha);
@@ -741,7 +741,7 @@ static void BG_Blended_SSE(const TTF_Image *image, Uint32 *destination, Sint32 s
 #endif
 
 #if defined(HAVE_NEON_INTRINSICS)
-/* Apply: alpha_table[i] = i << 24; */
+// Apply: alpha_table[i] = i << 24;
 static void BG_Blended_Opaque_NEON(const TTF_Image *image, Uint32 *destination, Sint32 srcskip, Uint32 dstskip)
 {
     const Uint32 *src    = (Uint32 *)image->buffer;
@@ -788,7 +788,7 @@ static void BG_Blended_Opaque_NEON(const TTF_Image *image, Uint32 *destination,
     }
 }
 
-/* Non-opaque, computes alpha blending on the fly */
+// Non-opaque, computes alpha blending on the fly
 static void BG_Blended_NEON(const TTF_Image *image, Uint32 *destination, Sint32 srcskip, Uint32 dstskip, Uint8 fg_alpha)
 {
     const Uint32 *src    = (Uint32 *)image->buffer;
@@ -820,7 +820,7 @@ static void BG_Blended_NEON(const TTF_Image *image, Uint32 *destination, Sint32
                                                         // enough room to multiply
 
             /* Apply: alpha_table[i] = ((i * fg.a / 255) << 24; */
-            /* Divide by 255 is done as:    (x + 1 + (x >> 8)) >> 8 */
+            // Divide by 255 is done as:    (x + 1 + (x >> 8)) >> 8
 
             sx.val[0] = vmulq_u16(sx.val[0], alpha);    // x := i * fg.a
             sx.val[1] = vmulq_u16(sx.val[1], alpha);
@@ -980,7 +980,7 @@ static void BG_NEON(const TTF_Image *image, Uint8 *destination, Sint32 srcskip,
 }
 #endif
 
-/* Underline and Strikethrough style. Draw a line at the given row. */
+// Underline and Strikethrough style. Draw a line at the given row.
 static void Draw_Line(TTF_Font *font, const SDL_Surface *textbuf, int column, int row, int line_width, int line_thickness, Uint32 color, const render_mode_t render_mode)
 {
     int tmp    = row + line_thickness - textbuf->h;
@@ -993,7 +993,7 @@ static void Draw_Line(TTF_Font *font, const SDL_Surface *textbuf, int column, in
         hb_direction = g_hb_direction;
     }
 
-    /* No Underline/Strikethrough style if direction is vertical */
+    // No Underline/Strikethrough style if direction is vertical
     if (hb_direction == HB_DIRECTION_TTB || hb_direction == HB_DIRECTION_BTT) {
         return;
     }
@@ -1016,7 +1016,7 @@ static void Draw_Line(TTF_Font *font, const SDL_Surface *textbuf, int column, in
         return;
     }
 
-    /* Wrapped mode with an unbroken line: 'line_width' is greater that 'textbuf->w' */
+    // Wrapped mode with an unbroken line: 'line_width' is greater that 'textbuf->w'
     line_width = SDL_min(line_width, textbuf->w);
 
     if (render_mode == RENDER_BLENDED || render_mode == RENDER_LCD) {
@@ -1044,7 +1044,7 @@ static void Draw_Line_TextEngine(TTF_Font *font, int width, int height, int colu
         hb_direction = g_hb_direction;
     }
 
-    /* No Underline/Strikethrough style if direction is vertical */
+    // No Underline/Strikethrough style if direction is vertical
     if (hb_direction == HB_DIRECTION_TTB || hb_direction == HB_DIRECTION_BTT) {
         return;
     }
@@ -1067,7 +1067,7 @@ static void Draw_Line_TextEngine(TTF_Font *font, int width, int height, int colu
         return;
     }
 
-    /* Wrapped mode with an unbroken line: 'line_width' is greater that 'width' */
+    // Wrapped mode with an unbroken line: 'line_width' is greater that 'width'
     line_width = SDL_min(line_width, width);
 
     op = &ops[op_index++];
@@ -1091,31 +1091,31 @@ static void clip_glyph(int *_x, int *_y, TTF_Image *image, const SDL_Surface *te
         srcbpp = 4;
     }
 
-    /* Don't go below x=0 */
+    // Don't go below x=0
     if (x < 0) {
         int tmp = -x;
         x = 0;
         image->width  -= tmp;
         image->buffer += srcbpp * tmp;
     }
-    /* Don't go above textbuf->w */
+    // Don't go above textbuf->w
     above_w = x + image->width - textbuf->w;
     if (above_w > 0) {
         image->width -= above_w;
     }
-    /* Don't go below y=0 */
+    // Don't go below y=0
     if (y < 0) {
         int tmp = -y;
         y = 0;
         image->rows   -= tmp;
         image->buffer += tmp * image->pitch;
     }
-    /* Don't go above textbuf->h */
+    // Don't go above textbuf->h
     above_h = y + image->rows - textbuf->h;
     if (above_h > 0) {
         image->rows -= above_h;
     }
-    /* Could be negative if (x > textbuf->w), or if (x + width < 0) */
+    // Could be negative if (x > textbuf->w), or if (x + width < 0)
     image->width = SDL_max(0, image->width);
     image->rows  = SDL_max(0, image->rows);
 
@@ -1129,7 +1129,7 @@ static void clip_glyph(int *_x, int *_y, TTF_Image *image, const SDL_Surface *te
     *_y = y;
 }
 
-/* Glyph width is rounded, dst addresses are aligned, src addresses are not aligned */
+// Glyph width is rounded, dst addresses are aligned, src addresses are not aligned
 static int Get_Alignment(void)
 {
 #if defined(HAVE_NEON_INTRINSICS)
@@ -1273,7 +1273,7 @@ static bool Render_Line_##NAME(TTF_Font *font, SDL_Surface *textbuf, int xstart,
 
 #define SUBPIX  CACHED_SUBPIX
 
-/* BUILD_RENDER_LINE(NAME, IS_BLENDED, IS_BLENDED_OPAQUE, WANT_PIXMAP_COLOR_LCD, WANT_SUBPIXEL, BLIT_GLYPH_BLENDED_OPAQUE_OPTIM, BLIT_GLYPH_BLENDED_OPTIM, BLIT_GLYPH_OPTIM) */
+// BUILD_RENDER_LINE(NAME, IS_BLENDED, IS_BLENDED_OPAQUE, WANT_PIXMAP_COLOR_LCD, WANT_SUBPIXEL, BLIT_GLYPH_BLENDED_OPAQUE_OPTIM, BLIT_GLYPH_BLENDED_OPTIM, BLIT_GLYPH_OPTIM)
 
 #if defined(HAVE_SSE2_INTRINSICS)
 BUILD_RENDER_LINE(SSE_Shaded            , 0, 0, 0, PIXMAP, 0     ,                       ,                , BG_SSE     )
@@ -1344,7 +1344,7 @@ static int (*Render_Line_SDF_LCD_SP)(TTF_Font *font, SDL_Surface *textbuf, int x
 
 static bool Render_Line(const render_mode_t render_mode, int subpixel, TTF_Font *font, SDL_Surface *textbuf, int xstart, int ystart, SDL_Color fg)
 {
-    /* Render line (pos_buf) to textbuf at (xstart, ystart) */
+    // Render line (pos_buf) to textbuf at (xstart, ystart)
 
     int is_opaque = (fg.a == SDL_ALPHA_OPAQUE);
 
@@ -1419,11 +1419,11 @@ static bool Render_Line_TextEngine(TTF_Font *font, int xstart, int ystart, int w
             int glyph_rows = glyph->sz_rows;
             TTF_DrawOperation *op;
 
-            /* Position updated after glyph rendering */
+            // Position updated after glyph rendering
             x = xstart + FT_FLOOR(x) + glyph->sz_left;
             y = ystart + FT_FLOOR(y) - glyph->sz_top;
 
-            /* Make sure glyph is inside text area */
+            // Make sure glyph is inside text area
             above_w = x + glyph_width - width;
             above_h = y + glyph_rows  - height;
 
@@ -1447,7 +1447,7 @@ static bool Render_Line_TextEngine(TTF_Font *font, int xstart, int ystart, int w
             }
 
             if (glyph_width <= 0 || glyph_rows <= 0) {
-                /* Completely clipped */
+                // Completely clipped
                 continue;
             }
 
@@ -1541,7 +1541,7 @@ stati

(Patch may be truncated, please check the link at the top of this post.)