Repository: fastfetch-cli/fastfetch
File: src/common/logo.c (C)

Code before:
    sprintf(logo->chars[16], FASTFETCH_TEXT_MODIFIER_BOLT"%s        d:SS@8ba89aa67a853Sxxad.              "FASTFETCH_TEXT_MODIFIER_RESET, color);
    sprintf(logo->chars[17], FASTFETCH_TEXT_MODIFIER_BOLT"%s          .d988999889889899dd.                "FASTFETCH_TEXT_MODIFIER_RESET, color);
    sprintf(logo->chars[18], FASTFETCH_TEXT_MODIFIER_BOLT"%s                                              "FASTFETCH_TEXT_MODIFIER_RESET, color);
    sprintf(logo->chars[19], FASTFETCH_TEXT_MODIFIER_BOLT"%s                                              "FASTFETCH_TEXT_MODIFIER_RESET, color);
}

static void loadLogoFromFile(FFlogo* logo, bool doColor, char* pathToFile)
{
    strcpy(logo->name, "amogus");

    const char* color = doColor ? "\033[91m" : "";
    strcpy(logo->color, "\033[91m");

    FILE* fp = fopen(pathToFile, "r");
    char buff[255];
    char* normalizedBuff;
    int len;

    int logoWidth = 0, logoHeight = 0;
    while(!feof(fp)) {
        fgets(buff, sizeof(buff), fp);
        normalizedBuff = strtok(buff, "\n");
        
        sprintf(logo->chars[logoHeight++],   FASTFETCH_TEXT_MODIFIER_BOLT"%s%s"FASTFETCH_TEXT_MODIFIER_RESET, color, normalizedBuff);

        len = utf8_strlen(normalizedBuff);
        logoWidth = len > logoWidth
            ? len
            : logoWidth;
    }

    fclose(fp);

    logo->width = logoWidth;
    logo->height = logoHeight;
}

void ffLoadLogoSet(FFconfig* config, const char* logo)
{
    if(strcasecmp(logo, "none") == 0)
    {
        loadNoneLogo(&config->logo);
        config->logo_spacing = 0; //This is wanted in most cases, so just set it
    }
    else if(strcasecmp(logo, "arch") == 0)
        loadArchLogo(&config->logo, config->colorLogo);
    else if(strcasecmp(logo, "artix") == 0)
        loadArtixLogo(&config->logo, config->colorLogo);
    else if(strcasecmp(logo, "ubuntu") == 0)
        loadUbuntuLogo(&config->logo, config->colorLogo);
    else if(strcasecmp(logo, "debian") == 0)

Review comment (suggestion):
Im not into this topic, why isn't a simple `strlen` enough? The point of Ascii logos is that they can be encoded using ascii so i'm not sure if we need to support unicode.


Code after:
    sprintf(logo->chars[16], FASTFETCH_TEXT_MODIFIER_BOLT"%s        d:SS@8ba89aa67a853Sxxad.              "FASTFETCH_TEXT_MODIFIER_RESET, color);
    sprintf(logo->chars[17], FASTFETCH_TEXT_MODIFIER_BOLT"%s          .d988999889889899dd.                "FASTFETCH_TEXT_MODIFIER_RESET, color);
    sprintf(logo->chars[18], FASTFETCH_TEXT_MODIFIER_BOLT"%s                                              "FASTFETCH_TEXT_MODIFIER_RESET, color);
    sprintf(logo->chars[19], FASTFETCH_TEXT_MODIFIER_BOLT"%s                                              "FASTFETCH_TEXT_MODIFIER_RESET, color);
}

static void loadLogoFromFile(FFlogo* logo, bool doColor, FFstrbuf* configColor, const char* pathToFile)
{
    const char* color = doColor ? configColor->chars : "";
    strcpy(logo->color, color);

    FILE* fp = fopen(pathToFile, "r");
    char* buff = NULL;
    size_t buffLen = 0;
    int lineBytes;
    int lineLength;

    int logoWidth = 0, logoHeight = 0;
    while( (lineBytes=getline(&buff, &buffLen, fp)) != -1 ) {
        // Remove trailing newline
        if(buff[lineBytes-1] == '\n')
            buff[lineBytes-1] = '\0';
        
        sprintf(logo->chars[logoHeight++],   FASTFETCH_TEXT_MODIFIER_BOLT"%s%s"FASTFETCH_TEXT_MODIFIER_RESET, color, buff);

        lineLength = utf8_strlen(buff);
        logoWidth = lineLength > logoWidth
            ? lineLength
            : logoWidth;
    }

    // Clean up
    fclose(fp);
    if(buff != NULL)
        free(buff);

    logo->width = logoWidth;
    logo->height = logoHeight;
}

void ffLoadLogoSet(FFconfig* config, const char* logo)
{
    if(config->readLogoFromFile) {
        ffLoadLogoFromFile(config, logo);
    } else {
        if(strcasecmp(logo, "none") == 0)
        {
            loadNoneLogo(&config->logo);
            config->logo_spacing = 0; //This is wanted in most cases, so just set it
        }
        else if(strcasecmp(logo, "arch") == 0)