Back to index

unity  6.0.0
Public Member Functions | Private Member Functions | Private Attributes
unity::FontSettings Class Reference

#include <FontSettings.h>

Collaboration diagram for unity::FontSettings:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 FontSettings ()

Private Member Functions

void Refresh (GtkSettings *unused0=nullptr, GParamSpec *unused1=nullptr)

Private Attributes

glib::SignalManager sig_man_

Detailed Description

Definition at line 29 of file FontSettings.h.


Constructor & Destructor Documentation

Definition at line 28 of file FontSettings.cpp.

{
  GtkSettings* settings = gtk_settings_get_default();

  sig_man_.Add(new glib::Signal<void, GtkSettings*, GParamSpec*>(settings, "notify::gtk-xft-hintstyle", sigc::mem_fun(this, &FontSettings::Refresh)));
  sig_man_.Add(new glib::Signal<void, GtkSettings*, GParamSpec*>(settings, "notify::gtk-xft-rgba", sigc::mem_fun(this, &FontSettings::Refresh)));
  sig_man_.Add(new glib::Signal<void, GtkSettings*, GParamSpec*>(settings, "notify::gtk-xft-antialias", sigc::mem_fun(this, &FontSettings::Refresh)));

  Refresh();
}

Here is the call graph for this function:


Member Function Documentation

void unity::FontSettings::Refresh ( GtkSettings *  unused0 = nullptr,
GParamSpec *  unused1 = nullptr 
) [private]

Definition at line 39 of file FontSettings.cpp.

{
  GtkSettings* settings = gtk_settings_get_default();
  cairo_font_options_t* font_options = cairo_font_options_create();

  {
    cairo_subpixel_order_t order = CAIRO_SUBPIXEL_ORDER_DEFAULT;
    glib::String value;
    g_object_get(settings, "gtk-xft-rgba", &value, NULL);
    gint antialias;
    g_object_get(settings, "gtk-xft-antialias", &antialias, NULL);
    
    if (value.Str() == "rgb")
      order = CAIRO_SUBPIXEL_ORDER_RGB;
    else if (value.Str() == "bgr")
      order = CAIRO_SUBPIXEL_ORDER_BGR;
    else if (value.Str() == "vrgb")
      order = CAIRO_SUBPIXEL_ORDER_VRGB;
    else if (value.Str() == "vbgr")
      order = CAIRO_SUBPIXEL_ORDER_VBGR;

    cairo_font_options_set_subpixel_order(font_options, order);
    cairo_font_options_set_antialias(font_options,
                                     value.Str() == "none" ? (antialias ? CAIRO_ANTIALIAS_GRAY : CAIRO_ANTIALIAS_NONE) 
                                                           : CAIRO_ANTIALIAS_SUBPIXEL);

  }

  {
    cairo_hint_style_t style = CAIRO_HINT_STYLE_DEFAULT;
    glib::String value;
    g_object_get(settings, "gtk-xft-hintstyle", &value, NULL);
    
    if (value.Str() == "hintnone")
      style = CAIRO_HINT_STYLE_NONE;
    else if (value.Str() == "hintslight")
      style = CAIRO_HINT_STYLE_SLIGHT;
    else if (value.Str() == "hintmedium")
      style = CAIRO_HINT_STYLE_MEDIUM;
    else if (value.Str() == "hintfull")
      style = CAIRO_HINT_STYLE_FULL;

    cairo_font_options_set_hint_style(font_options, style);
  }
  
  // FIXME: Where do we read this value from?
  cairo_font_options_set_hint_metrics(font_options, CAIRO_HINT_METRICS_ON);

  gdk_screen_set_font_options(gdk_screen_get_default(), font_options);
  cairo_font_options_destroy(font_options);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 38 of file FontSettings.h.


The documentation for this class was generated from the following files: