瀏覽代碼

WARNING: BREAKING: REDESIGN: `SetTextLineSpacing()`

Redesigned function to only consider separation between the end of vertical size of one line and the beginning of next line
pull/3949/head
Ray 1 年之前
父節點
當前提交
b03c8ba945
共有 3 個檔案被更改,包括 6 行新增6 行删除
  1. +1
    -1
      examples/text/text_codepoints_loading.c
  2. +1
    -1
      examples/text/text_font_loading.c
  3. +4
    -4
      src/rtext.c

+ 1
- 1
examples/text/text_codepoints_loading.c 查看文件

@ -52,7 +52,7 @@ int main(void)
// Set bilinear scale filter for better font scaling // Set bilinear scale filter for better font scaling
SetTextureFilter(font.texture, TEXTURE_FILTER_BILINEAR); SetTextureFilter(font.texture, TEXTURE_FILTER_BILINEAR);
SetTextLineSpacing(54); // Set line spacing for multiline text (when line breaks are included '\n') SetTextLineSpacing(20); // Set line spacing for multiline text (when line breaks are included '\n')
// Free codepoints, atlas has already been generated // Free codepoints, atlas has already been generated
free(codepointsNoDups); free(codepointsNoDups);

+ 1
- 1
examples/text/text_font_loading.c 查看文件

@ -47,7 +47,7 @@ int main(void)
// NOTE: We define a font base size of 32 pixels tall and up-to 250 characters // NOTE: We define a font base size of 32 pixels tall and up-to 250 characters
Font fontTtf = LoadFontEx("resources/pixantiqua.ttf", 32, 0, 250); Font fontTtf = LoadFontEx("resources/pixantiqua.ttf", 32, 0, 250);
SetTextLineSpacing(48); // Set line spacing for multiline text (when line breaks are included '\n') SetTextLineSpacing(16); // Set line spacing for multiline text (when line breaks are included '\n')
bool useTtf = false; bool useTtf = false;

+ 4
- 4
src/rtext.c 查看文件

@ -144,7 +144,7 @@ static Font LoadBMFont(const char *fileName); // Load a BMFont file (AngelCode
#if defined(SUPPORT_FILEFORMAT_BDF) #if defined(SUPPORT_FILEFORMAT_BDF)
static GlyphInfo *LoadFontDataBDF(const unsigned char *fileData, int dataSize, int *codepoints, int codepointCount, int *outFontSize); static GlyphInfo *LoadFontDataBDF(const unsigned char *fileData, int dataSize, int *codepoints, int codepointCount, int *outFontSize);
#endif #endif
static int textLineSpacing = 15; // Text vertical line spacing in pixels static int textLineSpacing = 2; // Text vertical line spacing in pixels (between lines)
#if defined(SUPPORT_DEFAULT_FONT) #if defined(SUPPORT_DEFAULT_FONT)
extern void LoadFontDefault(void); extern void LoadFontDefault(void);
@ -1166,7 +1166,7 @@ void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, f
if (codepoint == '\n') if (codepoint == '\n')
{ {
// NOTE: Line spacing is a global variable, use SetTextLineSpacing() to setup // NOTE: Line spacing is a global variable, use SetTextLineSpacing() to setup
textOffsetY += textLineSpacing; textOffsetY += p">(fontSize + textLineSpacing);
textOffsetX = 0.0f; textOffsetX = 0.0f;
} }
else else
@ -1237,7 +1237,7 @@ void DrawTextCodepoints(Font font, const int *codepoints, int codepointCount, Ve
if (codepoints[i] == '\n') if (codepoints[i] == '\n')
{ {
// NOTE: Line spacing is a global variable, use SetTextLineSpacing() to setup // NOTE: Line spacing is a global variable, use SetTextLineSpacing() to setup
textOffsetY += textLineSpacing; textOffsetY += p">(fontSize + textLineSpacing);
textOffsetX = 0.0f; textOffsetX = 0.0f;
} }
else else
@ -1319,7 +1319,7 @@ Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing
textWidth = 0; textWidth = 0;
// NOTE: Line spacing is a global variable, use SetTextLineSpacing() to setup // NOTE: Line spacing is a global variable, use SetTextLineSpacing() to setup
textHeight += (kt">float)textLineSpacing; textHeight += (n">fontSize + textLineSpacing);
} }
if (tempByteCounter < byteCounter) tempByteCounter = byteCounter; if (tempByteCounter < byteCounter) tempByteCounter = byteCounter;

||||||
x
 
000:0
Loading…
取消
儲存