Index: trunk/src/gfx/texture_font.cc
===================================================================
--- trunk/src/gfx/texture_font.cc	(revision 102)
+++ trunk/src/gfx/texture_font.cc	(revision 103)
@@ -71,4 +71,24 @@
 }
 
+static uint8* convert_to_rgba(uint8* rgb, const int lines, const int line_count, const int line_bpitch )
+{
+	uint8* result = new uint8[ lines * line_count * 4 ];
+	uint8* rgba   = result;
+	for(int l=0; l<lines; ++l) 
+	{
+		for(int c=0; c<line_count; ++c)
+		{
+			for(int j=0; j<3; ++j) {
+				rgba[j]  = rgb[j];
+			}
+			rgba[3] = uint8( uint16( rgb[0] + rgb[1] + rgb[2] ) / 3 );
+			rgba += 4;
+			rgb  += 3;
+		}
+		rgb += line_bpitch - ( 3 * line_count );
+	}
+	return result;
+}
+
 bool texture_font::load_glyphs( const std::string& codes )
 {
@@ -87,5 +107,5 @@
 	} 
 
-	if( m_atlas->get_depth() == 3 )
+	if( m_atlas->get_depth() >= 3 )
 	{
 		FT_Library_SetLcdFilter( (FT_Library)(m_rlibrary), FT_LCD_FILTER_LIGHT );
@@ -115,6 +135,7 @@
 		int ft_glyph_top    = slot->bitmap_top;
 		int ft_glyph_left   = slot->bitmap_left;
+		int reg_width       = ft_bitmap_width / (depth > 3 ? 3 : depth);
 
-		glm::ivec2 gsize( ft_bitmap_width/depth + 1, ft_bitmap_rows + 1 ); 
+		glm::ivec2 gsize( reg_width + 1, ft_bitmap_rows + 1 ); 
 		region r = m_atlas->get_region( gsize );
 		if ( r.pos.x < 0 ) 
@@ -126,7 +147,18 @@
 			NV_THROW( std::runtime_error, error_msg.str().c_str() );
 		}
-		r.size.x -= 1;
-		r.size.y -= 1;
-		m_atlas->set_region( r, ft_bitmap.buffer, ft_bitmap.pitch );
+		if (depth == 4)
+		{
+			r.size.x -= 1;
+			r.size.y -= 1;
+			uint8* data = convert_to_rgba(ft_bitmap.buffer, r.size.y, r.size.x, ft_bitmap.pitch );
+			m_atlas->set_region( r, data );
+			delete data;
+		}
+		else
+		{
+			r.size.x -= 1;
+			r.size.y -= 1;
+			m_atlas->set_region( r, ft_bitmap.buffer, ft_bitmap.pitch );
+		}
 
 		m_glyphs[ c ] = texture_glyph();
