本文整理汇总了C++中pango_attr_list_new函数的典型用法代码示例。如果您正苦于以下问题:C++ pango_attr_list_new函数的具体用法?C++ pango_attr_list_new怎么用?C++ pango_attr_list_new使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pango_attr_list_new函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create_cursor_attr
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);
}
示例2: ms_container_read_markup
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;
}
示例3: gtk_window_new
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;
}
示例4: wbcg_edit_add_markup
/**
* 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);
}
示例5: pango_cairo_font_map_get_default
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;
}
示例6: PangoItemize
// 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;
}
示例7: nimf_gtk_im_context_get_preedit_string
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);
}
}
示例8: iupgtkFontUpdatePangoLayout
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));
}
}
示例9: pango_cairo_create_layout
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;
}
示例10: gm_cell_renderer_bitext_update_style
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);
}
示例11: gnome_main_section_new_with_grid
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);
}
示例12: CoordWinSetFont
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
}
示例13: show_date_state
/* 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);
}
示例14: pango_cairo_create_layout
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;
}
示例15: update_fonts
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);
}