(Font drivers) Simplifications

This commit is contained in:
twinaphex 2020-06-24 21:27:47 +02:00
parent 9cb4d924cb
commit 67898f5d12
9 changed files with 93 additions and 157 deletions

View File

@ -334,25 +334,18 @@ static void ctr_font_render_message(
for (;;) for (;;)
{ {
const char* delim = strchr(msg, '\n'); const char* delim = strchr(msg, '\n');
unsigned msg_len = delim ?
(unsigned)(delim - msg) : strlen(msg);
/* Draw the line */ /* Draw the line */
if (delim) ctr_font_render_line(ctr, font, msg, msg_len,
{ scale, color, pos_x, pos_y - (float)lines * line_height,
unsigned msg_len = delim - msg; width, height, text_align);
ctr_font_render_line(ctr, font, msg, msg_len, if (!delim)
scale, color, pos_x, pos_y - (float)lines * line_height,
width, height, text_align);
msg += msg_len + 1;
lines++;
}
else
{
unsigned msg_len = strlen(msg);
ctr_font_render_line(ctr, font, msg, msg_len,
scale, color, pos_x, pos_y - (float)lines * line_height,
width, height, text_align);
break; break;
}
msg += msg_len + 1;
lines++;
} }
} }

View File

@ -259,27 +259,20 @@ static void d3d10_font_render_message(
for (;;) for (;;)
{ {
const char* delim = strchr(msg, '\n'); const char* delim = strchr(msg, '\n');
unsigned msg_len = delim ?
(unsigned)(delim - msg) : strlen(msg);
/* Draw the line */ /* Draw the line */
if (delim) d3d10_font_render_line(d3d10,
{ font, msg, msg_len, scale, color, pos_x,
unsigned msg_len = delim - msg; pos_y - (float)lines * line_height,
d3d10_font_render_line(d3d10, width, height, text_align);
font, msg, msg_len, scale, color, pos_x,
pos_y - (float)lines * line_height, if (!delim)
width, height, text_align);
msg += msg_len + 1;
lines++;
}
else
{
unsigned msg_len = strlen(msg);
d3d10_font_render_line(d3d10,
font, msg, msg_len, scale, color, pos_x,
pos_y - (float)lines * line_height,
width, height, text_align);
break; break;
}
msg += msg_len + 1;
lines++;
} }
} }

View File

@ -256,27 +256,20 @@ static void d3d11_font_render_message(
for (;;) for (;;)
{ {
const char* delim = strchr(msg, '\n'); const char* delim = strchr(msg, '\n');
unsigned msg_len = delim ?
(unsigned)(delim - msg) : strlen(msg);
/* Draw the line */ /* Draw the line */
if (delim) d3d11_font_render_line(d3d11,
{ font, msg, msg_len, scale, color, pos_x,
unsigned msg_len = delim - msg; pos_y - (float)lines * line_height,
d3d11_font_render_line(d3d11, width, height, text_align);
font, msg, msg_len, scale, color, pos_x,
pos_y - (float)lines * line_height, if (!delim)
width, height, text_align);
msg += msg_len + 1;
lines++;
}
else
{
unsigned msg_len = strlen(msg);
d3d11_font_render_line(d3d11,
font, msg, msg_len, scale, color, pos_x,
pos_y - (float)lines * line_height,
width, height, text_align);
break; break;
}
msg += msg_len + 1;
lines++;
} }
} }

View File

@ -270,25 +270,19 @@ static void d3d12_font_render_message(
for (;;) for (;;)
{ {
const char* delim = strchr(msg, '\n'); const char* delim = strchr(msg, '\n');
unsigned msg_len = delim ?
(unsigned)(delim - msg) : strlen(msg);
/* Draw the line */ /* Draw the line */
if (delim) d3d12_font_render_line(d3d12,
{ font, msg, msg_len, scale, color, pos_x,
unsigned msg_len = delim - msg; pos_y - (float)lines * line_height, width, height, text_align);
d3d12_font_render_line(d3d12,
font, msg, msg_len, scale, color, pos_x, if (!delim)
pos_y - (float)lines * line_height, width, height, text_align);
msg += msg_len + 1;
lines++;
}
else
{
unsigned msg_len = strlen(msg);
d3d12_font_render_line(d3d12,
font, msg, msg_len, scale, color, pos_x,
pos_y - (float)lines * line_height, width, height, text_align);
break; break;
}
msg += msg_len + 1;
lines++;
} }
} }

View File

@ -365,34 +365,24 @@ static INLINE void write_quad6(SpriteVertex *pv,
for (;;) for (;;)
{ {
const char *delim = strchr(msg, '\n'); const char *delim = strchr(msg, '\n');
NSUInteger msg_len = delim ?
(unsigned)(delim - msg) : strlen(msg);
/* Draw the line */ /* Draw the line */
if (delim) [self _renderLine:msg
{ length:msg_len
NSUInteger msg_len = delim - msg; scale:scale
[self _renderLine:msg color:color
length:msg_len posX:posX
scale:scale posY:posY - (float)lines * line_height
color:color aligned:aligned];
posX:posX
posY:posY - (float)lines * line_height if (!delim)
aligned:aligned];
msg += msg_len + 1;
lines++;
}
else
{
NSUInteger msg_len = strlen(msg);
[self _renderLine:msg
length:msg_len
scale:scale
color:color
posX:posX
posY:posY - (float)lines * line_height
aligned:aligned];
break; break;
}
msg += msg_len + 1;
lines++;
} }
} }

