Lagrange [work/v1.13]

Cleanup

=> ccb982160b68e08bebb92b6f244d4443dc7c133f

diff --git a/src/gmrequest.c b/src/gmrequest.c
index aa55aca2..12d1e5e2 100644
--- a/src/gmrequest.c
+++ b/src/gmrequest.c
@@ -400,24 +400,6 @@ static const iBlock *replaceVariables_(const iBlock *block) {
             if (equal_Rangecc(name, "APP_VERSION")) {
                 repl = range_CStr(LAGRANGE_APP_VERSION);
             }
-#if 0
-            else if (startsWith_Rangecc(name, "BT:")) { /* block text */
-                repl = range_String(collect_String(renderBlockChars_Text(
-                    &fontFiraSansRegular_Resources,
-                    11, /* should be larger if shaded */
-                    quadrants_TextBlockMode,
-                    &(iString){ iBlockLiteral(
-                        name.start + 3, size_Range(&name) - 3, size_Range(&name) - 3) })));
-            }
-            else if (startsWith_Rangecc(name, "ST:")) { /* shaded text */
-                repl = range_String(collect_String(renderBlockChars_Text(
-                    &fontSmolEmojiRegular_Resources,
-                    20,
-                    shading_TextBlockMode,
-                    &(iString){ iBlockLiteral(
-                        name.start + 3, size_Range(&name) - 3, size_Range(&name) - 3) })));
-            }
-#endif
             else if (equal_Rangecc(name, "ALT")) {
 #if defined (iPlatformApple)
                 repl = range_CStr("\u2325");
diff --git a/src/ui/text.c b/src/ui/text.c
index 048678ca..0de33619 100644
--- a/src/ui/text.c
+++ b/src/ui/text.c
@@ -2656,111 +2656,6 @@ SDL_Texture *glyphCache_Text(void) {
     return activeText_->cache;
 }
 
-static void freeBitmap_(void *ptr) {
-    stbtt_FreeBitmap(ptr, NULL);
-}
-
-iString *renderBlockChars_Text(const iBlock *fontData, int height, enum iTextBlockMode mode,
-                               const iString *text) {
-    iBeginCollect();
-    stbtt_fontinfo font;
-    iZap(font);
-    stbtt_InitFont(&font, constData_Block(fontData), 0);
-    int ascent;
-    stbtt_GetFontVMetrics(&font, &ascent, NULL, NULL);
-    iDeclareType(CharBuf);
-    struct Impl_CharBuf {
-        uint8_t *pixels;
-        iInt2 size;
-        int dy;
-        int advance;
-    };
-    iArray *    chars     = collectNew_Array(sizeof(iCharBuf));
-    int         pxRatio   = (mode == quadrants_TextBlockMode ? 2 : 1);
-    int         pxHeight  = height * pxRatio;
-    const float scale     = stbtt_ScaleForPixelHeight(&font, pxHeight);
-    const float xScale    = scale * 2; /* character aspect ratio */
-    const int   baseline  = ascent * scale;
-    int         width     = 0;
-    size_t      strRemain = length_String(text);
-    iConstForEach(String, i, text) {
-        if (!strRemain) break;
-        if (isVariationSelector_Char(i.value) || isDefaultIgnorable_Char(i.value)) {
-            strRemain--;
-            continue;
-        }
-        iCharBuf buf = { .size = zero_I2() };
-        buf.pixels = stbtt_GetCodepointBitmap(
-            &font, xScale, scale, i.value, &buf.size.x, &buf.size.y, 0, &buf.dy);
-        stbtt_GetCodepointHMetrics(&font, i.value, &buf.advance, NULL);
-        buf.advance *= xScale;
-        if (!isSpace_Char(i.value)) {
-            if (mode == quadrants_TextBlockMode) {
-                buf.advance = (buf.size.x - 1) / 2 * 2 + 2;
-            }
-            else {
-                buf.advance = buf.size.x + 1;
-            }
-        }
-        pushBack_Array(chars, &buf);
-        collect_Garbage(buf.pixels, freeBitmap_);
-        width += buf.advance;
-        strRemain--;
-    }
-    const size_t len = (mode == quadrants_TextBlockMode ? height * ((width + 1) / 2 + 1)
-                                                        : (height * (width + 1)));
-    iChar *outBuf = iCollectMem(malloc(sizeof(iChar) * len));
-    for (size_t i = 0; i < len; ++i) {
-        outBuf[i] = 0x20;
-    }
-    iChar *outPos = outBuf;
-    for (int y = 0; y < pxHeight; y += pxRatio) {
-        const iCharBuf *ch = constData_Array(chars);
-        int lx = 0;
-        for (int x = 0; x < width; x += pxRatio, lx += pxRatio) {
-            if (lx >= ch->advance) {
-                ch++;
-                lx = 0;
-            }
-            const int ly = y - baseline - ch->dy;
-            if (mode == quadrants_TextBlockMode) {
-                #define checkPixel_(offx, offy) \
-                    (lx + offx < ch->size.x && ly + offy < ch->size.y && ly + offy >= 0 ? \
-                        ch->pixels[(lx + offx) + (ly + offy) * ch->size.x] > 155 \
-                        : iFalse)
-                const int mask = (checkPixel_(0, 0) ? 1 : 0) |
-                                 (checkPixel_(1, 0) ? 2 : 0) |
-                                 (checkPixel_(0, 1) ? 4 : 0) |
-                                 (checkPixel_(1, 1) ? 8 : 0);
-                #undef checkPixel_
-                static const iChar blocks[16] = { 0x0020, 0x2598, 0x259D, 0x2580, 0x2596, 0x258C,
-                                                  0x259E, 0x259B, 0x2597, 0x259A, 0x2590, 0x259C,
-                                                  0x2584, 0x2599, 0x259F, 0x2588 };
-                *outPos++ = blocks[mask];
-            }
-            else {
-                static const iChar shades[5] = { 0x0020, 0x2591, 0x2592, 0x2593, 0x2588 };
-                *outPos++ = shades[lx < ch->size.x && ly < ch->size.y && ly >= 0 ?
-                                   ch->pixels[lx + ly * ch->size.x] * 5 / 256 : 0];
-            }
-        }
-        *outPos++ = '\n';
-    }
-    /* We could compose the lines separately, but we'd still need to convert them to Strings
-       individually to trim them. */
-    iStringList *lines = split_String(collect_String(newUnicodeN_String(outBuf, len)), "\n");
-    while (!isEmpty_StringList(lines) &&
-           isEmpty_String(collect_String(trimmed_String(at_StringList(lines, 0))))) {
-        popFront_StringList(lines);
-    }
-    while (!isEmpty_StringList(lines) && isEmpty_String(collect_String(trimmed_String(
-                                             at_StringList(lines, size_StringList(lines) - 1))))) {
-        popBack_StringList(lines);
-    }
-    iEndCollect();
-    return joinCStr_StringList(iClob(lines), "\n");
-}
-
 /*-----------------------------------------------------------------------------------------------*/
 
 iDefineTypeConstructionArgs(TextBuf, (iWrapText *wrapText, int font, int color), wrapText, font, color)
diff --git a/src/ui/text.h b/src/ui/text.h
index d86dbb16..88ab7dc2 100644
--- a/src/ui/text.h
+++ b/src/ui/text.h
@@ -218,11 +218,6 @@ void            resetMissing_Text   (iText *);
 iBool           checkMissing_Text   (void); /* returns the flag, and clears it */
 SDL_Texture *   glyphCache_Text     (void);
 
-enum iTextBlockMode { quadrants_TextBlockMode, shading_TextBlockMode };
-
-iString *   renderBlockChars_Text   (const iBlock *fontData, int height, enum iTextBlockMode,
-                                     const iString *text);
-
 iRegExp *   makeAnsiEscapePattern_Text  (iBool includeEscChar);
 
 /*-----------------------------------------------------------------------------------------------*/
Proxy Information
Original URL
gemini://git.skyjake.fi/lagrange/work%2Fv1.13/cdiff/ccb982160b68e08bebb92b6f244d4443dc7c133f
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
56.052542 milliseconds
Gemini-to-HTML Time
0.599221 milliseconds

This content has been proxied by September (3851b).