/*
* This file is part of hildon-libs
*
- * Copyright (C) 2005 Nokia Corporation.
+ * Copyright (C) 2005, 2006 Nokia Corporation, all rights reserved.
*
- * Contact: Luc Pionchon <luc.pionchon@nokia.com>
+ * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
+ * as published by the Free Software Foundation; version 2.1 of
+ * the License or any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
#define _(String) dgettext(PACKAGE, String)
#define SUPERSCRIPT_RISE 3333
-#define SUBSCRIPT_LOW -3333
-#define ON_BIT 0x01
+#define SUBSCRIPT_LOW -3333
+#define ON_BIT 0x01
#define OFF_BIT 0x02
-#define REFERENCE_LINE "Reference: " /*localized string?*/
/*
* These are what we use as the standard font sizes, for the size list.
PROP_STRIKETHROUGH_SET,
PROP_POSITION,
PROP_POSITION_SET,
- PROP_PREVIEW_TEXT
+ PROP_PREVIEW_TEXT,
+ PROP_FONT_SCALING
};
typedef struct
* when we change the color setting*/
gboolean color_set;
+
+ /* font_scaling is the scaling factor applied to font
+ * scale in the preview dialog */
+
+ gdouble font_scaling;
gulong color_modified_signal_handler;
};
g_value_set_string(value,
pango_font_family_get_name(priv->families[i]));
else
- g_value_set_string(value, "Nokia Sans");
+ g_value_set_string(value, "Sans");
break;
case PROP_FAMILY_SET:
else
g_value_set_int(value, 0);
break;
-
+
+ case PROP_FONT_SCALING:
+ g_value_set_double(value, priv->font_scaling);
+ break;
+
case PROP_POSITION_SET:
i = gtk_combo_box_get_active(GTK_COMBO_BOX(priv->cbx_positioning));
if(i >= 0 && i < 3)
else
gtk_combo_box_set_active(GTK_COMBO_BOX(priv->cbx_positioning), 0);
break;
+
+ case PROP_FONT_SCALING:
+ priv->font_scaling = g_value_get_double(value);
+ break;
case PROP_POSITION_SET:
b = g_value_get_boolean(value);
g_object_class_install_property(gobject_class, PROP_FAMILY,
g_param_spec_string("family",
"Font family", "String defines"
- " the font family", "Nokia Sans",
+ " the font family", "Sans",
G_PARAM_READWRITE));
g_object_class_install_property(gobject_class, PROP_FAMILY_SET,
"Font position super or subscript",
-1, 1, 0,
G_PARAM_READWRITE));
+
+ /* FIXME This was introduced in 0.14.1. We don't have documentation for
+ * properties anyways, but once it's there it needs to be marked as
+ * Since: 0.14.1 */
+ g_object_class_install_property(gobject_class, PROP_FONT_SCALING,
+ g_param_spec_double ("font-scaling",
+ "Font scaling",
+ "Font scaling for the preview dialog",
+ 0, 10, 1,
+ G_PARAM_READWRITE));
g_object_class_install_property(gobject_class, PROP_POSITION_SET,
g_param_spec_boolean ("position-set",
font_color_box = gtk_hbox_new(FALSE, 0);
priv->font_color_button = hildon_color_button_new();
priv->color_set = FALSE;
+ priv->font_scaling = 1.0;
priv->color_modified_signal_handler =
g_signal_connect(G_OBJECT(priv->font_color_button), "notify::color",
G_CALLBACK(color_modified_cb), (gpointer) priv);
strikethrough, strikethrough_set, position_set;
GdkColor *color = NULL;
gchar *family = NULL;
+ gdouble font_scaling = 1.0;
list = pango_attr_list_new();
"underline", &underline, "underline-set", &underline_set,
"strikethrough", &strikethrough, "strikethrough-set",
&strikethrough_set, "position", &position,
- "position-set", &position_set, NULL);
+ "position-set", &position_set,
+ "font-scaling", &font_scaling,
+ NULL);
/*family*/
if(family_set)
add_preview_text_attr(list, attr, start_index, len);
}
-
+
+ /*font scaling for preview*/
+ if(font_scaling)
+ {
+ attr = pango_attr_scale_new(font_scaling);
+ add_preview_text_attr(list, attr, 0, len + start_index);
+ }
+
return list;
}
GTK_RESPONSE_ACCEPT,
NULL);
- str = g_strconcat(REFERENCE_LINE, priv->preview_text, 0);
+ str = g_strconcat(_("ecdg_fi_preview_font_preview_reference"),
+ priv->preview_text, 0);
preview_label = gtk_label_new(str);
gtk_label_set_line_wrap(GTK_LABEL(preview_label), TRUE);
/*Set the font*/
list = hildon_font_selection_dialog_create_attrlist(fontsel,
- strlen(REFERENCE_LINE),
+ strlen(_("ecdg_fi_preview_font_preview_reference")),
strlen(priv->preview_text));
g_object_get(G_OBJECT(fontsel), "family", &str, "family-set",
if(family_set)
{
attr = pango_attr_family_new(str);
- add_preview_text_attr(list, attr, 0, strlen(REFERENCE_LINE));
+ add_preview_text_attr(list, attr, 0, strlen(_("ecdg_fi_preview_font_preview_reference")));
}
g_free(str);
if(size_set)
{
attr = pango_attr_size_new(size * PANGO_SCALE);
- add_preview_text_attr(list, attr, 0, strlen(REFERENCE_LINE));
+ add_preview_text_attr(list, attr, 0, strlen(_("ecdg_fi_preview_font_preview_reference")));
}
gtk_label_set_attributes(GTK_LABEL(preview_label), list);
gtk_widget_destroy(preview_dialog);
}
+
+static gboolean is_internal_font(const gchar * name){
+ return strcmp(name, "DeviceSymbols") == 0
+ || strcmp(name, "Nokia Smiley" ) == 0
+ || strcmp(name, "NewCourier" ) == 0
+ || strcmp(name, "NewTimes" ) == 0
+ || strcmp(name, "SwissA" ) == 0
+ || strcmp(name, "Nokia Sans" ) == 0
+ || strcmp(name, "Nokia Sans Cn") == 0;
+}
+
+static void filter_out_internal_fonts(PangoFontFamily **families, int *n_families){
+ int i;
+ int n; /* counts valid fonts */
+ const gchar * name = NULL;
+
+ for(i = 0, n = 0; i < *n_families; i++){
+
+ name = pango_font_family_get_name(families[i]);
+
+ if(!is_internal_font(name)){
+
+ if(i!=n){ /* there are filtered out families */
+ families[n] = families[i]; /* shift the current family */
+ }
+
+ n++; /* count one more valid */
+ }
+ }/* foreach font family */
+
+ *n_families = n;
+}
+
+
static void
hildon_font_selection_dialog_show_available_fonts(HildonFontSelectionDialog
*fontsel)
(GTK_WIDGET(fontsel)), &priv->families,
&priv->n_families);
+ filter_out_internal_fonts(priv->families, &priv->n_families);
+
qsort(priv->families, priv->n_families, sizeof(PangoFontFamily *),
cmp_families);