From a37668e44eca08009bccae4880202f08629e5181 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 8 Oct 2003 02:54:40 +0000 Subject: [PATCH] Add TextureHints font metric. By default, load fonts as 4-bit grayscale, 4-bit alpha (I4A4) maps. This halves font texture memory usage. --- stepmania/src/Font.cpp | 10 +++++++++- stepmania/src/Font.h | 6 ++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/stepmania/src/Font.cpp b/stepmania/src/Font.cpp index b55f6b6645..4b030d73c7 100644 --- a/stepmania/src/Font.cpp +++ b/stepmania/src/Font.cpp @@ -39,7 +39,14 @@ void FontPage::Load( FontPageSettings cfg ) // load texture RageTextureID ID(m_sTexturePath); - ID.iColorDepth = 16; + if( cfg.TextureHints != "default" ) + ID.AdditionalTextureHints = cfg.TextureHints; + else + { + /* Using grayscale and 16bpp together means to use a 16bpp image if a grayscale + * image couldn't be loaded. */ + ID.AdditionalTextureHints = "grayscale 16bpp"; + } m_pTexture = TEXTUREMAN->LoadTexture( ID ); ASSERT( m_pTexture != NULL ); @@ -484,6 +491,7 @@ void Font::LoadFontPageSettings(FontPageSettings &cfg, IniFile &ini, const CStri ini.GetValue( PageName, "Baseline", cfg.Baseline ); ini.GetValue( PageName, "DefaultWidth", cfg.DefaultWidth ); ini.GetValue( PageName, "AdvanceExtraPixels", cfg.AdvanceExtraPixels ); + ini.GetValue( PageName, "TextureHints", cfg.TextureHints ); /* Iterate over all keys. */ const IniFile::key *k = ini.GetKey(PageName); diff --git a/stepmania/src/Font.h b/stepmania/src/Font.h index c961e1fc81..87e0347999 100644 --- a/stepmania/src/Font.h +++ b/stepmania/src/Font.h @@ -48,7 +48,8 @@ struct FontPageSettings DefaultWidth, AdvanceExtraPixels; float ScaleAllWidthsBy; - + CString TextureHints; + map CharToGlyphNo; /* If a value is missing, the width of the texture frame is used. */ map GlyphWidths; @@ -61,7 +62,8 @@ struct FontPageSettings Baseline(-1), DefaultWidth(-1), AdvanceExtraPixels(1), - ScaleAllWidthsBy(1) + ScaleAllWidthsBy(1), + TextureHints("default") { } /* Map a range from a character map to glyphs. If cnt is -1, map the