summaryrefslogtreecommitdiff
path: root/src/lib/evas/canvas/evas_object_textgrid.c
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2015-09-02 23:02:29 +0200
committerBoris Faure <billiob@gmail.com>2016-03-12 18:42:50 +0100
commitb0d039aa02471c342523d11755dbb933f0ef5c83 (patch)
tree0383beb1b5b66532d53ce56e8faf725d225630f8 /src/lib/evas/canvas/evas_object_textgrid.c
parentf3dc094310d794435a9c7beceef760d1ea913a39 (diff)
evas_text_grid: display bold/italic/bolditalic fonts if available
Diffstat (limited to '')
-rw-r--r--src/lib/evas/canvas/evas_object_textgrid.c420
1 files changed, 310 insertions, 110 deletions
diff --git a/src/lib/evas/canvas/evas_object_textgrid.c b/src/lib/evas/canvas/evas_object_textgrid.c
index 45aeab620b..75ac501552 100644
--- a/src/lib/evas/canvas/evas_object_textgrid.c
+++ b/src/lib/evas/canvas/evas_object_textgrid.c
@@ -36,7 +36,7 @@ struct _Evas_Textgrid_Data
36 const char *font_source; 36 const char *font_source;
37 const char *font_name; 37 const char *font_name;
38 Evas_Font_Size font_size; 38 Evas_Font_Size font_size;
39 Evas_Font_Description *font_description; 39 Evas_Font_Description *font_description_normal;
40 40
41 Eina_Array palette_standard; 41 Eina_Array palette_standard;
42 Eina_Array palette_extended; 42 Eina_Array palette_extended;
@@ -44,7 +44,10 @@ struct _Evas_Textgrid_Data
44 44
45 int ascent; 45 int ascent;
46 46
47 Evas_Font_Set *font; 47 Evas_Font_Set *font_normal;
48 Evas_Font_Set *font_bold;
49 Evas_Font_Set *font_italic;
50 Evas_Font_Set *font_bolditalic;
48 51
49 unsigned int changed : 1; 52 unsigned int changed : 1;
50 unsigned int core_change : 1; 53 unsigned int core_change : 1;
@@ -75,9 +78,11 @@ struct _Evas_Object_Textgrid_Rect
75 78
76struct _Evas_Object_Textgrid_Text 79struct _Evas_Object_Textgrid_Text
77{ 80{
78 unsigned char r, g, b, a;
79 int x;
80 Evas_Text_Props text_props; 81 Evas_Text_Props text_props;
82 unsigned char r, g, b, a;
83 int x : 30;
84 unsigned char bold : 1;
85 unsigned char italic : 1;
81}; 86};
82 87
83struct _Evas_Object_Textgrid_Line 88struct _Evas_Object_Textgrid_Line
@@ -216,8 +221,14 @@ evas_object_textgrid_free(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj)
216 if (o->cur.rows) free(o->cur.rows); 221 if (o->cur.rows) free(o->cur.rows);
217 if (o->cur.font_name) eina_stringshare_del(o->cur.font_name); 222 if (o->cur.font_name) eina_stringshare_del(o->cur.font_name);
218 if (o->cur.font_source) eina_stringshare_del(o->cur.font_source); 223 if (o->cur.font_source) eina_stringshare_del(o->cur.font_source);
219 if (o->cur.font_description) evas_font_desc_unref(o->cur.font_description); 224
220 if (o->font) evas_font_free(obj->layer->evas->evas, o->font); 225 if (o->cur.font_description_normal)
226 evas_font_desc_unref(o->cur.font_description_normal);
227 if (o->font_normal) evas_font_free(obj->layer->evas->evas, o->font_normal);
228 if (o->font_bold) evas_font_free(obj->layer->evas->evas, o->font_bold);
229 if (o->font_italic) evas_font_free(obj->layer->evas->evas, o->font_italic);
230 if (o->font_bolditalic) evas_font_free(obj->layer->evas->evas, o->font_bolditalic);
231
221 if (o->cur.cells) free(o->cur.cells); 232 if (o->cur.cells) free(o->cur.cells);
222 while ((c = eina_array_pop(&o->cur.palette_standard))) 233 while ((c = eina_array_pop(&o->cur.palette_standard)))
223 free(c); 234 free(c);
@@ -265,17 +276,58 @@ evas_object_textgrid_row_rect_append(Evas_Object_Textgrid_Row *row,
265 row->rects[row->rects_num - 1].a = a; 276 row->rects[row->rects_num - 1].a = a;
266} 277}
267 278
279static Evas_Font_Set *
280_textgrid_font_get(Evas_Textgrid_Data *o,
281 Eina_Bool is_bold,
282 Eina_Bool is_italic)
283{
284 if ((!is_bold) && (!is_italic))
285 return o->font_normal;
286 /* bold */
287 else if ((is_bold) && (!is_italic))
288 {
289 if (o->font_bold)
290 return o->font_bold;
291 else
292 return o->font_normal;
293 }
294 /* italic */
295 else if ((!is_bold) && (is_italic))
296 {
297 if (o->font_italic)
298 return o->font_italic;
299 else
300 return o->font_normal;
301 }
302 /* bolditalic */
303 else
304 {
305 if (o->font_bolditalic)
306 return o->font_bolditalic;
307 else if (o->font_italic)
308 return o->font_italic;
309 else if (o->font_bold)
310 return o->font_bold;
311 else
312 return o->font_normal;
313 }
314}
315
268static void 316static void
269evas_object_textgrid_row_text_append(Evas_Object_Textgrid_Row *row, 317evas_object_textgrid_row_text_append(Evas_Object_Textgrid_Row *row,
270 Evas_Object_Protected_Data *obj, 318 Evas_Object_Protected_Data *obj,
271 Evas_Textgrid_Data *o, 319 Evas_Textgrid_Data *o,
272 int x, 320 int x,
273 Eina_Unicode codepoint, 321 Eina_Unicode codepoint,
274 int r, int g, int b, int a) 322 int r, int g, int b, int a,
323 Eina_Bool is_bold,
324 Eina_Bool is_italic)
275{ 325{
276 Evas_Script_Type script; 326 Evas_Script_Type script;
277 Evas_Font_Instance *script_fi = NULL; 327 Evas_Font_Instance *script_fi = NULL;
278 Evas_Font_Instance *cur_fi = NULL; 328 Evas_Font_Instance *cur_fi = NULL;
329 Evas_Object_Textgrid_Text *text;
330 Evas_Font_Set *font;
279 331
280 row->texts_num++; 332 row->texts_num++;
281 if (row->texts_num > row->texts_alloc) 333 if (row->texts_num > row->texts_alloc)
@@ -293,23 +345,24 @@ evas_object_textgrid_row_text_append(Evas_Object_Textgrid_Row *row,
293 } 345 }
294 346
295 script = evas_common_language_script_type_get(&codepoint, 1); 347 script = evas_common_language_script_type_get(&codepoint, 1);
296 ENFN->font_run_end_get(ENDT, o->font, &script_fi, &cur_fi, 348 text = &row->texts[row->texts_num - 1];
349 text->bold = is_bold;
350 text->italic = is_italic;
351 font = _textgrid_font_get(o, is_bold, is_italic);
352 ENFN->font_run_end_get(ENDT, font, &script_fi, &cur_fi,
297 script, &codepoint, 1); 353 script, &codepoint, 1);
298 memset(&(row->texts[row->texts_num - 1].text_props), 0, 354 memset(&(text->text_props), 0, sizeof(Evas_Text_Props));
299 sizeof(Evas_Text_Props)); 355 evas_common_text_props_script_set(&(text->text_props), script);
300 evas_common_text_props_script_set 356 ENFN->font_text_props_info_create(ENDT, script_fi, &codepoint,
301 (&(row->texts[row->texts_num - 1].text_props), script); 357 &(text->text_props), NULL, 0, 1,
302 ENFN->font_text_props_info_create 358 EVAS_TEXT_PROPS_MODE_NONE,
303 (ENDT, script_fi, &codepoint, 359 o->cur.font_description_normal->lang);
304 &(row->texts[row->texts_num - 1].text_props), NULL, 0, 1, 360
305 EVAS_TEXT_PROPS_MODE_NONE, 361 text->x = x;
306 o->cur.font_description->lang); 362 text->r = r;
307 363 text->g = g;
308 row->texts[row->texts_num - 1].x = x; 364 text->b = b;
309 row->texts[row->texts_num - 1].r = r; 365 text->a = a;
310 row->texts[row->texts_num - 1].g = g;
311 row->texts[row->texts_num - 1].b = b;
312 row->texts[row->texts_num - 1].a = a;
313} 366}
314 367
315static void 368static void
@@ -352,9 +405,10 @@ _drop_glyphs_ref(const void *container EINA_UNUSED, void *data, void *fdata)
352 405
353static void 406static void
354evas_object_textgrid_render(Evas_Object *eo_obj EINA_UNUSED, 407evas_object_textgrid_render(Evas_Object *eo_obj EINA_UNUSED,
355 Evas_Object_Protected_Data *obj, 408 Evas_Object_Protected_Data *obj,
356 void *type_private_data, 409 void *type_private_data,
357 void *output, void *context, void *surface, int x, int y, Eina_Bool do_async) 410 void *output, void *context, void *surface,
411 int x, int y, Eina_Bool do_async)
358{ 412{
359 Evas_Textgrid_Cell *cells; 413 Evas_Textgrid_Cell *cells;
360 Evas_Object_Textgrid_Color *c; 414 Evas_Object_Textgrid_Color *c;
@@ -367,7 +421,7 @@ evas_object_textgrid_render(Evas_Object *eo_obj EINA_UNUSED,
367 ENFN->context_multiplier_unset(output, context); 421 ENFN->context_multiplier_unset(output, context);
368 ENFN->context_render_op_set(output, context, obj->cur->render_op); 422 ENFN->context_render_op_set(output, context, obj->cur->render_op);
369 423
370 if (!(o->font) || (!o->cur.cells)) return; 424 if (!(o->font_normal) || (!o->cur.cells)) return;
371 425
372 w = o->cur.char_width; 426 w = o->cur.char_width;
373 h = o->cur.char_height; 427 h = o->cur.char_height;
@@ -439,7 +493,9 @@ evas_object_textgrid_render(Evas_Object *eo_obj EINA_UNUSED,
439 evas_object_textgrid_row_text_append(row, obj, 493 evas_object_textgrid_row_text_append(row, obj,
440 o, xp, 494 o, xp,
441 cells->codepoint, 495 cells->codepoint,
442 c->r, c->g, c->b, c->a); 496 c->r, c->g, c->b, c->a,
497 cells->bold,
498 cells->italic);
443 // XXX: underlines and strikethroughs dont get 499 // XXX: underlines and strikethroughs dont get
444 // merged into horizontal runs like bg rects above 500 // merged into horizontal runs like bg rects above
445 if (cells->underline) 501 if (cells->underline)
@@ -484,57 +540,82 @@ evas_object_textgrid_render(Evas_Object *eo_obj EINA_UNUSED,
484 { 540 {
485 if ((do_async) && (ENFN->multi_font_draw)) 541 if ((do_async) && (ENFN->multi_font_draw))
486 { 542 {
543 Evas_Font_Set *font, *current_font;
487 Eina_Bool async_unref; 544 Eina_Bool async_unref;
488 Evas_Font_Array_Data *fad; 545 Evas_Object_Textgrid_Text *text;
489
490 texts = malloc(sizeof(*texts));
491 texts->array = eina_inarray_new(sizeof(Evas_Font_Array_Data), 1); /* FIXME: Wasting 1 int here */
492 texts->refcount = 1;
493 546
494 fad = eina_inarray_grow(texts->array, row->texts_num); 547 xx = 0;
495 if (!fad) 548 do
496 {
497 ERR("Failed to allocate Evas_Font_Array_Data.");
498 eina_inarray_free(texts->array);
499 free(texts);
500 return;
501 }
502
503 for (xx = 0; xx < row->texts_num; xx++)
504 { 549 {
505 Evas_Text_Props *props; 550 texts = malloc(sizeof(*texts));
506 551 if (!texts)
507 props = &row->texts[xx].text_props; 552 {
508 553 ERR("Failed to allocate Evas_Font_Array.");
509 evas_common_font_draw_prepare(props); 554 return;
510 555 }
511 evas_common_font_glyphs_ref(props->glyphs); 556 texts->array = eina_inarray_new(sizeof(Evas_Font_Array_Data), 1);
512 evas_unref_queue_glyph_put(obj->layer->evas, 557 texts->refcount = 1;
513 props->glyphs); 558
514 559 text = &row->texts[xx];
515 fad->color.r = row->texts[xx].r; 560 font = _textgrid_font_get(o, text->bold, text->italic);
516 fad->color.g = row->texts[xx].g; 561
517 fad->color.b = row->texts[xx].b; 562 do
518 fad->color.a = row->texts[xx].a; 563 {
519 fad->x = row->texts[xx].x; 564 Evas_Font_Array_Data *fad;
520 fad->glyphs = props->glyphs; 565 Evas_Text_Props *props;
521 566
522 fad++; 567 current_font = font;
523 } 568
524 569 props = &text->text_props;
525 async_unref = 570 evas_common_font_draw_prepare(props);
526 ENFN->multi_font_draw(output, context, surface, 571
527 o->font, xp, yp + o->ascent, 572 evas_common_font_glyphs_ref(props->glyphs);
528 ww, hh, ww, hh, texts, do_async); 573 evas_unref_queue_glyph_put(obj->layer->evas,
529 if (async_unref) 574 props->glyphs);
530 evas_unref_queue_texts_put(obj->layer->evas, texts); 575
531 else 576 fad = eina_inarray_grow(texts->array, 1);
532 { 577 if (!fad)
533 eina_inarray_foreach(texts->array, _drop_glyphs_ref, 578 {
534 obj->layer->evas); 579 ERR("Failed to allocate Evas_Font_Array_Data.");
535 eina_inarray_free(texts->array); 580 eina_inarray_free(texts->array);
536 free(texts); 581 free(texts);
582 return;
583 }
584 fad->color.r = text->r;
585 fad->color.g = text->g;
586 fad->color.b = text->b;
587 fad->color.a = text->a;
588 fad->x = text->x;
589 fad->glyphs = props->glyphs;
590
591 fad++;
592
593 xx++;
594 if (xx >= row->texts_num)
595 break;
596 text = &row->texts[xx];
597 font = _textgrid_font_get(o, text->bold,
598 text->italic);
599 }
600 while (font == current_font);
601
602 async_unref =
603 ENFN->multi_font_draw(output, context, surface,
604 current_font,
605 xp,
606 yp + o->ascent,
607 ww, hh, ww, hh, texts, do_async);
608 if (async_unref)
609 evas_unref_queue_texts_put(obj->layer->evas, texts);
610 else
611 {
612 eina_inarray_foreach(texts->array, _drop_glyphs_ref,
613 obj->layer->evas);
614 eina_inarray_free(texts->array);
615 free(texts);
616 }
537 } 617 }
618 while (xx < row->texts_num);
538 } 619 }
539 else 620 else
540 { 621 {
@@ -542,20 +623,23 @@ evas_object_textgrid_render(Evas_Object *eo_obj EINA_UNUSED,
542 { 623 {
543 Evas_Text_Props *props; 624 Evas_Text_Props *props;
544 unsigned int r, g, b, a; 625 unsigned int r, g, b, a;
545 int tx = xp + row->texts[xx].x; 626 Evas_Object_Textgrid_Text *text = &row->texts[xx];
627 int tx = xp + text->x;
546 int ty = yp + o->ascent; 628 int ty = yp + o->ascent;
629 Evas_Font_Set *font;
547 630
548 props = &row->texts[xx].text_props; 631 props = &text->text_props;
549 632
550 r = row->texts[xx].r; 633 r = text->r;
551 g = row->texts[xx].g; 634 g = text->g;
552 b = row->texts[xx].b; 635 b = text->b;
553 a = row->texts[xx].a; 636 a = text->a;
554 637
555 ENFN->context_color_set(output, context, 638 ENFN->context_color_set(output, context,
556 r, g, b, a); 639 r, g, b, a);
640 font = _textgrid_font_get(o, text->bold, text->italic);
557 evas_font_draw_async_check(obj, output, context, surface, 641 evas_font_draw_async_check(obj, output, context, surface,
558 o->font, tx, ty, ww, hh, 642 font, tx, ty, ww, hh,
559 ww, hh, props, do_async); 643 ww, hh, props, do_async);
560 } 644 }
561 } 645 }
@@ -758,7 +842,7 @@ evas_object_textgrid_engine_data_get(Evas_Object *eo_obj)
758{ 842{
759 Evas_Textgrid_Data *o = eo_data_scope_get(eo_obj, MY_CLASS); 843 Evas_Textgrid_Data *o = eo_data_scope_get(eo_obj, MY_CLASS);
760 if (!o) return NULL; 844 if (!o) return NULL;
761 return o->font; 845 return o->font_normal; /* TODO: why ? */
762} 846}
763 847
764static int 848static int
@@ -899,35 +983,89 @@ _evas_textgrid_efl_text_properties_font_source_get(Eo *eo_obj EINA_UNUSED, Evas_
899 return o->cur.font_source; 983 return o->cur.font_source;
900} 984}
901 985
986static int
987_alternate_font_weight_slant(Evas_Object_Protected_Data *obj,
988 Evas_Textgrid_Data *o,
989 Evas_Font_Set **fontp,
990 Evas_Font_Description *fdesc)
991{
992 int ret = -1;
993 Evas_Font_Set *font;
994
995 font = evas_font_load(obj->layer->evas->evas,
996 fdesc,
997 o->cur.font_source,
998 (int)(((double) o->cur.font_size) *
999 obj->cur->scale));
1000 if (font)
1001 {
1002 Eina_Unicode W[2] = { 'O', 0 };
1003 Evas_Font_Instance *script_fi = NULL;
1004 Evas_Font_Instance *cur_fi = NULL;
1005 Evas_Text_Props text_props;
1006 Evas_Script_Type script;
1007 int advance, vadvance, ascent;
1008
1009 script = evas_common_language_script_type_get(W, 1);
1010 ENFN->font_run_end_get(ENDT, font, &script_fi, &cur_fi,
1011 script, W, 1);
1012 memset(&text_props, 0, sizeof(Evas_Text_Props));
1013 evas_common_text_props_script_set(&text_props, script);
1014 ENFN->font_text_props_info_create(ENDT, script_fi, W, &text_props,
1015 NULL, 0, 1,
1016 EVAS_TEXT_PROPS_MODE_NONE,
1017 fdesc->lang);
1018 advance = ENFN->font_h_advance_get(ENDT, font, &text_props);
1019 vadvance = ENFN->font_v_advance_get(ENDT, font, &text_props);
1020 ascent = ENFN->font_ascent_get(ENDT, font);
1021 if ((o->cur.char_width != advance) ||
1022 (o->cur.char_height != vadvance) ||
1023 (o->ascent != ascent))
1024 {
1025 evas_font_free(obj->layer->evas->evas, font);
1026 }
1027 else
1028 {
1029 *fontp = font;
1030 ret = 0;
1031 }
1032 evas_common_text_props_content_unref(&text_props);
1033 }
1034 return ret;
1035}
1036
902EOLIAN static void 1037EOLIAN static void
903_evas_textgrid_efl_text_properties_font_set(Eo *eo_obj, Evas_Textgrid_Data *o, const char *font_name, Evas_Font_Size font_size) 1038_evas_textgrid_efl_text_properties_font_set(Eo *eo_obj,
1039 Evas_Textgrid_Data *o,
1040 const char *font_name,
1041 Evas_Font_Size font_size)
904{ 1042{
905 Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS); 1043 Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
906 Eina_Bool is, was = EINA_FALSE; 1044 Eina_Bool is, was = EINA_FALSE;
907 Eina_Bool pass = EINA_FALSE, freeze = EINA_FALSE; 1045 Eina_Bool pass = EINA_FALSE, freeze = EINA_FALSE;
908 Eina_Bool source_invisible = EINA_FALSE; 1046 Eina_Bool source_invisible = EINA_FALSE;
909 Evas_Font_Description *font_description; 1047 Evas_Font_Description *fdesc;
910 1048
911 if ((!font_name) || (!*font_name) || (font_size <= 0)) 1049 if ((!font_name) || (!*font_name) || (font_size <= 0))
912 return; 1050 return;
913 1051
914 evas_object_async_block(obj); 1052 evas_object_async_block(obj);
915 font_description = evas_font_desc_new(); 1053 fdesc = evas_font_desc_new();
916
917 /* Set default language according to locale. */ 1054 /* Set default language according to locale. */
918 eina_stringshare_replace(&(font_description->lang), 1055 eina_stringshare_replace(&(fdesc->lang),
919 evas_font_lang_normalize("auto")); 1056 evas_font_lang_normalize("auto"));
920 evas_font_name_parse(font_description, font_name); 1057 evas_font_name_parse(fdesc, font_name);
921 if (o->cur.font_description && 1058 if (o->cur.font_description_normal &&
922 !evas_font_desc_cmp(font_description, o->cur.font_description) && 1059 !evas_font_desc_cmp(fdesc, o->cur.font_description_normal) &&
923 (font_size == o->cur.font_size)) 1060 (font_size == o->cur.font_size))
924 { 1061 {
925 evas_font_desc_unref(font_description); 1062 evas_font_desc_unref(fdesc);
926 return; 1063 return;
927 } 1064 }
928 1065
929 if (o->cur.font_description) evas_font_desc_unref(o->cur.font_description); 1066 if (o->cur.font_description_normal)
930 o->cur.font_description = font_description; 1067 evas_font_desc_unref(o->cur.font_description_normal);
1068 o->cur.font_description_normal = fdesc;
931 1069
932 o->cur.font_size = font_size; 1070 o->cur.font_size = font_size;
933 eina_stringshare_replace(&o->cur.font_name, font_name); 1071 eina_stringshare_replace(&o->cur.font_name, font_name);
@@ -944,19 +1082,19 @@ _evas_textgrid_efl_text_properties_font_set(Eo *eo_obj, Evas_Textgrid_Data *o, c
944 obj->layer->evas->pointer.y, 1082 obj->layer->evas->pointer.y,
945 1, 1); 1083 1, 1);
946 } 1084 }
947 1085
948 /* DO IT */ 1086 if (o->font_normal)
949 if (o->font)
950 { 1087 {
951 evas_font_free(obj->layer->evas->evas, o->font); 1088 evas_font_free(obj->layer->evas->evas, o->font_normal);
952 o->font = NULL; 1089 o->font_normal = NULL;
953 } 1090 }
954 1091
955 o->font = evas_font_load(obj->layer->evas->evas, o->cur.font_description, 1092 o->font_normal = evas_font_load(obj->layer->evas->evas,
1093 o->cur.font_description_normal,
956 o->cur.font_source, 1094 o->cur.font_source,
957 (int)(((double) o->cur.font_size) * 1095 (int)(((double) o->cur.font_size) *
958 obj->cur->scale)); 1096 obj->cur->scale));
959 if (o->font) 1097 if (o->font_normal)
960 { 1098 {
961 Eina_Unicode W[2] = { 'O', 0 }; 1099 Eina_Unicode W[2] = { 'O', 0 };
962 Evas_Font_Instance *script_fi = NULL; 1100 Evas_Font_Instance *script_fi = NULL;
@@ -964,21 +1102,21 @@ _evas_textgrid_efl_text_properties_font_set(Eo *eo_obj, Evas_Textgrid_Data *o, c
964 Evas_Text_Props text_props; 1102 Evas_Text_Props text_props;
965 Evas_Script_Type script; 1103 Evas_Script_Type script;
966 int advance, vadvance; 1104 int advance, vadvance;
967 1105
968 script = evas_common_language_script_type_get(W, 1); 1106 script = evas_common_language_script_type_get(W, 1);
969 ENFN->font_run_end_get(ENDT, o->font, &script_fi, &cur_fi, 1107 ENFN->font_run_end_get(ENDT, o->font_normal, &script_fi, &cur_fi,
970 script, W, 1); 1108 script, W, 1);
971 memset(&text_props, 0, sizeof(Evas_Text_Props)); 1109 memset(&text_props, 0, sizeof(Evas_Text_Props));
972 evas_common_text_props_script_set(&text_props, script); 1110 evas_common_text_props_script_set(&text_props, script);
973 ENFN->font_text_props_info_create(ENDT, script_fi, W, &text_props, 1111 ENFN->font_text_props_info_create(ENDT, script_fi, W, &text_props,
974 NULL, 0, 1, 1112 NULL, 0, 1,
975 EVAS_TEXT_PROPS_MODE_NONE, 1113 EVAS_TEXT_PROPS_MODE_NONE,
976 o->cur.font_description->lang); 1114 fdesc->lang);
977 advance = ENFN->font_h_advance_get(ENDT, o->font, &text_props); 1115 advance = ENFN->font_h_advance_get(ENDT, o->font_normal, &text_props);
978 vadvance = ENFN->font_v_advance_get(ENDT, o->font, &text_props); 1116 vadvance = ENFN->font_v_advance_get(ENDT, o->font_normal, &text_props);
979 o->cur.char_width = advance; 1117 o->cur.char_width = advance;
980 o->cur.char_height = vadvance; 1118 o->cur.char_height = vadvance;
981 o->ascent = ENFN->font_ascent_get(ENDT, o->font);; 1119 o->ascent = ENFN->font_ascent_get(ENDT, o->font_normal);
982 evas_common_text_props_content_unref(&text_props); 1120 evas_common_text_props_content_unref(&text_props);
983 } 1121 }
984 else 1122 else
@@ -993,6 +1131,68 @@ _evas_textgrid_efl_text_properties_font_set(Eo *eo_obj, Evas_Textgrid_Data *o, c
993 o->ascent = 0; 1131 o->ascent = 0;
994 } 1132 }
995 1133
1134 /* Bold */
1135 if (o->font_bold)
1136 {
1137 evas_font_free(obj->layer->evas->evas, o->font_bold);
1138 o->font_bold = NULL;
1139 }
1140 if (fdesc->weight == EVAS_FONT_WEIGHT_NORMAL)
1141 {
1142 Evas_Font_Description *bold_desc = evas_font_desc_dup(fdesc);
1143 bold_desc->weight = EVAS_FONT_WEIGHT_BOLD;
1144 _alternate_font_weight_slant(obj, o, &o->font_bold, bold_desc);
1145 evas_font_desc_unref(bold_desc);
1146 }
1147
1148 /* Italic */
1149 if (o->font_italic)
1150 {
1151 evas_font_free(obj->layer->evas->evas, o->font_italic);
1152 o->font_italic = NULL;
1153 }
1154 if (fdesc->slant == EVAS_FONT_SLANT_NORMAL)
1155 {
1156 Evas_Font_Description *italic_desc = evas_font_desc_dup(fdesc);
1157 int ret;
1158
1159 italic_desc->slant = EVAS_FONT_SLANT_ITALIC;
1160 ret = _alternate_font_weight_slant(obj, o, &o->font_italic,
1161 italic_desc);
1162 if (ret != 0)
1163 {
1164 italic_desc->slant = EVAS_FONT_SLANT_OBLIQUE;
1165 _alternate_font_weight_slant(obj, o, &o->font_italic,
1166 italic_desc);
1167 }
1168 evas_font_desc_unref(italic_desc);
1169 }
1170
1171 /* BoldItalic */
1172 if (o->font_bolditalic)
1173 {
1174 evas_font_free(obj->layer->evas->evas, o->font_bolditalic);
1175 o->font_bolditalic = NULL;
1176 }
1177 if (fdesc->slant == EVAS_FONT_SLANT_NORMAL &&
1178 fdesc->weight == EVAS_FONT_WEIGHT_NORMAL)
1179 {
1180 Evas_Font_Description *bolditalic_desc = evas_font_desc_dup(fdesc);
1181 int ret;
1182
1183 bolditalic_desc->slant = EVAS_FONT_SLANT_ITALIC;
1184 bolditalic_desc->weight = EVAS_FONT_WEIGHT_BOLD;
1185 ret = _alternate_font_weight_slant(obj, o, &o->font_bolditalic,
1186 bolditalic_desc);
1187 if (ret != 0)
1188 {
1189 bolditalic_desc->slant = EVAS_FONT_SLANT_OBLIQUE;
1190 _alternate_font_weight_slant(obj, o, &o->font_bolditalic,
1191 bolditalic_desc);
1192 }
1193 evas_font_desc_unref(bolditalic_desc);
1194 }
1195
996 o->changed = 1; 1196 o->changed = 1;
997 evas_object_change(eo_obj, obj); 1197 evas_object_change(eo_obj, obj);
998 evas_object_clip_dirty(eo_obj, obj); 1198 evas_object_clip_dirty(eo_obj, obj);