Evas font-engine: A couple of major fixes:
authortasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 30 Jan 2011 10:40:21 +0000 (10:40 +0000)
committertasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 30 Jan 2011 10:40:21 +0000 (10:40 +0000)
1. Worked around a fribid behavior that broke some stuff - we should handle it better in the future, this workaround is only temporary.
2. Fixed a bug with textblock's last_up_to_pos.
3. Fixed a bug with ot_shaping not reloading the font and activating the size in the wrong place.

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@56491 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/canvas/evas_object_textblock.c
src/lib/engines/common/evas_font_ot.c
src/lib/engines/common/language/evas_bidi_utils.c

index ab015d4..960363f 100644 (file)
@@ -2230,21 +2230,22 @@ _layout_line_advance(Ctxt *c, Evas_Object_Textblock_Format *fmt,
    c->y += c->maxascent + c->maxdescent;
    if (c->w >= 0)
      {
-        c->ln->x = c->par->x + c->marginl + c->o->style_pad.l +
+        c->ln->x = c->marginl + c->o->style_pad.l +
            ((c->w - c->ln->w -
              c->o->style_pad.l - c->o->style_pad.r -
              c->marginl - c->marginr) * _layout_line_align_get(c));
-        if ((c->ln->x + c->ln->w + c->marginr - c->o->style_pad.l) > c->wmax)
-          c->wmax = c->ln->x + c->ln->w + c->marginl + c->marginr - c->o->style_pad.l;
+        if ((c->par->x + c->ln->x + c->ln->w + c->marginr - c->o->style_pad.l) > c->wmax)
+          c->wmax = c->par->x + c->ln->x + c->ln->w + c->marginl + c->marginr - c->o->style_pad.l;
      }
    else
      {
-        c->ln->x = c->par->x + c->marginl + c->o->style_pad.l;
-        if ((c->ln->x + c->ln->w + c->marginr - c->o->style_pad.l) > c->wmax)
-          c->wmax = c->ln->x + c->ln->w + c->marginl + c->marginr - c->o->style_pad.l;
+        c->ln->x = c->marginl + c->o->style_pad.l;
+        if ((c->par->x + c->ln->x + c->ln->w + c->marginr - c->o->style_pad.l) > c->wmax)
+          c->wmax = c->par->x + c->ln->x + c->ln->w + c->marginl + c->marginr - c->o->style_pad.l;
      }
-   c->par->h += c->ln->h;
-   c->par->w = c->w;
+   c->par->h = c->ln->y + c->ln->h;
+   if (c->ln->w > c->par->w)
+     c->par->w = c->ln->w;
    if (add_line)
      _layout_line_new(c, fmt);
 }
@@ -2281,18 +2282,19 @@ _layout_text_item_new(Ctxt *c __UNUSED__, Evas_Object_Textblock_Format *fmt, con
  * or because of an error), cutoff index on success.
  */
 static int
-_layout_text_cutoff_get(Ctxt *c, Evas_Object_Textblock_Format *fmt, Evas_Object_Textblock_Text_Item *ti)
+_layout_text_cutoff_get(Ctxt *c, Evas_Object_Textblock_Format *fmt,
+      const Evas_Object_Textblock_Text_Item *ti)
 {
    if (fmt->font.font)
-     return c->ENFN->font_last_up_to_pos(c->ENDT, fmt->font.font, ti->text,
-           &ti->parent.text_props,
-           c->w -
-           c->o->style_pad.l -
-           c->o->style_pad.r -
-           c->marginl -
-           c->marginr -
-           c->x,
-           0);
+     {
+        Evas_Coord x;
+        x = c->w - c->o->style_pad.l - c->o->style_pad.r - c->marginl -
+           c->marginr - c->x;
+        if (x < 0)
+          x = 0;
+        return c->ENFN->font_last_up_to_pos(c->ENDT, fmt->font.font, ti->text,
+              &ti->parent.text_props, x, 0);
+     }
    return -1;
 }
 
index e5306b6..15bfcb1 100644 (file)
@@ -154,13 +154,6 @@ evas_common_font_ot_populate_text_props(void *_fn, const Eina_Unicode *text,
    props->ot_data->refcount = 1;
 
    fi = fn->fonts->data;
-   if (fi->src->current_size != fi->size)
-     {
-        FTLOCK();
-        FT_Activate_Size(fi->ft.size);
-        FTUNLOCK();
-        fi->src->current_size = fi->size;
-     }
    /* Load the font needed for this script */
      {
         /* Skip common chars */
@@ -173,6 +166,14 @@ evas_common_font_ot_populate_text_props(void *_fn, const Eina_Unicode *text,
         if (!*tmp && (tmp > text)) tmp--;
         evas_common_font_glyph_search(fn, &fi, *tmp);
      }
+   evas_common_font_int_reload(fi);
+   if (fi->src->current_size != fi->size)
+     {
+        FTLOCK();
+        FT_Activate_Size(fi->ft.size);
+        FTUNLOCK();
+        fi->src->current_size = fi->size;
+     }
 
    if (len < 0)
      {
@@ -211,6 +212,7 @@ evas_common_font_ot_populate_text_props(void *_fn, const Eina_Unicode *text,
      }
 
    hb_buffer_destroy(buffer);
+   evas_common_font_int_use_trim();
 
    return EINA_FALSE;
 }
index 62c7e15..069deb8 100644 (file)
@@ -305,13 +305,21 @@ evas_bidi_props_reorder_line(Eina_Unicode *eina_ustr, size_t start, size_t len,
 
    /* Shaping must be done *BEFORE* breaking to lines so there's no choice but
     doing it in textblock. */
-   if (!fribidi_reorder_line (FRIBIDI_FLAGS_DEFAULT,
-            props->char_types + start,
-            len, 0, props->direction,
-            props->embedding_levels + start,
-            ustr, v_to_l))
      {
-        goto error;
+        /* FIXME: Hack around fribidi altering embedding_levels */
+        EvasBiDiLevel *emb_lvl;
+        emb_lvl = malloc(len * sizeof(EvasBiDiLevel));
+        memcpy(emb_lvl, props->embedding_levels, len * sizeof(EvasBiDiLevel));
+        if (!fribidi_reorder_line (FRIBIDI_FLAGS_DEFAULT,
+                 props->char_types + start,
+                 len, 0, props->direction,
+                 emb_lvl,
+                 ustr, v_to_l))
+          {
+             free(emb_lvl);
+             goto error;
+          }
+        free(emb_lvl);
      }