From 056aedd9aac34fb3ba5c0ac3f756e26484f1ff4e Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 6 Jul 2003 05:32:45 +0000 Subject: [PATCH] allow tweaking horizontal spacing --- stepmania/src/Font.cpp | 9 ++++----- stepmania/src/Font.h | 6 ++++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/stepmania/src/Font.cpp b/stepmania/src/Font.cpp index 3cc9813f85..716980d23b 100644 --- a/stepmania/src/Font.cpp +++ b/stepmania/src/Font.cpp @@ -102,14 +102,14 @@ void FontPage::Load( FontPageSettings cfg ) /* Shift the character up so the top will be rendered at the baseline. */ vshift = (float) -baseline; - SetTextureCoords(FrameWidths); + SetTextureCoords(FrameWidths, cfg.AdvanceExtraPixels); SetExtraPixels(cfg.DrawExtraPixelsLeft, cfg.DrawExtraPixelsRight); // LOG->Trace("Font %s: height %i, baseline %i ( == top %i)", // m_sTexturePath.c_str(), height, baseline, baseline-height); } -void FontPage::SetTextureCoords(const vector &widths) +void FontPage::SetTextureCoords(const vector &widths, int AdvanceExtraPixels) { for(int i = 0; i < m_pTexture->GetNumFrames(); ++i) { @@ -125,9 +125,7 @@ void FontPage::SetTextureCoords(const vector &widths) g.width = float(widths[i]); g.height = float(m_pTexture->GetSourceFrameHeight()); - /* By default, advance one pixel more than the width. (This could be - * an option.) */ - g.hadvance = int(g.width + 1); + g.hadvance = int(g.width) + AdvanceExtraPixels; /* Do the same thing with X. Do this by changing the actual rendered * rect, instead of shifting it, so we don't render more than we need to. */ @@ -481,6 +479,7 @@ void Font::LoadFontPageSettings(FontPageSettings &cfg, IniFile &ini, const CStri ini.GetValueI( PageName, "Top", cfg.Top ); ini.GetValueI( PageName, "Baseline", cfg.Baseline ); ini.GetValueI( PageName, "DefaultWidth", cfg.DefaultWidth ); + ini.GetValueI( PageName, "AdvanceExtraPixels", cfg.AdvanceExtraPixels ); /* Iterate over all keys. */ const IniFile::key *k = ini.GetKey(PageName); diff --git a/stepmania/src/Font.h b/stepmania/src/Font.h index 792aaae800..c961e1fc81 100644 --- a/stepmania/src/Font.h +++ b/stepmania/src/Font.h @@ -45,7 +45,8 @@ struct FontPageSettings LineSpacing, Top, Baseline, - DefaultWidth; + DefaultWidth, + AdvanceExtraPixels; float ScaleAllWidthsBy; map CharToGlyphNo; @@ -59,6 +60,7 @@ struct FontPageSettings Top(-1), Baseline(-1), DefaultWidth(-1), + AdvanceExtraPixels(1), ScaleAllWidthsBy(1) { } @@ -92,7 +94,7 @@ public: private: void SetExtraPixels(int DrawExtraPixelsLeft, int DrawExtraPixelsRight); - void SetTextureCoords(const vector &widths); + void SetTextureCoords(const vector &widths, int AdvanceExtraPixels); }; class Font