Commit 1ce0f827 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

add a stub visual_order member to the TextLine struct

parent 72c28a07
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@
 */
#include "text_backend.h"

#include <numeric>
#include <fribidi/fribidi.h>

namespace fviz::text {
@@ -108,6 +109,15 @@ ReturnCode text_analyze_bidi_line(
    text_line->text_spans.emplace_back(fb_to_span_map[run_begin]);
  }

  text_line->text_direction_base = text_direction_base;
  text_line->visual_order.resize(text_line->text_runs.size());
  std::iota(
      text_line->visual_order.begin(),
      text_line->visual_order.end(),
      0);

  // TODO: reorder ranges according to unicode algorithm

  return OK;
}

+4 −6
Original line number Diff line number Diff line
@@ -64,7 +64,6 @@ Status text_layout_hrun(

Status text_layout_hline(
    const TextLine& text_line,
    const TextDirection text_direction_base,
    const FontInfo& font_info,
    double font_size,
    double dpi,
@@ -73,7 +72,7 @@ Status text_layout_hline(
  double line_top = 0.0;
  double line_bottom = 0.0;
  double line_length = 0;
  for (size_t i = 0; i < text_line.text_runs.size(); ++i) {
  for (auto i : text_line.visual_order) {
    double span_length = 0.0;
    std::vector<GlyphPlacement> span_glyphs;

@@ -95,7 +94,7 @@ Status text_layout_hline(
    }

    for (auto& gi : span_glyphs) {
      switch (text_direction_base) {
      switch (text_line.text_direction_base) {
        case TextDirection::LTR:
          gi.x += line_length;
          break;
@@ -109,7 +108,7 @@ Status text_layout_hline(
      gs.font = gi.font;
      gs.glyphs.emplace_back(gi);

      // TODO merge glyph spans witht the same font
      // TODO merge glyph spans with the same font
      if (glyph_spans) {
        glyph_spans->emplace_back(gs);
      }
@@ -119,7 +118,7 @@ Status text_layout_hline(
  }

  double line_left = 0.0;
  switch (text_direction_base) {
  switch (text_line.text_direction_base) {
    case TextDirection::LTR:
      line_left = 0;
      break;
@@ -151,7 +150,6 @@ Status text_layout_hline(

  return text_layout_hline(
      text_line,
      text_direction_base,
      font_info,
      font_size,
      dpi,
+2 −1
Original line number Diff line number Diff line
@@ -69,8 +69,10 @@ struct TextSpan {
 */
struct TextLine {
  std::vector<std::string> text_runs;
  TextDirection text_direction_base;
  std::vector<TextDirection> text_directions;
  std::vector<const TextSpan*> text_spans;
  std::vector<size_t> visual_order;
};


@@ -98,7 +100,6 @@ struct GlyphSpan {
 */
Status text_layout_hline(
    const TextLine& line,
    TextDirection base_direction,
    const FontInfo& font,
    double font_size,
    double dpi,