From 0284f6bfd14c66ab7c6086686cca042b137ef210 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 28 Dec 2023 15:42:07 +0800 Subject: [PATCH] Font: tidy --- src/common/font.c | 25 ++++++++++++++++++------- src/common/font.h | 6 +++++- src/util/FFstrbuf.c | 16 ---------------- src/util/FFstrbuf.h | 1 - 4 files changed, 23 insertions(+), 25 deletions(-) diff --git a/src/common/font.c b/src/common/font.c index 042fa74ee..b2f3547b8 100644 --- a/src/common/font.c +++ b/src/common/font.c @@ -12,6 +12,22 @@ void ffFontInit(FFfont* font) ffListInit(&font->styles, sizeof(FFstrbuf)); } +static void strbufAppendNSExcludingC(FFstrbuf* strbuf, uint32_t length, const char* value, char exclude) +{ + if(value == NULL || length == 0) + return; + + ffStrbufEnsureFree(strbuf, length); + + for(uint32_t i = 0; i < length; i++) + { + if(value[i] != exclude) + strbuf->chars[strbuf->length++] = value[i]; + } + + strbuf->chars[strbuf->length] = '\0'; +} + static void fontInitPretty(FFfont* font) { ffStrbufAppend(&font->pretty, &font->name); @@ -155,7 +171,7 @@ static void fontPangoParseWord(const char** data, FFfont* font, FFstrbuf* altern ffStrbufInit(alternativeBuffer); } - ffStrbufAppendNSExludingC(alternativeBuffer, wordLength, wordStart, '-'); + strbufAppendNSExcludingC(alternativeBuffer, wordLength, wordStart, '-'); if( strncasecmp(wordStart, "Ultra ", 6) == 0 || @@ -171,7 +187,7 @@ static void fontPangoParseWord(const char** data, FFfont* font, FFstrbuf* altern if(alternativeBuffer != NULL) { - ffStrbufAppendNSExludingC(alternativeBuffer, wordLength, wordStart, '-'); + strbufAppendNSExcludingC(alternativeBuffer, wordLength, wordStart, '-'); return; } @@ -200,11 +216,6 @@ void ffFontInitValues(FFfont* font, const char* name, const char* size) fontInitPretty(font); } -void ffFontInitCopy(FFfont* font, const char* name) -{ - ffFontInitValues(font, name, NULL); -} - void ffFontInitWithSpace(FFfont* font, const char* rawName) { const char* pspace = strrchr(rawName, ' '); diff --git a/src/common/font.h b/src/common/font.h index 5ececb2f6..4ba4cfbbd 100644 --- a/src/common/font.h +++ b/src/common/font.h @@ -14,7 +14,11 @@ typedef struct FFfont void ffFontInit(FFfont* font); void ffFontInitQt(FFfont* font, const char* data); void ffFontInitPango(FFfont* font, const char* data); -void ffFontInitCopy(FFfont* font, const char* name); void ffFontInitValues(FFfont* font, const char* name, const char* size); void ffFontInitWithSpace(FFfont* font, const char* rawName); void ffFontDestroy(FFfont* font); + +static inline void ffFontInitCopy(FFfont* font, const char* name) +{ + ffFontInitValues(font, name, NULL); +} diff --git a/src/util/FFstrbuf.c b/src/util/FFstrbuf.c index 71e0b4d50..703b4055d 100644 --- a/src/util/FFstrbuf.c +++ b/src/util/FFstrbuf.c @@ -119,22 +119,6 @@ void ffStrbufAppendNS(FFstrbuf* strbuf, uint32_t length, const char* value) strbuf->chars[strbuf->length] = '\0'; } -void ffStrbufAppendNSExludingC(FFstrbuf* strbuf, uint32_t length, const char* value, char exclude) -{ - if(value == NULL || length == 0) - return; - - ffStrbufEnsureFree(strbuf, length); - - for(uint32_t i = 0; i < length; i++) - { - if(value[i] != exclude) - strbuf->chars[strbuf->length++] = value[i]; - } - - strbuf->chars[strbuf->length] = '\0'; -} - void ffStrbufAppendTransformS(FFstrbuf* strbuf, const char* value, int(*transformFunc)(int)) { if(value == NULL) diff --git a/src/util/FFstrbuf.h b/src/util/FFstrbuf.h index afdf74520..df4a70951 100644 --- a/src/util/FFstrbuf.h +++ b/src/util/FFstrbuf.h @@ -41,7 +41,6 @@ static inline void ffStrbufAppend(FFstrbuf* __restrict strbuf, const FFstrbuf* _ void ffStrbufAppendC(FFstrbuf* strbuf, char c); void ffStrbufAppendNC(FFstrbuf* strbuf, uint32_t num, char c); void ffStrbufAppendNS(FFstrbuf* strbuf, uint32_t length, const char* value); -void ffStrbufAppendNSExludingC(FFstrbuf* strbuf, uint32_t length, const char* value, char exclude); void ffStrbufAppendTransformS(FFstrbuf* strbuf, const char* value, int(*transformFunc)(int)); FF_C_PRINTF(2, 3) void ffStrbufAppendF(FFstrbuf* strbuf, const char* format, ...); void ffStrbufAppendVF(FFstrbuf* strbuf, const char* format, va_list arguments);