本文整理汇总了C++中PANGO_PIXELS函数的典型用法代码示例。如果您正苦于以下问题:C++ PANGO_PIXELS函数的具体用法?C++ PANGO_PIXELS怎么用?C++ PANGO_PIXELS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PANGO_PIXELS函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: text_entry_get_cursor_rectangle
static void
text_entry_get_cursor_rectangle(struct text_entry *entry, struct rectangle *rectangle)
{
struct rectangle allocation;
PangoRectangle extents;
PangoRectangle cursor_pos;
widget_get_allocation(entry->widget, &allocation);
if (entry->preedit.text && entry->preedit.cursor < 0) {
rectangle->x = 0;
rectangle->y = 0;
rectangle->width = 0;
rectangle->height = 0;
return;
}
pango_layout_get_extents(entry->layout, &extents, NULL);
pango_layout_get_cursor_pos(entry->layout,
entry->cursor + entry->preedit.cursor,
&cursor_pos, NULL);
rectangle->x = allocation.x + (allocation.height / 2) + PANGO_PIXELS(cursor_pos.x);
rectangle->y = allocation.y + 10 + PANGO_PIXELS(cursor_pos.y);
rectangle->width = PANGO_PIXELS(cursor_pos.width);
rectangle->height = PANGO_PIXELS(cursor_pos.height);
}
示例2: char_bounds
/* Given a paragraph and offset in that paragraph, find the
* bounding rectangle for the character at the offset.
*/
void
char_bounds (Paragraph *para, int index, int width, PangoRectangle *rect)
{
GList *para_list;
int height = 0;
para_list = paragraphs;
while (para_list)
{
Paragraph *cur_para = para_list->data;
if (cur_para == para)
{
PangoRectangle pos;
pango_layout_index_to_pos (cur_para->layout, index, &pos);
rect->x = PANGO_PIXELS (MIN (pos.x, pos.x + pos.width));
rect->width = PANGO_PIXELS (ABS (pos.width));
rect->y = height + PANGO_PIXELS (pos.y);
rect->height = PANGO_PIXELS (pos.height);
}
height += cur_para->height;
para_list = para_list->next;
}
}
示例3: unicodeGetXRanges
int unicodeGetXRanges(char *utf8, int utf8Length, int *resultPtr, int resultLength) {
int w, h, offsetX, offsetY;
int count, ch, i, j;
PangoRectangle rect;
count = unicodeLength(utf8, utf8Length);
if (resultLength < (2 * count)) return -1;
if (cachedLayout == NULL) {
cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_A8, 1, 1);
cairo_t *cr = cairo_create(surface);
cachedLayout = pango_cairo_create_layout(cr);
}
computeLayout(cachedLayout, utf8, utf8Length, &w, &h, &offsetX, &offsetY, NULL);
i = j = 0;
while ((i < utf8Length) && (j < (resultLength - 1))) {
pango_layout_index_to_pos(cachedLayout, i, &rect);
ch = utf8[i];
if ((ch & 0xE0) == 0xC0) i += 2;
else if ((ch & 0xF0) == 0xE0) i += 3;
else if ((ch & 0xF8) == 0xF0) i += 4;
else i += 1;
resultPtr[j] = PANGO_PIXELS(rect.x);
resultPtr[j + 1] = PANGO_PIXELS(rect.x + rect.width);
j += 2;
}
return count;
}
示例4: 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);
}
示例5: layout_iter_get_line_clip_region
/* Get a clip region to draw only part of a layout. index_ranges
* contains alternating range starts/stops. The region is the
* region which contains the given ranges, i.e. if you draw with the
* region as clip, only the given ranges are drawn.
*/
static cairo_region_t*
layout_iter_get_line_clip_region (PangoLayoutIter *iter,
gint x_origin,
gint y_origin,
const gint *index_ranges,
gint n_ranges)
{
PangoLayoutLine *line;
cairo_region_t *clip_region;
PangoRectangle logical_rect;
gint baseline;
gint i;
line = pango_layout_iter_get_line_readonly (iter);
clip_region = cairo_region_create ();
pango_layout_iter_get_line_extents (iter, NULL, &logical_rect);
baseline = pango_layout_iter_get_baseline (iter);
i = 0;
while (i < n_ranges)
{
gint *pixel_ranges = NULL;
gint n_pixel_ranges = 0;
gint j;
/* Note that get_x_ranges returns layout coordinates
*/
if (index_ranges[i*2+1] >= line->start_index &&
index_ranges[i*2] < line->start_index + line->length)
pango_layout_line_get_x_ranges (line,
index_ranges[i*2],
index_ranges[i*2+1],
&pixel_ranges, &n_pixel_ranges);
for (j = 0; j < n_pixel_ranges; j++)
{
GdkRectangle rect;
int x_off, y_off;
x_off = PANGO_PIXELS (pixel_ranges[2*j] - logical_rect.x);
y_off = PANGO_PIXELS (baseline - logical_rect.y);
rect.x = x_origin + x_off;
rect.y = y_origin - y_off;
rect.width = PANGO_PIXELS (pixel_ranges[2*j + 1] - logical_rect.x) - x_off;
rect.height = PANGO_PIXELS (baseline - logical_rect.y + logical_rect.height) - y_off;
cairo_region_union_rectangle (clip_region, &rect);
}
g_free (pixel_ranges);
++i;
}
return clip_region;
}
示例6: ScriptXtoCPRightToLeft
HRESULT ScriptXtoCPRightToLeft(
/*__in*/ int iX,
/*__in*/ int cChars,
/*__in*/ int cGlyphs,
/*__in*/ const WORD *pwLogClust,
/*__in*/ const SCRIPT_VISATTR *psva,
/*__in*/ const int *piAdvance,
/*__in*/ const SCRIPT_ANALYSIS *psa,
/*__out*/ int *piCP,
/*__out*/ int *piTrailing
)
{
// TODO: this implementation doesn't use pwLogClust
// which means it doesn't handle scripts whose clusters are not single Glyphs
int totalRunWidth = 0;
int pos = 0;
int index = 0;
// is iX isn't before run
if (iX < 0)
{
*piCP = cChars;
*piTrailing = 0;
return S_OK;
}
for (index = 0; index < cGlyphs; ++index)
totalRunWidth += piAdvance[index];
totalRunWidth = PANGO_PIXELS(totalRunWidth);
// is iX after run
if (iX >= totalRunWidth)
{
*piCP = -1;
*piTrailing = 1;
return S_OK;
}
// loop until pos in run is greater than or equal to iX
for (index = cGlyphs - 1; index >= 0 && pos < iX; --index)
pos += PANGO_PIXELS(piAdvance[index]);
// trailing or leading edge?
if (pos - iX > PANGO_PIXELS(piAdvance[index]/2))
*piTrailing = 0;
else
*piTrailing = 1;
*piCP = index + 1;
Assert(*piCP >= 0);
return S_OK;
}
示例7: show_text
void
show_text(GtkWidget *window, const char *text)
{
GtkWidget *dialog, *content_area, *view, *sw;
GtkDialogFlags flags = GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT;
dialog = gtk_dialog_new_with_buttons(PACKAGE_NAME " Help",
GTK_WINDOW(window),
flags,
"_Close",
GTK_RESPONSE_CANCEL,
NULL);
content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CANCEL);
sw = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
GTK_SHADOW_IN);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
GTK_POLICY_NEVER,
GTK_POLICY_AUTOMATIC);
gtk_container_add_with_properties(GTK_CONTAINER(content_area), sw,
"expand", TRUE,
"fill", TRUE,
NULL);
view = gtk_text_view_new();
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(view), GTK_WRAP_WORD);
gtk_text_buffer_set_text(gtk_text_view_get_buffer(GTK_TEXT_VIEW(view)),
text, -1);
gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(view), FALSE);
gtk_text_view_set_editable(GTK_TEXT_VIEW(view), FALSE);
/* Use font metrics to set the size of the text view. */
PangoContext *context = gtk_widget_get_pango_context(view);
PangoFontMetrics *metrics = pango_context_get_metrics(context, NULL, NULL);
gint char_width = pango_font_metrics_get_approximate_char_width(metrics);
gint ascent = pango_font_metrics_get_ascent(metrics);
gint descent = pango_font_metrics_get_descent(metrics);
gint height = PANGO_PIXELS(ascent + descent);
gint width = PANGO_PIXELS(char_width);
gtk_text_view_set_left_margin(GTK_TEXT_VIEW(view), 2 * width);
gtk_text_view_set_right_margin(GTK_TEXT_VIEW(view), 2 * width);
gtk_window_set_default_size(GTK_WINDOW(dialog), 70 * width, 20 * height);
gtk_container_add(GTK_CONTAINER(sw), view);
gtk_widget_show_all(dialog);
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
}
示例8: mw_tooltip_timeout
gboolean mw_tooltip_timeout(GtkWidget *tv)
{
GtkAllocation allocation;
int scr_w,scr_h, w, h, x, y;
char *tooltiptext = NULL;
tooltiptext = get_tooltip_text();
tipwindow = gtk_window_new(GTK_WINDOW_POPUP);
gtk_widget_set_parent(tipwindow, tv);
gtk_widget_set_app_paintable(tipwindow, TRUE);
gtk_window_set_resizable(GTK_WINDOW(tipwindow), FALSE);
gtk_widget_set_name(tipwindow, "gtk-tooltips");
g_signal_connect(G_OBJECT(tipwindow), "expose_event",
G_CALLBACK(mw_paint_tip), NULL);
gtk_widget_ensure_style (tipwindow);
layout = gtk_widget_create_pango_layout (tipwindow, NULL);
pango_layout_set_wrap(layout, PANGO_WRAP_WORD);
pango_layout_set_width(layout, 300000);
pango_layout_set_markup(layout, tooltiptext, strlen(tooltiptext));
scr_w = gdk_screen_width();
scr_h = gdk_screen_height();
pango_layout_get_size (layout, &w, &h);
w = PANGO_PIXELS(w) + 8;
h = PANGO_PIXELS(h) + 8;
gdk_window_get_pointer(NULL, &x, &y, NULL);
if (!gtk_widget_get_has_window (mw.vbox))
{
gtk_widget_get_allocation (mw.vbox, &allocation);
y += allocation.y;
}
x -= ((w >> 1) + 4);
if ((x + w) > scr_w)
x -= (x + w) - scr_w;
else if (x < 0)
x = 0;
if ((y + h + 4) > scr_h)
y = y - h;
else
y = y + 6;
/*
g_object_unref(layout);
*/
g_free(tooltiptext);
gtk_widget_set_size_request(tipwindow, w, h);
gtk_window_move(GTK_WINDOW(tipwindow), x, y);
gtk_widget_show(tipwindow);
return FALSE;
}
示例9: drawstring
/* subfunction of gtk_plot_cairo_draw_string(). */
static gint
drawstring(GtkPlotPC *pc,
gint angle,
gint dx, gint dy,
GtkPSFont *psfont, gint height,
const gchar *text)
{
cairo_t *cairo = GTK_PLOT_CAIRO(pc)->cairo;
PangoLayout *layout = GTK_PLOT_CAIRO(pc)->layout;
PangoFontDescription *font;
PangoRectangle rect;
PangoFontMap *map;
gint ret_value;
gint dpi_cairo, dpi_screen;
GdkScreen *screen = gdk_screen_get_default();
if(!text || strlen(text) == 0) return 0;
cairo_save(cairo);
map = pango_cairo_font_map_get_default();
dpi_cairo = pango_cairo_font_map_get_resolution(PANGO_CAIRO_FONT_MAP(map));
dpi_screen = gdk_screen_get_resolution(screen);
height *= (double)dpi_screen/(double)dpi_cairo;
font = gtk_psfont_get_font_description(psfont, height);
pango_layout_set_font_description(GTK_PLOT_CAIRO(pc)->layout, font);
pango_layout_set_text(GTK_PLOT_CAIRO(pc)->layout, text, strlen(text));
pango_layout_get_extents(GTK_PLOT_CAIRO(pc)->layout, NULL, &rect);
if (psfont->i18n_latinfamily && psfont->vertical) {
/* vertical-writing CJK postscript fonts. */
return rect.height;
}
else
{
/* horizontal writing */
if(angle == 90)
// cairo_translate(cairo, dx, dy-PANGO_PIXELS(rect.width));
cairo_translate(cairo, dx, dy);
else if(angle == 270)
cairo_translate(cairo, dx+PANGO_PIXELS(rect.height), dy);
else if(angle == 180)
cairo_translate(cairo, dx-PANGO_PIXELS(rect.width), dy);
else
cairo_translate(cairo, dx, dy);
}
cairo_rotate(cairo, -angle * G_PI / 180);
pango_cairo_update_layout(cairo, layout);
pango_cairo_show_layout(cairo, layout);
cairo_restore(cairo);
pango_font_description_free(font);
ret_value = (angle == 0 || angle == 180) ? rect.width : rect.height;
return PANGO_PIXELS(rect.width);
}
示例10: wxGTK_CONV_FONT
// Notice we don't check here the font. It is supposed to be OK before the call.
void wxTextMeasure::DoGetTextExtent(const wxString& string,
wxCoord *width,
wxCoord *height,
wxCoord *descent,
wxCoord *externalLeading)
{
if ( !m_context )
{
if ( width )
*width = 0;
if ( height )
*height = 0;
return;
}
// Set layout's text
const wxCharBuffer dataUTF8 = wxGTK_CONV_FONT(string, GetFont());
if ( !dataUTF8 )
{
// hardly ideal, but what else can we do if conversion failed?
wxLogLastError(wxT("GetTextExtent"));
return;
}
pango_layout_set_text(m_layout, dataUTF8, -1);
if ( m_dc )
{
// in device units
pango_layout_get_pixel_size(m_layout, width, height);
}
else // win
{
// the logical rect bounds the ink rect
PangoRectangle rect;
pango_layout_get_extents(m_layout, NULL, &rect);
*width = PANGO_PIXELS(rect.width);
*height = PANGO_PIXELS(rect.height);
}
if (descent)
{
PangoLayoutIter *iter = pango_layout_get_iter(m_layout);
int baseline = pango_layout_iter_get_baseline(iter);
pango_layout_iter_free(iter);
*descent = *height - PANGO_PIXELS(baseline);
}
if (externalLeading)
{
// No support for MSW-like "external leading" in Pango.
*externalLeading = 0;
}
}
示例11: gdk_threads_enter
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkFontPeer_getFontMetrics
(JNIEnv *env, jobject java_font, jdoubleArray java_metrics)
{
struct peerfont *pfont = NULL;
jdouble *native_metrics = NULL;
PangoFontMetrics *pango_metrics;
gdk_threads_enter();
pfont = (struct peerfont *) NSA_GET_FONT_PTR (env, java_font);
g_assert (pfont != NULL);
pango_metrics
= pango_context_get_metrics (pfont->ctx, pfont->desc,
gtk_get_default_language ());
native_metrics
= (*env)->GetDoubleArrayElements (env, java_metrics, NULL);
g_assert (native_metrics != NULL);
native_metrics[FONT_METRICS_ASCENT]
= PANGO_PIXELS (pango_font_metrics_get_ascent (pango_metrics));
native_metrics[FONT_METRICS_MAX_ASCENT]
= native_metrics[FONT_METRICS_ASCENT];
native_metrics[FONT_METRICS_DESCENT]
= PANGO_PIXELS (pango_font_metrics_get_descent (pango_metrics));
if (native_metrics[FONT_METRICS_DESCENT] < 0)
native_metrics[FONT_METRICS_DESCENT]
= - native_metrics[FONT_METRICS_DESCENT];
native_metrics[FONT_METRICS_MAX_DESCENT]
= native_metrics[FONT_METRICS_DESCENT];
native_metrics[FONT_METRICS_MAX_ADVANCE]
= PANGO_PIXELS (pango_font_metrics_get_approximate_char_width
(pango_metrics));
(*env)->ReleaseDoubleArrayElements (env,
java_metrics,
native_metrics, 0);
pango_font_metrics_unref (pango_metrics);
gdk_threads_leave();
}
示例12: gnm_notebook_button_size_allocate
static void
gnm_notebook_button_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GnmNotebookButton *nbb = GNM_NOTEBOOK_BUTTON (widget);
gnm_notebook_button_ensure_layout (nbb);
nbb->x_offset =
(allocation->width - PANGO_PIXELS (nbb->logical.width)) / 2;
nbb->x_offset_active =
(allocation->width - PANGO_PIXELS (nbb->logical_active.width)) / 2;
GTK_WIDGET_CLASS(gnm_notebook_button_parent_class)
->size_allocate (widget, allocation);
}
示例13: util_split_font_string
static gboolean
util_split_font_string(const gchar *font_name, gchar **name, gint *size)
{
PangoFontDescription *desc;
PangoFontMask mask;
gboolean retval = FALSE;
if (font_name == NULL) {
return FALSE;
}
mask = (PangoFontMask) (PANGO_FONT_MASK_FAMILY | PANGO_FONT_MASK_SIZE);
desc = pango_font_description_from_string(font_name);
if (!desc) {
return FALSE;
}
if ((pango_font_description_get_set_fields(desc) & mask) == mask) {
*size = PANGO_PIXELS(pango_font_description_get_size (desc));
*name = g_strdup(pango_font_description_get_family (desc));
retval = TRUE;
}
pango_font_description_free(desc);
return retval;
}
示例14: nsfont_position_in_string
/**
* Find the position in a string where an x coordinate falls.
*
* \param[in] fstyle style for this text
* \param[in] string UTF-8 string to measure
* \param[in] length length of string, in bytes
* \param[in] x coordinate to search for
* \param[out] char_offset updated to offset in string of actual_x, [0..length]
* \param[out] actual_x updated to x coordinate of character closest to x
* \return NSERROR_OK and char_offset and actual_x updated or appropriate
* error code on faliure
*/
static nserror
nsfont_position_in_string(const plot_font_style_t *fstyle,
const char *string,
size_t length,
int x,
size_t *char_offset,
int *actual_x)
{
int index;
PangoFontDescription *desc;
PangoRectangle pos;
nsfont_pango_check();
desc = nsfont_style_to_description(fstyle);
pango_layout_set_font_description(nsfont_pango_layout, desc);
pango_font_description_free(desc);
pango_layout_set_text(nsfont_pango_layout, string, length);
if (pango_layout_xy_to_index(nsfont_pango_layout,
x * PANGO_SCALE,
0, &index, 0) == FALSE) {
index = length;
}
pango_layout_index_to_pos(nsfont_pango_layout, index, &pos);
*char_offset = index;
*actual_x = PANGO_PIXELS(pos.x);
return NSERROR_OK;
}
示例15: 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);
}