本文整理汇总了C++中pango_font_metrics_unref函数的典型用法代码示例。如果您正苦于以下问题:C++ pango_font_metrics_unref函数的具体用法?C++ pango_font_metrics_unref怎么用?C++ pango_font_metrics_unref使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pango_font_metrics_unref函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: gtk_glwidget_create_font
void gtk_glwidget_create_font (GtkWidget *widget)
{
PangoFontDescription *font_desc;
PangoFont *font;
PangoFontMetrics *font_metrics;
font_list_base = qglGenLists (256);
font_desc = pango_font_description_from_string (font_string);
font = gdk_gl_font_use_pango_font (font_desc, 0, 256, font_list_base);
if(font != NULL)
{
font_metrics = pango_font_get_metrics (font, NULL);
font_height = pango_font_metrics_get_ascent (font_metrics) +
pango_font_metrics_get_descent (font_metrics);
font_height = PANGO_PIXELS (font_height);
pango_font_metrics_unref (font_metrics);
}
pango_font_description_free (font_desc);
}
开发者ID:AEonZR,项目名称:GtkRadiant,代码行数:25,代码来源:glwidget.cpp
示例2: m_ascent
wxFontProperties::wxFontProperties(wxFont* font):
m_ascent(0), m_descent(0), m_lineGap(0), m_lineSpacing(0), m_xHeight(0)
{
PangoContext* context = gdk_pango_context_get_for_screen( gdk_screen_get_default() );
PangoLayout* layout = pango_layout_new(context);
// and use it if it's valid
if ( font && font->Ok() )
{
pango_layout_set_font_description
(
layout,
font->GetNativeFontInfo()->description
);
}
PangoFontMetrics* metrics = pango_context_get_metrics (context, font->GetNativeFontInfo()->description, NULL);
int height = font->GetPixelSize().GetHeight();
m_ascent = PANGO_PIXELS(pango_font_metrics_get_ascent(metrics));
m_descent = PANGO_PIXELS(pango_font_metrics_get_descent(metrics));
int h;
const char* x = "x";
pango_layout_set_text( layout, x, strlen(x) );
pango_layout_get_pixel_size( layout, NULL, &h );
m_xHeight = h;
m_lineGap = (m_ascent + m_descent) / 4; // FIXME: How can we calculate this via Pango?
m_lineSpacing = m_ascent + m_descent;
pango_font_metrics_unref(metrics);
}
开发者ID:Gin-Rye,项目名称:duibrowser,代码行数:34,代码来源:fontprops.cpp
示例3: myScreenUpdateFontHeight
gboolean
myScreenUpdateFontHeight (ScreenInfo *screen_info)
{
PangoFontDescription *desc;
PangoContext *context;
PangoFontMetrics *metrics;
GtkWidget *widget;
g_return_val_if_fail (screen_info != NULL, FALSE);
TRACE ("entering myScreenUpdateFontHeight");
widget = myScreenGetGtkWidget (screen_info);
context = getUIPangoContext (widget);
desc = getUIPangoFontDesc (widget);
if (desc && context)
{
metrics = pango_context_get_metrics (context, desc, NULL);
screen_info->font_height =
PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) +
pango_font_metrics_get_descent (metrics));
pango_font_metrics_unref (metrics);
return TRUE;
}
return FALSE;
}
开发者ID:Distrotech,项目名称:xfwm4,代码行数:28,代码来源:screen.c
示例4: 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
示例5: matchFont
WFontMetrics FontSupport::fontMetrics(const WFont& font)
{
PANGO_LOCK;
enabledFontFormats = enabledFontFormats_;
PangoFont *pangoFont = matchFont(font).pangoFont();
PangoFontMetrics *metrics = pango_font_get_metrics(pangoFont, nullptr);
double ascent
= pangoUnitsToDouble(pango_font_metrics_get_ascent(metrics));
double descent
= pangoUnitsToDouble(pango_font_metrics_get_descent(metrics));
double leading = (ascent + descent) - font.sizeLength(12).toPixels();
// ascent < leading is an odd thing. it happens with a font like
// Cursive.
if (ascent > leading)
ascent -= leading;
else
leading = 0;
WFontMetrics result(font, leading, ascent, descent);
pango_font_metrics_unref(metrics);
return result;
}
开发者ID:AlexanderKotliar,项目名称:wt,代码行数:29,代码来源:FontSupportPango.C
示例6: get_font_width
/* We don't support variable width fonts (yet) */
static gint get_font_width(GtkPrintContext *context, PangoFontDescription *desc)
{
PangoContext *pc;
PangoFontMetrics *metrics;
gint width;
pc = gtk_print_context_create_pango_context(context);
if (!utils_font_desc_check_monospace(pc, desc))
dialogs_show_msgbox_with_secondary(GTK_MESSAGE_WARNING,
_("The editor font is not a monospaced font!"),
_("Text will be wrongly spaced."));
metrics = pango_context_get_metrics(pc, desc, pango_context_get_language(pc));
/** TODO is this the best result we can get? */
/* digit and char width are mostly equal for monospace fonts, char width might be
* for dual width characters(e.g. Japanese) so use digit width to get sure we get the width
* for one character */
width = pango_font_metrics_get_approximate_digit_width(metrics) / PANGO_SCALE;
pango_font_metrics_unref(metrics);
g_object_unref(pc);
return width;
}
开发者ID:Hamakor,项目名称:geany,代码行数:26,代码来源:printing.c
示例7: pango_load
static bool
pango_load (Lisp_Font *f)
{
PangoLanguage *language;
PangoFontDescription *fontdesc;
PangoFont *font;
PangoFontMetrics *metrics;
if (pango_context)
{
language = pango_context_get_language (pango_context);
}
else
{
char *langname, *p;
#ifdef HAVE_PANGO_XFT
pango_context = pango_xft_get_context (dpy, screen_num);
#endif
langname = g_strdup (setlocale (LC_CTYPE, NULL));
p = strchr (langname, '.');
if (p)
*p = 0;
p = strchr (langname, '@');
if (p)
*p = 0;
language = pango_language_from_string (langname);
pango_context_set_language (pango_context, language);
g_free (langname);
}
fontdesc = pango_font_description_from_string (rep_STR (f->name));
if (!pango_font_description_get_family (fontdesc))
pango_font_description_set_family (fontdesc, "Sans");
if (pango_font_description_get_size (fontdesc) <= 0)
pango_font_description_set_size (fontdesc, 12 * PANGO_SCALE);
pango_context_set_font_description (pango_context, fontdesc);
font = pango_context_load_font (pango_context, fontdesc);
if (!font) {
pango_font_description_free(fontdesc);
return FALSE;
}
metrics = pango_font_get_metrics (font, language);
f->ascent = metrics->ascent / PANGO_SCALE;
f->descent = metrics->descent / PANGO_SCALE;
pango_font_metrics_unref (metrics);
f->font = fontdesc; /* We save the font description, not the font itself!
That's because it seems we can't recover it perfectly
later, and the layout routines want a description */
return TRUE;
}
开发者ID:tkorvola,项目名称:sawfish,代码行数:60,代码来源:fonts.c
示例8: tab_label_style_set_cb
static void
tab_label_style_set_cb (GtkWidget *hbox,
GtkStyle *previous_style,
gpointer user_data)
{
PangoFontMetrics *metrics;
PangoContext *context;
GtkWidget *button;
int char_width, h, w;
context = gtk_widget_get_pango_context (hbox);
metrics = pango_context_get_metrics (context,
hbox->style->font_desc,
pango_context_get_language (context));
char_width = pango_font_metrics_get_approximate_digit_width (metrics);
pango_font_metrics_unref (metrics);
gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (hbox),
GTK_ICON_SIZE_MENU, &w, &h);
gtk_widget_set_size_request
(hbox, TAB_WIDTH_N_CHARS * PANGO_PIXELS(char_width) + 2 * w, -1);
button = g_object_get_data (G_OBJECT (hbox), "close-button");
gtk_widget_set_size_request (button, w + 2, h + 2);
}
开发者ID:MDC,项目名称:Nautilus-Toolbar-Editor,代码行数:27,代码来源:nautilus-notebook.c
示例9: frame_update_titlebar_font
/*
* frame_update_titlebar_font
*
* Returns: void
* Description: updates the titlebar font from the pango context, should
* be called whenever the gtk style or font has changed
*/
void
frame_update_titlebar_font (decor_frame_t *frame)
{
const PangoFontDescription *font_desc;
PangoFontMetrics *metrics;
PangoLanguage *lang;
frame = gwd_decor_frame_ref (frame);
font_desc = get_titlebar_font (frame);
if (!font_desc)
{
GtkStyle *default_style;
default_style = gtk_widget_get_default_style ();
font_desc = default_style->font_desc;
}
pango_context_set_font_description (frame->pango_context, font_desc);
lang = pango_context_get_language (frame->pango_context);
metrics = pango_context_get_metrics (frame->pango_context, font_desc, lang);
frame->text_height = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) +
pango_font_metrics_get_descent (metrics));
gwd_decor_frame_unref (frame);
pango_font_metrics_unref (metrics);
}
开发者ID:Jubei-Mitsuyoshi,项目名称:aaa-compiz,代码行数:37,代码来源:decorator.c
示例10: _calc_footer_height
static gint
_calc_footer_height(GtkHTML * html, GtkPrintOperation * operation,
GtkPrintContext * context)
{
PangoContext *pango_context;
PangoFontDescription *desc;
PangoFontMetrics *metrics;
gint footer_height;
pango_context = gtk_print_context_create_pango_context(context);
desc = pango_font_description_from_string("Sans Regular 10");
metrics =
pango_context_get_metrics(pango_context, desc,
pango_language_get_default());
footer_height =
pango_font_metrics_get_ascent(metrics) +
pango_font_metrics_get_descent(metrics);
pango_font_metrics_unref(metrics);
pango_font_description_free(desc);
g_object_unref(pango_context);
return footer_height;
}
开发者ID:acli,项目名称:xiphos,代码行数:25,代码来源:slib-editor.c
示例11: matewnck_selector_get_width
static gint
matewnck_selector_get_width (GtkWidget *widget, const char *text)
{
GtkStyle *style;
PangoContext *context;
PangoFontMetrics *metrics;
gint char_width;
PangoLayout *layout;
PangoRectangle natural;
gint max_width;
gint screen_width;
gint width;
gtk_widget_ensure_style (widget);
style = gtk_widget_get_style (widget);
context = gtk_widget_get_pango_context (widget);
metrics = pango_context_get_metrics (context, style->font_desc,
pango_context_get_language (context));
char_width = pango_font_metrics_get_approximate_char_width (metrics);
pango_font_metrics_unref (metrics);
max_width = PANGO_PIXELS (SELECTOR_MAX_WIDTH * char_width);
layout = gtk_widget_create_pango_layout (widget, text);
pango_layout_get_pixel_extents (layout, NULL, &natural);
g_object_unref (G_OBJECT (layout));
screen_width = gdk_screen_get_width (gtk_widget_get_screen (widget));
width = MIN (natural.width, max_width);
width = MIN (width, 3 * (screen_width / 4));
return width;
}
开发者ID:bftanase,项目名称:libmatewnck,代码行数:34,代码来源:selector.c
示例12: pango_cairo_font_map_get_default
/*----------------------------------------------------------------------------------------------
Get Font Ascent and Descent in one go more efficent that making two calls.
----------------------------------------------------------------------------------------------*/
bool VwGraphicsCairo::FontAscentAndDescent(int * ascent, int * descent)
{
// cache the PangoFont and PangoFontMetricsfont to the m_pangoFontDescription
if (m_ascent == -1 && m_descent == -1)
{
if (m_fontMapForFontContext == NULL)
m_fontMapForFontContext = pango_cairo_font_map_get_default();
if (m_fontContext == NULL)
m_fontContext = pango_font_map_create_context (m_fontMapForFontContext);
PangoFont * font = pango_context_load_font(m_fontContext, m_pangoFontDescription);
// TODO-Linux: should we specify a language - for the font?
PangoFontMetrics * metrics = pango_font_get_metrics (font, NULL);
m_ascent = pango_font_metrics_get_ascent (metrics) / PANGO_SCALE;
m_descent = pango_font_metrics_get_descent (metrics) / PANGO_SCALE;
pango_font_metrics_unref(metrics);
g_object_unref(font);
}
if (ascent != NULL)
*ascent = m_ascent;
if (descent != NULL)
*descent = m_descent;
return true;
}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:37,代码来源:VwGraphicsCairo.cpp
示例13: measure_font
static void measure_font(const RrInstance *inst, RrFont *f)
{
PangoFontMetrics *metrics;
static PangoLanguage *lang = NULL;
if (lang == NULL) {
#if PANGO_VERSION_MAJOR > 1 || \
(PANGO_VERSION_MAJOR == 1 && PANGO_VERSION_MINOR >= 16)
lang = pango_language_get_default();
#else
gchar *locale, *p;
/* get the default language from the locale
(based on gtk_get_default_language in gtkmain.c) */
locale = g_strdup(setlocale(LC_CTYPE, NULL));
if ((p = strchr(locale, '.'))) *p = '\0'; /* strip off the . */
if ((p = strchr(locale, '@'))) *p = '\0'; /* strip off the @ */
lang = pango_language_from_string(locale);
g_free(locale);
#endif
}
/* measure the ascent and descent */
metrics = pango_context_get_metrics(inst->pango, f->font_desc, lang);
f->ascent = pango_font_metrics_get_ascent(metrics);
f->descent = pango_font_metrics_get_descent(metrics);
pango_font_metrics_unref(metrics);
}
开发者ID:AllesCoolAllesBestens,项目名称:openbox,代码行数:28,代码来源:font.c
示例14: e_contact_print_letter_heading
static void
e_contact_print_letter_heading (EContactPrintContext *ctxt,
gchar *letter)
{
PangoLayout *layout;
PangoFontDescription *desc;
PangoFontMetrics *metrics;
gint width, height;
cairo_t *cr;
desc = ctxt->letter_heading_font;
layout = gtk_print_context_create_pango_layout (ctxt->context);
/* Make the rectangle thrice the average character width.
* XXX Works well for English, what about other locales? */
metrics = pango_context_get_metrics (
pango_layout_get_context (layout),
desc, pango_language_get_default ());
width = pango_font_metrics_get_approximate_char_width (metrics) * 3;
pango_font_metrics_unref (metrics);
pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
pango_layout_set_font_description (layout, desc);
pango_layout_set_text (layout, letter, -1);
pango_layout_set_width (layout, width);
pango_layout_get_size (layout, NULL, &height);
if (ctxt->page_nr == -1 || ctxt->pages != ctxt->page_nr) {
/* only calculating number of pages
* or on page we do not want to print */
ctxt->y += pango_units_to_double (height);
return;
}
/* Draw white text centered in a black rectangle. */
cr = gtk_print_context_get_cairo_context (ctxt->context);
cairo_save (cr);
cairo_set_source_rgb (cr, .0, .0, .0);
cairo_rectangle (
cr, ctxt->x, ctxt->y,
pango_units_to_double (width),
pango_units_to_double (height));
cairo_fill (cr);
cairo_restore (cr);
cairo_save (cr);
cairo_move_to (cr, ctxt->x, ctxt->y);
cairo_set_source_rgb (cr, 1., 1., 1.);
pango_cairo_show_layout (cr, layout);
cairo_restore (cr);
ctxt->y += pango_units_to_double (height);
}
开发者ID:jdapena,项目名称:evolution,代码行数:56,代码来源:e-contact-print.c
示例15: ppb_browser_font_trusted_draw_text_at
PP_Bool
ppb_browser_font_trusted_draw_text_at(PP_Resource font, PP_Resource image_data,
const struct PP_BrowserFont_Trusted_TextRun *text,
const struct PP_Point *position, uint32_t color,
const struct PP_Rect *clip, PP_Bool image_data_is_opaque)
{
(void)image_data_is_opaque; // TODO: is it worth implementing?
struct pp_browser_font_s *bf = pp_resource_acquire(font, PP_RESOURCE_BROWSER_FONT);
if (!bf)
return PP_FALSE;
struct pp_image_data_s *id = pp_resource_acquire(image_data, PP_RESOURCE_IMAGE_DATA);
if (!id) {
pp_resource_release(font);
return PP_FALSE;
}
cairo_t *cr = cairo_create(id->cairo_surf);
if (clip) {
cairo_rectangle(cr, clip->point.x, clip->point.y, clip->size.width, clip->size.height);
cairo_clip(cr);
}
PangoFontMetrics *m = pango_font_get_metrics(bf->font, NULL);
int32_t ascent = pango_font_metrics_get_ascent(m) / PANGO_SCALE;
cairo_surface_mark_dirty(id->cairo_surf);
if (position)
cairo_move_to(cr, position->x, position->y - ascent);
else
cairo_move_to(cr, 0, 0);
pango_font_metrics_unref(m);
cairo_set_source_rgba(cr, ((color >> 16) & 0xffu) / 255.0,
((color >> 8) & 0xffu) / 255.0,
((color >> 0) & 0xffu) / 255.0,
((color >> 24) & 0xffu) / 255.0);
PangoLayout *layout = pango_cairo_create_layout(cr);
uint32_t len = 0;
const char *s = "";
if (text->text.type == PP_VARTYPE_STRING)
s = ppb_var_var_to_utf8(text->text, &len);
// TODO: factor into rtl direction
pango_layout_set_font_description(layout, bf->font_desc);
pango_layout_set_text(layout, s, len);
pango_cairo_layout_path(cr, layout);
cairo_fill(cr);
g_object_unref(layout);
cairo_surface_flush(id->cairo_surf);
cairo_destroy(cr);
pp_resource_release(font);
pp_resource_release(image_data);
return PP_FALSE;
}
开发者ID:evilpie,项目名称:freshplayerplugin,代码行数:55,代码来源:ppb_browser_font_trusted.c
示例16: draw_get_listview_rowheight
int
draw_get_listview_rowheight (drawctx_t *ctx) {
PangoFontDescription *font_desc = ctx->font_style->font_desc;
PangoFontMetrics *metrics = pango_context_get_metrics (ctx->pangoctx,
font_desc,
pango_context_get_language (ctx->pangoctx));
int row_height = (pango_font_metrics_get_ascent (metrics) +
pango_font_metrics_get_descent (metrics));
pango_font_metrics_unref (metrics);
return PANGO_PIXELS(row_height)+6;
}
开发者ID:rumly111,项目名称:deadbeef,代码行数:11,代码来源:gdkdrawing.c
示例17: textbox_get_estimated_char_width
double textbox_get_estimated_char_width ( void )
{
PangoFontDescription *pfd = pango_font_description_from_string ( config.menu_font );
// Get width
PangoFontMetrics *metric = pango_context_get_metrics ( p_context, pfd, NULL );
int width = pango_font_metrics_get_approximate_char_width ( metric );
pango_font_metrics_unref ( metric );
pango_font_description_free ( pfd );
return ( width ) / (double) PANGO_SCALE;
}
开发者ID:guyhughes,项目名称:rofi,代码行数:11,代码来源:textbox.c
示例18: textbox_cleanup
void textbox_cleanup ( void )
{
if ( p_metrics ) {
pango_font_metrics_unref ( p_metrics );
p_metrics = NULL;
}
if ( p_context ) {
g_object_unref ( p_context );
p_context = NULL;
}
}
开发者ID:DaveDavenport,项目名称:rofi,代码行数:11,代码来源:textbox.c
示例19: dump_font_sizes
static void
dump_font_sizes (PangoContext *context, FILE *f, guint flags)
{
PangoFont *font;
PangoFontDescription *pfd;
int nf;
real height;
fprintf (f, "height/cm");
for (nf = 0; test_families[nf] != NULL; ++nf)
fprintf (f, "\t%s", test_families[nf]);
fprintf (f, "\n");
for (height = 0.1; height <= 10.0; height += 0.1) {
fprintf (f, "%g", height);
for (nf = 0; test_families[nf] != NULL; ++nf) {
pfd = pango_font_description_new ();
pango_font_description_set_family (pfd, test_families[nf]);
//pango_font_description_set_size (pfd, height * pixels_per_cm * PANGO_SCALE);
if (flags & DUMP_ABSOLUTE)
pango_font_description_set_absolute_size (pfd, height * pixels_per_cm * PANGO_SCALE);
else
pango_font_description_set_size (pfd, height * pixels_per_cm * PANGO_SCALE);
font = pango_context_load_font (context, pfd);
if (font) {
PangoFontMetrics *metrics = pango_font_get_metrics (font, NULL);
/* now make a font-size where the font/line-height matches the given pixel size */
real total = ((double)pango_font_metrics_get_ascent (metrics)
+ pango_font_metrics_get_descent (metrics)) / PANGO_SCALE;
real factor = height*pixels_per_cm/total;
real line_height;
if (flags & DUMP_ABSOLUTE)
pango_font_description_set_absolute_size (pfd, factor * height * pixels_per_cm * PANGO_SCALE);
else
pango_font_description_set_size (pfd, factor * height * pixels_per_cm * PANGO_SCALE);
pango_font_metrics_unref (metrics);
g_object_unref (font);
font = pango_context_load_font (context, pfd);
metrics = pango_font_get_metrics (font, NULL);
line_height = ((double)pango_font_metrics_get_ascent (metrics)
+ pango_font_metrics_get_descent (metrics)) / PANGO_SCALE;
fprintf (f, "\t%.3g", flags & DUMP_FACTORS ? factor : line_height);
g_object_unref (font);
}
pango_font_description_free (pfd);
}
fprintf (f, "\n");
}
}
开发者ID:GNOME,项目名称:dia,代码行数:53,代码来源:font-height.c
示例20: textbox_get_estimated_char_height
int textbox_get_estimated_char_height ( void )
{
// Set font.
PangoFontDescription *pfd = pango_font_description_from_string ( config.menu_font );
// Get width
PangoFontMetrics *metric = pango_context_get_metrics ( p_context, pfd, NULL );
int height = pango_font_metrics_get_ascent ( metric ) + pango_font_metrics_get_descent ( metric );
pango_font_metrics_unref ( metric );
pango_font_description_free ( pfd );
return ( height ) / PANGO_SCALE + 2 * SIDE_MARGIN;
}
开发者ID:guyhughes,项目名称:rofi,代码行数:13,代码来源:textbox.c
注:本文中的pango_font_metrics_unref函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论