Esempio n. 1
0
static VALUE
rg_index_to_x(VALUE self, VALUE index, VALUE trailing)
{
    int x_pos;
    pango_layout_line_index_to_x(_SELF(self), NUM2INT(index),
                                 RVAL2CBOOL(trailing), &x_pos);
    return INT2NUM(x_pos);
}
Esempio n. 2
0
FloatRect Font::selectionRectForComplexText(const TextRun& run, const FloatPoint& point, int h, int from, int to) const
{
#if USE(FREETYPE)
    if (!primaryFont()->platformData().m_pattern)
        return selectionRectForSimpleText(run, point, h, from, to);
#endif

    PangoLayout* layout = getDefaultPangoLayout(run);
    setPangoAttributes(this, run, layout);

    gchar* utf8 = convertUniCharToUTF8(run.characters(), run.length(), 0, run.length());
    pango_layout_set_text(layout, utf8, -1);

    char* start = g_utf8_offset_to_pointer(utf8, from);
    char* end = g_utf8_offset_to_pointer(start, to - from);

    if (run.ltr()) {
        from = start - utf8;
        to = end - utf8;
    } else {
        from = end - utf8;
        to = start - utf8;
    }

    PangoLayoutLine* layoutLine = pango_layout_get_line_readonly(layout, 0);
    int xPos;

    xPos = 0;
    if (from < layoutLine->length)
        pango_layout_line_index_to_x(layoutLine, from, FALSE, &xPos);
    float beforeWidth = PANGO_PIXELS_FLOOR(xPos);

    xPos = 0;
    if (run.ltr() || to < layoutLine->length)
        pango_layout_line_index_to_x(layoutLine, to, FALSE, &xPos);
    float afterWidth = PANGO_PIXELS(xPos);

    g_free(utf8);
    g_object_unref(layout);

    return FloatRect(point.x() + beforeWidth, point.y(), afterWidth - beforeWidth, h);
}
Esempio n. 3
0
JNIEXPORT void JNICALL
Java_org_gnome_pango_PangoLayoutLine_pango_1layout_1line_1index_1to_1x
(
	JNIEnv* env,
	jclass cls,
	jlong _self,
	jint _index,
	jboolean _trailing,
	jintArray _xPos
)
{
	PangoLayoutLine* self;
	int index;
	gboolean trailing;
	int* xPos;

	// convert parameter self
	self = (PangoLayoutLine*) _self;

	// convert parameter index
	index = (int) _index;

	// convert parameter trailing
	trailing = (gboolean) _trailing;

	// convert parameter xPos
	xPos = (int*) (*env)->GetIntArrayElements(env, _xPos, NULL);
	if (xPos == NULL) {
		return; // Java Exception already thrown
	}

	// call function
	pango_layout_line_index_to_x(self, index, trailing, xPos);

	// cleanup parameter self

	// cleanup parameter index

	// cleanup parameter trailing

	// cleanup parameter xPos
	(*env)->ReleaseIntArrayElements(env, _xPos, (jint*)xPos, 0);
}