//----------------------------------------------------------------------------- // Purpose: Reloads all scheme fonts //----------------------------------------------------------------------------- void CScheme::ReloadFontGlyphs() { // get our current resolution if ( m_SizingPanel != 0 ) { g_pIPanel->GetSize( m_SizingPanel, m_nScreenWide, m_nScreenTall ); } else { g_pSurface->GetScreenSize( m_nScreenWide, m_nScreenTall ); } // check our language; some have minimum sizes int minimumFontHeight = GetMinimumFontHeightForCurrentLanguage(); // add the data to all the fonts KeyValues *fonts = m_pData->FindKey("Fonts", true); for (int i = 0; i < m_FontAliases.Count(); i++) { KeyValues *kv = fonts->FindKey(m_FontAliases[i]._trueFontName.String(), true); // walk through creating adding the first matching glyph set to the font for (KeyValues *fontdata = kv->GetFirstSubKey(); fontdata != NULL; fontdata = fontdata->GetNextKey()) { // skip over fonts not meant for this resolution int fontYResMin = 0, fontYResMax = 0; sscanf(fontdata->GetString("yres", ""), "%d %d", &fontYResMin, &fontYResMax); if (fontYResMin) { if (!fontYResMax) { fontYResMax = fontYResMin; } // check the range if (m_nScreenTall < fontYResMin || m_nScreenTall > fontYResMax) continue; } int flags = 0; if (fontdata->GetInt( "italic" )) { flags |= ISurface::FONTFLAG_ITALIC; } if (fontdata->GetInt( "underline" )) { flags |= ISurface::FONTFLAG_UNDERLINE; } if (fontdata->GetInt( "strikeout" )) { flags |= ISurface::FONTFLAG_STRIKEOUT; } if (fontdata->GetInt( "symbol" )) { flags |= ISurface::FONTFLAG_SYMBOL; } if (fontdata->GetInt( "antialias" ) && g_pSurface->SupportsFeature(ISurface::ANTIALIASED_FONTS)) { flags |= ISurface::FONTFLAG_ANTIALIAS; } if (fontdata->GetInt( "dropshadow" ) && g_pSurface->SupportsFeature(ISurface::DROPSHADOW_FONTS)) { flags |= ISurface::FONTFLAG_DROPSHADOW; } if (fontdata->GetInt( "outline" ) && g_pSurface->SupportsFeature(ISurface::OUTLINE_FONTS)) { flags |= ISurface::FONTFLAG_OUTLINE; } if (fontdata->GetInt( "custom" )) { flags |= ISurface::FONTFLAG_CUSTOM; } if (fontdata->GetInt( "bitmap" )) { flags |= ISurface::FONTFLAG_BITMAP; } if (fontdata->GetInt( "rotary" )) { flags |= ISurface::FONTFLAG_ROTARY; } if (fontdata->GetInt( "additive" )) { flags |= ISurface::FONTFLAG_ADDITIVE; } int tall = fontdata->GetInt("tall"); int blur = fontdata->GetInt("blur"); int scanlines = fontdata->GetInt("scanlines"); if ( (!fontYResMin && !fontYResMax) && m_FontAliases[i].m_bProportional ) // only grow this font if it doesn't have a resolution filter specified { tall = g_Scheme.GetProportionalScaledValueEx( this, tall ); blur = g_Scheme.GetProportionalScaledValueEx( this, blur ); scanlines = g_Scheme.GetProportionalScaledValueEx( this, scanlines ); } // clip the font size so that fonts can't be too big if (tall > 127) { tall = 127; } // check our minimum font height if (tall < minimumFontHeight) { tall = minimumFontHeight; } if ( flags & ISurface::FONTFLAG_BITMAP ) { // add the new set g_pSurface->SetBitmapFontGlyphSet( m_FontAliases[i]._font, g_pSurface->GetBitmapFontName( fontdata->GetString( "name" ) ), fontdata->GetFloat( "scalex", 1.0f ), fontdata->GetFloat( "scaley", 1.0f ), flags); } else { // add the new set g_pSurface->SetFontGlyphSet( m_FontAliases[i]._font, fontdata->GetString( "name" ), tall, fontdata->GetInt( "weight" ), blur, scanlines, flags); } // don't add any more break; } } }