summaryrefslogtreecommitdiff
path: root/src/lib/evas/common
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2016-07-14 17:31:09 +0100
committerTom Hacohen <tom@stosb.com>2016-07-14 17:32:01 +0100
commit8c6effae8ee027a928bcee79968a0b21d8250487 (patch)
tree5b506ad52e6217b3e5b2c3372c744b61202ea322 /src/lib/evas/common
parent281043e35718b3d6c5dec81d081c7785ed40bb90 (diff)
Evas font: Fix width query for OpenType fonts. (rewrite)
This is essentially a cleaner redo of ef817f15f0eaec9704ec25d9468c2c8497a5bc13. Logic should be exactly the same as there, the different is that this one shares the code between OT and non OT. Please refer to that commit for more information.
Diffstat (limited to 'src/lib/evas/common')
-rw-r--r--src/lib/evas/common/evas_font_query.c48
1 files changed, 37 insertions, 11 deletions
diff --git a/src/lib/evas/common/evas_font_query.c b/src/lib/evas/common/evas_font_query.c
index f435b9b..1d9b7dc 100644
--- a/src/lib/evas/common/evas_font_query.c
+++ b/src/lib/evas/common/evas_font_query.c
@@ -333,22 +333,48 @@ evas_common_font_query_size(RGBA_Font *fn, const Evas_Text_Props *text_props, in
333 333
334 if (text_props->len > 0) 334 if (text_props->len > 0)
335 { 335 {
336 const Evas_Font_Glyph_Info *glyph = text_props->info->glyph + 336 size_t off = text_props->start + text_props->len - 1;
337 const Evas_Font_Glyph_Info *first_glyph = text_props->info->glyph +
337 text_props->start; 338 text_props->start;
338 const Evas_Font_Glyph_Info *last_glyph = glyph; 339 const Evas_Font_Glyph_Info *last_glyph = text_props->info->glyph + off;;
340
341 const Evas_Font_Glyph_Info *glyph = last_glyph;
342 size_t cluster = 0;
343 size_t cur_cluster = 0;
344
345#ifdef OT_SUPPORT
346 Evas_Font_OT_Info *ot = text_props->info->ot + off;
347 cluster = ot->source_cluster;
348 cur_cluster = ot->source_cluster;
349#endif
339 350
340 if (text_props->len > 1) 351 do
341 { 352 {
342 last_glyph += text_props->len - 1; 353 Evas_Coord cur_w = 0;
343 ret_w = last_glyph[-1].pen_after; 354 if (text_props->len > 1)
344 if (text_props->start > 0) 355 {
345 ret_w -= glyph[-1].pen_after; 356 cur_w = last_glyph[-1].pen_after;
346 } 357 if (text_props->start > 0)
358 cur_w -= first_glyph[-1].pen_after;
359 }
360 cur_w += last_glyph->width + last_glyph->x_bear;
347#ifdef OT_SUPPORT 361#ifdef OT_SUPPORT
348 ret_w += EVAS_FONT_ROUND_26_6_TO_INT(EVAS_FONT_OT_X_OFF_GET( 362 cur_w += EVAS_FONT_ROUND_26_6_TO_INT(EVAS_FONT_OT_X_OFF_GET(
349 text_props->info->ot[text_props->start + text_props->len - 1])); 363 text_props->info->ot[text_props->start + text_props->len - 1]));
364
365 cur_cluster = ot->source_cluster;
366 ot--;
367#else
368 cur_cluster = cluster + 1; /* Change cluster manually for no OT */
350#endif 369#endif
351 ret_w += last_glyph->width + last_glyph->x_bear; 370 glyph--;
371
372 if (cur_w > ret_w)
373 {
374 ret_w = cur_w;
375 }
376 }
377 while ((glyph > first_glyph) && (cur_cluster == cluster));
352 } 378 }
353 379
354 if (w) *w = ret_w; 380 if (w) *w = ret_w;