Exemplo n.º 1
0
static float measure_string_part(const char *s, const char *e)
{
	int c;
	float w = 0;
	while (s < e)
	{
		s += fz_chartorune(&c, s);
		w += ui_measure_character(ctx, c);
	}
	return w;
}
Exemplo n.º 2
0
static char *find_string_location(char *s, char *e, float w, float x)
{
	int c;
	while (s < e)
	{
		int n = fz_chartorune(&c, s);
		float cw = ui_measure_character(ctx, c);
		if (w + (cw / 2) >= x)
			return s;
		w += cw;
		s += n;
	}
	return e;
}
Exemplo n.º 3
0
float ui_measure_string(fz_context *ctx, char *str)
{
    int ucs;
    float x = 0;

    ui_begin_text(ctx);

    while (*str)
    {
        str += fz_chartorune(&ucs, str);
        x += ui_measure_character(ctx, ucs);
    }

    ui_end_text(ctx);

    return x;
}