Ejemplo n.º 1
0
static void
gucharmap_charmap_set_font_desc_internal (GucharmapCharmap *charmap, 
                                          PangoFontDescription *font_desc /* adopting */,
                                          gboolean in_notification)
{
  GucharmapCharmapPrivate *priv = charmap->priv;
  GObject *object = G_OBJECT (charmap);
  gboolean equal;

  g_object_freeze_notify (object);

  equal = priv->font_desc != NULL &&
          pango_font_description_equal (priv->font_desc, font_desc);

  if (priv->font_desc)
    pango_font_description_free (priv->font_desc);

  priv->font_desc = font_desc; /* adopted */

  if (!in_notification)
    gucharmap_chartable_set_font_desc (priv->chartable, font_desc);

  if (gtk_widget_get_style (GTK_WIDGET (priv->details_view)))
    gucharmap_charmap_update_text_tags (charmap);

  if (!equal)
    g_object_notify (G_OBJECT (charmap), "font-desc");

  g_object_thaw_notify (object);
}
Ejemplo n.º 2
0
static void
font_changed (GObject *object, GParamSpec *pspec, gpointer data)
{
  GtkFontChooser *fb = GTK_FONT_CHOOSER (data);
  GValue val = G_VALUE_INIT;
  const PangoFontDescription *font_desc;
  PangoFontDescription *fb_font_desc;

  g_value_init (&val, PANGO_TYPE_FONT_DESCRIPTION);
  get_property_value (object, pspec, &val);

  font_desc = g_value_get_boxed (&val);
  fb_font_desc = gtk_font_chooser_get_font_desc (fb);

  if (font_desc == NULL ||
      (fb_font_desc != NULL &&
       !pango_font_description_equal (fb_font_desc, font_desc)))
    {
      block_controller (G_OBJECT (fb));
      gtk_font_chooser_set_font_desc (fb, font_desc);
      unblock_controller (G_OBJECT (fb));
    }

  g_value_unset (&val);
  pango_font_description_free (fb_font_desc);
}
Ejemplo n.º 3
0
JNIEXPORT jboolean JNICALL
Java_org_gnome_pango_PangoFontDescription_pango_1font_1description_1equal
(
	JNIEnv* env,
	jclass cls,
	jlong _self,
	jlong _desc2
)
{
	gboolean result;
	jboolean _result;
	PangoFontDescription* self;
	const PangoFontDescription* desc2;

	// convert parameter self
	self = (PangoFontDescription*) _self;

	// convert parameter desc2
	desc2 = (const PangoFontDescription*) _desc2;

	// call function
	result = pango_font_description_equal(self, desc2);

	// cleanup parameter self

	// cleanup parameter desc2

	// translate return value to JNI type
	_result = (jboolean) result;

	// and finally
	return _result;
}
bool FontPlatformData::operator==(const FontPlatformData& other) const
{
    if (m_font == other.m_font)
        return true;
    if (m_font == 0 || m_font == reinterpret_cast<PangoFont*>(-1)
        || other.m_font == 0 || other.m_font == reinterpret_cast<PangoFont*>(-1))
        return false;
    PangoFontDescription* thisDesc = pango_font_describe(m_font);
    PangoFontDescription* otherDesc = pango_font_describe(other.m_font);
    bool result = pango_font_description_equal(thisDesc, otherDesc);
    pango_font_description_free(otherDesc);
    pango_font_description_free(thisDesc);
    return result;
}
Ejemplo n.º 5
0
char* iupgtkFindPangoFontDesc(PangoFontDescription* fontdesc)
{
  int i, count = iupArrayCount(gtk_fonts);
  IgtkFont* fonts = (IgtkFont*)iupArrayGetData(gtk_fonts);

  /* Check if the standardfont already exists in cache */
  for (i = 0; i < count; i++)
  {
    if (pango_font_description_equal(fontdesc, fonts[i].fontdesc))
      return fonts[i].standardfont;
  }

  return NULL;
}
Ejemplo n.º 6
0
/**
 * st_theme_context_set_font:
 * @context: a #StThemeContext
 * @font: the default font for theme context
 *
 * Sets the default font for the theme context. This is the font that
 * is inherited by the root node of the tree of theme nodes. If the
 * font is not overriden, then this font will be used. If the font is
 * partially modified (for example, with 'font-size: 110%', then that
 * modification is based on this font.
 */
