diff --git a/Sources/Plasma/PubUtilLib/plGImage/plDynamicTextMap.cpp b/Sources/Plasma/PubUtilLib/plGImage/plDynamicTextMap.cpp index ad869803..f22e327e 100644 --- a/Sources/Plasma/PubUtilLib/plGImage/plDynamicTextMap.cpp +++ b/Sources/Plasma/PubUtilLib/plGImage/plDynamicTextMap.cpp @@ -379,6 +379,17 @@ void plDynamicTextMap::IClearFromBuffer( uint32_t *clearBuffer ) } } +//// IPropagateFlags ////////////////////////////////////////////////////////// + +void plDynamicTextMap::IPropagateFlags() +{ + SetJustify(fJustify); + fCurrFont->SetRenderFlag(plFont::kRenderShadow, fFontFlags & kFontShadowed); + fCurrFont->SetRenderFlag(plFont::kRenderIntoAlpha, fFontBlockRGB); + fCurrFont->SetRenderFlag(plFont::kRenderAlphaPremultiplied, fPremultipliedAlpha); + fCurrFont->SetRenderColor(fFontColor.ToARGB32()); +} + //// ClearToColor ///////////////////////////////////////////////////////////// void plDynamicTextMap::ClearToColor( hsColorRGBA &color ) @@ -450,6 +461,8 @@ void plDynamicTextMap::SetFont( const plString &face, uint16_t size, uint8_t // This will be nil if we're just running the page optimizer. if (fCurrFont) { + if (fFontFlags & kFontShadowed) + fCurrFont->SetRenderFlag(plFont::kRenderShadow, true); fCurrFont->SetRenderYJustify( plFont::kRenderJustYTop ); SetJustify( fJustify ); } @@ -496,12 +509,9 @@ void plDynamicTextMap::DrawString( uint16_t x, uint16_t y, const wchar_t *tex if( !IIsValid() ) return; - SetJustify( fJustify ); + IPropagateFlags(); fCurrFont->SetRenderFlag( plFont::kRenderWrap | plFont::kRenderClip, false ); fCurrFont->SetRenderClipRect( 0, 0, fVisWidth, fVisHeight ); - fCurrFont->SetRenderColor( fFontColor.ToARGB32() ); - fCurrFont->SetRenderFlag( plFont::kRenderIntoAlpha, fFontBlockRGB ); - fCurrFont->SetRenderFlag( plFont::kRenderAlphaPremultiplied, fPremultipliedAlpha ); fCurrFont->RenderString( this, x, y, text ); } @@ -518,11 +528,8 @@ void plDynamicTextMap::DrawClippedString( int16_t x, int16_t y, const wchar_t if( !IIsValid() ) return; - SetJustify( fJustify ); + IPropagateFlags(); fCurrFont->SetRenderClipping( x, y, width, height ); - fCurrFont->SetRenderColor( fFontColor.ToARGB32() ); - fCurrFont->SetRenderFlag( plFont::kRenderIntoAlpha, fFontBlockRGB ); - fCurrFont->SetRenderFlag( plFont::kRenderAlphaPremultiplied, fPremultipliedAlpha ); fCurrFont->RenderString( this, x, y, text ); } @@ -539,10 +546,8 @@ void plDynamicTextMap::DrawClippedString( int16_t x, int16_t y, const wchar_t if( !IIsValid() ) return; - SetJustify( fJustify ); + IPropagateFlags(); fCurrFont->SetRenderClipping( clipX, clipY, width, height ); - fCurrFont->SetRenderColor( fFontColor.ToARGB32() ); - fCurrFont->SetRenderFlag( plFont::kRenderAlphaPremultiplied, fPremultipliedAlpha ); fCurrFont->RenderString( this, x, y, text ); } @@ -559,11 +564,8 @@ void plDynamicTextMap::DrawWrappedString( uint16_t x, uint16_t y, const wchar if( !IIsValid() ) return; - SetJustify( fJustify ); + IPropagateFlags(); fCurrFont->SetRenderWrapping( x, y, width, height ); - fCurrFont->SetRenderColor( fFontColor.ToARGB32() ); - fCurrFont->SetRenderFlag( plFont::kRenderIntoAlpha, fFontBlockRGB ); - fCurrFont->SetRenderFlag( plFont::kRenderAlphaPremultiplied, fPremultipliedAlpha ); fCurrFont->RenderString( this, x, y, text, lastX, lastY ); } diff --git a/Sources/Plasma/PubUtilLib/plGImage/plDynamicTextMap.h b/Sources/Plasma/PubUtilLib/plGImage/plDynamicTextMap.h index 318238b8..ad47bab3 100644 --- a/Sources/Plasma/PubUtilLib/plGImage/plDynamicTextMap.h +++ b/Sources/Plasma/PubUtilLib/plGImage/plDynamicTextMap.h @@ -221,6 +221,8 @@ class plDynamicTextMap : public plMipmap uint32_t *IAllocateOSSurface( uint16_t width, uint16_t height ); void IDestroyOSSurface( void ); + void IPropagateFlags(); + bool fHasAlpha, fPremultipliedAlpha, fShadowed; Justify fJustify; diff --git a/Sources/Plasma/PubUtilLib/plGImage/plFont.cpp b/Sources/Plasma/PubUtilLib/plGImage/plFont.cpp index ffa5468f..1766ef40 100644 --- a/Sources/Plasma/PubUtilLib/plGImage/plFont.cpp +++ b/Sources/Plasma/PubUtilLib/plGImage/plFont.cpp @@ -336,7 +336,7 @@ void plFont::IRenderString( plMipmap *mip, uint16_t x, uint16_t y, const wcha { if( fRenderInfo.fFlags & kRenderAlphaPremultiplied ) { - if (1)//( ( fRenderInfo.fColor & 0x00ffffff ) == 0x00ffffff ) //FIXME + if (fRenderInfo.fFlags & kRenderShadow) fRenderInfo.fRenderFunc = &plFont::IRenderChar8To32AlphaPremShadow; else fRenderInfo.fRenderFunc = &plFont::IRenderChar8To32AlphaPremultiplied; diff --git a/Sources/Plasma/PubUtilLib/plGImage/plFont.h b/Sources/Plasma/PubUtilLib/plGImage/plFont.h index 4123fa56..68a2f88f 100644 --- a/Sources/Plasma/PubUtilLib/plGImage/plFont.h +++ b/Sources/Plasma/PubUtilLib/plGImage/plFont.h @@ -117,6 +117,7 @@ class plFont : public hsKeyedObject // leave the alpha as-is // This flag has no effect on monochrome fonts kRenderAlphaPremultiplied = 0x00001000, // Destination has color values premultiplied by alpha + kRenderShadow = 0x00002000, // Render text shadows }; enum Flags