add support for Right to Left fonts
This commit is contained in:
@@ -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; j<szLine.size(); j++ ) // for each character in the line
|
||||
{
|
||||
RageSpriteVertex v[4];
|
||||
const glyph &g = m_pFont->GetGlyph(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: */
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
@@ -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<FontPage *> m_apPages;
|
||||
@@ -148,6 +150,11 @@ private:
|
||||
map<longchar,glyph*> 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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user