replaced qt font scaling
remove the qt font scaling and added code that uses the actual scale/dpi value
This commit is contained in:
+25
-8
@@ -6,29 +6,33 @@ namespace chatterino {
|
||||
|
||||
FontManager::FontManager()
|
||||
: currentFontFamily("/appearance/currentFontFamily", "Arial")
|
||||
, currentFontSize("/appearance/currentFontSize", 14)
|
||||
, currentFont(this->currentFontFamily.getValue().c_str(), currentFontSize.getValue())
|
||||
, currentFontSize("/appearance/currentFontSize", 12)
|
||||
// , currentFont(this->currentFontFamily.getValue().c_str(), currentFontSize.getValue())
|
||||
{
|
||||
this->currentFontFamily.connect([this](const std::string &newValue, auto) {
|
||||
this->incGeneration();
|
||||
this->currentFont.setFamily(newValue.c_str());
|
||||
// this->currentFont.setFamily(newValue.c_str());
|
||||
this->currentFontByDpi.clear();
|
||||
this->fontChanged.invoke();
|
||||
});
|
||||
this->currentFontSize.connect([this](const int &newValue, auto) {
|
||||
this->incGeneration();
|
||||
this->currentFont.setSize(newValue);
|
||||
// this->currentFont.setSize(newValue);
|
||||
this->currentFontByDpi.clear();
|
||||
this->fontChanged.invoke();
|
||||
});
|
||||
}
|
||||
|
||||
QFont &FontManager::getFont(Type type)
|
||||
QFont &FontManager::getFont(Type type, float dpi)
|
||||
{
|
||||
return this->currentFont.getFont(type);
|
||||
// return this->currentFont.getFont(type);
|
||||
return this->getCurrentFont(dpi).getFont(type);
|
||||
}
|
||||
|
||||
QFontMetrics &FontManager::getFontMetrics(Type type)
|
||||
QFontMetrics &FontManager::getFontMetrics(Type type, float dpi)
|
||||
{
|
||||
return this->currentFont.getFontMetrics(type);
|
||||
// return this->currentFont.getFontMetrics(type);
|
||||
return this->getCurrentFont(dpi).getFontMetrics(type);
|
||||
}
|
||||
|
||||
FontManager::FontData &FontManager::Font::getFontData(Type type)
|
||||
@@ -62,4 +66,17 @@ QFontMetrics &FontManager::Font::getFontMetrics(Type type)
|
||||
return this->getFontData(type).metrics;
|
||||
}
|
||||
|
||||
FontManager::Font &FontManager::getCurrentFont(float dpi)
|
||||
{
|
||||
for (auto it = this->currentFontByDpi.begin(); it != this->currentFontByDpi.end(); it++) {
|
||||
if (it->first == dpi) {
|
||||
return it->second;
|
||||
}
|
||||
}
|
||||
this->currentFontByDpi.push_back(std::make_pair(
|
||||
dpi,
|
||||
Font(this->currentFontFamily.getValue().c_str(), this->currentFontSize.getValue() * dpi)));
|
||||
|
||||
return this->currentFontByDpi.back().second;
|
||||
}
|
||||
} // namespace chatterino
|
||||
|
||||
Reference in New Issue
Block a user