本文整理汇总了C++中pango_font_description_get_family函数的典型用法代码示例。如果您正苦于以下问题:C++ pango_font_description_get_family函数的具体用法?C++ pango_font_description_get_family怎么用?C++ pango_font_description_get_family使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pango_font_description_get_family函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: action_font_activate_cb
G_MODULE_EXPORT void
action_font_activate_cb(GtkWidget *widget, EDITOR *e)
{
GtkWidget *dialog;
gchar *selected_text = NULL;
gchar *size = NULL;
#ifdef HAVE_GTK_32
dialog = gtk_font_chooser_dialog_new("Select font", NULL);
gtk_font_chooser_set_font((GtkFontChooser *)dialog,
#else
dialog = gtk_font_selection_dialog_new("Select font");
gtk_font_selection_dialog_set_font_name((GtkFontSelectionDialog *)
dialog,
#endif
"Droid Sans 14");
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
#ifdef HAVE_GTK_32
const gchar *fontname = gtk_font_chooser_get_font((GtkFontChooser *)dialog);
#else
const gchar *fontname = gtk_font_selection_dialog_get_font_name((GtkFontSelectionDialog *)dialog);
#endif
GString *name = g_string_new(fontname);
size = get_font_size_from_name(name);
g_string_free(name, TRUE);
selected_text = editor_get_selected_text(e);
#ifdef HAVE_GTK_32
PangoFontDescription *font_description =
gtk_font_chooser_get_font_desc((GtkFontChooser *)
dialog);
fontname = pango_font_description_get_family(font_description);
#else
PangoFontDescription *font_description =
pango_font_description_from_string(fontname);
fontname = pango_font_description_get_family(font_description);
#endif
gchar *script = g_strdup_printf("<SPAN STYLE=\"font-family:%s;font-size:%spx;\">%s</SPAN>",
fontname, size, selected_text);
editor_insert_html(script, e);
g_free(script);
}
if (size)
g_free(size);
if (selected_text)
g_free(selected_text);
gtk_widget_destroy(dialog);
}
示例2: webkit_pref_callback_font_family
static void
webkit_pref_callback_font_family (GSettings *settings,
const char *key,
gpointer data)
{
char *webkit_pref = data;
char *value = NULL;
char *schema = NULL;
g_object_get (settings, "schema-id", &schema, NULL);
/* If we are changing a GNOME font value and we are not using GNOME fonts in
* Epiphany, return. */
if (g_strcmp0 (schema, EPHY_PREFS_WEB_SCHEMA) != 0 &&
g_settings_get_boolean (EPHY_SETTINGS_WEB, EPHY_PREFS_WEB_USE_GNOME_FONTS) != TRUE) {
g_free (schema);
return;
}
g_free (schema);
value = g_settings_get_string (settings, key);
if (value) {
PangoFontDescription *desc;
const char *family = NULL;
desc = pango_font_description_from_string (value);
family = pango_font_description_get_family (desc);
g_object_set (webkit_settings, webkit_pref, family, NULL);
pango_font_description_free (desc);
}
g_free (value);
}
示例3: gtk_settings_get_default
void RenderThemeGtk::systemFont(CSSValueID, FontDescription& fontDescription) const
{
GtkSettings* settings = gtk_settings_get_default();
if (!settings)
return;
// This will be a font selection string like "Sans 10" so we cannot use it as the family name.
GUniqueOutPtr<gchar> fontName;
g_object_get(settings, "gtk-font-name", &fontName.outPtr(), NULL);
PangoFontDescription* pangoDescription = pango_font_description_from_string(fontName.get());
if (!pangoDescription)
return;
fontDescription.setOneFamily(pango_font_description_get_family(pangoDescription));
int size = pango_font_description_get_size(pangoDescription) / PANGO_SCALE;
// If the size of the font is in points, we need to convert it to pixels.
if (!pango_font_description_get_size_is_absolute(pangoDescription))
size = size * (getScreenDPI() / 72.0);
fontDescription.setSpecifiedSize(size);
fontDescription.setIsAbsoluteSize(true);
fontDescription.setGenericFamily(FontDescription::NoFamily);
fontDescription.setWeight(FontWeightNormal);
fontDescription.setItalic(false);
pango_font_description_free(pangoDescription);
}
示例4: util_split_font_string
static gboolean
util_split_font_string(const gchar *font_name, gchar **name, gint *size)
{
PangoFontDescription *desc;
PangoFontMask mask;
gboolean retval = FALSE;
if (font_name == NULL) {
return FALSE;
}
mask = (PangoFontMask) (PANGO_FONT_MASK_FAMILY | PANGO_FONT_MASK_SIZE);
desc = pango_font_description_from_string(font_name);
if (!desc) {
return FALSE;
}
if ((pango_font_description_get_set_fields(desc) & mask) == mask) {
*size = PANGO_PIXELS(pango_font_description_get_size (desc));
*name = g_strdup(pango_font_description_get_family (desc));
retval = TRUE;
}
pango_font_description_free(desc);
return retval;
}
示例5: make_families_menu
GtkWidget *
make_families_menu ()
{
GtkWidget *combo;
int n_families;
PangoFontFamily **families;
GList *family_list = NULL;
int i;
pango_context_list_families (context, &families, &n_families);
qsort (families, n_families, sizeof(char *), cmp_families);
for (i=0; i<n_families; i++)
family_list = g_list_prepend (family_list, pango_font_family_get_name (families[i]));
family_list = g_list_reverse (family_list);
combo = gtk_combo_new ();
gtk_combo_set_popdown_strings (GTK_COMBO (combo), family_list);
gtk_combo_set_value_in_list (GTK_COMBO (combo), TRUE, FALSE);
gtk_editable_set_editable (GTK_EDITABLE (GTK_COMBO (combo)->entry), FALSE);
gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (combo)->entry), pango_font_description_get_family(font_description));
gtk_signal_connect (GTK_OBJECT (GTK_COMBO (combo)->entry), "changed",
GTK_SIGNAL_FUNC (set_family), NULL);
g_list_free (family_list);
return combo;
}
示例6: gkbd_indicator_config_get_font_for_widget
void
gkbd_indicator_config_get_font_for_widget (GkbdIndicatorConfig *
ind_config, GtkWidget * widget,
gchar ** font_family,
int *font_size)
{
GtkStyleContext *context;
const PangoFontDescription *fd = NULL;
g_return_if_fail (GTK_IS_WIDGET (widget));
if (ind_config->font_family != NULL &&
ind_config->font_family[0] != '\0') {
if (font_family)
*font_family = g_strdup (ind_config->font_family);
if (font_size)
*font_size = ind_config->font_size;
return;
}
context = gtk_widget_get_style_context (widget);
fd = gtk_style_context_get_font (context, GTK_STATE_FLAG_NORMAL);
if (font_family)
*font_family =
g_strdup (pango_font_description_get_family (fd));
if (font_size)
*font_size =
pango_font_description_get_size (fd) / PANGO_SCALE;
}
示例7: pango_font_description_get_family
JNIEXPORT jstring JNICALL
Java_org_gnome_pango_PangoFontDescription_pango_1font_1description_1get_1family
(
JNIEnv* env,
jclass cls,
jlong _self
)
{
const char* result;
jstring _result;
PangoFontDescription* self;
// convert parameter self
self = (PangoFontDescription*) _self;
// call function
result = pango_font_description_get_family(self);
// cleanup parameter self
// translate return value to JNI type
_result = (jstring) bindings_java_newString(env, result);
// and finally
return _result;
}
示例8: g_object_get
bool GtkToolkitUiSettings::GetDefaultFont(FontDetails& font)
{
gchararray font_face = 0;
g_object_get(m_settings, "gtk-font-name", &font_face, NULL);
PangoFontDescription* font_desc = pango_font_description_from_string(font_face);
g_free(font_face);
if (!font_desc)
return false;
const char* family = pango_font_description_get_family(font_desc);
if (family)
{
if (strcmp(family, "Sans") == 0)
font.type = SANSSERIF;
else if (strcmp(family, "Serif") == 0)
font.type = SERIF;
else if (strcmp(family, "Monospace") == 0)
font.type = MONOSPACE;
font.family = strdup(family);
}
font.weight = pango_font_description_get_weight(font_desc) / 100;
font.italic = pango_font_description_get_style(font_desc) == PANGO_STYLE_ITALIC;
font.smallcaps = pango_font_description_get_variant(font_desc) == PANGO_VARIANT_SMALL_CAPS;
double size = pango_font_description_get_size(font_desc) / PANGO_SCALE;
font.size = size;
pango_font_description_free(font_desc);
return true;
}
示例9: Clear
bool PangoFontInfo::ParseFontDescription(const PangoFontDescription *desc) {
Clear();
const char* family = pango_font_description_get_family(desc);
if (!family) {
char* desc_str = pango_font_description_to_string(desc);
tprintf("WARNING: Could not parse family name from description: '%s'\n",
desc_str);
g_free(desc_str);
return false;
}
family_name_ = string(family);
desc_ = pango_font_description_copy(desc);
is_monospace_ = IsMonospaceFontFamily(family);
// Set font size in points
font_size_ = pango_font_description_get_size(desc);
if (!pango_font_description_get_size_is_absolute(desc)) {
font_size_ /= PANGO_SCALE;
}
PangoStyle style = pango_font_description_get_style(desc);
is_italic_ = (PANGO_STYLE_ITALIC == style ||
PANGO_STYLE_OBLIQUE == style);
is_smallcaps_ = (pango_font_description_get_variant(desc)
== PANGO_VARIANT_SMALL_CAPS);
is_bold_ = (pango_font_description_get_weight(desc) >= PANGO_WEIGHT_BOLD);
// We dont have a way to detect whether a font is of type Fraktur. The fonts
// we currently use all have "Fraktur" in their family name, so we do a
// fragile but functional check for that here.
is_fraktur_ = (strcasestr(family, "Fraktur") != NULL);
return true;
}
示例10: pango_load
static bool
pango_load (Lisp_Font *f)
{
PangoLanguage *language;
PangoFontDescription *fontdesc;
PangoFont *font;
PangoFontMetrics *metrics;
if (pango_context)
{
language = pango_context_get_language (pango_context);
}
else
{
char *langname, *p;
#ifdef HAVE_PANGO_XFT
pango_context = pango_xft_get_context (dpy, screen_num);
#endif
langname = g_strdup (setlocale (LC_CTYPE, NULL));
p = strchr (langname, '.');
if (p)
*p = 0;
p = strchr (langname, '@');
if (p)
*p = 0;
language = pango_language_from_string (langname);
pango_context_set_language (pango_context, language);
g_free (langname);
}
fontdesc = pango_font_description_from_string (rep_STR (f->name));
if (!pango_font_description_get_family (fontdesc))
pango_font_description_set_family (fontdesc, "Sans");
if (pango_font_description_get_size (fontdesc) <= 0)
pango_font_description_set_size (fontdesc, 12 * PANGO_SCALE);
pango_context_set_font_description (pango_context, fontdesc);
font = pango_context_load_font (pango_context, fontdesc);
if (!font) {
pango_font_description_free(fontdesc);
return FALSE;
}
metrics = pango_font_get_metrics (font, language);
f->ascent = metrics->ascent / PANGO_SCALE;
f->descent = metrics->descent / PANGO_SCALE;
pango_font_metrics_unref (metrics);
f->font = fontdesc; /* We save the font description, not the font itself!
That's because it seems we can't recover it perfectly
later, and the layout routines want a description */
return TRUE;
}
示例11: update_font_family_combo
static void
update_font_family_combo (MucharmapMiniFontSelection *fontsel)
{
GtkTreeModel *model = GTK_TREE_MODEL (fontsel->family_store);
GtkTreeIter iter;
const char *font_family;
gboolean found = FALSE;
font_family = pango_font_description_get_family (fontsel->font_desc);
if (!font_family || !font_family[0]) {
gtk_combo_box_set_active (GTK_COMBO_BOX (fontsel->family), -1);
return;
}
if (!gtk_tree_model_get_iter_first (model, &iter))
return;
do {
char *family;
gtk_tree_model_get (model, &iter, COL_FAMILIY, &family, -1);
found = family && strcmp (family, font_family) == 0;
g_free (family);
} while (!found && gtk_tree_model_iter_next (model, &iter));
if (found) {
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (fontsel->family), &iter);
} else {
gtk_combo_box_set_active (GTK_COMBO_BOX (fontsel->family), -1);
}
}
示例12: get_default_font
static gchar*
get_default_font (GtkWidget *widget)
{
PangoFontDescription *font_desc = widget->style->font_desc;
return g_strdup_printf ("%s %d",
pango_font_description_get_family (font_desc),
pango_font_description_get_size (font_desc) / PANGO_SCALE);
}
示例13: gtk_css_value_initial_compute
static GtkCssValue *
gtk_css_value_initial_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
GtkSettings *settings;
switch (property_id)
{
case GTK_CSS_PROPERTY_DPI:
settings = _gtk_style_provider_private_get_settings (provider);
if (settings)
{
GdkScreen *screen = _gtk_settings_get_screen (settings);
double resolution = gdk_screen_get_resolution (screen);
if (resolution > 0.0)
return _gtk_css_number_value_new (resolution, GTK_CSS_NUMBER);
}
break;
case GTK_CSS_PROPERTY_FONT_FAMILY:
settings = _gtk_style_provider_private_get_settings (provider);
if (settings)
{
PangoFontDescription *description;
char *font_name;
GtkCssValue *value;
g_object_get (settings, "gtk-font-name", &font_name, NULL);
description = pango_font_description_from_string (font_name);
g_free (font_name);
if (description == NULL)
break;
if (pango_font_description_get_set_fields (description) & PANGO_FONT_MASK_FAMILY)
{
value = _gtk_css_array_value_new (_gtk_css_string_value_new (pango_font_description_get_family (description)));
pango_font_description_free (description);
return value;
}
pango_font_description_free (description);
}
break;
default:
break;
}
return _gtk_css_value_compute (_gtk_css_style_property_get_initial_value (_gtk_css_style_property_lookup_by_id (property_id)),
property_id,
provider,
style,
parent_style);
}
示例14: mucharmap_mini_font_selection_set_font_desc
void
mucharmap_mini_font_selection_set_font_desc (MucharmapMiniFontSelection *fontsel,
PangoFontDescription *font_desc)
{
GObject *object = G_OBJECT (fontsel);
PangoFontDescription *new_font_desc;
const char *new_font_family;
g_return_if_fail (MUCHARMAP_IS_MINI_FONT_SELECTION (fontsel));
g_return_if_fail (font_desc != NULL);
g_object_freeze_notify (object);
new_font_desc = pango_font_description_copy (font_desc);
new_font_family = pango_font_description_get_family (new_font_desc);
if (!new_font_family) {
pango_font_description_set_family (new_font_desc, "Sans");
new_font_family = pango_font_description_get_family (new_font_desc);
}
if ((!fontsel->font_desc ||
strcmp (pango_font_description_get_family (fontsel->font_desc), new_font_family) != 0) &&
pango_font_description_get_size (new_font_desc) > 0)
fontsel->default_size = pango_font_description_get_size (new_font_desc) / PANGO_SCALE;
if (fontsel->font_desc)
pango_font_description_free (fontsel->font_desc);
fontsel->font_desc = new_font_desc;
update_font_family_combo (fontsel);
/* treat oblique and italic both as italic */
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fontsel->italic), pango_font_description_get_style (fontsel->font_desc) == PANGO_STYLE_ITALIC || pango_font_description_get_style (fontsel->font_desc) == PANGO_STYLE_OBLIQUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fontsel->bold), pango_font_description_get_weight (fontsel->font_desc) > PANGO_WEIGHT_NORMAL);
gtk_adjustment_set_value (
GTK_ADJUSTMENT (fontsel->size_adj),
pango_font_description_get_size (fontsel->font_desc) / PANGO_SCALE);
g_object_notify (G_OBJECT (fontsel), "font-desc");
g_object_thaw_notify (object);
}
示例15: gtk_widget_get_settings
nsresult
nsSystemFontsGTK2::GetSystemFontInfo(GtkWidget *aWidget, nsString *aFontName,
gfxFontStyle *aFontStyle) const
{
#ifdef MOZ_PANGO
GtkSettings *settings = gtk_widget_get_settings(aWidget);
aFontStyle->style = FONT_STYLE_NORMAL;
gchar *fontname;
g_object_get(settings, "gtk-font-name", &fontname, NULL);
PangoFontDescription *desc;
desc = pango_font_description_from_string(fontname);
aFontStyle->systemFont = PR_TRUE;
g_free(fontname);
NS_NAMED_LITERAL_STRING(quote, "\"");
NS_ConvertUTF8toUTF16 family(pango_font_description_get_family(desc));
*aFontName = quote + family + quote;
aFontStyle->weight = pango_font_description_get_weight(desc);
// FIXME: Set aFontStyle->stretch correctly!
aFontStyle->stretch = NS_FONT_STRETCH_NORMAL;
float size = float(pango_font_description_get_size(desc)) / PANGO_SCALE;
// |size| is now either pixels or pango-points (not Mozilla-points!)
if (!MOZ_pango_font_description_get_size_is_absolute(desc)) {
// |size| is in pango-points, so convert to pixels.
size *= float(gfxPlatformGtk::GetDPI()) / POINTS_PER_INCH_FLOAT;
}
// |size| is now pixels
aFontStyle->size = size;
pango_font_description_free(desc);
#else
/* FIXME: DFB FT2 Hardcoding the system font info for now.. */
aFontStyle->style = FONT_STYLE_NORMAL;
aFontStyle->systemFont = PR_TRUE;
NS_NAMED_LITERAL_STRING(fontname, "\"Sans\"");
*aFontName = fontname;
aFontStyle->weight = 400;
aFontStyle->size = 40/3;
#endif
return NS_OK;
}