allow tweaking horizontal spacing

This commit is contained in:
Glenn Maynard
2003-07-06 05:32:45 +00:00
parent e68bd0a3e6
commit 056aedd9aa
2 changed files with 8 additions and 7 deletions
+4 -5
View File
@@ -102,14 +102,14 @@ void FontPage::Load( FontPageSettings cfg )
/* Shift the character up so the top will be rendered at the baseline. */ /* Shift the character up so the top will be rendered at the baseline. */
vshift = (float) -baseline; vshift = (float) -baseline;
SetTextureCoords(FrameWidths); SetTextureCoords(FrameWidths, cfg.AdvanceExtraPixels);
SetExtraPixels(cfg.DrawExtraPixelsLeft, cfg.DrawExtraPixelsRight); SetExtraPixels(cfg.DrawExtraPixelsLeft, cfg.DrawExtraPixelsRight);
// LOG->Trace("Font %s: height %i, baseline %i ( == top %i)", // LOG->Trace("Font %s: height %i, baseline %i ( == top %i)",
// m_sTexturePath.c_str(), height, baseline, baseline-height); // m_sTexturePath.c_str(), height, baseline, baseline-height);
} }
void FontPage::SetTextureCoords(const vector<int> &widths) void FontPage::SetTextureCoords(const vector<int> &widths, int AdvanceExtraPixels)
{ {
for(int i = 0; i < m_pTexture->GetNumFrames(); ++i) for(int i = 0; i < m_pTexture->GetNumFrames(); ++i)
{ {
@@ -125,9 +125,7 @@ void FontPage::SetTextureCoords(const vector<int> &widths)
g.width = float(widths[i]); g.width = float(widths[i]);
g.height = float(m_pTexture->GetSourceFrameHeight()); g.height = float(m_pTexture->GetSourceFrameHeight());
/* By default, advance one pixel more than the width. (This could be g.hadvance = int(g.width) + AdvanceExtraPixels;
* an option.) */
g.hadvance = int(g.width + 1);
/* Do the same thing with X. Do this by changing the actual rendered /* 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. */ * 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, "Top", cfg.Top );
ini.GetValueI( PageName, "Baseline", cfg.Baseline ); ini.GetValueI( PageName, "Baseline", cfg.Baseline );
ini.GetValueI( PageName, "DefaultWidth", cfg.DefaultWidth ); ini.GetValueI( PageName, "DefaultWidth", cfg.DefaultWidth );
ini.GetValueI( PageName, "AdvanceExtraPixels", cfg.AdvanceExtraPixels );
/* Iterate over all keys. */ /* Iterate over all keys. */
const IniFile::key *k = ini.GetKey(PageName); const IniFile::key *k = ini.GetKey(PageName);
+4 -2
View File
@@ -45,7 +45,8 @@ struct FontPageSettings
LineSpacing, LineSpacing,
Top, Top,
Baseline, Baseline,
DefaultWidth; DefaultWidth,
AdvanceExtraPixels;
float ScaleAllWidthsBy; float ScaleAllWidthsBy;
map<longchar,int> CharToGlyphNo; map<longchar,int> CharToGlyphNo;
@@ -59,6 +60,7 @@ struct FontPageSettings
Top(-1), Top(-1),
Baseline(-1), Baseline(-1),
DefaultWidth(-1), DefaultWidth(-1),
AdvanceExtraPixels(1),
ScaleAllWidthsBy(1) ScaleAllWidthsBy(1)
{ } { }
@@ -92,7 +94,7 @@ public:
private: private:
void SetExtraPixels(int DrawExtraPixelsLeft, int DrawExtraPixelsRight); void SetExtraPixels(int DrawExtraPixelsLeft, int DrawExtraPixelsRight);
void SetTextureCoords(const vector<int> &widths); void SetTextureCoords(const vector<int> &widths, int AdvanceExtraPixels);
}; };
class Font class Font