Commit 4677c964 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

add a 'span_id'

parent 667ec5b2
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -85,6 +85,8 @@ Status drawTextLabel(
  span.text = text;
  span.font = style.font;
  span.font_size = style.font_size;
  span.span_id = 0;

  return drawTextLabel(&span, &span + 1, position, align_x, align_y, 0, style, layer);
}

@@ -109,6 +111,7 @@ Status text_measure_label(
  span.text = text;
  span.font = font;
  span.font_size = font_size;
  span.span_id = 0;

  return text_layout_line(
      &span,
+1 −22
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ Status text_place_hrun(
    gp.codepoint = gi.codepoint;
    gp.y = 0;
    gp.x = *span_length;
    gp.span_id = span.span_id;
    glyphs->emplace_back(gp);

    *span_length += gi.advance_x;
@@ -244,28 +245,6 @@ Status text_layout_line(
      bbox);
}

Status text_layout_line(
    const std::string& text,
    const TextDirection text_direction_base,
    const FontInfo& font_info,
    double font_size,
    double dpi,
    std::vector<GlyphPlacementGroup>* glyphs,
    Rectangle* bbox) {
  TextSpan span;
  span.text = text;
  span.font = font_info;
  span.font_size = font_size;

  return text_layout_line(
      &span,
      &span + 1,
      text_direction_base,
      dpi,
      glyphs,
      bbox);
}

} // namespace text
} // namespace fviz
+4 −19
Original line number Diff line number Diff line
@@ -31,7 +31,8 @@ namespace fviz::text {
 * in a text span must have the same font, font size and script.
 *
 * The text data of this span is a UTF-8 encoded string in logical character
 * order.
 * order. The span id may be used to map glyphs in the output to the span
 * that produced them.
 */
struct TextSpan {
  std::string text;
@@ -40,6 +41,7 @@ struct TextSpan {
  std::string script;
  FontInfo font;
  double font_size;
  uint32_t span_id;
};


@@ -52,6 +54,7 @@ struct GlyphPlacement {
  uint32_t codepoint;
  double x;
  double y;
  uint32_t span_id;
};


@@ -81,23 +84,5 @@ Status text_layout_line(
    Rectangle* bbox);


/**
 * Layout a single line of text. The input text must be provided in UTF-8
 * encoding and in logical character order. The `text_direction_base` argument
 * controls the base writing direction of the line
 *
 * Note that at this point only LTR and RTL text as well as bidirectional LTR/RTL
 * text is supported. Vertical (TTB) line layout is not yet implemented.
 */
Status text_layout_line(
    const std::string& text,
    TextDirection text_direction_base,
    const FontInfo& font,
    double font_size,
    double dpi,
    std::vector<GlyphPlacementGroup>* glyphs,
    Rectangle* bbox);


} // namespace fviz::text