Пример #1
0
/* make sure the font list is valid */
static void
ensure_font_list (FontViewModel *self)
{
    FcPattern *pat;
    FcObjectSet *os;
    gint i;
    FcChar8 *file;
    gchar *font_name, *collation_key;
    GdkPixbuf *pix;

    if (self->priv->font_list) {
            FcFontSetDestroy (self->priv->font_list);
            self->priv->font_list = NULL;
    }

    gtk_list_store_clear (GTK_LIST_STORE (self));

    /* always reinitialize the font database */
    if (!FcInitReinitialize())
        return;

    pat = FcPatternCreate ();
    os = FcObjectSetBuild (FC_FILE, FC_FAMILY, FC_WEIGHT, FC_SLANT, NULL);

    self->priv->font_list = FcFontList (NULL, pat, os);

    FcPatternDestroy (pat);
    FcObjectSetDestroy (os);

    if (!self->priv->font_list)
        return;

    for (i = 0; i < self->priv->font_list->nfont; i++) {
	FcPatternGetString (self->priv->font_list->fonts[i], FC_FILE, 0, &file);
        font_name = font_utils_get_font_name_for_file (self->priv->library, (const gchar *) file);

        if (!font_name)
            continue;

        pix = get_fallback_icon ();
        collation_key = g_utf8_collate_key (font_name, -1);

        gtk_list_store_insert_with_values (GTK_LIST_STORE (self), NULL, -1,
                                           COLUMN_NAME, font_name,
                                           COLUMN_POINTER, self->priv->font_list->fonts[i],
                                           COLUMN_PATH, file,
                                           COLUMN_ICON, pix,
                                           COLUMN_COLLATION_KEY, collation_key,
                                           -1);

        ensure_thumbnail (self, (const gchar *) file);

        g_free (font_name);
        g_free (collation_key);
        g_object_unref (pix);
    }
}
Пример #2
0
void
gimp_fonts_reset (Gimp *gimp)
{
  g_return_if_fail (GIMP_IS_GIMP (gimp));

  if (gimp->no_fonts)
    return;

  /* Reinit the library with defaults. */
  FcInitReinitialize ();
}
Пример #3
0
static void
settings_update_fontmap (ClutterSettings *self,
                         guint            stamp)
{
  if (self->backend == NULL)
    return;

#ifdef HAVE_PANGO_FT2
  CLUTTER_NOTE (BACKEND, "Update fontmaps (stamp: %d)", stamp);

  if (self->last_fontconfig_timestamp != stamp)
    {
      ClutterMainContext *context;
      gboolean update_needed = FALSE;

      context = _clutter_context_get_default ();

      /* If there is no font map yet then we don't need to do anything
       * because the config for fontconfig will be read when it is
       * created */
      if (context->font_map)
        {
          PangoFontMap *fontmap = PANGO_FONT_MAP (context->font_map);

          if (PANGO_IS_FC_FONT_MAP (fontmap) &&
              !FcConfigUptoDate (NULL))
            {
              pango_fc_font_map_cache_clear (PANGO_FC_FONT_MAP (fontmap));

              if (FcInitReinitialize ())
                update_needed = TRUE;
            }
        }

      self->last_fontconfig_timestamp = stamp;

      if (update_needed)
        g_signal_emit_by_name (self->backend, "font-changed");
    }
#endif /* HAVE_PANGO_FT2 */
}
Пример #4
0
static gboolean
xfce_xsettings_helper_fc_notify (gpointer data)
{
    XfceXSettingsHelper *helper = XFCE_XSETTINGS_HELPER (data);
    XfceXSetting        *setting;

    helper->fc_notify_timeout_id = 0;

    /* check if the font config setup changed */
    if (!FcConfigUptoDate (NULL) && FcInitReinitialize ())
    {
        /* stop the monitors */
        xfce_xsettings_helper_fc_free (helper);

        setting = g_hash_table_lookup (helper->settings, FC_PROPERTY);
        if (setting == NULL)
        {
            /* create new setting */
            setting = g_slice_new0 (XfceXSetting);
            setting->value = g_new0 (GValue, 1);
            g_value_init (setting->value, G_TYPE_INT);
            g_hash_table_insert (helper->settings, g_strdup (FC_PROPERTY), setting);
        }

        /* update setting */
        setting->last_change_serial = helper->serial;
        g_value_set_int (setting->value, time (NULL));

        xfsettings_dbg (XFSD_DEBUG_FONTCONFIG, "timestamp updated (time=%d)",
                        g_value_get_int (setting->value));

        /* schedule xsettings update */
        if (helper->notify_idle_id == 0)
            helper->notify_idle_id = g_idle_add (xfce_xsettings_helper_notify_idle, helper);

        /* restart monitoring */
        helper->fc_init_id = g_idle_add (xfce_xsettings_helper_fc_init, helper);
    }

    return FALSE;
}
Пример #5
0
FcBool
FcInitBringUptoDate (void)
{
    FcConfig	*config = FcConfigGetCurrent ();
    time_t	now;

    /*
     * rescanInterval == 0 disables automatic up to date
     */
    if (config->rescanInterval == 0)
	return FcTrue;
    /*
     * Check no more often than rescanInterval seconds
     */
    now = time (0);
    if (config->rescanTime + config->rescanInterval - now > 0)
	return FcTrue;
    /*
     * If up to date, don't reload configuration
     */
    if (FcConfigUptoDate (0))
	return FcTrue;
    return FcInitReinitialize ();
}
Пример #6
0
gboolean
FcCacheUpdate (void) {
    FcConfigDestroy(FcConfigGetCurrent());
    return !FcConfigUptoDate(NULL) && FcInitReinitialize();
}
Пример #7
0
void QFontconfigDatabase::populateFontDatabase()
{
    FcInitReinitialize();
    FcFontSet  *fonts;

    {
        FcObjectSet *os = FcObjectSetCreate();
        FcPattern *pattern = FcPatternCreate();
        const char *properties [] = {
            FC_FAMILY, FC_STYLE, FC_WEIGHT, FC_SLANT,
            FC_SPACING, FC_FILE, FC_INDEX,
            FC_LANG, FC_CHARSET, FC_FOUNDRY, FC_SCALABLE, FC_PIXEL_SIZE,
            FC_WIDTH,
#if FC_VERSION >= 20297
            FC_CAPABILITY,
#endif
            (const char *)0
        };
        const char **p = properties;
        while (*p) {
            FcObjectSetAdd(os, *p);
            ++p;
        }
        fonts = FcFontList(0, pattern, os);
        FcObjectSetDestroy(os);
        FcPatternDestroy(pattern);
    }

    for (int i = 0; i < fonts->nfont; i++)
        populateFromPattern(fonts->fonts[i]);

    FcFontSetDestroy (fonts);

    struct FcDefaultFont {
        const char *qtname;
        const char *rawname;
        bool fixed;
    };
    const FcDefaultFont defaults[] = {
        { "Serif", "serif", false },
        { "Sans Serif", "sans-serif", false },
        { "Monospace", "monospace", true },
        { 0, 0, false }
    };
    const FcDefaultFont *f = defaults;
    // aliases only make sense for 'common', not for any of the specials
    QSupportedWritingSystems ws;
    ws.setSupported(QFontDatabase::Latin);

    while (f->qtname) {
        QString familyQtName = QString::fromLatin1(f->qtname);
        registerFont(familyQtName,QString(),QString(),QFont::Normal,QFont::StyleNormal,QFont::Unstretched,true,true,0,f->fixed,ws,0);
        registerFont(familyQtName,QString(),QString(),QFont::Normal,QFont::StyleItalic,QFont::Unstretched,true,true,0,f->fixed,ws,0);
        registerFont(familyQtName,QString(),QString(),QFont::Normal,QFont::StyleOblique,QFont::Unstretched,true,true,0,f->fixed,ws,0);
        ++f;
    }

    //Lighthouse has very lazy population of the font db. We want it to be initialized when
    //QApplication is constructed, so that the population procedure can do something like this to
    //set the default font
//    const FcDefaultFont *s = defaults;
//    QFont font("Sans Serif");
//    font.setPointSize(9);
//    QApplication::setFont(font);
}
gboolean
fontconfig_cache_update (void)
{
        return !FcConfigUptoDate (NULL) && FcInitReinitialize ();
}