summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2015-09-02 23:02:29 +0200
committerBoris Faure <billiob@gmail.com>2015-10-04 17:18:19 +0200
commitb802a620c37d3304ceaaa366f29abd2c1455e2f1 (patch)
tree197198a8342746c75c25707983f9c13f05fb481d
parentad0c89bd2b926d712288520a6a3b699b043f6ade (diff)
evas_text_grid: display bold/italic/bolditalic fonts if availabledevs/billiob/textgrid_bolditalic
-rw-r--r--src/lib/evas/canvas/evas_object_textgrid.c421
1 files changed, 314 insertions, 107 deletions
diff --git a/src/lib/evas/canvas/evas_object_textgrid.c b/src/lib/evas/canvas/evas_object_textgrid.c
index 53f38a9238..f23a3dd67a 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 int bold : 1;
85 int italic : 1;
81}; 86};
82 87
83struct _Evas_Object_Textgrid_Line 88struct _Evas_Object_Textgrid_Line
@@ -217,8 +222,14 @@ evas_object_textgrid_free(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj)
217 if (o->cur.rows) free(o->cur.rows); 222 if (o->cur.rows) free(o->cur.rows);
218 if (o->cur.font_name) eina_stringshare_del(o->cur.font_name); 223 if (o->cur.font_name) eina_stringshare_del(o->cur.font_name);
219 if (o->cur.font_source) eina_stringshare_del(o->cur.font_source); 224 if (o->cur.font_source) eina_stringshare_del(o->cur.font_source);
220 if (o->cur.font_description) evas_font_desc_unref(o->cur.font_description); 225
221 if (o->font) evas_font_free(obj->layer->evas->evas, o->font); 226 if (o->cur.font_description_normal)
227 evas_font_desc_unref(o->cur.font_description_normal);
228 if (o->font_normal) evas_font_free(obj->layer->evas->evas, o->font_normal);
229 if (o->font_bold) evas_font_free(obj->layer->evas->evas, o->font_bold);
230 if (o->font_italic) evas_font_free(obj->layer->evas->evas, o->font_italic);
231 if (o->font_bolditalic) evas_font_free(obj->layer->evas->evas, o->font_bolditalic);
232
222 if (o->cur.cells) free(o->cur.cells); 233 if (o->cur.cells) free(o->cur.cells);
223 while ((c = eina_array_pop(&o->cur.palette_standard))) 234 while ((c = eina_array_pop(&o->cur.palette_standard)))
224 free(c); 235 free(c);
@@ -266,17 +277,58 @@ evas_object_textgrid_row_rect_append(Evas_Object_Textgrid_Row *row,
266 row->rects[row->rects_num - 1].a = a; 277 row->rects[row->rects_num - 1].a = a;
267} 278}
268 279
280static Evas_Font_Set *
281_textgrid_font_description_get(Evas_Textgrid_Data *o,
282 Eina_Bool is_bold,
283 Eina_Bool is_italic)
284{
285 if ((!is_bold) && (!is_italic))
286 return o->font_normal;
287 /* bold */
288 else if ((is_bold) && (!is_italic))
289 {
290 if (o->font_bold)
291 return o->font_bold;
292 else
293 return o->font_normal;
294 }
295 /* italic */
296 else if ((!is_bold) && (is_italic))
297 {
298 if (o->font_italic)
299 return o->font_italic;
300 else
301 return o->font_normal;
302 }
303 /* bolditalic */
304 else
305 {
306 if (o->font_bolditalic)
307 return o->font_bolditalic;
308 else if (o->font_italic)
309 return o->font_italic;
310 else if (o->font_bold)
311 return o->font_bold;
312 else
313 return o->font_normal;
314 }
315}
316
269static void 317static void
270evas_object_textgrid_row_text_append(Evas_Object_Textgrid_Row *row, 318evas_object_textgrid_row_text_append(Evas_Object_Textgrid_Row *row,
271 Evas_Object_Protected_Data *obj, 319 Evas_Object_Protected_Data *obj,
272 Evas_Textgrid_Data *o, 320 Evas_Textgrid_Data *o,
273 int x, 321 int x,
274 Eina_Unicode codepoint, 322 Eina_Unicode codepoint,
275 int r, int g, int b, int a) 323 int r, int g, int b, int a,
324 Eina_Bool is_bold,
325 Eina_Bool is_italic)
276{ 326{
277 Evas_Script_Type script; 327 Evas_Script_Type script;
278 Evas_Font_Instance *script_fi = NULL; 328 Evas_Font_Instance *script_fi = NULL;
279 Evas_Font_Instance *cur_fi = NULL; 329 Evas_Font_Instance *cur_fi = NULL;
330 Evas_Object_Textgrid_Text *text;
331 Evas_Font_Set *font;
280 332
281 row->texts_num++; 333 row->texts_num++;
282 if (row->texts_num > row->texts_alloc) 334 if (row->texts_num > row->texts_alloc)
@@ -294,22 +346,23 @@ evas_object_textgrid_row_text_append(Evas_Object_Textgrid_Row *row,
294 } 346 }
295 347
296 script = evas_common_language_script_type_get(&codepoint, 1); 348 script = evas_common_language_script_type_get(&codepoint, 1);
297 ENFN->font_run_end_get(ENDT, o->font, &script_fi, &cur_fi, 349 text = &row->texts[row->texts_num - 1];
350 text->bold = is_bold;
351 text->italic = is_italic;
352 font = _textgrid_font_description_get(o, is_bold, is_italic);
353 ENFN->font_run_end_get(ENDT, font, &script_fi, &cur_fi,
298 script, &codepoint, 1); 354 script, &codepoint, 1);
299 memset(&(row->texts[row->texts_num - 1].text_props), 0, 355 memset(&(text->text_props), 0, sizeof(Evas_Text_Props));
300 sizeof(Evas_Text_Props)); 356 evas_common_text_props_script_set(&(text->text_props), script);
301 evas_common_text_props_script_set 357 ENFN->font_text_props_info_create(ENDT, script_fi, &codepoint,
302 (&(row->texts[row->texts_num - 1].text_props), script); 358 &(text->text_props), NULL, 0, 1,
303 ENFN->font_text_props_info_create 359 EVAS_TEXT_PROPS_MODE_NONE);
304 (ENDT, script_fi, &codepoint, 360
305 &(row->texts[row->texts_num - 1].text_props), NULL, 0, 1, 361 text->x = x;
306 EVAS_TEXT_PROPS_MODE_NONE); 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
@@ -351,10 +404,11 @@ _drop_glyphs_ref(const void *container EINA_UNUSED, void *data, void *fdata)
351} 404}
352 405
353static void 406static void
354evas_object_textgrid_render(Evas_Object *eo_obj, 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,
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,
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,85 @@ evas_object_textgrid_render(Evas_Object *eo_obj,
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_description_get(o,
516 fad->color.g = row->texts[xx].g; 561 text->bold,
517 fad->color.b = row->texts[xx].b; 562 text->italic);
518 fad->color.a = row->texts[xx].a; 563
519 fad->x = row->texts[xx].x; 564 do
520 fad->glyphs = props->glyphs; 565 {
521 566 Evas_Font_Array_Data *fad;
522 fad++; 567 Evas_Text_Props *props;
523 } 568
524 569 current_font = font;
525 async_unref = 570
526 ENFN->multi_font_draw(output, context, surface, 571 props = &text->text_props;
527 o->font, xp, yp + o->ascent, 572 evas_common_font_draw_prepare(props);
528 ww, hh, ww, hh, texts, do_async); 573
529 if (async_unref) 574 evas_common_font_glyphs_ref(props->glyphs);
530 evas_unref_queue_texts_put(obj->layer->evas, texts); 575 evas_unref_queue_glyph_put(obj->layer->evas,
531 else 576 props->glyphs);
532 { 577
533 eina_inarray_foreach(texts->array, _drop_glyphs_ref, 578 fad = eina_inarray_grow(texts->array, 1);
534 obj->layer->evas); 579 if (!fad)
535 eina_inarray_free(texts->array); 580 {
536 free(texts); 581 ERR("Failed to allocate Evas_Font_Array_Data.");
582 eina_inarray_free(texts->array);
583 free(texts);
584 return;
585 }
586 fad->color.r = text->r;
587 fad->color.g = text->g;
588 fad->color.b = text->b;
589 fad->color.a = text->a;
590 fad->x = text->x;
591 fad->glyphs = props->glyphs;
592
593 fad++;
594
595 xx++;
596 if (xx >= row->texts_num)
597 break;
598 text = &row->texts[xx];
599 font = _textgrid_font_description_get(o,
600 text->bold,
601 text->italic);
602 }
603 while (font == current_font);
604
605 async_unref =
606 ENFN->multi_font_draw(output, context, surface,
607 current_font,
608 xp,
609 yp + o->ascent,
610 ww, hh, ww, hh, texts, do_async);
611 if (async_unref)
612 evas_unref_queue_texts_put(obj->layer->evas, texts);
613 else
614 {
615 eina_inarray_foreach(texts->array, _drop_glyphs_ref,
616 obj->layer->evas);
617 eina_inarray_free(texts->array);
618 free(texts);
619 }
537 } 620 }
621 while (xx < row->texts_num);
538 } 622 }
539 else 623 else
540 { 624 {
@@ -542,20 +626,25 @@ evas_object_textgrid_render(Evas_Object *eo_obj,
542 { 626 {
543 Evas_Text_Props *props; 627 Evas_Text_Props *props;
544 unsigned int r, g, b, a; 628 unsigned int r, g, b, a;
545 int tx = xp + row->texts[xx].x; 629 Evas_Object_Textgrid_Text *text = &row->texts[xx];
630 int tx = xp + text->x;
546 int ty = yp + o->ascent; 631 int ty = yp + o->ascent;
632 Evas_Font_Set *font;
547 633
548 props = &row->texts[xx].text_props; 634 props = &text->text_props;
549 635
550 r = row->texts[xx].r; 636 r = text->r;
551 g = row->texts[xx].g; 637 g = text->g;
552 b = row->texts[xx].b; 638 b = text->b;
553 a = row->texts[xx].a; 639 a = text->a;
554 640
555 ENFN->context_color_set(output, context, 641 ENFN->context_color_set(output, context,
556 r, g, b, a); 642 r, g, b, a);
643 font = _textgrid_font_description_get(o,
644 text->bold,
645 text->italic);
557 evas_font_draw_async_check(obj, output, context, surface, 646 evas_font_draw_async_check(obj, output, context, surface,
558 o->font, tx, ty, ww, hh, 647 font, tx, ty, ww, hh,
559 ww, hh, props, do_async); 648 ww, hh, props, do_async);
560 } 649 }
561 } 650 }
@@ -758,7 +847,7 @@ evas_object_textgrid_engine_data_get(Evas_Object *eo_obj)
758{ 847{
759 Evas_Textgrid_Data *o = eo_data_scope_get(eo_obj, MY_CLASS); 848 Evas_Textgrid_Data *o = eo_data_scope_get(eo_obj, MY_CLASS);
760 if (!o) return NULL; 849 if (!o) return NULL;
761 return o->font; 850 return o->font_normal; /* TODO: why ? */
762} 851}
763 852
764static int 853static int
@@ -899,31 +988,86 @@ _evas_textgrid_efl_text_properties_font_source_get(Eo *eo_obj EINA_UNUSED, Evas_
899 return o->cur.font_source; 988 return o->cur.font_source;
900} 989}
901 990
991static int
992_alternate_font_weight_slant(Evas_Object_Protected_Data *obj,
993 Evas_Textgrid_Data *o,
994 Evas_Font_Set **fontp,
995 Evas_Font_Description *fdesc,
996 const char *alternate)
997{
998 int ret = -1;
999 Evas_Font_Set *font;
1000
1001 font = evas_font_load(obj->layer->evas->evas,
1002 fdesc,
1003 o->cur.font_source,
1004 (int)(((double) o->cur.font_size) *
1005 obj->cur->scale));
1006 if (font)
1007 {
1008 Eina_Unicode W[2] = { 'O', 0 };
1009 Evas_Font_Instance *script_fi = NULL;
1010 Evas_Font_Instance *cur_fi = NULL;
1011 Evas_Text_Props text_props;
1012 Evas_Script_Type script;
1013 int advance, vadvance, ascent;
1014
1015 script = evas_common_language_script_type_get(W, 1);
1016 ENFN->font_run_end_get(ENDT, font, &script_fi, &cur_fi,
1017 script, W, 1);
1018 memset(&text_props, 0, sizeof(Evas_Text_Props));
1019 evas_common_text_props_script_set(&text_props, script);
1020 ENFN->font_text_props_info_create(ENDT, script_fi, W, &text_props,
1021 NULL, 0, 1,
1022 EVAS_TEXT_PROPS_MODE_NONE);
1023 advance = ENFN->font_h_advance_get(ENDT, font, &text_props);
1024 vadvance = ENFN->font_v_advance_get(ENDT, font, &text_props);
1025 ascent = ENFN->font_ascent_get(ENDT, font);
1026 if ((o->cur.char_width != advance) ||
1027 (o->cur.char_height != vadvance) ||
1028 (o->ascent != ascent))
1029 {
1030 evas_font_free(obj->layer->evas->evas, font);
1031 }
1032 else
1033 {
1034 *fontp = font;
1035 ret = 0;
1036 }
1037 evas_common_text_props_content_unref(&text_props);
1038 }
1039 return ret;
1040}
1041
902EOLIAN static void 1042EOLIAN 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) 1043_evas_textgrid_efl_text_properties_font_set(Eo *eo_obj,
1044 Evas_Textgrid_Data *o,
1045 const char *font_name,
1046 Evas_Font_Size font_size)
904{ 1047{
905 Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS); 1048 Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
906 Eina_Bool is, was = EINA_FALSE; 1049 Eina_Bool is, was = EINA_FALSE;
907 Eina_Bool pass = EINA_FALSE, freeze = EINA_FALSE; 1050 Eina_Bool pass = EINA_FALSE, freeze = EINA_FALSE;
908 Eina_Bool source_invisible = EINA_FALSE; 1051 Eina_Bool source_invisible = EINA_FALSE;
909 Evas_Font_Description *font_description; 1052 Evas_Font_Description *fdesc;
910 1053
911 if ((!font_name) || (!*font_name) || (font_size <= 0)) 1054 if ((!font_name) || (!*font_name) || (font_size <= 0))
912 return; 1055 return;
913 1056
914 evas_object_async_block(obj); 1057 evas_object_async_block(obj);
915 font_description = evas_font_desc_new(); 1058 fdesc = evas_font_desc_new();
916 evas_font_name_parse(font_description, font_name); 1059 evas_font_name_parse(fdesc, font_name);
917 if (o->cur.font_description && 1060 if (o->cur.font_description_normal &&
918 !evas_font_desc_cmp(font_description, o->cur.font_description) && 1061 !evas_font_desc_cmp(fdesc, o->cur.font_description_normal) &&
919 (font_size == o->cur.font_size)) 1062 (font_size == o->cur.font_size))
920 { 1063 {
921 evas_font_desc_unref(font_description); 1064 evas_font_desc_unref(fdesc);
922 return; 1065 return;
923 } 1066 }
924 1067
925 if (o->cur.font_description) evas_font_desc_unref(o->cur.font_description); 1068 if (o->cur.font_description_normal)
926 o->cur.font_description = font_description; 1069 evas_font_desc_unref(o->cur.font_description_normal);
1070 o->cur.font_description_normal = fdesc;
927 1071
928 o->cur.font_size = font_size; 1072 o->cur.font_size = font_size;
929 eina_stringshare_replace(&o->cur.font_name, font_name); 1073 eina_stringshare_replace(&o->cur.font_name, font_name);
@@ -940,19 +1084,19 @@ _evas_textgrid_efl_text_properties_font_set(Eo *eo_obj, Evas_Textgrid_Data *o, c
940 obj->layer->evas->pointer.y, 1084 obj->layer->evas->pointer.y,
941 1, 1); 1085 1, 1);
942 } 1086 }
943 1087
944 /* DO IT */ 1088 if (o->font_normal)
945 if (o->font)
946 { 1089 {
947 evas_font_free(obj->layer->evas->evas, o->font); 1090 evas_font_free(obj->layer->evas->evas, o->font_normal);
948 o->font = NULL; 1091 o->font_normal = NULL;
949 } 1092 }
950 1093
951 o->font = evas_font_load(obj->layer->evas->evas, o->cur.font_description, 1094 o->font_normal = evas_font_load(obj->layer->evas->evas,
1095 o->cur.font_description_normal,
952 o->cur.font_source, 1096 o->cur.font_source,
953 (int)(((double) o->cur.font_size) * 1097 (int)(((double) o->cur.font_size) *
954 obj->cur->scale)); 1098 obj->cur->scale));
955 if (o->font) 1099 if (o->font_normal)
956 { 1100 {
957 Eina_Unicode W[2] = { 'O', 0 }; 1101 Eina_Unicode W[2] = { 'O', 0 };
958 Evas_Font_Instance *script_fi = NULL; 1102 Evas_Font_Instance *script_fi = NULL;
@@ -960,20 +1104,20 @@ _evas_textgrid_efl_text_properties_font_set(Eo *eo_obj, Evas_Textgrid_Data *o, c
960 Evas_Text_Props text_props; 1104 Evas_Text_Props text_props;
961 Evas_Script_Type script; 1105 Evas_Script_Type script;
962 int advance, vadvance; 1106 int advance, vadvance;
963 1107
964 script = evas_common_language_script_type_get(W, 1); 1108 script = evas_common_language_script_type_get(W, 1);
965 ENFN->font_run_end_get(ENDT, o->font, &script_fi, &cur_fi, 1109 ENFN->font_run_end_get(ENDT, o->font_normal, &script_fi, &cur_fi,
966 script, W, 1); 1110 script, W, 1);
967 memset(&text_props, 0, sizeof(Evas_Text_Props)); 1111 memset(&text_props, 0, sizeof(Evas_Text_Props));
968 evas_common_text_props_script_set(&text_props, script); 1112 evas_common_text_props_script_set(&text_props, script);
969 ENFN->font_text_props_info_create(ENDT, script_fi, W, &text_props, 1113 ENFN->font_text_props_info_create(ENDT, script_fi, W, &text_props,
970 NULL, 0, 1, 1114 NULL, 0, 1,
971 EVAS_TEXT_PROPS_MODE_NONE); 1115 EVAS_TEXT_PROPS_MODE_NONE);
972 advance = ENFN->font_h_advance_get(ENDT, o->font, &text_props); 1116 advance = ENFN->font_h_advance_get(ENDT, o->font_normal, &text_props);
973 vadvance = ENFN->font_v_advance_get(ENDT, o->font, &text_props); 1117 vadvance = ENFN->font_v_advance_get(ENDT, o->font_normal, &text_props);
974 o->cur.char_width = advance; 1118 o->cur.char_width = advance;
975 o->cur.char_height = vadvance; 1119 o->cur.char_height = vadvance;
976 o->ascent = ENFN->font_ascent_get(ENDT, o->font);; 1120 o->ascent = ENFN->font_ascent_get(ENDT, o->font_normal);
977 evas_common_text_props_content_unref(&text_props); 1121 evas_common_text_props_content_unref(&text_props);
978 } 1122 }
979 else 1123 else
@@ -988,6 +1132,69 @@ _evas_textgrid_efl_text_properties_font_set(Eo *eo_obj, Evas_Textgrid_Data *o, c
988 o->ascent = 0; 1132 o->ascent = 0;
989 } 1133 }
990 1134
1135 /* Bold */
1136 if (o->font_bold)
1137 {
1138 evas_font_free(obj->layer->evas->evas, o->font_bold);
1139 o->font_bold = NULL;
1140 }
1141 if (fdesc->weight == EVAS_FONT_WEIGHT_NORMAL)
1142 {
1143 Evas_Font_Description *bold_desc = evas_font_desc_dup(fdesc);
1144 bold_desc->weight = EVAS_FONT_WEIGHT_BOLD;
1145 _alternate_font_weight_slant(obj, o, &o->font_bold,
1146 bold_desc, "bold");
1147 evas_font_desc_unref(bold_desc);
1148 }
1149
1150 /* Italic */
1151 if (o->font_italic)
1152 {
1153 evas_font_free(obj->layer->evas->evas, o->font_italic);
1154 o->font_italic = NULL;
1155 }
1156 if (fdesc->slant == EVAS_FONT_SLANT_NORMAL)
1157 {
1158 Evas_Font_Description *italic_desc = evas_font_desc_dup(fdesc);
1159 int ret;
1160
1161 italic_desc->slant = EVAS_FONT_SLANT_ITALIC;
1162 ret = _alternate_font_weight_slant(obj, o, &o->font_italic,
1163 italic_desc, "italic");
1164 if (ret != 0)
1165 {
1166 italic_desc->slant = EVAS_FONT_SLANT_OBLIQUE;
1167 _alternate_font_weight_slant(obj, o, &o->font_italic,
1168 italic_desc, "italic(oblique)");
1169 }
1170 evas_font_desc_unref(italic_desc);
1171 }
1172
1173 /* BoldItalic */
1174 if (o->font_bolditalic)
1175 {
1176 evas_font_free(obj->layer->evas->evas, o->font_bolditalic);
1177 o->font_bolditalic = NULL;
1178 }
1179 if (fdesc->slant == EVAS_FONT_SLANT_NORMAL &&
1180 fdesc->weight == EVAS_FONT_WEIGHT_NORMAL)
1181 {
1182 Evas_Font_Description *bolditalic_desc = evas_font_desc_dup(fdesc);
1183 int ret;
1184
1185 bolditalic_desc->slant = EVAS_FONT_SLANT_ITALIC;
1186 bolditalic_desc->weight = EVAS_FONT_WEIGHT_BOLD;
1187 ret = _alternate_font_weight_slant(obj, o, &o->font_bolditalic,
1188 bolditalic_desc, "bolditalic");
1189 if (ret != 0)
1190 {
1191 bolditalic_desc->slant = EVAS_FONT_SLANT_OBLIQUE;
1192 _alternate_font_weight_slant(obj, o, &o->font_bolditalic,
1193 bolditalic_desc, "bolditalic(oblique)");
1194 }
1195 evas_font_desc_unref(bolditalic_desc);
1196 }
1197
991 o->changed = 1; 1198 o->changed = 1;
992 evas_object_change(eo_obj, obj); 1199 evas_object_change(eo_obj, obj);
993 evas_object_clip_dirty(eo_obj, obj); 1200 evas_object_clip_dirty(eo_obj, obj);