void
st_theme_context_set_font (StThemeContext             *context,
                           const PangoFontDescription *font)
{
  g_return_if_fail (ST_IS_THEME_CONTEXT (context));
  g_return_if_fail (font != NULL);

  if (context->font == font ||
      pango_font_description_equal (context->font, font))
    return;

  pango_font_description_free (context->font);
  context->font = pango_font_description_copy (font);
  st_theme_context_changed (context);
}
Ejemplo n.º 7
0
/**
 * gucharmap_charmap_set_font_desc:
 * @charmap:
 * @font_desc: a #PangoFontDescription
 *
 * Sets @font_desc as the font to use to display the character table.
 */
void
gucharmap_charmap_set_font_desc (GucharmapCharmap *charmap,
                                 PangoFontDescription *font_desc)
{
  GucharmapCharmapPrivate *priv;

  g_return_if_fail (GUCHARMAP_IS_CHARMAP (charmap));
  g_return_if_fail (font_desc != NULL);

  priv = charmap->priv;
  if (priv->font_desc &&
      pango_font_description_equal (font_desc, priv->font_desc))
    return;

  gucharmap_charmap_set_font_desc_internal (charmap,
                                            pango_font_description_copy (font_desc),
                                            FALSE);
}
static int
values_equal (GParamSpec *pspec,
              const GValue *va,
              const GValue *vb)
{
	/* g_param_values_cmp isn't good enough for some types, since e.g.
	 * it compares colours and font descriptions by pointer value, not
	 * with the correct compare functions. Providing extra
	 * PangoParamSpecFontDescription and GdkParamSpecColor wouldn't
	 * have fixed this either, since it's unclear how to _order_ them.
	 * Luckily we only need to check them for equality here.
	 */

	if (g_param_values_cmp (pspec, va, vb) == 0)
		return TRUE;

	if (G_PARAM_SPEC_VALUE_TYPE (pspec) == GDK_TYPE_COLOR)
		return gdk_color_equal (g_value_get_boxed (va), g_value_get_boxed (vb));

	if (G_PARAM_SPEC_VALUE_TYPE (pspec) == PANGO_TYPE_FONT_DESCRIPTION)
		return pango_font_description_equal (g_value_get_boxed (va), g_value_get_boxed (vb));

	if (G_IS_PARAM_SPEC_VALUE_ARRAY (pspec) &&
	        G_PARAM_SPEC_VALUE_TYPE (G_PARAM_SPEC_VALUE_ARRAY (pspec)->element_spec) == GDK_TYPE_COLOR)
	{
		GValueArray *ara, *arb;
		guint i;

		ara = g_value_get_boxed (va);
		arb = g_value_get_boxed (vb);

		if (!ara || !arb || ara->n_values != arb->n_values)
			return FALSE;

		for (i = 0; i < ara->n_values; ++i)
			if (!gdk_color_equal (g_value_get_boxed (g_value_array_get_nth (ara, i)),
			                      g_value_get_boxed (g_value_array_get_nth (arb, i))))
				return FALSE;

		return TRUE;
	}

	return FALSE;
}
Ejemplo n.º 9
0
/* static */
bool FontUtils::IsAvailableFont(const char* input_query_desc) {
  string query_desc(input_query_desc);
  if (PANGO_VERSION <= 12005) {
    // Strip commas and any ' Medium' substring in the name.
    query_desc.erase(std::remove(query_desc.begin(), query_desc.end(), ','),
                     query_desc.end());
    const string kMediumStr = " Medium";
    std::size_t found = query_desc.find(kMediumStr);
    if (found != std::string::npos) {
      query_desc.erase(found, kMediumStr.length());
    }
  }

  PangoFontDescription *desc = pango_font_description_from_string(
      query_desc.c_str());
  PangoFont* selected_font = NULL;
  {
    InitFontconfig();
    PangoFontMap* font_map = pango_cairo_font_map_get_default();
    PangoContext* context = pango_context_new();
    pango_context_set_font_map(context, font_map);
    {
      DISABLE_HEAP_LEAK_CHECK;
      selected_font = pango_font_map_load_font(font_map, context, desc);
    }
    g_object_unref(context);
  }
  PangoFontDescription* selected_desc = pango_font_describe(selected_font);

  bool equal = pango_font_description_equal(desc, selected_desc);
  tlog(3, "query weight = %d \t selected weight =%d\n",
       pango_font_description_get_weight(desc),
       pango_font_description_get_weight(selected_desc));

  char* selected_desc_str = pango_font_description_to_string(selected_desc);
  tlog(2, "query_desc: '%s' Selected: 's'\n", query_desc.c_str(),
       selected_desc_str);

  g_free(selected_desc_str);
  pango_font_description_free(selected_desc);
  pango_font_description_free(desc);
  return equal;
}
Ejemplo n.º 10
0
static void
gnm_font_button_take_font_desc (GnmFontButton        *font_button,
                                PangoFontDescription *font_desc)
{
  GnmFontButtonPrivate *priv = font_button->priv;
  GObject *object = G_OBJECT (font_button);

  if (priv->font_desc && font_desc &&
      pango_font_description_equal (priv->font_desc, font_desc))
    {
      pango_font_description_free (font_desc);
      return;
    }

  g_object_freeze_notify (object);

  clear_font_data (font_button);

  if (font_desc)
    priv->font_desc = font_desc; /* adopted */
  else
    priv->font_desc = pango_font_description_from_string (_("Sans 12"));

  if (pango_font_description_get_size_is_absolute (priv->font_desc))
    priv->font_size = pango_font_description_get_size (priv->font_desc);
  else
    priv->font_size = pango_font_description_get_size (priv->font_desc) / PANGO_SCALE;

  gnm_font_button_update_font_data (font_button);
  gnm_font_button_update_font_info (font_button);

  if (priv->font_dialog)
    gtk_font_chooser_set_font_desc (GTK_FONT_CHOOSER (priv->font_dialog),
                                    priv->font_desc);

  g_object_notify (G_OBJECT (font_button), "font");
  g_object_notify (G_OBJECT (font_button), "font-desc");
  g_object_notify (G_OBJECT (font_button), "font-name");

  g_object_thaw_notify (object);
}
Ejemplo n.º 11
0
static gboolean
titlebar_handler (GVariant *value,
                  gpointer *result,
                  gpointer  data)
{
    PangoFontDescription *desc;
    const gchar *string_value;

    *result = NULL; /* ignored */
    string_value = g_variant_get_string (value, NULL);
    desc = pango_font_description_from_string (string_value);

    if (desc == NULL)
    {
        meta_warning (_("Could not parse font description "
                        "\"%s\" from GSettings key %s\n"),
                      string_value ? string_value : "(null)",
                      KEY_TITLEBAR_FONT);

        return FALSE;
    }

    /* Is the new description the same as the old? */
    if (titlebar_font &&
            pango_font_description_equal (desc, titlebar_font))
    {
        pango_font_description_free (desc);
    }
    else
    {
        if (titlebar_font)
            pango_font_description_free (titlebar_font);

        titlebar_font = desc;
        queue_changed (META_PREF_TITLEBAR_FONT);
    }

    return TRUE;
}
Ejemplo n.º 12
0
void
_gtk_modifier_style_set_font (GtkModifierStyle           *style,
                              const PangoFontDescription *font_desc)
{
  GtkModifierStylePrivate *priv;
  PangoFontDescription *old_font;

  g_return_if_fail (GTK_IS_MODIFIER_STYLE (style));

  priv = style->priv;
  gtk_style_properties_get (priv->style, 0,
                            "font", &old_font,
                            NULL);

  if ((!old_font && !font_desc) ||
      (old_font && font_desc &&
       pango_font_description_equal (old_font, font_desc)))
    {
      if (old_font)
        pango_font_description_free (old_font);

      return;
    }

  if (font_desc)
    gtk_style_properties_set (priv->style, 0,
                              "font", font_desc,
                              NULL);
  else
    gtk_style_properties_unset_property (priv->style, "font", 0);

  if (old_font)
    pango_font_description_free (old_font);

  g_signal_emit (style, signals[CHANGED], 0);
}
Ejemplo n.º 13
0
static int gtk_compare_fonts(GtkStyle* psOne, GtkStyle* psTwo)
{
	return pango_font_description_equal(psOne->font_desc, psTwo->font_desc);
}