View File

@ -197,7 +197,7 @@ static void switch_font_render_message(
int lines = 0; int lines = 0;
float line_height; float line_height;
if (!msg || !*msg) if (!msg || !*msg || !sw)
return; return;
/* If font line metrics are not supported just draw as usual */ /* If font line metrics are not supported just draw as usual */
@ -218,33 +218,20 @@ static void switch_font_render_message(
for (;;) for (;;)
{ {
const char *delim = strchr(msg, '\n'); const char *delim = strchr(msg, '\n');
unsigned msg_len = delim ?
(unsigned)(delim - msg) : strlen(msg);
/* Draw the line */ /* Draw the line */
if (delim) if (msg_len <= AVG_GLPYH_LIMIT)
{ switch_font_render_line(sw, font, msg, msg_len,
unsigned msg_len = delim - msg; scale, color, pos_x, pos_y - (float)lines * line_height,
if (msg_len <= AVG_GLPYH_LIMIT) text_align);
{
if (sw) if (!delim)
switch_font_render_line(sw, font, msg, msg_len,
scale, color, pos_x, pos_y - (float)lines * line_height,
text_align);
}
msg += msg_len + 1;
lines++;
}
else
{
unsigned msg_len = strlen(msg);
if (msg_len <= AVG_GLPYH_LIMIT)
{
if (sw)
switch_font_render_line(sw, font, msg, msg_len,
scale, color, pos_x, pos_y - (float)lines * line_height,
text_align);
}
break; break;
}
msg += msg_len + 1;
lines++;
} }
} }

View File

@ -246,13 +246,14 @@ static void vita2d_font_render_message(
for (;;) for (;;)
{ {
const char *delim = strchr(msg, '\n'); const char *delim = strchr(msg, '\n');
unsigned msg_len = (delim) ? (delim - msg) : strlen(msg); unsigned msg_len = (delim) ?
(unsigned)(delim - msg) : strlen(msg);
/* Draw the line */
vita2d_font_render_line(font, msg, msg_len, vita2d_font_render_line(font, msg, msg_len,
scale, color, pos_x, pos_y - (float)lines * line_height, scale, color, pos_x, pos_y - (float)lines * line_height,
width, height, text_align); width, height, text_align);
/* Draw the line */
if (!delim) if (!delim)
break; break;

View File

@ -244,9 +244,8 @@ static void vulkan_raster_font_render_message(
if (!font->font_driver->get_line_metrics || if (!font->font_driver->get_line_metrics ||
!font->font_driver->get_line_metrics(font->font_data, &line_metrics)) !font->font_driver->get_line_metrics(font->font_data, &line_metrics))
{ {
if (font->vk) vulkan_raster_font_render_line(font, msg, strlen(msg),
vulkan_raster_font_render_line(font, msg, strlen(msg), scale, color, pos_x, pos_y, text_align);
scale, color, pos_x, pos_y, text_align);
return; return;
} }
@ -255,27 +254,19 @@ static void vulkan_raster_font_render_message(
for (;;) for (;;)
{ {
const char *delim = strchr(msg, '\n'); const char *delim = strchr(msg, '\n');
unsigned msg_len = delim
? (unsigned)(delim - msg) : (unsigned)strlen(msg);
/* Draw the line */ /* Draw the line */
if (delim) vulkan_raster_font_render_line(font, msg, msg_len,
{ scale, color, pos_x, pos_y - (float)lines * line_height,
unsigned msg_len = delim - msg; text_align);
if (font->vk)
vulkan_raster_font_render_line(font, msg, msg_len, if (!delim)
scale, color, pos_x, pos_y - (float)lines * line_height,
text_align);
msg += msg_len + 1;
lines++;
}
else
{
unsigned msg_len = strlen(msg);
if (font->vk)
vulkan_raster_font_render_line(font, msg, msg_len,
scale, color, pos_x, pos_y - (float)lines * line_height,
text_align);
break; break;
}
msg += msg_len + 1;
lines++;
} }
} }

View File

@ -263,25 +263,19 @@ static void wiiu_font_render_message(
for (;;) for (;;)
{ {
const char* delim = strchr(msg, '\n'); const char* delim = strchr(msg, '\n');
unsigned msg_len = delim ?
(unsigned)(delim - msg) : strlen(msg);
/* Draw the line */ /* Draw the line */
if (delim) wiiu_font_render_line(wiiu, font, msg, msg_len,
{ scale, color, pos_x, pos_y - (float)lines * line_height,
unsigned msg_len = delim - msg; width, height, text_align);
wiiu_font_render_line(wiiu, font, msg, msg_len,
scale, color, pos_x, pos_y - (float)lines * line_height, if (!delim)
width, height, text_align);
msg += msg_len + 1;
lines++;
}
else
{
unsigned msg_len = strlen(msg);
wiiu_font_render_line(wiiu, font, msg, msg_len,
scale, color, pos_x, pos_y - (float)lines * line_height,
width, height, text_align);
break; break;
}
msg += msg_len + 1;
lines++;
} }
} }