struct PP_Var ppb_font_dev_get_font_families(PP_Instance instance) { PangoFontFamily **families; int n, k, total_len; pango_font_map_list_families(tables_get_pango_font_map(), &families, &n); total_len = 0; for (k = 0; k < n; k ++) { const char *name = pango_font_family_get_name(families[k]); total_len += strlen(name) + 1; // with '\0' at the end } char *s = malloc(total_len); char *ptr = s; for (k = 0; k < n; k ++) { const char *name = pango_font_family_get_name(families[k]); const int len = strlen(name); memcpy(ptr, name, len + 1); // with '\0' at the end ptr += len + 1; } struct PP_Var var = ppb_var_var_from_utf8(s, total_len); free(s); g_free(families); return var; }
static int wxCMPFUNC_CONV wxCompareFamilies (const void *a, const void *b) { const char *a_name = pango_font_family_get_name (*(PangoFontFamily **)a); const char *b_name = pango_font_family_get_name (*(PangoFontFamily **)b); return g_utf8_collate (a_name, b_name); }
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 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); }
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; }
gboolean gtkutil_find_font (const char *fontname) { int i; int n_families; const char *family_name; PangoFontMap *fontmap; PangoFontFamily *family; PangoFontFamily **families; fontmap = pango_cairo_font_map_get_default (); pango_font_map_list_families (fontmap, &families, &n_families); for (i = 0; i < n_families; i++) { family = families[i]; family_name = pango_font_family_get_name (family); if (!g_ascii_strcasecmp (family_name, fontname)) { g_free (families); return TRUE; } } g_free (families); return FALSE; }
bool FontPlatformData::init() { static bool initialized = false; if (initialized) return true; initialized = true; if (!m_fontMap) m_fontMap = pango_cairo_font_map_get_default(); if (!m_hashTable) { PangoFontFamily** families = 0; int n_families = 0; m_hashTable = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_object_unref); pango_font_map_list_families(m_fontMap, &families, &n_families); for (int family = 0; family < n_families; family++) g_hash_table_insert(m_hashTable, g_strdup(pango_font_family_get_name(families[family])), g_object_ref(families[family])); g_free(families); } return true; }
int main(int argc, char **argv) { PangoFontMap* map; PangoFontFamily **families; int n_families; int i; PangoFontFace **faces; int n_faces; int j; gtk_init(&argc, &argv); map = pango_cairo_font_map_get_default(); pango_font_map_list_families(map, &families, &n_families); for (i = 0; i < n_families; i++) { g_print("%s\n", pango_font_family_get_name(families[i])); pango_font_family_list_faces(families[i], &faces, &n_faces); for (j = 0; j < n_faces; j++) { g_print(" %s\n", pango_font_face_get_face_name(faces[j])); } } return 0; }
void font_print_result (void) { if (options.font_data.separate_output) { PangoFontFace *face; PangoFontFamily *family; gint size; face = gtk_font_selection_get_face (GTK_FONT_SELECTION (font)); family = gtk_font_selection_get_family (GTK_FONT_SELECTION (font)); size = gtk_font_selection_get_size (GTK_FONT_SELECTION (font)); if (options.common_data.quoted_output) { gchar *q1 = g_shell_quote (pango_font_family_get_name (family)); gchar *q2 = g_shell_quote (pango_font_face_get_face_name (face)); g_printf ("%s%s%s%s%d\n", q1, options.common_data.separator, q2, options.common_data.separator, size / 1000); g_free (q1); g_free (q2); } else { g_printf ("%s%s%s%s%d\n", pango_font_family_get_name (family), options.common_data.separator, pango_font_face_get_face_name (face), options.common_data.separator, size / 1000); } } else { gchar *fn = gtk_font_selection_get_font_name (GTK_FONT_SELECTION (font)); if (options.common_data.quoted_output) { gchar *buf = g_shell_quote (fn); g_printf ("%s\n", buf); g_free (buf); } else g_printf ("%s\n", fn); g_free (fn); } }
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); } }
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; }
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; }
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); }
void pangox_layout_list_fonts(FILE *fp, PangoLayout *layout) { PangoContext *context; PangoFontMap *fontmap; PangoFontFamily **families; int n, i; context = pango_layout_get_context(layout); fontmap = pango_context_get_font_map(context); pango_font_map_list_families(fontmap, &families, &n); fprintf(fp, "Found %d fonts\n", n); for (i = 0; i < n; i++) { fprintf(fp, " %s\n", pango_font_family_get_name(families[i])); } g_free(families); }
/* static */ const vector<string>& FontUtils::ListAvailableFonts() { static vector<string> available_fonts_; // cache list if (available_fonts_.size()) { return available_fonts_; } #ifndef USE_STD_NAMESPACE if (FLAGS_use_only_legacy_fonts) { // Restrict view to list of fonts in legacy_fonts.h tprintf("Using list of legacy fonts only\n"); const int kNumFontLists = 4; for (int i = 0; i < kNumFontLists; ++i) { for (int j = 0; kFontlists[i][j] != NULL; ++j) { available_fonts_.push_back(kFontlists[i][j]); } } return available_fonts_; } #endif PangoFontFamily** families = 0; int n_families = 0; ListFontFamilies(&families, &n_families); for (int i = 0; i < n_families; ++i) { const char* family_name = pango_font_family_get_name(families[i]); tlog(2, "Listing family %s\n", family_name); if (ShouldIgnoreFontFamilyName(family_name)) continue; int n_faces; PangoFontFace** faces = NULL; pango_font_family_list_faces(families[i], &faces, &n_faces); for (int j = 0; j < n_faces; ++j) { PangoFontDescription* desc = pango_font_face_describe(faces[j]); char* desc_str = pango_font_description_to_string(desc); if (IsAvailableFont(desc_str)) { available_fonts_.push_back(desc_str); } pango_font_description_free(desc); g_free(desc_str); } g_free(faces); } g_free(families); sort(available_fonts_.begin(), available_fonts_.end()); return available_fonts_; }
StringList Font::familiesAvailable() { PangoFontMap* map = pango_cairo_font_map_get_default(); PangoFontFamily** families; int count; pango_font_map_list_families(map, &families, &count); StringList result; for(int i = 0; i < count; ++i) { PangoFontFamily* family = families[i]; result.push_back(pango_font_family_get_name(family)); } free(families); return result; }
// Inspects whether a given font family is monospace. If the font is not // available, it cannot make a decision and returns false by default. static bool IsMonospaceFontFamily(const char* family_name) { PangoFontFamily** families = 0; int n_families = 0; bool is_monospace = false; ListFontFamilies(&families, &n_families); ASSERT_HOST(n_families > 0); bool found = false; for (int i = 0; i < n_families; ++i) { if (!strcasecmp(family_name, pango_font_family_get_name(families[i]))) { is_monospace = pango_font_family_is_monospace(families[i]); found = true; break; } } if (!found) { tlog(1, "Could not find monospace property of family %s\n", family_name); } g_free(families); return is_monospace; }
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 gtk_font_button_update_font_info (GtkFontButton *font_button) { GtkFontButtonPrivate *priv = font_button->priv; const gchar *fam_name; const gchar *face_name; gchar *family_style; if (priv->font_family) fam_name = pango_font_family_get_name (priv->font_family); else fam_name = C_("font", "None"); if (priv->font_face) face_name = pango_font_face_get_face_name (priv->font_face); else face_name = ""; if (priv->show_style) family_style = g_strconcat (fam_name, " ", face_name, NULL); else family_style = g_strdup (fam_name); gtk_label_set_text (GTK_LABEL (font_button->priv->font_label), family_style); g_free (family_style); if (font_button->priv->show_size) { /* mirror Pango, which doesn't translate this either */ gchar *size = g_strdup_printf ("%2.4g%s", pango_font_description_get_size (priv->font_desc) / (double)PANGO_SCALE, pango_font_description_get_size_is_absolute (priv->font_desc) ? "px" : ""); gtk_label_set_text (GTK_LABEL (font_button->priv->size_label), size); g_free (size); } gtk_font_button_label_use_font (font_button); }
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; } ; }
int unicodeGetFontList(char *str, int strLength) { PangoFontMap *fontMap; PangoFontFamily **fontFomilies; int count, i; str[0] = '\0'; if (cachedLayout == NULL) { cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_A8, 1, 1); cairo_t *cr = cairo_create(surface); cachedLayout = pango_cairo_create_layout(cr); } fontMap = pango_context_get_font_map(pango_layout_get_context(cachedLayout)); pango_font_map_list_families(fontMap, &fontFomilies, &count); for (i = 0; i < count; i++) { strncat(str, pango_font_family_get_name(fontFomilies[i]), strLength); strncat(str, "\n", strLength); } g_free(fontFomilies); return strlen(str); }
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); } }
static void notify_font_cb (GtkFontChooser *fontchooser, GParamSpec *pspec, gpointer data) { PangoFontFamily *family; PangoFontFace *face; g_debug ("Changed font name %s", gtk_font_chooser_get_font (fontchooser)); family = gtk_font_chooser_get_font_family (fontchooser); face = gtk_font_chooser_get_font_face (fontchooser); if (family) { g_debug (" Family: %s is-monospace:%s", pango_font_family_get_name (family), pango_font_family_is_monospace (family) ? "true" : "false"); } else g_debug (" No font family!"); if (face) g_debug (" Face description: %s", pango_font_face_get_face_name (face)); else g_debug (" No font face!"); }
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); }
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 VALUE rg_name(VALUE self) { return CSTR2RVAL(pango_font_family_get_name(_SELF(self))); }
/* This function creates an array of font definitions. Each entry corresponds to one of the Graphviz PS fonts. The font definitions contain the generic font name and a list of equivalent fonts that can be used in place of the PS font if the PS font is not available on the system */ static availfont_t *gv_get_ps_fontlist(PangoFontMap * fontmap) { PangoFontFamily **families; PangoFontFamily *family; fontdef_t* gv_ps_fontdef; int n_families; int i, j, k, array_sz, availfaces; availfont_t *gv_af_p, *gv_afs; const char *name; char *family_name; /* Get a list of font families installed on the system */ pango_font_map_list_families(fontmap, &families, &n_families); /* Setup a pointer to available font structs */ gv_af_p = N_NEW(GV_FONT_LIST_SIZE, availfont_t); for (j = 0; j < GV_FONT_LIST_SIZE; j++) { /* get the Graphviz PS font information and create the available font definition structs */ gv_afs = gv_af_p+j; gv_ps_fontdef = gv_ps_fontdefs+j; gv_afs->gv_ps_fontname = gv_ps_fontdef->fontname; family_name = NULL; /* Search the installed system font families for the current Graphvis PS font family name, i.e. AvantGarde */ for (i = 0; i < n_families; i++) { family = families[i]; name = pango_font_family_get_name(family); /* if a match is found get the installed font faces */ if (strcasecmp(gv_ps_fontdef->fontname, name) == 0) { family_name = strdup(name); availfaces = get_faces(family); } if (family_name) break; } /* if a match is not found on the primary Graphviz font family, search for a match on the equivalent font family names */ if (!family_name) { array_sz = gv_ps_fontdef->eq_sz; for (k = 0; k < array_sz; k++) { for (i = 0; i < n_families; i++) { family = families[i]; name = pango_font_family_get_name(family); if (strcasecmp(gv_ps_fontdef->equiv[k], name) == 0) { family_name = strdup(name); availfaces = get_faces(family); break; } } if (family_name) break; } } /* if a match is not found on the equivalent font family names, search for a match on the generic family name assigned to the Graphviz PS font */ if (!family_name) { for (i = 0; i < n_families; i++) { family = families[i]; name = pango_font_family_get_name(family); if (strcasecmp(gv_ps_fontdef->generic_name, name) == 0) { family_name = strdup(name); availfaces = get_faces(family); break; } } } /* if not match is found on the generic name, set the available font name to NULL */ if (family_name && availfaces) { gv_afs->fontname = family_name; gv_afs->faces = availfaces; } else { gv_afs->fontname = NULL; gv_afs->faces = 0; } } g_free(families); #ifdef DEBUG display_available_fonts(gv_af_p); #endif /* Free the Graphviz PS font definitions */ return (gv_af_p); }
weed_plant_t *weed_setup(weed_bootstrap_f weed_boot) { weed_plant_t *plugin_info=weed_plugin_info_init(weed_boot,num_versions,api_versions); if (plugin_info!=NULL) { weed_plant_t *in_params[P_END+1],*gui; weed_plant_t *filter_class; PangoContext *ctx; const char *modes[]= {"Spiral text","Spinning letters","Letter starfield","Word coalesce",NULL}; char *rfx_strings[]= {"special|fileread|0|"}; char *deftextfile; int palette_list[2]; weed_plant_t *in_chantmpls[2]; weed_plant_t *out_chantmpls[2]; int flags,error; if (is_big_endian()) palette_list[0]=WEED_PALETTE_ARGB32; else palette_list[0]=WEED_PALETTE_BGRA32; palette_list[1]=WEED_PALETTE_END; in_chantmpls[0]=weed_channel_template_init("in channel 0",0,palette_list); in_chantmpls[1]=NULL; out_chantmpls[0]=weed_channel_template_init("out channel 0",WEED_CHANNEL_CAN_DO_INPLACE,palette_list); out_chantmpls[1]=NULL; init_unal(); // this section contains code // for configure fonts available num_fonts_available = 0; fonts_available = NULL; ctx = gdk_pango_context_get(); if (ctx) { PangoFontMap *pfm = pango_context_get_font_map(ctx); if (pfm) { int num = 0; PangoFontFamily **pff = NULL; pango_font_map_list_families(pfm, &pff, &num); if (num > 0) { // we should reserve num+1 for a final NULL pointer fonts_available = (char **)weed_malloc((num+1)*sizeof(char *)); if (fonts_available) { register int i; num_fonts_available = num; for (i = 0; i < num; ++i) { fonts_available[i] = strdup(pango_font_family_get_name(pff[i])); } // don't forget this thing fonts_available[num] = NULL; } } g_free(pff); } g_object_unref(ctx); } deftextfile=g_build_filename(g_get_home_dir(), "livestext.txt", NULL); in_params[P_TEXT]=weed_text_init("textfile","_Text file",deftextfile); gui=weed_parameter_template_get_gui(in_params[P_TEXT]); weed_set_int_value(gui,"maxchars",80); // for display only - fileread will override this flags=0; if (weed_plant_has_leaf(in_params[P_TEXT],"flags")) flags=weed_get_int_value(in_params[P_TEXT],"flags",&error); flags|=WEED_PARAMETER_REINIT_ON_VALUE_CHANGE; weed_set_int_value(in_params[P_TEXT],"flags",flags); in_params[P_MODE]=weed_string_list_init("mode","Effect _mode",0,modes); flags=0; if (weed_plant_has_leaf(in_params[P_MODE],"flags")) flags=weed_get_int_value(in_params[P_MODE],"flags",&error); flags|=WEED_PARAMETER_REINIT_ON_VALUE_CHANGE; weed_set_int_value(in_params[P_MODE],"flags",flags); in_params[P_END]=NULL; g_free(deftextfile); filter_class=weed_filter_class_init("puretext","Salsaman & Aleksej Penkov",1,0,&puretext_init,&puretext_process,NULL, in_chantmpls,out_chantmpls,in_params,NULL); gui=weed_filter_class_get_gui(filter_class); weed_set_string_value(gui,"layout_scheme","RFX"); weed_set_string_value(gui,"rfx_delim","|"); weed_set_string_array(gui,"rfx_strings",1,rfx_strings); weed_plugin_info_add_filter_class(plugin_info,filter_class); weed_set_int_value(plugin_info,"version",package_version); } return plugin_info; }
/* * Do all the bar display and register the events */ void gc_config_start () { GcomprisProperties *properties = gc_prop_get(); gint y_start = 0; gint x_start = 0; gint x_text_start = 0; gint y = 0; GooCanvasItem *item; /* Pause the board */ gc_board_pause(TRUE); if(rootitem) { gc_config_stop(); return; } gc_bar_hide(TRUE); rootitem = goo_canvas_group_new (goo_canvas_get_root_item(gc_get_canvas()), NULL); item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", "#DIALOG", "pointer-events", GOO_CANVAS_EVENTS_NONE, NULL); GooCanvasBounds bounds; goo_canvas_item_get_bounds(item, &bounds); x_start = bounds.x1; y_start = bounds.y1; y = bounds.y2 - 26; goo_canvas_text_new (rootitem, _("GCompris Configuration"), (gdouble) BOARDWIDTH/2, (gdouble) y_start + 40, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_title, "fill-color-rgba", gc_skin_color_title, NULL); pixmap_checked = "#CHECKED"; pixmap_unchecked = "#UNCHECKED"; pixmap_width = 30; x_start += 60; x_text_start = x_start + 80; //-------------------------------------------------- // Locale y_start += 105; display_previous_next(x_start, y_start, "locale_previous", "locale_next"); y_flag_start = y_start - pixmap_width/2; /* A repeat icon to reset the selection */ item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", "#REPEAT", NULL); goo_canvas_item_get_bounds(item, &bounds); double zoom = 0.50; goo_canvas_item_scale(item, zoom, zoom); goo_canvas_item_translate(item, (-1 * bounds.x1 + x_start - 100) * zoom, (-1 * bounds.y1 + y_start - 145) * zoom); g_signal_connect(item, "button_press_event", (GCallback) item_event_ok, "locale_reset"); gc_item_focus_init(item, NULL); /* * The current locale is the one found in the config file */ current_locale = properties->locale; set_locale_flag(current_locale); item_locale_text = goo_canvas_text_new (rootitem, gc_locale_get_name(current_locale), (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_content, NULL); // Fullscreen / Window y_start += Y_GAP; item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", (properties->fullscreen ? pixmap_checked : pixmap_unchecked), NULL); SET_ITEM_LOCATION(item, x_start, y_start - pixmap_width/2); g_signal_connect(item, "button_press_event", (GCallback) item_event_ok, "fullscreen"); gc_item_focus_init(item, NULL); goo_canvas_text_new (rootitem, _("Fullscreen"), (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_content, NULL); // Rememberlevel y_start += Y_GAP; item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", (properties->rememberlevel ? pixmap_checked : pixmap_unchecked), NULL); SET_ITEM_LOCATION(item, x_start, y_start - pixmap_width/2); g_signal_connect(item, "button_press_event", (GCallback) item_event_ok, "rememberlevel"); gc_item_focus_init(item, NULL); goo_canvas_text_new (rootitem, _("Remember level for default user"), (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_content, NULL); // Music y_start += Y_GAP; item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", (properties->music ? pixmap_checked : pixmap_unchecked), NULL); SET_ITEM_LOCATION(item, x_start, y_start - pixmap_width/2); g_signal_connect(item, "button_press_event", (GCallback) item_event_ok, "music"); gc_item_focus_init(item, NULL); goo_canvas_text_new (rootitem, _("Music"), (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_content, NULL); // Effect y_start += Y_GAP; item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", (properties->fx ? pixmap_checked : pixmap_unchecked), NULL); SET_ITEM_LOCATION(item, x_start, y_start - pixmap_width/2); g_signal_connect(item, "button_press_event", (GCallback) item_event_ok, "effect"); gc_item_focus_init(item, NULL); goo_canvas_text_new (rootitem, _("Effect"), (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_content, NULL); // Zoom y_start += Y_GAP; item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", (properties->zoom ? pixmap_checked : pixmap_unchecked), NULL); SET_ITEM_LOCATION(item, x_start, y_start - pixmap_width/2); g_signal_connect(item, "button_press_event", (GCallback) item_event_ok, "zoom"); gc_item_focus_init(item, NULL); goo_canvas_text_new (rootitem, _("Zoom"), (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_content, NULL); // Timer y_start += Y_GAP; display_previous_next(x_start, y_start, "timer_previous", "timer_next"); item_timer_text = goo_canvas_text_new (rootitem, gettext(timername[properties->timer]), (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_content, NULL); // Font y_start += Y_GAP; { int i; PangoFontFamily ** families; int n_families; PangoFontMap * fontmap; const gchar *current_familly_name = NULL; fontmap = pango_cairo_font_map_get_default(); pango_font_map_list_families (fontmap, & families, & n_families); for (i = 0; i < n_families; i++) { PangoFontFamily * family = families[i]; const gchar * family_name; family_name = pango_font_family_get_name (family); /* Skip font to exclude */ guint j = 0; gboolean exclude = FALSE; while(excluded_fonts[j] != NULL) { if( !g_ascii_strncasecmp(excluded_fonts[j], family_name, strlen(excluded_fonts[j])) ) { exclude = TRUE; break; } j++; } if(exclude) continue; fontlist = g_list_insert_sorted (fontlist, (gpointer)family_name, (GCompareFunc)strcmp); if(!strcmp(properties->fontface, family_name)) current_familly_name = family_name; } g_free (families); current_font_index = font_index = g_list_index(fontlist, current_familly_name); display_previous_next(x_start, y_start, "font_previous", "font_next"); /* A repeat icon to reset the selection */ item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", "#REPEAT", NULL); goo_canvas_item_get_bounds(item, &bounds); double zoom = 0.50; goo_canvas_item_scale(item, zoom, zoom); goo_canvas_item_translate(item, (-1 * bounds.x1 + x_start - 100) * zoom, (-1 * bounds.y1 + y_start + 650) * zoom); g_signal_connect(item, "button_press_event", (GCallback) item_event_ok, "fontface_reset"); gc_item_focus_init(item, NULL); gchar *first_font_name = g_strdup_printf(_("Font: %s"), (char *)g_list_nth_data(fontlist, font_index)); item_font_text = goo_canvas_text_new (rootitem, first_font_name, (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_content, NULL); } // Difficulty Filter y_start += Y_GAP; stars_group_x = x_start + 45; stars_group_y = y_start - 25; gchar *text = g_strdup_printf("<i>%s</i>", gettext(filtername)); item_filter_text = goo_canvas_text_new (rootitem, text, x_text_start, y_start, 400, GTK_ANCHOR_WEST, "use-markup", TRUE, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_content, NULL); g_free(text); // OK gc_util_button_text_svg(rootitem, BOARDWIDTH * 0.5, y, "#BUTTON_TEXT", _("OK"), (GCallback) item_event_ok, "ok"); is_displayed = TRUE; }