st: Remove our own font DPI resolution implementation
Clutter has had clutter_backend_get_resolution for a little while. https://bugzilla.gnome.org/show_bug.cgi?id=672807
This commit is contained in:
parent
dc3d3acb3b
commit
de8a66d4ce
@ -805,38 +805,9 @@ global_stage_after_paint (ClutterStage *stage,
|
|||||||
"clutter.stagePaintDone");
|
"clutter.stagePaintDone");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
update_font_options (GtkSettings *settings,
|
|
||||||
ClutterStage *stage)
|
|
||||||
{
|
|
||||||
StThemeContext *context;
|
|
||||||
gint dpi;
|
|
||||||
|
|
||||||
g_object_get (settings,
|
|
||||||
"gtk-xft-dpi", &dpi,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
context = st_theme_context_get_for_stage (stage);
|
|
||||||
|
|
||||||
if (dpi != -1)
|
|
||||||
/* GTK stores resolution as 1024 * dots/inch */
|
|
||||||
st_theme_context_set_resolution (context, dpi / 1024);
|
|
||||||
else
|
|
||||||
st_theme_context_set_default_resolution (context);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
settings_notify_cb (GtkSettings *settings,
|
|
||||||
GParamSpec *pspec,
|
|
||||||
gpointer data)
|
|
||||||
{
|
|
||||||
update_font_options (settings, CLUTTER_STAGE (data));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
shell_fonts_init (ClutterStage *stage)
|
shell_fonts_init (ClutterStage *stage)
|
||||||
{
|
{
|
||||||
GtkSettings *settings;
|
|
||||||
CoglPangoFontMap *fontmap;
|
CoglPangoFontMap *fontmap;
|
||||||
|
|
||||||
/* Disable text mipmapping; it causes problems on pre-GEM Intel
|
/* Disable text mipmapping; it causes problems on pre-GEM Intel
|
||||||
@ -846,13 +817,6 @@ shell_fonts_init (ClutterStage *stage)
|
|||||||
*/
|
*/
|
||||||
fontmap = COGL_PANGO_FONT_MAP (clutter_get_font_map ());
|
fontmap = COGL_PANGO_FONT_MAP (clutter_get_font_map ());
|
||||||
cogl_pango_font_map_set_use_mipmapping (fontmap, FALSE);
|
cogl_pango_font_map_set_use_mipmapping (fontmap, FALSE);
|
||||||
|
|
||||||
settings = gtk_settings_get_default ();
|
|
||||||
g_object_connect (settings,
|
|
||||||
"signal::notify::gtk-xft-dpi",
|
|
||||||
G_CALLBACK (settings_notify_cb), stage,
|
|
||||||
NULL);
|
|
||||||
update_font_options (settings, stage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This is an IBus workaround. The flow of events with IBus is that every time
|
/* This is an IBus workaround. The flow of events with IBus is that every time
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
struct _StThemeContext {
|
struct _StThemeContext {
|
||||||
GObject parent;
|
GObject parent;
|
||||||
|
|
||||||
double resolution;
|
|
||||||
PangoFontDescription *font;
|
PangoFontDescription *font;
|
||||||
StThemeNode *root_node;
|
StThemeNode *root_node;
|
||||||
StTheme *theme;
|
StTheme *theme;
|
||||||
@ -38,7 +37,6 @@ struct _StThemeContextClass {
|
|||||||
GObjectClass parent_class;
|
GObjectClass parent_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DEFAULT_RESOLUTION 96.
|
|
||||||
#define DEFAULT_FONT "sans-serif 10"
|
#define DEFAULT_FONT "sans-serif 10"
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@ -93,7 +91,6 @@ st_theme_context_class_init (StThemeContextClass *klass)
|
|||||||
static void
|
static void
|
||||||
st_theme_context_init (StThemeContext *context)
|
st_theme_context_init (StThemeContext *context)
|
||||||
{
|
{
|
||||||
context->resolution = DEFAULT_RESOLUTION;
|
|
||||||
context->font = pango_font_description_from_string (DEFAULT_FONT);
|
context->font = pango_font_description_from_string (DEFAULT_FONT);
|
||||||
|
|
||||||
g_signal_connect (st_texture_cache_get_default (),
|
g_signal_connect (st_texture_cache_get_default (),
|
||||||
@ -232,66 +229,6 @@ st_theme_context_get_theme (StThemeContext *context)
|
|||||||
return context->theme;
|
return context->theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* st_theme_context_set_resolution:
|
|
||||||
* @context: a #StThemeContext
|
|
||||||
* @resolution: resolution of the context (number of pixels in an "inch")
|
|
||||||
*
|
|
||||||
* Sets the resolution of the theme context. This is the scale factor
|
|
||||||
* used to convert between points and the length units pt, in, and cm.
|
|
||||||
* This does not necessarily need to correspond to the actual number
|
|
||||||
* resolution of the device. A value of 72. means that points and
|
|
||||||
* pixels are identical. The default value is 96.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
st_theme_context_set_resolution (StThemeContext *context,
|
|
||||||
double resolution)
|
|
||||||
{
|
|
||||||
g_return_if_fail (ST_IS_THEME_CONTEXT (context));
|
|
||||||
|
|
||||||
if (resolution == context->resolution)
|
|
||||||
return;
|
|
||||||
|
|
||||||
context->resolution = resolution;
|
|
||||||
st_theme_context_changed (context);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* st_theme_context_set_default_resolution:
|
|
||||||
* @context: a #StThemeContext
|
|
||||||
*
|
|
||||||
* Sets the resolution of the theme context to the default value of 96.
|
|
||||||
* See st_theme_context_set_resolution().
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
st_theme_context_set_default_resolution (StThemeContext *context)
|
|
||||||
{
|
|
||||||
g_return_if_fail (ST_IS_THEME_CONTEXT (context));
|
|
||||||
|
|
||||||
if (context->resolution == DEFAULT_RESOLUTION)
|
|
||||||
return;
|
|
||||||
|
|
||||||
context->resolution = DEFAULT_RESOLUTION;
|
|
||||||
st_theme_context_changed (context);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* st_theme_context_get_resolution:
|
|
||||||
* @context: a #StThemeContext
|
|
||||||
*
|
|
||||||
* Gets the current resolution of the theme context.
|
|
||||||
* See st_theme_context_set_resolution().
|
|
||||||
*
|
|
||||||
* Return value: the resolution (in dots-per-"inch")
|
|
||||||
*/
|
|
||||||
double
|
|
||||||
st_theme_context_get_resolution (StThemeContext *context)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (ST_IS_THEME_CONTEXT (context), DEFAULT_RESOLUTION);
|
|
||||||
|
|
||||||
return context->resolution;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* st_theme_context_set_font:
|
* st_theme_context_set_font:
|
||||||
* @context: a #StThemeContext
|
* @context: a #StThemeContext
|
||||||
|
@ -56,10 +56,6 @@ void st_theme_context_set_theme (StThemeContext
|
|||||||
StTheme *theme);
|
StTheme *theme);
|
||||||
StTheme * st_theme_context_get_theme (StThemeContext *context);
|
StTheme * st_theme_context_get_theme (StThemeContext *context);
|
||||||
|
|
||||||
void st_theme_context_set_resolution (StThemeContext *context,
|
|
||||||
gdouble resolution);
|
|
||||||
void st_theme_context_set_default_resolution (StThemeContext *context);
|
|
||||||
double st_theme_context_get_resolution (StThemeContext *context);
|
|
||||||
void st_theme_context_set_font (StThemeContext *context,
|
void st_theme_context_set_font (StThemeContext *context,
|
||||||
const PangoFontDescription *font);
|
const PangoFontDescription *font);
|
||||||
const PangoFontDescription *st_theme_context_get_font (StThemeContext *context);
|
const PangoFontDescription *st_theme_context_get_font (StThemeContext *context);
|
||||||
|
@ -820,7 +820,7 @@ get_length_from_term (StThemeNode *node,
|
|||||||
break;
|
break;
|
||||||
case POINTS:
|
case POINTS:
|
||||||
{
|
{
|
||||||
double resolution = st_theme_context_get_resolution (node->context);
|
double resolution = clutter_backend_get_resolution (clutter_get_default_backend ());
|
||||||
*length = num->val * multiplier * (resolution / 72.);
|
*length = num->val * multiplier * (resolution / 72.);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -842,7 +842,7 @@ get_length_from_term (StThemeNode *node,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
double resolution = st_theme_context_get_resolution (node->context);
|
double resolution = clutter_backend_get_resolution (clutter_get_default_backend ());
|
||||||
*length = num->val * multiplier * (resolution / 72.) * font_size;
|
*length = num->val * multiplier * (resolution / 72.) * font_size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2139,7 +2139,7 @@ font_size_from_term (StThemeNode *node,
|
|||||||
{
|
{
|
||||||
if (term->type == TERM_IDENT)
|
if (term->type == TERM_IDENT)
|
||||||
{
|
{
|
||||||
double resolution = st_theme_context_get_resolution (node->context);
|
double resolution = clutter_backend_get_resolution (clutter_get_default_backend ());
|
||||||
/* We work in integers to avoid double comparisons when converting back
|
/* We work in integers to avoid double comparisons when converting back
|
||||||
* from a size in pixels to a logical size.
|
* from a size in pixels to a logical size.
|
||||||
*/
|
*/
|
||||||
@ -2346,7 +2346,7 @@ st_theme_node_get_font (StThemeNode *node)
|
|||||||
parent_size = pango_font_description_get_size (node->font_desc);
|
parent_size = pango_font_description_get_size (node->font_desc);
|
||||||
if (!pango_font_description_get_size_is_absolute (node->font_desc))
|
if (!pango_font_description_get_size_is_absolute (node->font_desc))
|
||||||
{
|
{
|
||||||
double resolution = st_theme_context_get_resolution (node->context);
|
double resolution = clutter_backend_get_resolution (clutter_get_default_backend ());
|
||||||
parent_size *= (resolution / 72.);
|
parent_size *= (resolution / 72.);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -435,7 +435,6 @@ main (int argc, char **argv)
|
|||||||
stage = clutter_stage_new ();
|
stage = clutter_stage_new ();
|
||||||
context = st_theme_context_get_for_stage (CLUTTER_STAGE (stage));
|
context = st_theme_context_get_for_stage (CLUTTER_STAGE (stage));
|
||||||
st_theme_context_set_theme (context, theme);
|
st_theme_context_set_theme (context, theme);
|
||||||
st_theme_context_set_resolution (context, 96.);
|
|
||||||
st_theme_context_set_font (context,
|
st_theme_context_set_font (context,
|
||||||
pango_font_description_from_string ("sans-serif 12"));
|
pango_font_description_from_string ("sans-serif 12"));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user