本文整理汇总了C++中pango_layout_new函数的典型用法代码示例。如果您正苦于以下问题:C++ pango_layout_new函数的具体用法?C++ pango_layout_new怎么用?C++ pango_layout_new使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pango_layout_new函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: content_draw
void
content_draw (GtkWidget *widget,
cairo_t *cr)
{
PangoContext *context;
PangoLayout *title_layout;
PangoLayout *sub_layout;
PangoFontDescription *desc;
int width, height;
int sub_width;
width = gdk_window_get_width (gtk_widget_get_window (widget));
height = gdk_window_get_height (gtk_widget_get_window (widget));
cairo_translate (cr, width / 2, height / 2);
context = gdk_pango_context_get_for_screen (gtk_widget_get_screen (widget));
title_layout = pango_layout_new (context);
pango_layout_set_text (title_layout, _("This session is locked"), -1);
desc = pango_font_description_from_string (TITLE_FONT);
pango_layout_set_font_description (title_layout, desc);
pango_font_description_free (desc);
cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 1.0);
pango_cairo_update_layout (cr, title_layout);
pango_layout_get_size (title_layout, &width, &height);
cairo_save (cr);
/* Adjust the translation to the middle left of the icon */
cairo_translate (cr, - width / PANGO_SCALE / 2 - height / PANGO_SCALE, - height / PANGO_SCALE / 2);
draw_lock_icon (cr, height / PANGO_SCALE);
cairo_restore (cr);
cairo_move_to (cr, - width / PANGO_SCALE / 2 + height / PANGO_SCALE, - height / PANGO_SCALE);
pango_cairo_show_layout (cr, title_layout);
g_object_unref (title_layout);
sub_layout = pango_layout_new (context);
pango_layout_set_text (sub_layout, _("You'll be redirected to the unlock dialog automatically in a few seconds"), -1);
pango_layout_set_wrap (sub_layout, PANGO_WRAP_WORD_CHAR);
pango_layout_set_width (sub_layout, width + 2 * height);
desc = pango_font_description_from_string (MESSAGE_FONT);
pango_layout_set_font_description (sub_layout, desc);
pango_font_description_free (desc);
cairo_set_source_rgba (cr, 0.6, 0.6, 0.6, 1.0);
pango_cairo_update_layout (cr, sub_layout);
pango_layout_get_size (sub_layout, &sub_width, NULL);
cairo_move_to (cr, - (width + 2 * height) / PANGO_SCALE / 2, height / PANGO_SCALE);
cairo_scale (cr, (width + 2 * height) / (gdouble)sub_width, (width + 2 * height) / (gdouble)sub_width);
pango_cairo_show_layout (cr, sub_layout);
g_object_unref (sub_layout);
g_object_unref (context);
}
开发者ID:cavalier38,项目名称:light-locker,代码行数:60,代码来源:gs-content.c
示例2: workrave_timebar_init_ui
static void
workrave_timebar_init_ui(WorkraveTimebar *self)
{
WorkraveTimebarPrivate *priv = WORKRAVE_TIMEBAR_GET_PRIVATE(self);
priv->style_context = gtk_style_context_new();
GtkWidgetPath *path = gtk_widget_path_new();
gtk_widget_path_append_type(path, GTK_TYPE_BUTTON);
gtk_style_context_set_path(priv->style_context, path);
gtk_style_context_add_class(priv->style_context, GTK_STYLE_CLASS_TROUGH);
GdkScreen *screen = gdk_screen_get_default();
priv->pango_context = gdk_pango_context_get_for_screen(screen);
const PangoFontDescription *font_desc = gtk_style_context_get_font(priv->style_context, GTK_STATE_FLAG_ACTIVE);
pango_context_set_language(priv->pango_context, gtk_get_default_language());
pango_context_set_font_description(priv->pango_context, font_desc);
priv->pango_layout = pango_layout_new(priv->pango_context);
pango_layout_set_text(priv->pango_layout, "-9:59:59", -1);
pango_layout_get_pixel_size(priv->pango_layout, &priv->width, &priv->height);
priv->width = MAX(priv->width + 2 * MARGINX, MIN_HORIZONTAL_BAR_WIDTH);
priv->height = MAX(priv->height + 2 * MARGINY, MIN_HORIZONTAL_BAR_HEIGHT);
gtk_widget_path_free(path);
}
开发者ID:sergei-dyshel,项目名称:workrave,代码行数:30,代码来源:timebar.c
示例3: expose_cb
static gboolean
expose_cb (GtkWidget *widget,
GdkEventExpose *event,
ccss_style_t const *style)
{
cairo_t *cr;
char *font_family;
cr = gdk_cairo_create (widget->window);
font_family = NULL;
ccss_style_get_string (style, "font-family", &font_family);
if (font_family) {
PangoContext *context;
PangoLayout *layout;
context = gtk_widget_get_pango_context (widget);
layout = pango_layout_new (context);
pango_layout_set_text (layout, font_family, strlen (font_family));
pango_cairo_show_layout (cr, layout);
g_object_unref (G_OBJECT (layout)), layout = NULL;
}
cairo_destroy (cr);
return FALSE;
}
开发者ID:freedesktop-unofficial-mirror,项目名称:ccss,代码行数:28,代码来源:example-4-1.c
示例4: PANGO_VERSION_CHECK
ttext::ttext() :
#if PANGO_VERSION_CHECK(1,22,0)
context_(pango_font_map_create_context(pango_cairo_font_map_get_default())),
#else
context_(pango_cairo_font_map_create_context((
reinterpret_cast<PangoCairoFontMap*>(pango_cairo_font_map_get_default())))),
#endif
layout_(pango_layout_new(context_)),
rect_(),
surface_(),
#ifdef SDL_GPU
texture_(),
#endif
text_(),
markedup_text_(false),
link_aware_(false),
link_color_(),
font_class_(font::FONT_SANS_SERIF),
font_size_(14),
font_style_(STYLE_NORMAL),
foreground_color_(0xFFFFFFFF), // solid white
maximum_width_(-1),
characters_per_line_(0),
maximum_height_(-1),
ellipse_mode_(PANGO_ELLIPSIZE_END),
alignment_(PANGO_ALIGN_LEFT),
maximum_length_(std::string::npos),
calculation_dirty_(true),
length_(0),
surface_dirty_(true),
surface_buffer_(nullptr)
{
// With 72 dpi the sizes are the same as with SDL_TTF so hardcoded.
pango_cairo_context_set_resolution(context_, 72.0);
pango_layout_set_ellipsize(layout_, ellipse_mode_);
pango_layout_set_alignment(layout_, alignment_);
pango_layout_set_wrap(layout_, PANGO_WRAP_WORD_CHAR);
/*
* Set the pango spacing a bit bigger since the default is deemed to small
* http://www.wesnoth.org/forum/viewtopic.php?p=358832#p358832
*/
pango_layout_set_spacing(layout_, 2 * PANGO_SCALE);
cairo_font_options_t *fo = cairo_font_options_create();
cairo_font_options_set_hint_style(fo, CAIRO_HINT_STYLE_FULL);
cairo_font_options_set_hint_metrics(fo, CAIRO_HINT_METRICS_ON);
#ifdef _WIN32
// Cairo on Windows (at least the latest available version from gtk.org
// as of 2014-02-22, version 1.10.2) has issues with ClearType resulting
// in glitchy anti-aliasing with CAIRO_ANTIALIAS_SUBPIXEL or
// CAIRO_ANTIALIAS_DEFAULT, but not CAIRO_ANTIALIAS_GRAY, so we use that
// as a workaround until the Windows package is updated to use a newer
// version of Cairo (see Wesnoth bug #21648).
cairo_font_options_set_antialias(fo, CAIRO_ANTIALIAS_GRAY);
#endif
pango_cairo_context_set_font_options(context_, fo);
cairo_font_options_destroy(fo);
}
开发者ID:PoignardAzur,项目名称:wesnoth,代码行数:60,代码来源:text.cpp
示例5: gitg_label_renderer_render_ref
GdkPixbuf *
gitg_label_renderer_render_ref (GtkWidget *widget, PangoFontDescription *description, GitgRef *ref, gint height, gint minwidth)
{
PangoContext *ctx = gtk_widget_get_pango_context(widget);
PangoLayout *layout = pango_layout_new(ctx);
pango_layout_set_font_description(layout, description);
gint width = MAX(get_label_width (layout, ref), minwidth);
cairo_surface_t *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width + 2, height + 2);
cairo_t *context = cairo_create (surface);
cairo_set_line_width (context, 1);
render_label (context, layout, ref, 1, 1, height, FALSE);
guint8 *data = cairo_image_surface_get_data (surface);
GdkPixbuf *ret = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, width + 2, height + 2);
guint8 *pixdata = gdk_pixbuf_get_pixels (ret);
convert_bgra_to_rgba (data, pixdata, width + 2, height + 2);
cairo_destroy (context);
cairo_surface_destroy (surface);
g_object_unref (layout);
return ret;
}
开发者ID:archanakumari,项目名称:gitg,代码行数:29,代码来源:gitg-label-renderer.c
示例6: GetVisibleStringWidth
//________________________________________________________
long GetVisibleStringWidth (_String& s, _HYFont& f)
{
static PangoLayout* textLayout = pango_layout_new (screenPContext);
static PangoFontDescription * fd = pango_font_description_new ();
static _HYFont stashedFont;
if (s.sLength) {
if (stashedFont.size!=f.size || stashedFont.style != f.style || stashedFont.face != f.face) {
HYFont2PangoFontDesc(f,fd);
pango_layout_set_width (textLayout,-1);
pango_layout_set_font_description(textLayout,fd);
stashedFont = f;
}
pango_layout_set_text (textLayout, s.sData,s.sLength);
//PangoRectangle charPos;
//pango_layout_index_to_pos (textLayout,s.sLength-1,&charPos);
//return PANGO_PIXELS(charPos.x+charPos.width);
PangoRectangle extents,
logical_ext;
pango_layout_get_pixel_extents (textLayout,&extents,&logical_ext);
return logical_ext.width;
} else {
return 0;
}
}
开发者ID:Nicholas-NVS,项目名称:hyphy,代码行数:28,代码来源:HYPlatformUtils.cpp
示例7: wxDynamicCast
// Get Gtk needed elements, if we have not them yet.
void wxTextMeasure::BeginMeasuring()
{
if ( m_dc )
{
#ifndef __WXGTK3__
m_wdc = wxDynamicCast(m_dc->GetImpl(), wxWindowDCImpl);
if ( m_wdc )
{
m_context = m_wdc->m_context;
m_layout = m_wdc->m_layout;
}
#endif // GTK+ < 3
}
else if ( m_win )
{
m_context = gtk_widget_get_pango_context( m_win->GetHandle() );
if ( m_context )
m_layout = pango_layout_new(m_context);
}
// set the font to use
if ( m_layout )
{
pango_layout_set_font_description(m_layout,
GetFont().GetNativeFontInfo()->description);
}
}
开发者ID:CobaltBlues,项目名称:wxWidgets,代码行数:28,代码来源:textmeasure.cpp
示例8: gitg_label_renderer_width
gint
gitg_label_renderer_width(GtkWidget *widget, PangoFontDescription *font, GSList *labels)
{
gint width = 0;
GSList *item;
if (labels == NULL)
return 0;
PangoContext *ctx = gtk_widget_get_pango_context(widget);
PangoLayout *layout = pango_layout_new(ctx);
pango_layout_set_font_description(layout, font);
for (item = labels; item; item = item->next)
{
gint w;
GitgRef *ref = (GitgRef *)item->data;
gchar *smaller = g_strdup_printf("<span size='smaller'>%s</span>", ref->shortname);
pango_layout_set_markup(layout, smaller, -1);
pango_layout_get_pixel_size(layout, &w, NULL);
width += w + PADDING * 2 + MARGIN;
g_free(smaller);
}
g_object_unref(layout);
//g_object_unref(ctx);
return width + MARGIN;
}
开发者ID:krh,项目名称:gitg,代码行数:31,代码来源:gitg-label-renderer.c
示例9: pango_layout_create
static PangoLayout *
pango_layout_create(JoyStyle *self)
{
struct Private *priv = GET_PRIVATE(self);
if (G_UNLIKELY(!priv->context)) {
goto error;
}
PangoLayout *layout = pango_layout_new(priv->context);
if (G_UNLIKELY(!layout)) {
goto error;
}
g_signal_connect(self, "context-changed",
G_CALLBACK(on_context_changed), layout);
exit:
{
PangoFontDescription *desc =
joy_style_get_font_description(self);
if (desc) {
pango_layout_set_font_description(layout, desc);
}
return layout;
}
error:
{
JoyStyle *parent = joy_style_get_parent(self);
if (!parent) {
return NULL;
}
layout = joy_style_pango_layout_create(parent);
goto exit;
}
}
开发者ID:msteinert,项目名称:joybubbles,代码行数:32,代码来源:theme.c
示例10: lmplayer_lyric_widget_da_new
GtkWidget *
lmplayer_lyric_widget_da_new()
{
LmplayerLyricWidgetDa *lyric;
LmplayerLyricWidgetDaPrivate *priv;
lyric = g_object_new(LMPLAYER_TYPE_LYRIC_WIDGET_DA, NULL);
priv = lyric->priv;
priv->alignment = gtk_alignment_new(0, 0, 1, 1);
gtk_widget_show(priv->alignment);
priv->da = gtk_drawing_area_new();
gtk_widget_show(priv->da);
//priv->da_gc = gdk_gc_new(priv->da->window);
priv->pango_context = gtk_widget_get_pango_context(priv->da);
priv->pango_layout = pango_layout_new(priv->pango_context);
gtk_container_add(GTK_CONTAINER(priv->alignment), priv->da);
gtk_container_add(GTK_CONTAINER(lyric), priv->alignment);
gtk_widget_set_events(priv->da, GDK_EXPOSURE_MASK);
g_signal_connect(G_OBJECT(lyric), "expose-event", G_CALLBACK(layout_expose_cb), lyric);
g_signal_connect(G_OBJECT(priv->da), "expose-event", G_CALLBACK(da_expose_cb), lyric);
g_signal_connect(G_OBJECT(priv->da), "configure-event", G_CALLBACK(da_configure_cb), lyric);
return GTK_WIDGET(lyric);
}
开发者ID:kelvenxu,项目名称:liblmplayer-lyric,代码行数:30,代码来源:lyric-widget-da.c
示例11: g_new0
LoadGraph *load_graph_new(gint size)
{
LoadGraph *lg;
lg = g_new0(LoadGraph, 1);
size++;
lg->suffix = g_strdup("");
lg->area = gtk_drawing_area_new();
lg->size = (size * 3) / 2;
lg->data = g_new0(gint, lg->size);
lg->scale = 1.0;
lg->width = size * 6;
lg->height = size * 2;
lg->max_value = 1;
lg->remax_count = 0;
lg->layout = pango_layout_new(gtk_widget_get_pango_context(lg->area));
gtk_widget_set_size_request(lg->area, lg->width, lg->height);
gtk_widget_show(lg->area);
return lg;
}
开发者ID:JamesMarkCN,项目名称:hardinfo,代码行数:28,代码来源:loadgraph.c
示例12: main
int
main (int argc,
char**argv)
{
PangoContext* context;
PangoLayout * layout;
Testcase * testcase;
gboolean passed = TRUE;
/* prepare */
gtk_init (&argc, &argv);
testcase = testcase_new ();
context = gdk_pango_context_get ();
layout = pango_layout_new (context);
pango_layout_set_text (layout, "Foo Bar Baz", -1);
/* exercise */
g_signal_connect (testcase, "exercise-gdk",
G_CALLBACK (test_gdk_cb), layout);
g_signal_connect (testcase, "exercise-cairo",
G_CALLBACK (test_cairo_cb), layout);
testcase_exercise (testcase);
/* verify */
passed = testcase_get_passed (testcase);
/* cleanup */
g_object_unref (testcase);
g_object_unref (layout);
g_object_unref (context);
return passed ? 0 : 1;
}
开发者ID:herzi,项目名称:rev-browser,代码行数:34,代码来源:test-gdk-draw-layout.c
示例13: GTK_WIDGET
//__________________________________________________________________
_HYRect _HYPullDown::_SuggestDimensions (void)
{
_HYRect res = {25,100,25,100,HY_COMPONENT_NO_SCROLL};
if (theMenu) {
long naturalWidth = 0;
PangoLayout * fontMeasurer = nil;
for (long k=0; k<widgetList.lLength; k+=2) {
GtkWidget * dropWidget = GTK_WIDGET (widgetList(k));
if (!fontMeasurer) {
fontMeasurer = pango_layout_new (gtk_widget_get_pango_context (dropWidget));
}
pango_layout_set_text(fontMeasurer,GetMenuItem(k/2)->sData ,GetMenuItem(k/2)->sLength);
PangoRectangle extents,
log_ext;
pango_layout_get_pixel_extents (fontMeasurer,&extents,nil);
if (extents.width > naturalWidth) {
naturalWidth = extents.width;
}
}
if (fontMeasurer) {
g_object_unref (fontMeasurer);
}
res.right = res.left = naturalWidth+25;
}
return res;
}
开发者ID:ArtPoon,项目名称:hyphy,代码行数:31,代码来源:HYPlatformPullDown.cpp
示例14: draw_init_font
void
draw_init_font (drawctx_t *ctx, int type, int reset) {
if (reset || !ctx->pango_ready) {
if (ctx->pangoctx) {
g_object_unref (ctx->pangoctx);
ctx->pangoctx = NULL;
}
if (ctx->pangolayout) {
g_object_unref (ctx->pangolayout);
ctx->pangolayout = NULL;
}
if (ctx->font_style) {
g_object_unref (ctx->font_style);
ctx->font_style = NULL;
}
ctx->font_style = gtk_style_new ();
if (ctx->font_style->font_desc) {
pango_font_description_free (ctx->font_style->font_desc);
ctx->font_style->font_desc = get_new_font_description_from_type (type);
}
ctx->pangoctx = gdk_pango_context_get ();
ctx->pangolayout = pango_layout_new (ctx->pangoctx);
pango_layout_set_ellipsize (ctx->pangolayout, PANGO_ELLIPSIZE_END);
PangoFontDescription *desc = ctx->font_style->font_desc;
ctx->font_weight = pango_font_description_get_weight (desc);
pango_layout_set_font_description (ctx->pangolayout, desc);
ctx->pango_ready = 1;
}
else if (ctx->pango_ready) {
PangoFontDescription *desc = ctx->font_style->font_desc;
pango_layout_set_font_description (ctx->pangolayout, desc);
}
}
开发者ID:bro1,项目名称:deadbeef,代码行数:35,代码来源:gdkdrawing.c
示例15: file_view_query_tooltip
static gboolean
file_view_query_tooltip (GtkWidget* widget, gint x, gint y, gboolean keyboard,
GtkTooltip* tooltip)
{
AnjutaFileView* view = ANJUTA_FILE_VIEW (widget);
AnjutaFileViewPrivate* priv = ANJUTA_FILE_VIEW_GET_PRIVATE (view);
GtkTreeModel* model_sort;
GtkTreeModel* file_model = GTK_TREE_MODEL (priv->model);
GtkTreePath* path;
GtkTreeIter iter;
GtkTreeIter real_iter;
gchar* filename;
gboolean result = TRUE;
GdkRectangle visible_rect, column_rect;
GdkScreen *screen = gdk_screen_get_default ();
PangoContext *context;
PangoLayout *layout;
gint width, height;
if (!gtk_tree_view_get_tooltip_context (GTK_TREE_VIEW (view),
&x, &y, keyboard,
&model_sort,
&path,
&iter))
return FALSE;
gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (model_sort),
&real_iter, &iter);
filename = file_model_get_filename (FILE_MODEL (file_model), &real_iter);
context = gdk_pango_context_get_for_screen (screen);
layout = pango_layout_new (context);
pango_layout_set_text (layout, filename, -1);
pango_layout_get_pixel_size (layout, &width, &height);
gtk_tree_view_get_visible_rect (GTK_TREE_VIEW (view), &visible_rect);
gtk_tree_view_get_cell_area (GTK_TREE_VIEW (view), path,
gtk_tree_view_get_column (GTK_TREE_VIEW (view), 0), &column_rect);
if (column_rect.x + width > visible_rect.x + visible_rect.width ||
column_rect.x < visible_rect.x)
{
gtk_tooltip_set_text (tooltip, filename);
gtk_tree_view_set_tooltip_row (GTK_TREE_VIEW (view),
tooltip,
path);
} else
{
result = FALSE;
}
g_free (filename);
gtk_tree_path_free (path);
g_object_unref (layout);
g_object_unref (context);
return result;
}
开发者ID:rosedu,项目名称:anjuta,代码行数:60,代码来源:file-view.c
示例16: 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;
}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:25,代码来源:VwGraphicsCairo.cpp
示例17: get_pango_layout
static PangoLayout *
get_pango_layout (GtkNumerableIcon *self)
{
PangoContext *context;
GdkScreen *screen;
PangoLayout *layout;
if (self->priv->style != NULL)
{
screen = gtk_style_context_get_screen (self->priv->style);
context = gdk_pango_context_get_for_screen (screen);
layout = pango_layout_new (context);
if (self->priv->font != NULL)
pango_layout_set_font_description (layout, self->priv->font);
pango_layout_set_text (layout, self->priv->rendered_string, -1);
g_object_unref (context);
}
else
{
GtkWidget *fake;
/* steal gtk text settings from the window */
fake = gtk_window_new (GTK_WINDOW_TOPLEVEL);
layout = gtk_widget_create_pango_layout (fake, self->priv->rendered_string);
gtk_widget_destroy (fake);
}
return layout;
}
开发者ID:BoozzyAmdJin,项目名称:gtk-,代码行数:32,代码来源:gtknumerableicon.c
示例18: ol_scroll_window_get_font_height
static int
ol_scroll_window_get_font_height (OlScrollWindow *scroll)
{
ol_assert_ret (OL_IS_SCROLL_WINDOW (scroll), 0);
OlScrollWindowPrivate *priv = OL_SCROLL_WINDOW_GET_PRIVATE (scroll);
PangoContext *pango_context = gdk_pango_context_get ();
PangoLayout *pango_layout = pango_layout_new (pango_context);
PangoFontDescription *font_desc = pango_font_description_from_string (priv->font_name);
pango_layout_set_font_description (pango_layout, font_desc);
PangoFontMetrics *metrics = pango_context_get_metrics (pango_context,
pango_layout_get_font_description (pango_layout), /* font desc */
NULL); /* languague */
int height = 0;
int ascent, descent;
ascent = pango_font_metrics_get_ascent (metrics);
descent = pango_font_metrics_get_descent (metrics);
pango_font_metrics_unref (metrics);
height += PANGO_PIXELS (ascent + descent);
pango_font_description_free (font_desc);
g_object_unref (pango_layout);
g_object_unref (pango_context);
return height;
}
开发者ID:AhmadMAlam,项目名称:osd-lyrics-1,代码行数:26,代码来源:ol_scroll_window.c
示例19: draw_init_font
void
draw_init_font (drawctx_t *ctx, GtkStyle *new_font_style) {
if (!ctx->pango_ready || (new_font_style && ctx->font_style != new_font_style)) {
if (ctx->pangoctx) {
g_object_unref (ctx->pangoctx);
ctx->pangoctx = NULL;
}
if (ctx->pangolayout) {
g_object_unref (ctx->pangolayout);
ctx->pangolayout = NULL;
}
ctx->font_style = new_font_style ? new_font_style : gtk_widget_get_default_style ();
ctx->pangoctx = gdk_pango_context_get ();
ctx->pangolayout = pango_layout_new (ctx->pangoctx);
pango_layout_set_ellipsize (ctx->pangolayout, PANGO_ELLIPSIZE_END);
PangoFontDescription *desc = ctx->font_style->font_desc;
ctx->font_weight = pango_font_description_get_weight (desc);
pango_layout_set_font_description (ctx->pangolayout, desc);
ctx->pango_ready = 1;
}
else if (new_font_style) {
PangoFontDescription *desc = ctx->font_style->font_desc;
pango_layout_set_font_description (ctx->pangolayout, desc);
}
}
开发者ID:rumly111,项目名称:deadbeef,代码行数:27,代码来源:gdkdrawing.c
示例20: text_widget_init
struct TEXT_WIDGET_HANDLE text_widget_init ( float x_mm, float y_mm,
float width_mm,
float height_mm,
float dpmm_x,
float dpmm_y )
{
struct TEXT_WIDGET_HANDLE handle;
handle.d = malloc( sizeof( struct TEXT_WIDGET_PRIVATE ) );
handle.d->x_mm = x_mm;
handle.d->y_mm = y_mm;
handle.d->dpmm_x = dpmm_x;
handle.d->dpmm_y = dpmm_y;
handle.d->font_map = pango_ft2_font_map_new();
// Note: FreeType works in DPI.
pango_ft2_font_map_set_resolution( (PangoFT2FontMap*)handle.d->font_map,
dpmm_x * 25.4, dpmm_y * 25.4 );
handle.d->context = pango_font_map_create_context( handle.d->font_map );
handle.d->layout = pango_layout_new( handle.d->context );
// Pango works in Pango Units. Not exactly clear how the resolution of
// the font and the size of the rendering box fit together.
int width = pango_units_from_double( dpmm_x * width_mm );
int height = pango_units_from_double( dpmm_y * height_mm );
pango_layout_set_width( handle.d->layout, width );
pango_layout_set_height( handle.d->layout, height );
handle.d->foreground = vgCreatePaint();
vgSetParameterfv( handle.d->foreground, VG_PAINT_COLOR, 4, DEFAULT_FOREGROUND );
return handle;
}
开发者ID:allenbarnett5,项目名称:mpddisplay,代码行数:33,代码来源:text_widget.c
注:本文中的pango_layout_new函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论