X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FApplications%2Faxwin3_src%2FWM%2Fwm_render_text.c;h=01b82ff8307fc28445bd9b7c1a996fcc9a7d2948;hb=e3aca1210498cec4f1cb4d9337aeb774990194a0;hp=d189e5e04b98e19de8a799e84a1b07b2cc2ce56a;hpb=f0c407e7d468bc5acfd8d436be7f79f6e6248421;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 d189e5e0..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,8 @@ #include #include #include -#include +#include +#include // INT_MAX // === TYPES === typedef struct sGlyph tGlyph; @@ -55,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 === @@ -107,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; } @@ -171,7 +172,7 @@ tGlyph *_GetGlyph(tFont *Font, uint32_t Codepoint) prev = next, next = next->Next ); - if( next->Codepoint == Codepoint ) + if( next && next->Codepoint == Codepoint ) return next; } @@ -185,7 +186,7 @@ tGlyph *_GetGlyph(tFont *Font, uint32_t Codepoint) prev && prev->Codepoint > Codepoint; next = prev, prev = prev->Prev ); - if( prev->Codepoint == Codepoint ) + if( prev && prev->Codepoint == Codepoint ) return prev; } } @@ -234,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; @@ -257,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] ); }