예제 #1
0
JNIEXPORT void JNICALL
Java_org_gnome_pango_PangoFontDescription_pango_1font_1description_1merge
(
	JNIEnv* env,
	jclass cls,
	jlong _self,
	jlong _descToMerge,
	jboolean _replaceExisting
)
{
	PangoFontDescription* self;
	const PangoFontDescription* descToMerge;
	gboolean replaceExisting;

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

	// convert parameter descToMerge
	descToMerge = (const PangoFontDescription*) _descToMerge;

	// convert parameter replaceExisting
	replaceExisting = (gboolean) _replaceExisting;

	// call function
	pango_font_description_merge(self, descToMerge, replaceExisting);

	// cleanup parameter self

	// cleanup parameter descToMerge

	// cleanup parameter replaceExisting
}
예제 #2
0
void set_label_font_size(GtkWidget *label, int size)
{
  if (! GTK_IS_WIDGET(label))
    return;

  PangoContext *pango_context = gtk_widget_get_pango_context (label);
  PangoFontDescription* font=pango_context_get_font_description (pango_context);
#if 0
  pango_font_description_set_family(font, hime_font_name);
  pango_font_description_set_size(font, PANGO_SCALE * size);
#else
  char tt[256];
  sprintf(tt, "%s %d", hime_font_name, size);
  PangoFontDescription* nfont = pango_font_description_from_string(tt);
  pango_font_description_merge(font, nfont, TRUE);
  pango_font_description_free(nfont);
#endif
  gtk_widget_override_font(label, font);
}
예제 #3
0
void gglk_text_init_tags(GglkText *tb) 
{
    PangoContext *context;
    PangoFontMetrics *metrics;
    PangoFontDescription *font_desc = NULL;
    GtkTextTag *tag;
    
    tb->buffer = gtk_text_view_get_buffer(&tb->view);
    gtk_text_buffer_get_end_iter(tb->buffer, &tb->iter);

    tb->startedit=gtk_text_buffer_create_mark(tb->buffer,NULL,&tb->iter,TRUE);
    tb->endedit  =gtk_text_buffer_create_mark(tb->buffer,NULL,&tb->iter,FALSE);
    tb->scrollmark=gtk_text_buffer_create_mark(tb->buffer,NULL,&tb->iter,TRUE);
    tb->endmark  =gtk_text_buffer_create_mark(tb->buffer,NULL,&tb->iter,FALSE);
    tb->hypermark=gtk_text_buffer_create_mark(tb->buffer,NULL,&tb->iter,TRUE);

    tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(tb->buffer),
				    "Normal");
    if(!tag) return;

    gglk_text_set_style(tb, tag);

    /* Measure default font size */
    g_object_get(G_OBJECT(tag), "font-desc", &font_desc, NULL);

    font_desc = pango_font_description_copy(font_desc);
    pango_font_description_merge(font_desc,
				 GTK_WIDGET(tb)->style->font_desc,FALSE);

    context = gtk_widget_get_pango_context(GTK_WIDGET(tb));
    metrics = pango_context_get_metrics(context,
					font_desc,
					pango_context_get_language(context));

    pango_font_description_free(font_desc);

    tb->xunits = PANGO_PIXELS(pango_font_metrics_get_approximate_digit_width(
				  metrics));
    tb->yunits = PANGO_PIXELS(pango_font_metrics_get_ascent(metrics) +
			      pango_font_metrics_get_descent(metrics));
    pango_font_metrics_unref(metrics);
}
예제 #4
0
파일: gtktextattributes.c 프로젝트: BYC/gtk
void
_gtk_text_attributes_fill_from_tags (GtkTextAttributes *dest,
                                     GtkTextTag**       tags,
                                     guint              n_tags)
{
  guint n = 0;

  guint left_margin_accumulative = 0;
  guint right_margin_accumulative = 0;

  while (n < n_tags)
    {
      GtkTextTag *tag = tags[n];
      GtkTextAttributes *vals = tag->priv->values;

      g_assert (tag->priv->table != NULL);
      if (n > 0)
        g_assert (tags[n]->priv->priority > tags[n-1]->priv->priority);

      if (tag->priv->bg_color_set)
        {
          dest->appearance.bg_color = vals->appearance.bg_color;

          dest->appearance.draw_bg = TRUE;
        }
      if (tag->priv->fg_color_set)
        dest->appearance.fg_color = vals->appearance.fg_color;

      if (tag->priv->pg_bg_color_set)
        {
          dest->pg_bg_color = gdk_color_copy (vals->pg_bg_color);
        }

      if (vals->font)
	{
	  if (dest->font)
	    pango_font_description_merge (dest->font, vals->font, TRUE);
	  else
	    dest->font = pango_font_description_copy (vals->font);
	}

      /* multiply all the scales together to get a composite */
      if (tag->priv->scale_set)
        dest->font_scale *= vals->font_scale;

      if (tag->priv->justification_set)
        dest->justification = vals->justification;

      if (vals->direction != GTK_TEXT_DIR_NONE)
        dest->direction = vals->direction;

      if (tag->priv->left_margin_set)
        {
          if (tag->priv->accumulative_margin)
            left_margin_accumulative += vals->left_margin;
          else
            dest->left_margin = vals->left_margin;
        }

      if (tag->priv->indent_set)
        dest->indent = vals->indent;

      if (tag->priv->rise_set)
        dest->appearance.rise = vals->appearance.rise;

      if (tag->priv->right_margin_set)
        {
          if (tag->priv->accumulative_margin)
            right_margin_accumulative += vals->right_margin;
          else
            dest->right_margin = vals->right_margin;
        }

      if (tag->priv->pixels_above_lines_set)
        dest->pixels_above_lines = vals->pixels_above_lines;

      if (tag->priv->pixels_below_lines_set)
        dest->pixels_below_lines = vals->pixels_below_lines;

      if (tag->priv->pixels_inside_wrap_set)
        dest->pixels_inside_wrap = vals->pixels_inside_wrap;

      if (tag->priv->tabs_set)
        {
          if (dest->tabs)
            pango_tab_array_free (dest->tabs);
          dest->tabs = pango_tab_array_copy (vals->tabs);
        }

      if (tag->priv->wrap_mode_set)
        dest->wrap_mode = vals->wrap_mode;

      if (tag->priv->underline_set)
        dest->appearance.underline = vals->appearance.underline;

      if (tag->priv->strikethrough_set)
        dest->appearance.strikethrough = vals->appearance.strikethrough;

      if (tag->priv->invisible_set)
        dest->invisible = vals->invisible;

      if (tag->priv->editable_set)
        dest->editable = vals->editable;

      if (tag->priv->bg_full_height_set)
        dest->bg_full_height = vals->bg_full_height;

      if (tag->priv->language_set)
	dest->language = vals->language;

      ++n;
    }

  dest->left_margin += left_margin_accumulative;
  dest->right_margin += right_margin_accumulative;
}
예제 #5
0
static PangoLayout*
create_layout(HippoCanvasText *text,
              int              allocation_width)
{
    HippoCanvasBox *box = HIPPO_CANVAS_BOX(text);
    PangoLayout *layout;
    HippoCanvasStyle *style = hippo_canvas_context_get_style(HIPPO_CANVAS_CONTEXT(text));

    g_return_val_if_fail(box->context != NULL, NULL);
    
    layout = hippo_canvas_context_create_layout(box->context);

    if (box->font_desc) {
        PangoFontDescription *merged = pango_font_description_copy(hippo_canvas_style_get_font(style));
        pango_font_description_merge(merged, box->font_desc, TRUE);
        pango_layout_set_font_description(layout, merged);
        pango_font_description_free(merged);
    } else {
        pango_layout_set_font_description(layout, hippo_canvas_style_get_font(style));
    }
    
    {
        PangoAttrList *attrs;
        HippoTextDecoration decoration = hippo_canvas_style_get_text_decoration(style);
        
        if (text->attributes)
            attrs = pango_attr_list_copy(text->attributes);
        else
            attrs = pango_attr_list_new();

        
        if (ABS(1.0 - text->font_scale) > .000001) {
            PangoAttribute *attr = pango_attr_scale_new(text->font_scale);
            attr->start_index = 0;
            attr->end_index = G_MAXUINT;
            pango_attr_list_insert(attrs, attr);
        }

        if ((decoration & HIPPO_TEXT_DECORATION_UNDERLINE) != 0) {
            PangoAttribute *attr = pango_attr_underline_new(TRUE);
            attr->start_index = 0;
            attr->end_index = G_MAXUINT;
            pango_attr_list_insert(attrs, attr);
        }

        if ((decoration & HIPPO_TEXT_DECORATION_LINE_THROUGH) != 0) {
            PangoAttribute *attr = pango_attr_strikethrough_new(TRUE);
            attr->start_index = 0;
            attr->end_index = G_MAXUINT;
            pango_attr_list_insert(attrs, attr);
        }

        pango_layout_set_attributes(layout, attrs);
        pango_attr_list_unref(attrs);
    }
    
    if (text->text != NULL) {
        pango_layout_set_text(layout, text->text, -1);
    }

    if (allocation_width >= 0) {
        int layout_width, layout_height;
        pango_layout_get_size(layout, &layout_width, &layout_height);
        layout_width /= PANGO_SCALE;
        layout_height /= PANGO_SCALE;
        
        /* Force layout smaller if required, but we don't want to make
         * the layout _wider_ because it breaks alignment, so only do
         * this if required.
         */
        if (layout_width > allocation_width) {
            pango_layout_set_width(layout, allocation_width * PANGO_SCALE);

            /* If we set ellipsize, then it overrides wrapping. If we get
             * too-small allocation for HIPPO_CANVAS_SIZE_FULL_WIDTH, then
             * we want to ellipsize instead of wrapping.
             */
            if (text->size_mode == HIPPO_CANVAS_SIZE_WRAP_WORD) {
                pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE);
            } else {
                pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
            }

            /* For now if we say ellipsize end, we always just want one line.
             * Maybe this should be an orthogonal property?
             */
            if (text->size_mode == HIPPO_CANVAS_SIZE_ELLIPSIZE_END) {
                pango_layout_set_single_paragraph_mode(layout, TRUE);

                /* Pango's line separator character in this case is ugly, so we
                 * fix it. Not a very efficient approach, but oh well.
                 */
                if (text->text != NULL) {
                    char *new_text = remove_newlines(text->text);
                    /* avoid making the layout recompute everything
                     * if we didn't have newlines anyhow
                     */
                    if (strcmp(text->text, new_text) != 0) {
                        pango_layout_set_text(layout, new_text, -1);
                    }
                    g_free(new_text);
                }
            }
        }
    }
    
    return layout;
}
static void
terminal_profile_set_property (GObject *object,
                               guint prop_id,
                               const GValue *value,
                               GParamSpec *pspec)
{
	TerminalProfile *profile = TERMINAL_PROFILE (object);
	TerminalProfilePrivate *priv = profile->priv;
	GValue *prop_value;

	if (prop_id == 0 || prop_id >= LAST_PROP)
	{
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
		return;
	}

	prop_value = g_value_array_get_nth (priv->properties, prop_id);

	/* Preprocessing */
	switch (prop_id)
	{
#if 0
	case PROP_FONT:
	{
		PangoFontDescription *font_desc, *new_font_desc;

		font_desc = g_value_get_boxed (prop_value);
		new_font_desc = g_value_get_boxed (value);

		if (font_desc && new_font_desc)
		{
			/* Merge in case the new string isn't complete enough to load a font */
			pango_font_description_merge (font_desc, new_font_desc, TRUE);
			pango_font_description_free (new_font_desc);
			break;
		}

		/* fall-through */
	}
#endif
	default:
		g_value_copy (value, prop_value);
		break;
	}

	/* Postprocessing */
	switch (prop_id)
	{
	case PROP_NAME:
	{
		const char *name = g_value_get_string (value);

		g_assert (name != NULL);
		priv->profile_dir = g_strdup (name);
		if (priv->settings != NULL) {
			g_signal_handlers_disconnect_by_func (priv->settings,
							      G_CALLBACK(terminal_profile_gsettings_notify_cb),
							      profile);
			g_object_unref (priv->settings);
			priv->settings = g_settings_new_with_path (CONF_PROFILE_SCHEMA,
						g_strconcat (CONF_PROFILE_PREFIX, priv->profile_dir, "/", NULL));
			g_signal_connect (priv->settings,
					  g_strconcat("changed::", priv->profile_dir, "/", NULL),
						      G_CALLBACK(terminal_profile_gsettings_notify_cb),
					  profile);
		}
		break;
	}

	case PROP_BACKGROUND_IMAGE_FILE:
		/* Clear the cached image */
		g_value_set_object (g_value_array_get_nth (priv->properties, PROP_BACKGROUND_IMAGE), NULL);
		priv->background_load_failed = FALSE;
		g_object_notify (object, TERMINAL_PROFILE_BACKGROUND_IMAGE);
		break;

	default:
		break;
	}
}
예제 #7
0
void
_gtk_text_attributes_fill_from_tags (GtkTextAttributes *dest,
                                     GtkTextTag**       tags,
                                     guint              n_tags)
{
  guint n = 0;

  guint left_margin_accumulative = 0;
  guint right_margin_accumulative = 0;

  while (n < n_tags)
    {
      GtkTextTag *tag = tags[n];
      GtkTextAttributes *vals = tag->priv->values;

      g_assert (tag->priv->table != NULL);
      if (n > 0)
        g_assert (tags[n]->priv->priority > tags[n-1]->priv->priority);

      if (tag->priv->bg_color_set)
        {
	  if (dest->appearance.rgba[0])
	    {
	      gdk_rgba_free (dest->appearance.rgba[0]);
	      dest->appearance.rgba[0] = NULL;
	    }

	  if (vals->appearance.rgba[0])
	    dest->appearance.rgba[0] = gdk_rgba_copy (vals->appearance.rgba[0]);

          dest->appearance.draw_bg = TRUE;
        }

      if (tag->priv->fg_color_set)
	{
	  if (dest->appearance.rgba[1])
	    {
	      gdk_rgba_free (dest->appearance.rgba[1]);
	      dest->appearance.rgba[1] = NULL;
	    }

	  if (vals->appearance.rgba[1])
	    dest->appearance.rgba[1] = gdk_rgba_copy (vals->appearance.rgba[1]);
	}

      if (tag->priv->pg_bg_color_set)
        {
	  if (dest->pg_bg_rgba)
	    {
	      gdk_rgba_free (dest->pg_bg_rgba);
	      dest->pg_bg_rgba = NULL;
	    }

	  if (dest->pg_bg_color)
	    {
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
	      gdk_color_free (dest->pg_bg_color);
	      dest->pg_bg_color = NULL;
G_GNUC_END_IGNORE_DEPRECATIONS
	    }

	  if (vals->pg_bg_rgba)
	    dest->pg_bg_rgba = gdk_rgba_copy (vals->pg_bg_rgba);

G_GNUC_BEGIN_IGNORE_DEPRECATIONS
	  if (vals->pg_bg_color)
	    dest->pg_bg_color = gdk_color_copy (vals->pg_bg_color);
G_GNUC_END_IGNORE_DEPRECATIONS
        }

      if (vals->font)
	{
	  if (dest->font)
	    pango_font_description_merge (dest->font, vals->font, TRUE);
	  else
	    dest->font = pango_font_description_copy (vals->font);
	}

      /* multiply all the scales together to get a composite */
      if (tag->priv->scale_set)
        dest->font_scale *= vals->font_scale;

      if (tag->priv->justification_set)
        dest->justification = vals->justification;

      if (vals->direction != GTK_TEXT_DIR_NONE)
        dest->direction = vals->direction;

      if (tag->priv->left_margin_set)
        {
          if (tag->priv->accumulative_margin)
            left_margin_accumulative += vals->left_margin;
          else
            dest->left_margin = vals->left_margin;
        }

      if (tag->priv->indent_set)
        dest->indent = vals->indent;

      if (tag->priv->rise_set)
        dest->appearance.rise = vals->appearance.rise;

      if (tag->priv->right_margin_set)
        {
          if (tag->priv->accumulative_margin)
            right_margin_accumulative += vals->right_margin;
          else
            dest->right_margin = vals->right_margin;
        }

      if (tag->priv->pixels_above_lines_set)
        dest->pixels_above_lines = vals->pixels_above_lines;

      if (tag->priv->pixels_below_lines_set)
        dest->pixels_below_lines = vals->pixels_below_lines;

      if (tag->priv->pixels_inside_wrap_set)
        dest->pixels_inside_wrap = vals->pixels_inside_wrap;

      if (tag->priv->tabs_set)
        {
          if (dest->tabs)
            pango_tab_array_free (dest->tabs);
          dest->tabs = pango_tab_array_copy (vals->tabs);
        }

      if (tag->priv->wrap_mode_set)
        dest->wrap_mode = vals->wrap_mode;

      if (tag->priv->underline_set)
        dest->appearance.underline = vals->appearance.underline;

      if (GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA_SET (&vals->appearance))
        {
          GdkRGBA rgba;

          GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA (&vals->appearance, &rgba);
          GTK_TEXT_APPEARANCE_SET_UNDERLINE_RGBA (&dest->appearance, &rgba);
          GTK_TEXT_APPEARANCE_SET_UNDERLINE_RGBA_SET (&dest->appearance, TRUE);
        }

      if (tag->priv->strikethrough_set)
        dest->appearance.strikethrough = vals->appearance.strikethrough;

      if (GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA_SET (&vals->appearance))
        {
          GdkRGBA rgba;

          GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA (&vals->appearance, &rgba);
          GTK_TEXT_APPEARANCE_SET_STRIKETHROUGH_RGBA (&dest->appearance, &rgba);
          GTK_TEXT_APPEARANCE_SET_STRIKETHROUGH_RGBA_SET (&dest->appearance, TRUE);
        }

      if (tag->priv->invisible_set)
        dest->invisible = vals->invisible;

      if (tag->priv->editable_set)
        dest->editable = vals->editable;

      if (tag->priv->bg_full_height_set)
        dest->bg_full_height = vals->bg_full_height;

      if (tag->priv->language_set)
	dest->language = vals->language;

      if (tag->priv->fallback_set)
        dest->no_fallback = vals->no_fallback;

      if (tag->priv->letter_spacing_set)
        dest->letter_spacing = vals->letter_spacing;

      if (tag->priv->font_features_set)
        dest->font_features = g_strdup (vals->font_features);

      ++n;
    }