X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FApplications%2Faxwin3_src%2FWM%2Fwm_render_text.c;h=01b82ff8307fc28445bd9b7c1a996fcc9a7d2948;hb=6f00be304598cbaac2ed145f4d2079574717e984;hp=6ad72be6830b1c90be3a773fae8697190c79b473;hpb=52fad670ab81459de0ff1bd0fa99a3396a6999e3;p=tpg%2Facess2.git diff --git a/Usermode/Applications/axwin3_src/WM/wm_render_text.c b/Usermode/Applications/axwin3_src/WM/wm_render_text.c index 6ad72be6..01b82ff8 100644 --- a/Usermode/Applications/axwin3_src/WM/wm_render_text.c +++ b/Usermode/Applications/axwin3_src/WM/wm_render_text.c @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include // INT_MAX // === TYPES === @@ -56,7 +56,7 @@ struct sFont int WM_Render_DrawText(tWindow *Window, int X, int Y, int W, int H, tFont *Font, tColour Color, const char *Text, int MaxLen); void WM_Render_GetTextDims(tFont *Font, const char *Text, int MaxLen, int *W, int *H); tGlyph *_GetGlyph(tFont *Font, uint32_t Codepoint); -void _RenderGlyph(tWindow *Window, short X, short Y, tGlyph *Glyph, uint32_t Color); +void _RenderGlyph(tWindow *Window, short X, short Y, short ClipW, short ClipH, tGlyph *Glyph, uint32_t Color); tGlyph *_SystemFont_CacheGlyph(tFont *Font, uint32_t Codepoint); // === GLOBALS === @@ -108,11 +108,11 @@ int WM_Render_DrawText(tWindow *Window, int X, int Y, int W, int H, tFont *Font, glyph = _GetGlyph(Font, ch); if( !glyph ) continue ; // If not found, just don't render it - // End render if it will overflow the provided range - if( xOfs + glyph->TrueWidth > W ) + // End render if it will not fit at all + if( xOfs >= W ) break; - _RenderGlyph(Window, X + xOfs, Y, glyph, Colour); + _RenderGlyph(Window, X + xOfs, Y, W-xOfs, H, glyph, Colour); xOfs += glyph->Width; } @@ -235,7 +235,7 @@ tGlyph *_GetGlyph(tFont *Font, uint32_t Codepoint) /** */ -void _RenderGlyph(tWindow *Window, short X, short Y, tGlyph *Glyph, uint32_t Color) +void _RenderGlyph(tWindow *Window, short X, short Y, short ClipW, short ClipH, tGlyph *Glyph, uint32_t Color) { int xStart = 0, yStart = 0; int x, y, dst_x; @@ -258,9 +258,9 @@ void _RenderGlyph(tWindow *Window, short X, short Y, tGlyph *Glyph, uint32_t Col outBuf = (uint32_t*)Window->RenderBuffer + Y*Window->RealW + X; inBuf = Glyph->Bitmap + yStart*Glyph->TrueWidth; - for( y = yStart; y < Glyph->TrueHeight; y ++ ) + for( y = yStart; y < Glyph->TrueHeight && ClipH--; y ++ ) { - for( x = xStart, dst_x = 0; x < Glyph->TrueWidth; x ++, dst_x ++ ) + for( x = xStart, dst_x = 0; x < Glyph->TrueWidth && dst_x < ClipW; x ++, dst_x ++ ) { outBuf[dst_x] = Video_AlphaBlend( outBuf[dst_x], Color, inBuf[x] ); }