static void fill_font_families_combo (MucharmapMiniFontSelection *fontsel) { GtkComboBox *combo = GTK_COMBO_BOX (fontsel->family); PangoFontFamily **families; int n_families, i; fontsel->family_store = gtk_list_store_new (1, G_TYPE_STRING); pango_context_list_families ( gtk_widget_get_pango_context (GTK_WIDGET (fontsel)), &families, &n_families); for (i = 0; i < n_families; i++) { PangoFontFamily *family = families[i]; GtkTreeIter iter; gtk_list_store_insert_with_values (fontsel->family_store, &iter, -1, COL_FAMILIY, pango_font_family_get_name (family), -1); } g_free (families); /* Now turn on sorting in the combo box */ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (fontsel->family_store), COL_FAMILIY, GTK_SORT_ASCENDING); gtk_combo_box_set_model (combo, GTK_TREE_MODEL (fontsel->family_store)); g_object_unref (fontsel->family_store); }
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; }
static void gnm_font_button_update_font_data (GnmFontButton *font_button) { GnmFontButtonPrivate *priv = font_button->priv; PangoFontFamily **families; PangoFontFace **faces; gint n_families, n_faces, i; const gchar *family; g_assert (priv->font_desc != NULL); priv->fontname = pango_font_description_to_string (priv->font_desc); family = pango_font_description_get_family (priv->font_desc); if (family == NULL) return; n_families = 0; families = NULL; pango_context_list_families (gtk_widget_get_pango_context (GTK_WIDGET (font_button)), &families, &n_families); n_faces = 0; faces = NULL; for (i = 0; i < n_families; i++) { const gchar *name = pango_font_family_get_name (families[i]); if (!g_ascii_strcasecmp (name, family)) { priv->font_family = g_object_ref (families[i]); pango_font_family_list_faces (families[i], &faces, &n_faces); break; } } g_free (families); for (i = 0; i < n_faces; i++) { PangoFontDescription *tmp_desc = pango_font_face_describe (faces[i]); if (font_description_style_equal (tmp_desc, priv->font_desc)) { priv->font_face = g_object_ref (faces[i]); pango_font_description_free (tmp_desc); break; } else pango_font_description_free (tmp_desc); } g_free (faces); }
void GtkPaintContext::fillFamiliesList(std::vector<std::string> &families) const { if (myContext != 0) { PangoFontFamily **pangoFamilies; int nFamilies; pango_context_list_families(myContext, &pangoFamilies, &nFamilies); for (int i = 0; i < nFamilies; ++i) { families.push_back(pango_font_family_get_name(pangoFamilies[i])); } std::sort(families.begin(), families.end()); g_free(pangoFamilies); } }
static PyObject * pango_GetFontMap(PyObject *self, PyObject *args) { PangoFontMap *fm; PangoContext *ctx; PangoFontFamily **families; PangoFontFace **faces; PyObject *family; int n_families, n_faces, i, j; int *sizes, n_sizes; PyObject *faces_tuple; PyObject *ret; fm = pango_cairo_font_map_get_default(); ctx = pango_font_map_create_context(fm); pango_context_list_families(ctx, &families, &n_families); ret = PyTuple_New(n_families); for (i = 0; i < n_families; i++) { family = PyTuple_New(2); PyTuple_SetItem(family, 0, Py_BuildValue("s", pango_font_family_get_name(families[i]))); pango_font_family_list_faces(families[i], &faces, &n_faces); pango_font_face_list_sizes(faces[0], &sizes, &n_sizes); if (!sizes) { faces_tuple = PyTuple_New(n_faces); for (j = 0; j < n_faces; j++) { PyTuple_SetItem(faces_tuple, j, Py_BuildValue("s", pango_font_face_get_face_name(faces[j]))); } PyTuple_SetItem(family, 1, faces_tuple); } else { Py_INCREF(Py_None); PyTuple_SetItem(family, 1, Py_None); } PyTuple_SetItem(ret, i, family); g_free(sizes); g_free(faces); } g_free(families); g_object_unref(ctx); return ret; }
bool wxFontEnumerator::EnumerateFacenames(wxFontEncoding encoding, bool fixedWidthOnly) { if ( encoding != wxFONTENCODING_SYSTEM && encoding != wxFONTENCODING_UTF8 ) { // Pango supports only UTF-8 encoding (and system means any, so we // accept it too) return false; } #if defined(__WXGTK20__) || !defined(HAVE_PANGO_FONT_FAMILY_IS_MONOSPACE) if ( fixedWidthOnly #if defined(__WXGTK24__) && (gtk_check_version(2,4,0) != NULL) #endif ) { OnFacename( wxT("monospace") ); } else // !fixedWidthOnly #endif // __WXGTK20__ || !HAVE_PANGO_FONT_FAMILY_IS_MONOSPACE { PangoFontFamily **families = NULL; gint n_families = 0; pango_context_list_families ( #ifdef __WXGTK20__ gtk_widget_get_pango_context( wxGetRootWindow() ), #else wxTheApp->GetPangoContext(), #endif &families, &n_families ); qsort (families, n_families, sizeof (PangoFontFamily *), wxCompareFamilies); for (int i=0; i<n_families; i++) { #if defined(__WXGTK24__) || defined(HAVE_PANGO_FONT_FAMILY_IS_MONOSPACE) if (!fixedWidthOnly || ( #ifdef __WXGTK24__ !gtk_check_version(2,4,0) && #endif pango_font_family_is_monospace(families[i]) ) ) #endif { const gchar *name = pango_font_family_get_name(families[i]); OnFacename(wxString(name, wxConvUTF8)); } } g_free(families); } return true; }
void GenerateFontList (_List& fonts) { fonts.Clear(); PangoFontFamily **families; PangoFontFamily *match_family = NULL; gint n_families, i; pango_context_list_families ((screenPContext),&families, &n_families); for (i=0; i<n_families; i++) { fonts.AppendNewInstance(new _String(pango_font_family_get_name (families[i]))); } fonts.Sort(); g_free (families); }
static gboolean utils_font_desc_check_monospace(PangoContext *pc, PangoFontDescription *desc) { PangoFontFamily **families; gint n_families, i; const gchar *font; gboolean ret = TRUE; font = pango_font_description_get_family(desc); pango_context_list_families(pc, &families, &n_families); for (i = 0; i < n_families; i++) { if (utils_str_equal(font, pango_font_family_get_name(families[i]))) { if (!pango_font_family_is_monospace(families[i])) { ret = FALSE; } } } g_free(families); return ret; }
static void inline_F791_8121 (EIF_POINTER arg1, EIF_POINTER* arg2, EIF_INTEGER_32* arg3) { { PangoFontFamily **families; gchar **l_name_array = NULL; gint i; pango_context_list_families (gtk_widget_get_pango_context ((GtkWidget*) arg1), &families, arg3); l_name_array = malloc (*arg3 * sizeof (gchar*)); for (i=0; i < *arg3; i++) { l_name_array [i] = (gchar *) pango_font_family_get_name (families[i]); } g_free (families); *(EIF_POINTER *) arg2 = (EIF_POINTER *) l_name_array; } ; }
static void hildon_font_selection_dialog_show_available_fonts (HildonFontSelectionDialog *fontsel) { gint i; HildonFontSelectionDialogPrivate *priv = HILDON_FONT_SELECTION_DIALOG_GET_PRIVATE (fontsel); g_assert (priv); pango_context_list_families (gtk_widget_get_pango_context (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); for (i = 0; i < priv->n_families; i++) { const gchar *name = pango_font_family_get_name (priv->families[i]); gtk_combo_box_append_text (GTK_COMBO_BOX (priv->cbx_font_type), name); } }
wxFontFamily wxNativeFontInfo::GetFamily() const { wxFontFamily ret = wxFONTFAMILY_UNKNOWN; const char *family_name = pango_font_description_get_family( description ); // note: not passing -1 as the 2nd parameter to g_ascii_strdown to work // around a bug in the 64-bit glib shipped with solaris 10, -1 causes it // to try to allocate 2^32 bytes. if ( !family_name ) return ret; wxGtkString family_text(g_ascii_strdown(family_name, strlen(family_name))); // Check for some common fonts, to salvage what we can from the current // win32 centric wxFont API: if (wxStrnicmp( family_text, "monospace", 9 ) == 0) ret = wxFONTFAMILY_TELETYPE; // begins with "Monospace" else if (wxStrnicmp( family_text, "courier", 7 ) == 0) ret = wxFONTFAMILY_TELETYPE; // begins with "Courier" #if defined(__WXGTK20__) || defined(HAVE_PANGO_FONT_FAMILY_IS_MONOSPACE) else { PangoFontFamily **families; PangoFontFamily *family = NULL; int n_families; PangoContext* context = wxGetPangoContext(); pango_context_list_families(context, &families, &n_families); for (int i = 0; i < n_families; ++i) { if (g_ascii_strcasecmp(pango_font_family_get_name( families[i] ), pango_font_description_get_family( description )) == 0 ) { family = families[i]; break; } } g_free(families); g_object_unref(context); // Some gtk+ systems might query for a non-existing font from // wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) on initialization, // don't assert until wxSystemSettings::GetFont is checked for this - MR // wxASSERT_MSG( family, "No appropriate PangoFontFamily found for ::description" ); if (family != NULL && pango_font_family_is_monospace( family )) ret = wxFONTFAMILY_TELETYPE; // is deemed a monospace font by pango } #endif // GTK+ 2 || HAVE_PANGO_FONT_FAMILY_IS_MONOSPACE if (ret == wxFONTFAMILY_UNKNOWN) { if (strstr( family_text, "sans" ) != NULL || strstr( family_text, "Sans" ) != NULL) // checked before serif, so that "* Sans Serif" fonts are detected correctly ret = wxFONTFAMILY_SWISS; // contains "Sans" else if (strstr( family_text, "serif" ) != NULL || strstr( family_text, "Serif" ) != NULL) ret = wxFONTFAMILY_ROMAN; // contains "Serif" else if (wxStrnicmp( family_text, "times", 5 ) == 0) ret = wxFONTFAMILY_ROMAN; // begins with "Times" else if (wxStrnicmp( family_text, "old", 3 ) == 0) ret = wxFONTFAMILY_DECORATIVE; // begins with "Old" - "Old English", "Old Town" } return ret; }
static void gtk_font_button_update_font_info (GtkFontButton *font_button) { PangoFontDescription *desc; const gchar *family; gchar *style; gchar *family_style; desc = pango_font_description_from_string (font_button->priv->fontname); family = pango_font_description_get_family (desc); #if 0 /* This gives the wrong names, e.g. Italic when the font selection * dialog displayed Oblique. */ pango_font_description_unset_fields (desc, PANGO_FONT_MASK_FAMILY | PANGO_FONT_MASK_SIZE); style = pango_font_description_to_string (desc); gtk_label_set_text (GTK_LABEL (font_button->priv->style_label), style); #endif style = NULL; if (font_button->priv->show_style && family) { PangoFontFamily **families; PangoFontFace **faces; gint n_families, n_faces, i; n_families = 0; families = NULL; pango_context_list_families (gtk_widget_get_pango_context (GTK_WIDGET (font_button)), &families, &n_families); n_faces = 0; faces = NULL; for (i = 0; i < n_families; i++) { const gchar *name = pango_font_family_get_name (families[i]); if (!g_ascii_strcasecmp (name, family)) { pango_font_family_list_faces (families[i], &faces, &n_faces); break; } } g_free (families); for (i = 0; i < n_faces; i++) { PangoFontDescription *tmp_desc = pango_font_face_describe (faces[i]); if (font_description_style_equal (tmp_desc, desc)) { style = g_strdup (pango_font_face_get_face_name (faces[i])); pango_font_description_free (tmp_desc); break; } else pango_font_description_free (tmp_desc); } g_free (faces); } if (style == NULL || !g_ascii_strcasecmp (style, "Regular")) family_style = g_strdup (family); else family_style = g_strdup_printf ("%s %s", family, style); gtk_label_set_text (GTK_LABEL (font_button->priv->font_label), family_style); g_free (style); g_free (family_style); if (font_button->priv->show_size) { gchar *size = g_strdup_printf ("%g", pango_font_description_get_size (desc) / (double)PANGO_SCALE); gtk_label_set_text (GTK_LABEL (font_button->priv->size_label), size); g_free (size); } gtk_font_button_label_use_font (font_button); pango_font_description_free (desc); }
static void fill_styles_combo (GtkWidget *combo) { int i; GList *style_list = NULL; PangoFontFace **faces; PangoFontFamily *family, **families; FontDescInfo *info; int n_families; const char *family_name = pango_font_description_get_family(font_description); /* * Now map back the given family name to the family. There are more efficient * ways to handle this but it should not matter much ... */ pango_context_list_families (context, &families, &n_families); g_assert(n_families > 0); family = families[0]; /* just in case */ for (i = 0; i < n_families; i++) { if (0 == g_strcasecmp(pango_font_family_get_name(families[i]), family_name)) { family = families[i]; break; } } g_free (families); info = g_new (FontDescInfo, 1); pango_font_family_list_faces (family, &faces, &info->n_descs); info->descs = g_new0 (PangoFontDescription*, info->n_descs); for (i = 0; i < info->n_descs; i++) { info->descs[i] = pango_font_face_describe(faces[i]); } g_free (faces); gtk_object_set_data_full (GTK_OBJECT (combo), "descs", info, (GtkDestroyNotify)free_info); qsort (info->descs, info->n_descs, sizeof(PangoFontDescription *), font_description_sort_func); for (i=0; i<info->n_descs; i++) { char *str; PangoFontDescription *tmp_desc; tmp_desc = info->descs[i]; pango_font_description_set_family(tmp_desc, NULL); pango_font_description_unset_fields(tmp_desc, PANGO_FONT_MASK_SIZE); str = pango_font_description_to_string (tmp_desc); style_list = g_list_prepend (style_list, str); } style_list = g_list_reverse (style_list); gtk_combo_set_popdown_strings (GTK_COMBO (combo), style_list); g_list_foreach (style_list, (GFunc)g_free, NULL); }