summaryrefslogtreecommitdiff
path: root/unity-shared
diff options
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2017-09-22 04:36:33 +0200
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2017-09-22 04:36:33 +0200
commit9827be183c04917fc0908733a0c7dfab8d905dd0 (patch)
tree2b481e50a79ebd4ffe82510c4f1eaf5b9649bcd9 /unity-shared
parent9be8ff33679ff128d43eb76d2f3ca9651e85be4a (diff)
EMConverter: remove unneeded font size management
(bzr r4253.4.1)
Diffstat (limited to 'unity-shared')
-rw-r--r--unity-shared/EMConverter.cpp65
-rw-r--r--unity-shared/EMConverter.h17
-rw-r--r--unity-shared/UnitySettings.cpp28
3 files changed, 6 insertions, 104 deletions
diff --git a/unity-shared/EMConverter.cpp b/unity-shared/EMConverter.cpp
index 6a65ab38f..9616a057f 100644
--- a/unity-shared/EMConverter.cpp
+++ b/unity-shared/EMConverter.cpp
@@ -23,86 +23,31 @@
namespace unity
{
-double const BASE_DPI = 96.0;
-double const DEFAULT_PPE = 10.0;
-double const PIXELS_PER_INCH = 72.0;
-
-EMConverter::EMConverter(int font_size, double dpi)
- : pixels_per_em_(DEFAULT_PPE)
- , base_pixels_per_em_(DEFAULT_PPE)
- , dpi_(dpi)
- , font_size_(font_size)
-{
- UpdatePixelsPerEM();
- UpdateBasePixelsPerEM();
-}
-
-double EMConverter::PtToPx(int pt)
-{
- return pt * dpi_ / PIXELS_PER_INCH;
-}
-
-void EMConverter::UpdatePixelsPerEM()
+namespace
{
- pixels_per_em_ = font_size_ * dpi_ / PIXELS_PER_INCH;
-
- if (pixels_per_em_ == 0)
- pixels_per_em_ = DEFAULT_PPE;
+const double BASE_DPI = 96.0;
}
-void EMConverter::UpdateBasePixelsPerEM()
-{
- base_pixels_per_em_ = font_size_ * BASE_DPI / PIXELS_PER_INCH;
-
- if (base_pixels_per_em_ == 0)
- base_pixels_per_em_ = DEFAULT_PPE;
-}
-
-bool EMConverter::SetFontSize(int font_size)
-{
- if (font_size != font_size_)
- {
- font_size_ = font_size;
- UpdatePixelsPerEM();
- UpdateBasePixelsPerEM();
- return true;
- }
-
- return false;
-}
+EMConverter::EMConverter(double dpi)
+ : dpi_(dpi)
+{}
bool EMConverter::SetDPI(double dpi)
{
if (dpi != dpi_)
{
dpi_ = dpi;
- UpdatePixelsPerEM();
return true;
}
return false;
}
-int EMConverter::GetFontSize() const
-{
- return font_size_;
-}
-
double EMConverter::GetDPI() const
{
return dpi_;
}
-double EMConverter::EMToPixels(double em) const
-{
- return (em * pixels_per_em_);
-}
-
-double EMConverter::PixelsToBaseEM(int pixels) const
-{
- return (pixels / base_pixels_per_em_);
-}
-
double EMConverter::CP(int pixels) const
{
return std::round(pixels * DPIScale());
diff --git a/unity-shared/EMConverter.h b/unity-shared/EMConverter.h
index 4847d6274..374ed43c2 100644
--- a/unity-shared/EMConverter.h
+++ b/unity-shared/EMConverter.h
@@ -30,31 +30,16 @@ class EMConverter
public:
typedef std::shared_ptr<EMConverter> Ptr;
- EMConverter(int font_size = 0, double dpi = 96.0);
+ EMConverter(double dpi = 96.0);
- bool SetFontSize(int font_size);
bool SetDPI(double dpi);
-
- int GetFontSize() const;
double GetDPI() const;
double CP(int pixels) const;
double DPIScale() const;
- double PtToPx(int pt);
-
private:
- void UpdatePixelsPerEM();
- void UpdateBasePixelsPerEM();
-
- double EMToPixels(double em) const;
- double PixelsToBaseEM(int pixels) const;
-
- double pixels_per_em_;
- double base_pixels_per_em_;
-
double dpi_;
- int font_size_;
};
} // namespace unity
diff --git a/unity-shared/UnitySettings.cpp b/unity-shared/UnitySettings.cpp
index cf3f557d9..27e91b9be 100644
--- a/unity-shared/UnitySettings.cpp
+++ b/unity-shared/UnitySettings.cpp
@@ -65,7 +65,6 @@ const std::string UBUNTU_UI_SETTINGS = "com.ubuntu.user-interface";
const std::string SCALE_FACTOR = "scale-factor";
const std::string GNOME_UI_SETTINGS = "org.gnome.desktop.interface";
-const std::string GNOME_FONT_NAME = "font-name";
const std::string GNOME_CURSOR_SIZE = "cursor-size";
const std::string GNOME_SCALE_FACTOR = "scaling-factor";
const std::string GNOME_TEXT_SCALE_FACTOR = "text-scaling-factor";
@@ -174,11 +173,6 @@ public:
UpdateDPI();
});
- signals_.Add<void, GSettings*, const gchar*>(gnome_ui_settings_, "changed::" + GNOME_FONT_NAME, [this] (GSettings*, const gchar* t) {
- UpdateFontSize();
- UpdateDPI();
- });
-
signals_.Add<void, GSettings*, const gchar*>(gnome_ui_settings_, "changed::" + GNOME_TEXT_SCALE_FACTOR, [this] (GSettings*, const gchar* t) {
double new_scale_factor = g_settings_get_double(gnome_ui_settings_, GNOME_TEXT_SCALE_FACTOR.c_str());
g_settings_set_double(ui_settings_, TEXT_SCALE_FACTOR.c_str(), new_scale_factor);
@@ -203,7 +197,6 @@ public:
UpdateGesturesSetting();
UpdateTextScaleFactor();
UpdateCursorScaleFactor();
- UpdateFontSize();
UpdateDPI();
CacheFormFactor();
@@ -365,27 +358,6 @@ public:
return g_settings_get_boolean(usettings_, PAM_CHECK_ACCOUNT_TYPE.c_str());
}
- int GetFontSize() const
- {
- gint font_size;
- PangoFontDescription* desc;
-
- glib::String font_name(g_settings_get_string(gnome_ui_settings_, GNOME_FONT_NAME.c_str()));
- desc = pango_font_description_from_string(font_name);
- font_size = pango_font_description_get_size(desc);
- pango_font_description_free(desc);
-
- return font_size / 1024;
- }
-
- void UpdateFontSize()
- {
- int font_size = GetFontSize();
-
- for (auto const& em : em_converters_)
- em->SetFontSize(font_size);
- }
-
void UpdateTextScaleFactor()
{
parent_->font_scaling = g_settings_get_double(ui_settings_, TEXT_SCALE_FACTOR.c_str());