diff --git a/sc2/src/libs/graphics/drawable.h b/sc2/src/libs/graphics/drawable.h index 626ef326e..59f4dd572 100644 --- a/sc2/src/libs/graphics/drawable.h +++ b/sc2/src/libs/graphics/drawable.h @@ -88,7 +88,7 @@ extern BOOLEAN _ReleaseCelData (void *handle); extern FRAME _CurFramePtr; // ClipRect is relative to ctxOrigin -extern void _text_blt (RECT *pClipRect, PRIMITIVE *PrimPtr, POINT ctxOrigin); +extern void _text_blt (RECT *pClipRect, TEXT *TextPtr, POINT ctxOrigin); #endif /* _DRAWABLE_H */ diff --git a/sc2/src/libs/graphics/font.c b/sc2/src/libs/graphics/font.c index 80afbbf39..cac494006 100644 --- a/sc2/src/libs/graphics/font.c +++ b/sc2/src/libs/graphics/font.c @@ -49,13 +49,24 @@ DestroyFont (FONT FontRef) return (FreeFont (FontRef)); } +// XXX: Should be in frame.c (renamed to something decent?) void font_DrawText (TEXT *lpText) { + RECT ClipRect; + POINT origin; + TEXT text; + FixContextFontEffect (); - SetPrimType (&_locPrim, TEXT_PRIM); - _locPrim.Object.Text = *lpText; - DrawBatch (&_locPrim, 0, BATCH_SINGLE); + if (!GraphicsSystemActive () || !GetContextValidRect (NULL, &origin)) + return; + + // TextRect() clobbers TEXT.CharCount so we have to make a copy + text = *lpText; + if (!TextRect (&text, &ClipRect, NULL)) + return; + // ClipRect is relative to origin + _text_blt (&ClipRect, &text, origin); } /* Draw the stroke by drawing the same text in the @@ -224,14 +235,12 @@ TextRect (TEXT *lpText, RECT *pRect, BYTE *pdelta) } void -_text_blt (RECT *pClipRect, PRIMITIVE *PrimPtr, POINT ctxOrigin) +_text_blt (RECT *pClipRect, TEXT *TextPtr, POINT ctxOrigin) { FONT FontPtr; - COUNT num_chars; UniChar next_ch; const unsigned char *pStr; - TEXT *TextPtr; POINT origin; TFB_Image *backing; @@ -242,7 +251,6 @@ _text_blt (RECT *pClipRect, PRIMITIVE *PrimPtr, POINT ctxOrigin) if (!backing) return; - TextPtr = &PrimPtr->Object.Text; origin.x = pClipRect->corner.x; origin.y = TextPtr->baseline.y; num_chars = TextPtr->CharCount; diff --git a/sc2/src/libs/graphics/frame.c b/sc2/src/libs/graphics/frame.c index 29a60bc03..26efc5267 100644 --- a/sc2/src/libs/graphics/frame.c +++ b/sc2/src/libs/graphics/frame.c @@ -171,7 +171,7 @@ DrawBatch (PRIMITIVE *lpBasePrim, PRIM_LINKS PrimLinks, if (!TextRect (&lpWorkPrim->Object.Text, &ClipRect, NULL)) continue; // ClipRect is relative to origin - _text_blt (&ClipRect, lpWorkPrim, origin); + _text_blt (&ClipRect, &lpWorkPrim->Object.Text, origin); break; case RECT_PRIM: color = GetPrimColor (lpWorkPrim);