static void create_cursor_attr() { if (attr_list) pango_attr_list_unref(attr_list); GdkColor color_bg, color_fg; if (hime_win_color_use) gdk_color_parse(tsin_cursor_color, &color_bg); else gdk_color_parse(TSIN_CURSOR_COLOR_DEFAULT, &color_bg); gdk_color_parse("white", &color_fg); attr_list = pango_attr_list_new (); attr_list_blank = pango_attr_list_new (); PangoAttribute *blue_bg = pango_attr_background_new( color_bg.red, color_bg.green, color_bg.blue); blue_bg->start_index = 0; blue_bg->end_index = 128; pango_attr_list_insert (attr_list, blue_bg); PangoAttribute *white_fg = pango_attr_foreground_new( color_fg.red, color_fg.green, color_fg.blue); white_fg->start_index = 0; white_fg->end_index = 128; pango_attr_list_insert (attr_list, white_fg); }
PangoAttrList * ms_container_read_markup (MSContainer const *c, guint8 const *data, size_t txo_len, char const *str) { TXORun txo_run; size_t str_len; XL_CHECK_CONDITION_VAL (txo_len >= 16, pango_attr_list_new ()); /* min two records */ str_len = g_utf8_strlen (str, -1); txo_run.last = G_MAXINT; txo_run.accum = NULL; for (txo_len -= 16 ; (gssize)txo_len >= 0 ; txo_len -= 8) { guint16 o = GSF_LE_GET_GUINT16 (data + txo_len); guint16 idx = GSF_LE_GET_GUINT16 (data + txo_len + 2); XL_CHECK_CONDITION_VAL (o <= str_len, txo_run.accum); txo_run.first = g_utf8_offset_to_pointer (str, o) - str; XL_CHECK_CONDITION_VAL (txo_run.first < txo_run.last, txo_run.accum); if (idx != 0) { if (!txo_run.accum) txo_run.accum = pango_attr_list_new (); pango_attr_list_filter (ms_container_get_markup (c, idx), (PangoAttrFilterFunc) append_txorun, &txo_run); } txo_run.last = txo_run.first; } return txo_run.accum; }
static void check_replace_text (IdeEditorFrame *self) { GtkSourceSearchContext *search_context; GtkSourceSearchSettings *search_settings; g_autoptr(GError) error = NULL; PangoAttrList *attrs; g_assert (IDE_IS_EDITOR_FRAME (self)); search_context = ide_source_view_get_search_context (self->source_view); search_settings = gtk_source_search_context_get_settings (search_context); attrs = pango_attr_list_new (); /* * If the replace expression is invalid, add a white squiggly underline; * otherwise remove it. */ if (gtk_source_search_settings_get_regex_enabled (search_settings)) { const gchar *replace_text; replace_text = gtk_entry_get_text (GTK_ENTRY (self->replace_entry)); if (!g_regex_check_replacement (replace_text, NULL, &error)) { pango_attr_list_insert (attrs, pango_attr_underline_new (PANGO_UNDERLINE_ERROR)); pango_attr_list_insert (attrs, pango_attr_underline_color_new (65535, 65535, 65535)); } } gtk_entry_set_attributes (GTK_ENTRY (self->replace_entry), attrs); pango_attr_list_unref (attrs); }
static void on_regex_error_changed (IdeEditorFrame *self, GParamSpec *pspec, GtkSourceSearchContext *search_context) { g_autoptr(GError) error = NULL; PangoAttrList *attrs; g_assert (IDE_IS_EDITOR_FRAME (self)); g_assert (GTK_SOURCE_IS_SEARCH_CONTEXT (search_context)); /* * If the regular expression is invalid, add a white squiggly underline; * otherwise remove it. */ attrs = pango_attr_list_new (); error = gtk_source_search_context_get_regex_error (search_context); if (error != NULL) { pango_attr_list_insert (attrs, pango_attr_underline_new (PANGO_UNDERLINE_ERROR)); pango_attr_list_insert (attrs, pango_attr_underline_color_new (65535, 65535, 65535)); } gtk_entry_set_attributes (GTK_ENTRY (self->search_entry), attrs); pango_attr_list_unref (attrs); update_replace_actions_sensitivity (self); }
static GtkWidget *app_window_common(void) { GtkWidget *window; PangoAttrList *attr; window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_container_set_border_width(GTK_CONTAINER(window), 10); gtk_window_set_title(GTK_WINDOW(window), WINDOW_TITLE); g_signal_connect(window, "delete-event", G_CALLBACK(delete_event), NULL); tokencode_text = gtk_label_new(NULL); attr = pango_attr_list_new(); pango_attr_list_insert(attr, pango_attr_scale_new(PANGO_SCALE_XX_LARGE)); pango_attr_list_insert(attr, pango_attr_weight_new(PANGO_WEIGHT_BOLD)); gtk_label_set_attributes(GTK_LABEL(tokencode_text), attr); pango_attr_list_unref(attr); /* hack to turn off progress bar animation seen on some themes */ gtk_rc_parse_string("style \"default\" { engine \"\" { }\n" "bg[PRELIGHT] = \"#4b6785\" }\n" "widget_class \"*.<GtkProgressBar>\" style \"default\""); return window; }
/** * wbcg_edit_add_markup: * @wbcg: #WBCGtk * @attr: #PangoAttribute * * Absorbs the ref to @attr. **/ void wbcg_edit_add_markup (WBCGtk *wbcg, PangoAttribute *attr) { GObject *entry = (GObject *)wbcg_get_entry (wbcg); if (wbcg->edit_line.full_content == NULL) wbcg_edit_init_markup (wbcg, pango_attr_list_new ()); if (gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &attr->start_index, &attr->end_index)) { char const *str = gtk_entry_get_text (GTK_ENTRY (entry)); attr->start_index = g_utf8_offset_to_pointer (str, attr->start_index) - str; attr->end_index = g_utf8_offset_to_pointer (str, attr->end_index) - str; set_or_unset (wbcg->edit_line.full_content, attr, wbcg->edit_line.cell_attrs); set_or_unset (wbcg->edit_line.markup, attr, wbcg->edit_line.cell_attrs); } /* the format to use when inserting text, we will resize it later */ attr->start_index = 0; attr->end_index = INT_MAX; set_or_unset (wbcg->edit_line.cur_fmt, attr, wbcg->edit_line.cell_attrs); pango_attribute_destroy (attr); wbc_gtk_markup_changer (wbcg); }
PangoLayout * VwGraphicsCairo::GetPangoLayoutHelper() { if (m_fontMap == NULL) m_fontMap = pango_cairo_font_map_get_default(); if (m_context == NULL) { m_context = pango_context_new(); pango_context_set_font_map(m_context, m_fontMap); } if (m_layout == NULL) { m_layout = pango_layout_new(m_context); PangoAttrList* list = pango_attr_list_new(); PangoAttribute * fallbackAttrib = pango_attr_fallback_new(true); pango_attr_list_insert(list, fallbackAttrib); pango_layout_set_attributes(m_layout, list); pango_attr_list_unref(list); pango_layout_set_single_paragraph_mode(m_layout, true); } return m_layout; }
// Helper function used in the implementation of ScriptItemize HRESULT PangoItemize(const char * chars, int cInChars, int cMaxItems, SCRIPT_ITEM *pItems, int * pcItems) { SCRIPT_CACHE context = NULL; PangoAttrList * attributes_list = pango_attr_list_new(); GList * items = pango_itemize(GetPangoContext(&context), chars, 0, cInChars, attributes_list, NULL); *pcItems = g_list_length(items); if (*pcItems >= cMaxItems) { pango_attr_list_unref(attributes_list); g_list_free(items); return E_OUTOFMEMORY; } for(int i = 0; i < *pcItems; ++i) { PangoItem* item = static_cast<PangoItem*>(g_list_nth_data(items, i)); pItems[i].iCharPos = item->offset; pItems[i].a.fRTL = item->analysis.level == 1; pItems[i].a.fLayoutRTL = pItems[i].a.fRTL; // TODO: set other fields in SCRIPT_ANALYSIS as needed. pango_item_free(item); } pango_attr_list_unref(attributes_list); g_list_free(items); return S_OK; }
static void nimf_gtk_im_context_get_preedit_string (GtkIMContext *context, gchar **str, PangoAttrList **attrs, gint *cursor_pos) { g_debug (G_STRLOC ": %s", G_STRFUNC); PangoAttribute *attr; nimf_im_get_preedit_string (NIMF_GTK_IM_CONTEXT (context)->im, str, cursor_pos); if (attrs) { *attrs = pango_attr_list_new (); attr = pango_attr_underline_new (PANGO_UNDERLINE_SINGLE); if (str) { attr->start_index = 0; attr->end_index = strlen (*str); } pango_attr_list_change (*attrs, attr); } }
void iupgtkFontUpdatePangoLayout(Ihandle* ih, PangoLayout* layout) { IgtkFont* gtkfont; PangoAttrList *attrs; if (!layout) return; gtkfont = gtkFontGet(ih); if (!gtkfont) return; attrs = pango_layout_get_attributes(layout); if (!attrs) { attrs = pango_attr_list_new(); pango_attr_list_insert(attrs, pango_attribute_copy(gtkfont->strikethrough)); pango_attr_list_insert(attrs, pango_attribute_copy(gtkfont->underline)); pango_layout_set_attributes(layout, attrs); } else { pango_attr_list_change(attrs, pango_attribute_copy(gtkfont->strikethrough)); pango_attr_list_change(attrs, pango_attribute_copy(gtkfont->underline)); } }
PangoLayout *get_pango_layout(cairo_t *cairo, const char *font, const char *text, double scale, bool markup) { PangoLayout *layout = pango_cairo_create_layout(cairo); PangoAttrList *attrs; if (markup) { char *buf; GError *error = NULL; if (pango_parse_markup(text, -1, 0, &attrs, &buf, NULL, &error)) { pango_layout_set_text(layout, buf, -1); free(buf); } else { sway_log(SWAY_ERROR, "pango_parse_markup '%s' -> error %s", text, error->message); g_error_free(error); markup = false; // fallback to plain text } } if (!markup) { attrs = pango_attr_list_new(); pango_layout_set_text(layout, text, -1); } pango_attr_list_insert(attrs, pango_attr_scale_new(scale)); PangoFontDescription *desc = pango_font_description_from_string(font); pango_layout_set_font_description(layout, desc); pango_layout_set_single_paragraph_mode(layout, 1); pango_layout_set_attributes(layout, attrs); pango_attr_list_unref(attrs); pango_font_description_free(desc); return layout; }
static void gm_cell_renderer_bitext_update_style (GmCellRendererBitext* renderer, GtkWidget* widget) { GtkStyleContext *style = NULL; GtkStateFlags state; PangoAttrList *attr_list = NULL; PangoAttribute *attr_size = NULL; const PangoFontDescription* font = NULL; style = gtk_widget_get_style_context (widget); state = gtk_widget_get_state_flags (widget); attr_list = pango_attr_list_new (); /* we want the secondary text smaller */ gtk_style_context_get (style, state, "font", &font, NULL); attr_size = pango_attr_size_new ((int) (pango_font_description_get_size (font) * 0.8)); attr_size->start_index = strlen (renderer->priv->primary_text) + 1; attr_size->end_index = (guint) - 1; pango_attr_list_insert (attr_list, attr_size); g_object_set (renderer, "visible", TRUE, "weight", PANGO_WEIGHT_NORMAL, "attributes", attr_list, NULL); pango_attr_list_unref (attr_list); }
void gnome_main_section_new_with_grid(const gchar *title, GtkWidget **frame, GtkWidget **grid) { PangoAttrList *attrs = pango_attr_list_new(); PangoAttribute *attr = pango_attr_weight_new(PANGO_WEIGHT_BOLD); attr->start_index = 0; attr->end_index = -1; pango_attr_list_insert(attrs, attr); *frame = gtk_frame_new(title); gtk_frame_set_shadow_type(GTK_FRAME(*frame), GTK_SHADOW_NONE); gtk_container_set_border_width(GTK_CONTAINER(*frame), 2); GtkWidget *label = gtk_frame_get_label_widget(GTK_FRAME(*frame)); gtk_label_set_attributes(GTK_LABEL(label), attrs); pango_attr_list_unref(attrs); GtkWidget *align = gtk_alignment_new(0.08, 0.2, 0.1, 0.1); gtk_container_add(GTK_CONTAINER(*frame), align); *grid = gtk_grid_new(); gtk_grid_set_row_spacing(GTK_GRID(*grid), 2); gtk_grid_set_column_spacing(GTK_GRID(*grid), 2); gtk_widget_show(*grid); gtk_container_add(GTK_CONTAINER(align), *grid); }
void CoordWinSetFont(const char *font) { #if GTK_CHECK_VERSION(3, 16, 0) if (NgraphApp.CoordWin.data.text && font) { set_widget_font(NgraphApp.CoordWin.data.text, font); } #else /* GTK_CHECK_VERSION(3, 16, 0) */ const char *ptr; PangoAttrList *pattr; PangoFontDescription *desc; GtkLabel *label; label = GTK_LABEL(NgraphApp.CoordWin.data.text); if (label == NULL) return; pattr = gtk_label_get_attributes(label); if (pattr == NULL) { pattr = pango_attr_list_new(); gtk_label_set_attributes(GTK_LABEL(label), pattr); } ptr = (font) ? font : "Monospace"; desc = pango_font_description_from_string(ptr); pango_attr_list_change(pattr, pango_attr_font_desc_new(desc)); pango_font_description_free(desc); #endif }
/* Set the colour of the "valid from" and "valid until" elements on the * Certificate page to red if they are incorrectly in the future or * past. */ static void show_date_state(char* label, void* data, int length) { gchar* labelname = g_strndup(label, strstr(label, ":") - label); GtkLabel* l = GTK_LABEL(gtk_builder_get_object(builder, labelname)); PangoAttrList *attrs = pango_attr_list_new(); PangoAttribute *attr; gboolean* is_invalid = (gboolean*)data; g_free(labelname); if(*is_invalid) { attr = pango_attr_foreground_new(G_MAXUINT16, 0, 0); } else { #if HAVE_GTK == 3 GdkRGBA color; GtkStyleContext *style = gtk_widget_get_style_context(GTK_WIDGET(l)); gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color); attr = pango_attr_foreground_new(color.red * G_MAXUINT16, color.green * G_MAXUINT16, color.blue * G_MAXUINT16); #else #if HAVE_GTK == 2 /* In GTK+ 2, there is no GtkStyleContext yet. It * should, in theory, be possible to figure out what the * default foreground color is by using a GTK+ * 2-specific API, but that's too much work and GTK+ 2 * is a minority now anyway, so... */ attr = pango_attr_foreground_new(0, 0, 0); #else /* The configure script only allows GTK+2 or GTK+3. */ #error should not happen #endif #endif } pango_attr_list_insert(attrs, attr); gtk_label_set_attributes(l, attrs); }
TextAsset::Size TextAsset::computeSizeOfText(cairo_t* cairoContext, const std::string textString, int bounds, PangoFontDescription* font, Rect* tight, float* lineHeightOut) { PangoLayout* layout = pango_cairo_create_layout(cairoContext); // Kerning PangoAttrList* attr_list = pango_attr_list_new(); PangoAttribute* spacing_attr = pango_attr_letter_spacing_new(pango_units_from_double(_kern)); pango_attr_list_insert(attr_list, spacing_attr); pango_layout_set_attributes(layout, attr_list); pango_cairo_context_set_resolution(pango_layout_get_context(layout), DISPLAY_RESOLUTION); pango_layout_set_text(layout, textString.c_str(), (int)textString.length()); pango_layout_set_alignment(layout, _alignment); pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); const Size maxTextureSize(bounds, 1024); pango_layout_set_width(layout, pango_units_from_double(maxTextureSize.width)); pango_layout_set_height(layout, pango_units_from_double(maxTextureSize.height)); pango_layout_set_font_description(layout, font); applyLeading(cairoContext, layout, font); PangoRectangle estimateSize; PangoRectangle ink; pango_layout_get_pixel_extents(layout, &ink, &estimateSize); // If the text is right or center aligned the offsets will contain all the // leading space. We ignore that for the size because drawText will draw // in the larger box. The tight box below will get the offsets so we know // where to draw so the text lands in the same tight box. Size res(estimateSize.width, estimateSize.height); if (tight != NULL) { float lineHeight; float xHeight = charHeight(cairoContext, font, 'x', &lineHeight); if (lineHeightOut != NULL) { *lineHeightOut = lineHeight; } const float capHeight = charHeight(cairoContext, font, 'Y'); const float ascender = pango_units_to_double(pango_layout_get_baseline(layout)); const float topSpace = ascender - capHeight; const float bottomSpace = MAX(lineHeight - ascender - (capHeight - xHeight), 0); if (res.height > topSpace + bottomSpace) { *tight = Rect(estimateSize.x, estimateSize.y + topSpace, res.width, res.height - topSpace - bottomSpace); } else { *tight = Rect(0, 0, res.width, res.height); } } g_object_unref(layout); return res; }
static void update_fonts (UmEditableButton *button) { PangoAttrList *attrs; PangoAttribute *attr; GtkWidget *label; UmEditableButtonPrivate *priv = button->priv; attrs = pango_attr_list_new (); if (priv->scale_set) { attr = pango_attr_scale_new (priv->scale); pango_attr_list_insert (attrs, attr); } if (priv->weight_set) { attr = pango_attr_weight_new (priv->weight); pango_attr_list_insert (attrs, attr); } gtk_label_set_attributes (priv->label, attrs); label = gtk_bin_get_child (GTK_BIN (priv->button)); gtk_label_set_attributes (GTK_LABEL (label), attrs); pango_attr_list_unref (attrs); }
static void match_label_color (GstyleColorWidget *self, GstyleColor *color) { PangoLayout *layout; PangoAttrList *attr_list; PangoAttribute *attr; GdkRGBA rgba; GdkRGBA dst_rgba; g_assert (GSTYLE_IS_COLOR_WIDGET (self)); g_assert (GSTYLE_IS_COLOR (color)); layout = gtk_label_get_layout (self->label); attr_list = pango_layout_get_attributes (layout); if (attr_list == NULL) { attr_list = pango_attr_list_new (); gtk_label_set_attributes (self->label, attr_list); pango_attr_list_unref (attr_list); } gstyle_color_fill_rgba (color, &rgba); gstyle_utils_get_contrasted_rgba (rgba, &dst_rgba); attr = pango_attr_foreground_new (dst_rgba.red * 0xffff, dst_rgba.green * 0xffff, dst_rgba.blue * 0xffff); pango_attr_list_change (attr_list, attr); attr = pango_attr_background_new (rgba.red * 0xffff, rgba.green * 0xffff, rgba.blue * 0xffff); pango_attr_list_change (attr_list, attr); }
static void apply_subtitle_style_to_layout (GtkStyleContext *context, PangoLayout *layout, GtkStateFlags flags) { PangoFontDescription *desc; PangoAttrList *layout_attr; PangoAttribute *attr_alpha; gtk_style_context_save (context); gtk_style_context_set_state (context, flags); gtk_style_context_get (context, gtk_style_context_get_state (context), "font", &desc, NULL); gtk_style_context_restore (context); /* Set the font size */ pango_font_description_set_size (desc, pango_font_description_get_size (desc) * SUBTITLE_SIZE_PERCENTAGE); pango_layout_set_font_description (layout, desc); pango_font_description_free (desc); /* Set the font alpha */ layout_attr = pango_attr_list_new (); attr_alpha = pango_attr_foreground_alpha_new (SUBTITLE_DIM_PERCENTAGE * 65535); pango_attr_list_insert (layout_attr, attr_alpha); pango_layout_set_attributes (layout, layout_attr); pango_attr_list_unref (layout_attr); }
static void setPangoAttributes(const Font* font, const TextRun& run, PangoLayout* layout, bool rtl) { PangoAttrList* list = pango_attr_list_new(); PangoAttribute* attr; attr = pango_attr_size_new_absolute((int)(font->size() * PANGO_SCALE)); attr->end_index = G_MAXUINT; pango_attr_list_insert_before(list, attr); attr = pango_attr_letter_spacing_new(font->letterSpacing() * PANGO_SCALE); attr->end_index = G_MAXUINT; pango_attr_list_insert_before(list, attr); // Pango does not yet support synthesising small caps // See http://bugs.webkit.org/show_bug.cgi?id=15610 pango_layout_set_attributes(layout, list); pango_attr_list_unref(list); pango_layout_set_auto_dir(layout, FALSE); PangoContext* pangoContext = pango_layout_get_context(layout); PangoDirection direction = rtl ? PANGO_DIRECTION_RTL : PANGO_DIRECTION_LTR; pango_context_set_base_dir(pangoContext, direction); }
static void append_item (NemoImagePropertiesPage *page, const char *name, const char *value) { GtkWidget *name_label; GtkWidget *label; PangoAttrList *attrs; name_label = gtk_label_new (name); attrs = pango_attr_list_new (); pango_attr_list_insert (attrs, pango_attr_weight_new (PANGO_WEIGHT_BOLD)); gtk_label_set_attributes (GTK_LABEL (name_label), attrs); pango_attr_list_unref (attrs); gtk_misc_set_alignment (GTK_MISC (name_label), 0, 0); gtk_container_add (GTK_CONTAINER (page->details->grid), name_label); gtk_widget_show (name_label); if (value != NULL) { label = gtk_label_new (value); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_grid_attach_next_to (GTK_GRID (page->details->grid), label, name_label, GTK_POS_RIGHT, 1, 1); gtk_widget_show (label); } }
static AboutRenderer * make_text_item (AboutState *state, const char *text, int duration) { AboutRenderer *r = g_new0 (AboutRenderer, 1); PangoAttrList *attrlist; PangoAttribute *attr; duration = (int)(duration / SPEED_FACTOR); r->start_time = state->now; r->duration = duration; r->layout = gtk_widget_create_pango_layout (state->anim_area, NULL); r->renderer = text_item_renderer; r->fade_in = r->fade_out = TRUE; set_text_motion (r, 0.5, 0.5, 0.5, 0.5); pango_layout_set_text (r->layout, text, -1); pango_layout_get_size (r->layout, &r->natural_width, NULL); attrlist = pango_attr_list_new (); attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD); pango_attr_list_change (attrlist, attr); pango_layout_set_attributes (r->layout, attrlist); pango_attr_list_unref (attrlist); state->now += duration; return r; }
static void create_layout (GtkSourceGutterRendererText *renderer, GtkWidget *widget) { PangoLayout *layout; PangoAttribute *attr; GtkStyleContext *context; GdkRGBA color; PangoAttrList *attr_list; layout = gtk_widget_create_pango_layout (widget, NULL); context = gtk_widget_get_style_context (widget); gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &color); attr = pango_attr_foreground_new (color.red * 65535, color.green * 65535, color.blue * 65535); attr->start_index = 0; attr->end_index = G_MAXINT; attr_list = pango_attr_list_new (); pango_attr_list_insert (attr_list, attr); renderer->priv->fg_attr = attr; renderer->priv->cached_layout = layout; renderer->priv->cached_attr_list = attr_list; }
void LeftMargin::setupMargin(GtkTextView *textView) { if(!mMarginLayout) { GtkWidget *widget = GTK_WIDGET(textView); mMarginLayout = gtk_widget_create_pango_layout(widget, ""); updateTextInfo(textView); pango_layout_set_width(mMarginLayout, mTextWidth); pango_layout_set_alignment(mMarginLayout, PANGO_ALIGN_RIGHT); GtkStyleContext *widgetStyle = gtk_widget_get_style_context(widget); GdkRGBA color; gtk_style_context_get_color(widgetStyle, GTK_STATE_FLAG_NORMAL, &color); mMarginAttr = pango_attr_foreground_new(convertGdkColorToPango(color.red), convertGdkColorToPango(color.green), convertGdkColorToPango(color.blue)); mMarginAttrList = pango_attr_list_new(); mMarginAttr->start_index = 0; mMarginAttr->end_index = G_MAXUINT; pango_attr_list_insert(mMarginAttrList, mMarginAttr); pango_layout_set_attributes(mMarginLayout, mMarginAttrList); } }
static void gnm_notebook_button_ensure_layout (GnmNotebookButton *nbb) { const char *text = gtk_label_get_text (GTK_LABEL (nbb)); if (nbb->layout) { if (strcmp (text, pango_layout_get_text (nbb->layout)) == 0) return; pango_layout_set_text (nbb->layout, text, -1); pango_layout_set_text (nbb->layout_active, text, -1); } else { PangoAttrList *attrs, *attrs_active; PangoAttribute *attr; PangoFontDescription *desc; GtkWidget *widget = GTK_WIDGET (nbb); GtkStyleContext *context = gtk_widget_get_style_context (widget); nbb->layout = gtk_widget_create_pango_layout (widget, text); nbb->layout_active = gtk_widget_create_pango_layout (widget, text); /* Common */ attrs = pango_attr_list_new (); if (nbb->bg) { attr = go_color_to_pango (go_color_from_gdk_rgba (nbb->bg, NULL), FALSE); attr->start_index = 0; attr->end_index = -1; pango_attr_list_insert (attrs, attr); } attrs_active = pango_attr_list_copy (attrs); /* Normal */ gtk_style_context_get (context, GTK_STATE_FLAG_NORMAL, "font", &desc, NULL); attr = pango_attr_font_desc_new (desc); attr->start_index = 0; attr->end_index = -1; pango_attr_list_insert (attrs, attr); pango_font_description_free (desc); pango_layout_set_attributes (nbb->layout, attrs); pango_attr_list_unref (attrs); /* Active */ gtk_style_context_get (context, GTK_STATE_FLAG_ACTIVE, "font", &desc, NULL); attr = pango_attr_font_desc_new (desc); attr->start_index = 0; attr->end_index = -1; pango_attr_list_insert (attrs_active, attr); pango_font_description_free (desc); pango_layout_set_attributes (nbb->layout_active, attrs_active); pango_attr_list_unref (attrs_active); } pango_layout_get_extents (nbb->layout, NULL, &nbb->logical); pango_layout_get_extents (nbb->layout_active, NULL, &nbb->logical_active); }
static void set_background(CustomData *data) { PangoAttrList *attrs; attrs = pango_attr_list_new(); pango_attr_list_insert (attrs, pango_attr_background_new (65535, 0, 0)); gtk_label_set_attributes(GTK_LABEL (data->timelabel), attrs); pango_attr_list_unref (attrs); }
bool OxLabel_SetTextColor(OxLabelObject* ox, int iRed, int iGreen, int iBlue) { PangoAttrList* pAL = pango_attr_list_new(); pango_attr_list_insert(pAL, pango_attr_foreground_new(iRed, iGreen, iBlue)); gtk_label_set_attributes(GTK_LABEL(ox->pGtk), pAL); return TRUE; }
GtkWidget * gnome_prefs_subsection_new (GtkWidget *window, GtkWidget *container, const gchar *frame_name, int rows, int cols) { GnomePrefsWindow *gpw = NULL; GtkWidget *hbox = NULL; GtkWidget *frame = NULL; GtkWidget *table = NULL; GtkWidget *label = NULL; PangoAttrList *attrs = NULL; PangoAttribute *attr = NULL; if (window) gpw = (GnomePrefsWindow *) g_object_get_data (G_OBJECT (window), "gpw"); hbox = gtk_hbox_new (FALSE, 6); frame = gtk_frame_new (frame_name); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE); attrs = pango_attr_list_new (); attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD); attr->start_index = 0; attr->end_index = -1; pango_attr_list_insert (attrs, attr); label = gtk_frame_get_label_widget (GTK_FRAME (frame)); gtk_label_set_attributes (GTK_LABEL (label), attrs); pango_attr_list_unref (attrs); gtk_box_pack_start (GTK_BOX (container), frame, FALSE, FALSE, 0); table = gtk_table_new (rows, cols, FALSE); gtk_container_add (GTK_CONTAINER (frame), hbox); gtk_container_set_border_width (GTK_CONTAINER (hbox), 3); gtk_container_set_border_width (GTK_CONTAINER (frame), 6); label = gtk_label_new (" "); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), table, FALSE, FALSE, 0); gtk_table_set_row_spacings (GTK_TABLE (table), 2); gtk_table_set_col_spacings (GTK_TABLE (table), 6); if (gpw) g_object_set_data (G_OBJECT (table), "gpw", gpw); gtk_widget_show_all (table); return table; }
void _HYPlatformGraphicPane::_BuildCharGlyphs(void) { char c[] = "ACGT"; PangoAttrList* natl = pango_attr_list_new (); PangoAttribute* pafd = pango_attr_font_desc_new (theFont); pango_attr_list_insert (natl, pafd); charCachePangoItems = pango_itemize (screenPContext, c, 0, 4, natl,NULL); pango_attr_list_unref (natl); }
static PangoAttrList* gdip_get_layout_attributes (PangoLayout *layout) { PangoAttrList *list = pango_layout_get_attributes (layout); if (!list) list = pango_attr_list_new (); else pango_attr_list_ref (list); return list; }