From 1a7899e270783dc580a8b4107582e7b1c208d9cb Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Thu, 22 Sep 2005 09:08:11 +0000 Subject: [PATCH] add support for Right to Left fonts --- stepmania/src/BitmapText.cpp | 8 ++++++++ stepmania/src/Font.cpp | 1 + stepmania/src/Font.h | 7 +++++++ 3 files changed, 16 insertions(+) diff --git a/stepmania/src/BitmapText.cpp b/stepmania/src/BitmapText.cpp index 31684b1050..15ba6e0555 100644 --- a/stepmania/src/BitmapText.cpp +++ b/stepmania/src/BitmapText.cpp @@ -198,12 +198,17 @@ void BitmapText::BuildChars() case align_right: iX = -iLineWidth; break; default: ASSERT( false ); return; } + if( m_pFont->IsRightToLeft() ) + iX += iLineWidth; for( unsigned j=0; jGetGlyph(szLine[j]); + if( m_pFont->IsRightToLeft() ) + iX -= g.m_iHadvance; + /* set vertex positions */ v[0].p = RageVector3( iX+g.m_fHshift, iY+g.m_pPage->m_fVshift, 0 ); // top left v[1].p = RageVector3( iX+g.m_fHshift, iY+g.m_pPage->m_fVshift+g.m_fHeight, 0 ); // bottom left @@ -221,6 +226,9 @@ void BitmapText::BuildChars() m_aVertices.insert( m_aVertices.end(), &v[0], &v[4] ); m_pTextures.push_back( g.GetTexture() ); + + if( m_pFont->IsRightToLeft() ) + iX -= g.m_iHadvance; } /* The amount of padding a line needs: */ diff --git a/stepmania/src/Font.cpp b/stepmania/src/Font.cpp index 0198bdd772..51e04b5e42 100644 --- a/stepmania/src/Font.cpp +++ b/stepmania/src/Font.cpp @@ -691,6 +691,7 @@ void Font::Load( const CString &sIniPath, CString sChars ) ini.ReadFile( sIniPath ); ini.RenameKey("Char Widths", "main"); ini.GetValue( "main", "CapitalsOnly", bCapitalsOnly ); + ini.GetValue( "main", "RightToLeft", m_bRightToLeft ); } { diff --git a/stepmania/src/Font.h b/stepmania/src/Font.h index 6b186e0038..cb18b3a3fc 100644 --- a/stepmania/src/Font.h +++ b/stepmania/src/Font.h @@ -136,6 +136,8 @@ public: static const wchar_t DEFAULT_GLYPH; + bool IsRightToLeft() const { return m_bRightToLeft; }; + private: /* List of pages and fonts that we use (and are responsible for freeing). */ vector m_apPages; @@ -148,6 +150,11 @@ private: map m_iCharToGlyph; glyph *m_iCharToGlyphCache[128]; + // True for Hebrew, Arabic, Urdu fonts. + // This will also change the way glyphs from the default FontPage are rendered. + // There may be a better way to handle this. + bool m_bRightToLeft; + /* We keep this around only for reloading. */ CString m_sChars;