Commit 5d0fd782 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

simplify the bidirectional line layout logic

parent 5404984e
Loading
Loading
Loading
Loading
+2 −21
Original line number Diff line number Diff line
@@ -47,16 +47,7 @@ Status text_layout_hrun(
    gp.font = gi.font;
    gp.codepoint = gi.codepoint;
    gp.y = 0;

    switch (text_direction) {
      case TextDirection::LTR:
    gp.x = *span_length;
        break;
      case TextDirection::RTL:
        gp.x = -*span_length - gi.advance_x;
        break;
    }

    glyphs->emplace_back(gp);

    *span_length += gi.advance_x;
@@ -101,23 +92,13 @@ Status text_layout_hline(
    }

    for (auto& gi : span_glyphs) {
      if (base_text_direction != text_line.text_directions[i]) {
        switch (base_text_direction) {
          case TextDirection::LTR:
            gi.x += span_length;
            break;
          case TextDirection::RTL:
            gi.x -= span_length;
            break;
        }
      }

      switch (base_text_direction) {
        case TextDirection::LTR:
          gi.x += line_length;
          break;
        case TextDirection::RTL:
          gi.x -= line_length;
          gi.x -= span_length;
          break;
      }