Skip to content

Commit

Permalink
Windows|libappfw: Update font sizes according the UI scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Nov 27, 2018
1 parent 9d88eaf commit a37319b
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions doomsday/sdk/libappfw/src/style.cpp
Expand Up @@ -65,14 +65,21 @@ DENG2_PIMPL(Style)
loadedPack = nullptr;
}

void load(Package const &pack)
void updateFontSizeFactor()
{
loadedPack = &pack;

float fontSize = 1.f;
if (CommandLine::ArgWithParams arg = App::commandLine().check("-fontsize", 1))
{
fonts.setFontSizeFactor(arg.params.at(0).toFloat());
fontSize = arg.params.at(0).toFloat();
}
fonts.setFontSizeFactor(fontSize);
}

void load(Package const &pack)
{
loadedPack = &pack;

updateFontSizeFactor();

rules .addFromInfo(pack.root().locate<File>("rules.dei"));
fonts .addFromInfo(pack.root().locate<File>("fonts.dei"));
Expand All @@ -91,6 +98,16 @@ DENG2_PIMPL(Style)
if (loadedPack)
{
LOG_MSG("UI style being updated due to pixel ratio change");

#if defined (WIN32)
/*
* KLUDGE: The operating system provides fonts scaled according to the desktop
* scaling factor. The user's scaling factor affects the sizing of the fonts
* on Windows via this value; on other platforms, the font definitions use
* DisplayMode.PIXEL_RATIO directly. (Should do that on Windows, too?)
*/
updateFontSizeFactor();
#endif
self().performUpdate();
}
}
Expand Down

0 comments on commit a37319b

Please sign in to comment.