本文整理汇总了C++中pango_font_description_from_string函数的典型用法代码示例。如果您正苦于以下问题:C++ pango_font_description_from_string函数的具体用法?C++ pango_font_description_from_string怎么用?C++ pango_font_description_from_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pango_font_description_from_string函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gtk_window_new
GtkWidget *tip_window_new_autocomp (gchar *tip)
{
GtkWidget *win;
GtkWidget *label;
GtkWidget *eb;
PangoFontDescription *pfd;
win = gtk_window_new (GTK_WINDOW_POPUP);
gtk_container_set_border_width (GTK_CONTAINER (win), 0);
eb = gtk_event_box_new ();
gtk_container_set_border_width (GTK_CONTAINER (eb), 1);
gtk_container_add (GTK_CONTAINER (win), eb);
label = gtk_label_new (tip);
gtk_container_add (GTK_CONTAINER (eb), label);
pfd = pango_font_description_from_string ("courier");
gtk_widget_modify_font (label, pfd);
return win;
}
示例2: draw_text
static void
draw_text (cairo_t *cr)
{
#define RADIUS 150
#define N_WORDS 10
#define FONT "Sans Bold 27"
PangoLayout *layout;
PangoFontDescription *desc;
int i;
/* Center coordinates on the middle of the region we are drawing
*/
cairo_translate (cr, RADIUS, RADIUS);
/* Create a PangoLayout, set the font and text */
layout = pango_cairo_create_layout (cr);
pango_layout_set_text (layout, "Text", -1);
desc = pango_font_description_from_string (FONT);
pango_layout_set_font_description (layout, desc);
pango_font_description_free (desc);
/* Draw the layout N_WORDS times in a circle */
for (i = 0; i < N_WORDS; i++)
{
int width, height;
double angle = (360. * i) / N_WORDS;
double red;
cairo_save (cr);
/* Gradient from red at angle == 60 to blue at angle == 240 */
red = (1 + cos ((angle - 60) * G_PI / 180.)) / 2;
cairo_set_source_rgb (cr, red, 0, 1.0 - red);
cairo_rotate (cr, angle * G_PI / 180.);
/* Inform Pango to re-layout the text with the new transformation */
pango_cairo_update_layout (cr, layout);
pango_layout_get_size (layout, &width, &height);
cairo_move_to (cr, - ((double)width / PANGO_SCALE) / 2, - RADIUS);
pango_cairo_show_layout (cr, layout);
cairo_restore (cr);
}
/* free the layout object */
g_object_unref (layout);
}
示例3: gtk_css_custom_property_create_initial_value
static GtkCssValue *
gtk_css_custom_property_create_initial_value (GParamSpec *pspec)
{
GValue value = G_VALUE_INIT;
GtkCssValue *result;
g_value_init (&value, pspec->value_type);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
if (pspec->value_type == GTK_TYPE_THEMING_ENGINE)
g_value_set_object (&value, gtk_theming_engine_load (NULL));
else if (pspec->value_type == PANGO_TYPE_FONT_DESCRIPTION)
g_value_take_boxed (&value, pango_font_description_from_string ("Sans 10"));
else if (pspec->value_type == GDK_TYPE_RGBA)
{
GdkRGBA color;
gdk_rgba_parse (&color, "pink");
g_value_set_boxed (&value, &color);
}
else if (pspec->value_type == g_type_from_name ("GdkColor"))
{
GdkColor color;
gdk_color_parse ("pink", &color);
g_value_set_boxed (&value, &color);
}
else if (pspec->value_type == GTK_TYPE_BORDER)
{
g_value_take_boxed (&value, gtk_border_new ());
}
else
g_param_value_set_default (pspec, &value);
G_GNUC_END_IGNORE_DEPRECATIONS
result = _gtk_css_typed_value_new (&value);
g_value_unset (&value);
return result;
}
示例4: pango_cairo_create_layout
PangoLayout *get_pango_layout(cairo_t *cairo, const char *font, const char *text,
int32_t scale, bool markup) {
PangoLayout *layout = pango_cairo_create_layout(cairo);
PangoAttrList *attrs;
if (markup) {
char *buf;
pango_parse_markup(text, -1, 0, &attrs, &buf, NULL, NULL);
pango_layout_set_markup(layout, buf, -1);
free(buf);
} else {
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;
}
示例5: NSA_GET_PTR
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkWidgetModifyFont
(JNIEnv *env, jobject obj, jstring name, jint style, jint size)
{
const char *font_name;
void *ptr;
GtkWidget *button;
GtkWidget *label;
PangoFontDescription *font_desc;
ptr = NSA_GET_PTR (env, obj);
button = GTK_WIDGET (ptr);
label = gtk_bin_get_child (GTK_BIN(button));
if (!label)
return;
font_name = (*env)->GetStringUTFChars (env, name, NULL);
gdk_threads_enter();
font_desc = pango_font_description_from_string (font_name);
pango_font_description_set_size (font_desc, size * dpi_conversion_factor);
if (style & AWT_STYLE_BOLD)
pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);
if (style & AWT_STYLE_ITALIC)
pango_font_description_set_style (font_desc, PANGO_STYLE_OBLIQUE);
gtk_widget_modify_font (GTK_WIDGET(label), font_desc);
pango_font_description_free (font_desc);
gdk_threads_leave();
(*env)->ReleaseStringUTFChars (env, name, font_name);
}
开发者ID:BackupTheBerlios,项目名称:iphone-binutils-svn,代码行数:39,代码来源:gnu_java_awt_peer_gtk_GtkCheckboxPeer.c
示例6: gt_text_width_calculator_cairo_new
GtTextWidthCalculator* gt_text_width_calculator_cairo_new(cairo_t *context,
GtStyle *style,
GtError *err)
{
GtTextWidthCalculatorCairo *twcc;
GtTextWidthCalculator *twc;
double theight = TEXT_SIZE_DEFAULT;
char buf[64];
twc = gt_text_width_calculator_create(gt_text_width_calculator_cairo_class());
twcc = gt_text_width_calculator_cairo_cast(twc);
if (style)
twcc->style = gt_style_ref(style);
if (!context)
{
twcc->mysurf = cairo_image_surface_create(GT_TWC_FORMAT, GT_TWC_WIDTH,
GT_TWC_HEIGHT);
twcc->context = cairo_create(twcc->mysurf);
twcc->own_context = true;
} else {
twcc->context = context;
twcc->own_context = false;
}
if (twcc->style)
{
if (gt_style_get_num(twcc->style,
"format", "block_caption_font_size",
&theight, NULL, err) == GT_STYLE_QUERY_ERROR) {
gt_text_width_calculator_delete(twc);
return NULL;
}
cairo_save(twcc->context);
}
twcc->layout = pango_cairo_create_layout(twcc->context);
snprintf(buf, 64, "Sans %d", (int) theight);
twcc->desc = pango_font_description_from_string(buf);
pango_layout_set_font_description(twcc->layout, twcc->desc);
pango_font_description_free(twcc->desc);
return twc;
}
示例7: main
int main (int argc,
char *argv[])
{
GtkWidget *window, *vbox, *button, *label;
PangoFontDescription *initial_font;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "Font Button");
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
g_signal_connect (G_OBJECT (window), "destroy",
G_CALLBACK (destroy), NULL);
label = gtk_label_new ("Look at the font!");
initial_font = pango_font_description_from_string ("Sans Bold 12");
gtk_widget_modify_font (label, initial_font);
/* Create a new font selection button with the given default font. */
button = gtk_font_button_new_with_font ("Sans Bold 12");
gtk_font_button_set_title (GTK_FONT_BUTTON (button), "Choose a Font");
/* Monitor for changes to the font chosen in the font button. */
g_signal_connect (G_OBJECT (button), "font_set",
G_CALLBACK (font_changed),
(gpointer) label);
vbox= gtk_vbox_new (FALSE, 5);
gtk_box_pack_start_defaults (GTK_BOX (vbox), button);
gtk_box_pack_start_defaults (GTK_BOX (vbox), label);
gtk_container_add (GTK_CONTAINER (window), vbox);
gtk_widget_show_all (window);
gtk_main ();
return 0;
}
示例8: begin_print
static void begin_print(GtkPrintOperation *operation, GtkPrintContext *context, gpointer user_data)
{
DocInfo *dinfo = user_data;
PangoFontDescription *desc;
if (dinfo == NULL)
return;
gtk_widget_show(main_widgets.progressbar);
/* init dinfo fields */
/* setup printing scintilla object */
dinfo->sci = editor_create_widget(dinfo->doc->editor);
scintilla_send_message(dinfo->sci, SCI_SETDOCPOINTER, 0,
scintilla_send_message(dinfo->doc->editor->sci, SCI_GETDOCPOINTER, 0, 0));
highlighting_set_styles(dinfo->sci, dinfo->doc->file_type);
sci_set_line_numbers(dinfo->sci, printing_prefs.print_line_numbers, 0);
scintilla_send_message(dinfo->sci, SCI_SETVIEWWS, SCWS_INVISIBLE, 0);
scintilla_send_message(dinfo->sci, SCI_SETVIEWEOL, FALSE, 0);
scintilla_send_message(dinfo->sci, SCI_SETEDGEMODE, EDGE_NONE, 0);
scintilla_send_message(dinfo->sci, SCI_SETPRINTMAGNIFICATION, (uptr_t) -2, 0); /* WTF? */
scintilla_send_message(dinfo->sci, SCI_SETPRINTCOLOURMODE, SC_PRINT_COLOURONWHITE, 0);
dinfo->pages = g_array_new(FALSE, FALSE, sizeof(gint));
dinfo->print_time = time(NULL);
/* create a PangoLayout to be commonly used in add_page_header() and draw_page() */
desc = pango_font_description_from_string(interface_prefs.editor_font);
dinfo->layout = setup_pango_layout(context, desc);
pango_font_description_free(desc);
get_text_dimensions(dinfo->layout, "|XMfjgq_" /* reasonably representative character set */,
NULL, &dinfo->line_height);
get_text_dimensions(dinfo->layout, "99999 " /* Scintilla resets the margin to the width of "99999" when printing */,
&dinfo->margin_width, NULL);
/* setup dinfo->fr */
setup_range(dinfo, context);
}
示例9: vte_config
static void
vte_config(VteTerminal* vte)
{
GRegex* regex = g_regex_new(url_regex, G_REGEX_CASELESS, G_REGEX_MATCH_NOTEMPTY, NULL);
vte_terminal_search_set_gregex(vte, regex, G_REGEX_MATCH_NOTEMPTY);
vte_terminal_search_set_wrap_around (vte, TINYTERM_SEARCH_WRAP_AROUND);
vte_terminal_set_audible_bell (vte, TINYTERM_AUDIBLE_BELL);
vte_terminal_set_cursor_shape (vte, TINYTERM_CURSOR_SHAPE);
vte_terminal_set_cursor_blink_mode (vte, TINYTERM_CURSOR_BLINK);
vte_terminal_set_word_char_exceptions (vte, TINYTERM_WORD_CHARS);
vte_terminal_set_scrollback_lines (vte, TINYTERM_SCROLLBACK_LINES);
PangoFontDescription *font = pango_font_description_from_string(TINYTERM_FONT);
vte_terminal_set_font(vte, font);
GdkRGBA color_fg, color_bg;
GdkRGBA color_palette[16];
gdk_rgba_parse(&color_fg, TINYTERM_COLOR_FOREGROUND);
gdk_rgba_parse(&color_bg, TINYTERM_COLOR_BACKGROUND);
gdk_rgba_parse(&color_palette[0], TINYTERM_COLOR00);
gdk_rgba_parse(&color_palette[1], TINYTERM_COLOR01);
gdk_rgba_parse(&color_palette[2], TINYTERM_COLOR02);
gdk_rgba_parse(&color_palette[3], TINYTERM_COLOR03);
gdk_rgba_parse(&color_palette[4], TINYTERM_COLOR04);
gdk_rgba_parse(&color_palette[5], TINYTERM_COLOR05);
gdk_rgba_parse(&color_palette[6], TINYTERM_COLOR06);
gdk_rgba_parse(&color_palette[7], TINYTERM_COLOR07);
gdk_rgba_parse(&color_palette[8], TINYTERM_COLOR08);
gdk_rgba_parse(&color_palette[9], TINYTERM_COLOR09);
gdk_rgba_parse(&color_palette[10], TINYTERM_COLOR0A);
gdk_rgba_parse(&color_palette[11], TINYTERM_COLOR0B);
gdk_rgba_parse(&color_palette[12], TINYTERM_COLOR0C);
gdk_rgba_parse(&color_palette[13], TINYTERM_COLOR0D);
gdk_rgba_parse(&color_palette[14], TINYTERM_COLOR0E);
gdk_rgba_parse(&color_palette[15], TINYTERM_COLOR0F);
vte_terminal_set_colors(vte, &color_fg, &color_bg, &color_palette, 16);
}
示例10: pango_font_description_free
bool wxNativeFontInfo::FromString(const wxString& s)
{
if (description)
pango_font_description_free( description );
// there is a bug in at least pango <= 1.13 which makes it (or its backends)
// segfault for very big point sizes and for negative point sizes.
// To workaround that bug for pango <= 1.13
// (see http://bugzilla.gnome.org/show_bug.cgi?id=340229)
// we do the check on the size here using same (arbitrary) limits used by
// pango > 1.13. Note that the segfault could happen also for pointsize
// smaller than this limit !!
wxString str(s);
const size_t pos = str.find_last_of(_T(" "));
double size;
if ( pos != wxString::npos && wxString(str, pos + 1).ToDouble(&size) )
{
wxString sizeStr;
if ( size < 1 )
sizeStr = _T("1");
else if ( size >= 1E6 )
sizeStr = _T("1E6");
if ( !sizeStr.empty() )
{
// replace the old size with the adjusted one
str = wxString(s, 0, pos) + sizeStr;
}
}
description = pango_font_description_from_string(wxPANGO_CONV(str));
// ensure a valid facename is selected
if (!wxFontEnumerator::IsValidFacename(GetFaceName()))
SetFaceName(wxNORMAL_FONT->GetFaceName());
return true;
}
示例11: setup_page
static GogPlot *
setup_page (GtkNotebook *notebook, const gchar *service_id)
{
GtkWidget *child, *w;
GogChart *chart;
GogGraph *graph;
GogLabel *label;
GogPlot *plot;
GOData *data;
GOStyle *style;
PangoFontDescription *desc;
child = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_notebook_append_page (notebook, child, gtk_label_new (service_id));
/* Create a graph widget and add it to the GtkVBox */
w = go_graph_widget_new (NULL);
gtk_box_pack_end (GTK_BOX (child), w, TRUE, TRUE, 0);
/* Get the embedded graph */
graph = go_graph_widget_get_graph (GO_GRAPH_WIDGET (w));
/* Add a title */
label = (GogLabel *) g_object_new (GOG_TYPE_LABEL, NULL);
data = go_data_scalar_str_new (service_id, FALSE);
gog_dataset_set_dim (GOG_DATASET (label), 0, data, NULL);
gog_object_add_by_name (GOG_OBJECT (graph), "Title", GOG_OBJECT (label));
/* Change the title font */
style = go_styled_object_get_style (GO_STYLED_OBJECT (label));
desc = pango_font_description_from_string ("Sans bold 16");
go_style_set_font_desc (style, desc);
/* Get the chart created by the widget initialization */
chart = go_graph_widget_get_chart (GO_GRAPH_WIDGET (w));
/* Create a plot and add it to the chart */
plot = (GogPlot *) gog_plot_new_by_name (service_id);
gog_object_add_by_name (GOG_OBJECT (chart), "Plot", GOG_OBJECT (plot));
/* Add a legend to the chart */
gog_object_add_by_name (GOG_OBJECT (chart), "Legend", NULL);
return plot;
}
示例12: _draw_footer
static void
_draw_footer(GtkHTML * html, GtkPrintOperation * operation,
GtkPrintContext * context,
gint page_nr, PangoRectangle * rec, EDITOR * e)
{
PangoFontDescription *desc;
PangoLayout *layout;
gdouble x, y;
gint n_pages;
gchar *text;
cairo_t *cr;
g_object_get(operation, "n-pages", &n_pages, NULL);
text = g_strdup_printf(_("Page %d of %d"), page_nr + 1, n_pages);
desc = pango_font_description_from_string("Sans Regular 10");
layout = gtk_print_context_create_pango_layout(context);
pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER);
pango_layout_set_font_description(layout, desc);
pango_layout_set_text(layout, text, -1);
pango_layout_set_width(layout, rec->width);
x = pango_units_to_double(rec->x);
y = pango_units_to_double(rec->y);
cr = gtk_print_context_get_cairo_context(context);
cairo_save(cr);
cairo_set_source_rgb(cr, .0, .0, .0);
cairo_move_to(cr, x, y);
pango_cairo_show_layout(cr, layout);
cairo_restore(cr);
g_object_unref(layout);
pango_font_description_free(desc);
g_free(text);
}
示例13: gw_kanjipadwindow_initialize_candidates
//!
//! @brief To be written
//!
void gw_kanjipadwindow_initialize_candidates (GwKanjipadWindow *window)
{
//Declarations
GwKanjipadWindowPrivate *priv;
gint mask;
PangoFontDescription *desc;
//Initializations
priv = window->priv;
mask = (GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
desc = pango_font_description_from_string ("Sans 18");
g_signal_connect (priv->candidates, "configure_event", G_CALLBACK (gw_kanjipadwindow_candidatearea_configure_event_cb), window);
g_signal_connect (priv->candidates, "draw", G_CALLBACK (gw_kanjipadwindow_candidatearea_draw_cb), window);
g_signal_connect (priv->candidates, "button_press_event", G_CALLBACK (gw_kanjipadwindow_candidatearea_button_press_event_cb), window);
gtk_widget_add_events (GTK_WIDGET (priv->candidates), mask);
if (desc != NULL)
{
gtk_widget_override_font (GTK_WIDGET (priv->candidates), desc);
pango_font_description_free (desc);
}
}
示例14: write_chars
void write_chars(term_data* td, int x, int y, int n, byte a, const char* text)
{
PangoLayout *layout;
PangoFontDescription* font;
cairo_t *cr;
clear_chars(td, x, y, n);
cr = cairo_create(td->surface);
set_foreground_color(cr, a);
layout = pango_cairo_create_layout(cr);
font = pango_font_description_from_string(td->font.name);
pango_layout_set_font_description (layout, font);
pango_layout_set_text (layout, text, n);
cairo_move_to(cr, x * td->font.w, y * td->font.h);
pango_cairo_show_layout (cr, layout);
g_object_unref (layout);
pango_font_description_free(font);
cairo_destroy(cr);
}
示例15: select_font
void select_font(GtkWidget *widget, gpointer label)
{
GtkResponseType result;
GtkWidget *dialog = gtk_font_selection_dialog_new("Select Font");
result = gtk_dialog_run(GTK_DIALOG(dialog));
if( result == GTK_RESPONSE_OK || result == GTK_RESPONSE_APPLY)
{
PangoFontDescription *font_desc;
gchar *fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(dialog));
g_printf("%s\n", fontname);
font_desc = pango_font_description_from_string(fontname);
gtk_widget_modify_font(GTK_WIDGET(label), font_desc);
g_free(fontname);
}
gtk_widget_destroy(dialog);
}