Skip to content

Commit

Permalink
String meter: Allow floating font sizes
Browse files Browse the repository at this point in the history
FontSize and InlineSetting=Size
  • Loading branch information
brianferguson committed Dec 24, 2022
1 parent 8e0c652 commit c1fb982
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Common/Gfx/TextFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class __declspec(novtable) TextFormat
// Sets the logical properties of the font to use. If the font is not found in the system font
// collection, the given |fontCollection| is also searched. |fontCollection| may be nullptr.
virtual void SetProperties(
const WCHAR* fontFamily, int size, bool bold, bool italic,
const WCHAR* fontFamily, FLOAT size, bool bold, bool italic,
const FontCollection* fontCollection) = 0;

// Sets the font weight of the font used. |weight| should be between 1-999.
Expand Down
4 changes: 2 additions & 2 deletions Common/Gfx/TextFormatD2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ bool TextFormatD2D::CreateLayout(ID2D1DeviceContext* target, const std::wstring&
}

void TextFormatD2D::SetProperties(
const WCHAR* fontFamily, int size, bool bold, bool italic,
const WCHAR* fontFamily, FLOAT size, bool bold, bool italic,
const FontCollection* fontCollection)
{
auto fontCollectionD2D = (FontCollectionD2D*)fontCollection;
Expand Down Expand Up @@ -706,7 +706,7 @@ bool TextFormatD2D::CreateInlineOption(const size_t index, const std::wstring pa
{
if (optSize > 1)
{
FLOAT size = (FLOAT)ConfigParser::ParseInt(options[1].c_str(), 0);
FLOAT size = (FLOAT)ConfigParser::ParseDouble(options[1].c_str(), 10.0);
UpdateInlineSize(index, pattern, size);
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion Common/Gfx/TextFormatD2D.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class TextFormatD2D : public TextFormat
virtual bool IsInitialized() const override { return m_TextFormat != nullptr; }

virtual void SetProperties(
const WCHAR* fontFamily, int size, bool bold, bool italic,
const WCHAR* fontFamily, FLOAT size, bool bold, bool italic,
const FontCollection* fontCollection) override;

virtual void SetFontWeight(int weight) override;
Expand Down
10 changes: 5 additions & 5 deletions Library/MeterString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ MeterString::MeterString(Skin* skin, const WCHAR* name) : Meter(skin, name),
m_Style(NORMAL),
m_Effect(EFFECT_NONE),
m_Case(TEXTCASE_NONE),
m_FontSize(10),
m_FontSize(10.0f),
m_Scale(1.0),
m_NoDecimals(true),
m_Percentual(true),
Expand Down Expand Up @@ -117,7 +117,7 @@ void MeterString::ReadOptions(ConfigParser& parser, const WCHAR* section)
{
// Store the current font values so we know if the font needs to be updated
std::wstring oldFontFace = m_FontFace;
int oldFontSize = m_FontSize;
FLOAT oldFontSize = m_FontSize;
TEXTSTYLE oldStyle = m_Style;
Gfx::HorizontalAlignment oldHAlign = m_TextFormat->GetHorizontalAlignment();
Gfx::VerticalAlignment oldVAlign = m_TextFormat->GetVerticalAlignment();
Expand Down Expand Up @@ -161,10 +161,10 @@ void MeterString::ReadOptions(ConfigParser& parser, const WCHAR* section)
m_FontFace = L"Arial";
}

m_FontSize = parser.ReadInt(section, L"FontSize", 10);
if (m_FontSize < 0)
m_FontSize = (FLOAT)parser.ReadFloat(section, L"FontSize", 10.0);
if (m_FontSize < 0.0f)
{
m_FontSize = 10;
m_FontSize = 10.0f;
}

m_NumOfDecimals = parser.ReadInt(section, L"NumOfDecimals", -1);
Expand Down
2 changes: 1 addition & 1 deletion Library/MeterString.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class MeterString : public Meter
TEXTSTYLE m_Style;
TEXTEFFECT m_Effect;
TEXTCASE m_Case;
int m_FontSize;
FLOAT m_FontSize;
double m_Scale;
bool m_NoDecimals;
bool m_Percentual;
Expand Down

0 comments on commit c1fb982

Please sign in to comment.