Commit 52ec457d authored by Paul Asmuth's avatar Paul Asmuth
Browse files

implement horizontal text alignment

parent 0ac638cb
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
signaltk
========

A set of command line utilities and C++ classes for creating toolkit for creating
high-quality charts, figures and dashboards.
A toolkit for creating data-driven graphics, such as charts, figures and
dashboards.

Documentation: [signaltk.org](http://signaltk.org/)

+2 −2
Original line number Diff line number Diff line
@@ -22,12 +22,12 @@ TextStyle::TextStyle() :

Status drawText(
    const std::string& text,
    const TextStyle& text_style,
    double x,
    double y,
    const TextStyle& text_style,
    Layer* layer) {
  FontInfo font_info {
    .font_file = "/usr/share/fonts/google-roboto/Roboto-Regular.ttf",
    .font_file = "/Library/Fonts/Arial.ttf",
    .font_size = 12
  };

+1 −1
Original line number Diff line number Diff line
@@ -53,9 +53,9 @@ struct GlyphPlacement {

Status drawText(
    const std::string& text,
    const TextStyle& text_style,
    double x,
    double y,
    const TextStyle& text_style,
    Layer* layer);

Status drawTextGlyphs(
+1 −1
Original line number Diff line number Diff line
@@ -98,7 +98,7 @@ Status renderAxisVertical(
    TextStyle style;
    style.halign = TextHAlign::LEFT;
    style.valign = TextVAlign::TOP;
    if (auto rc = drawText(label_text, style, x, y, target); rc != OK) {
    if (auto rc = drawText(label_text, x, y, style, target); rc != OK) {
      return rc;
    }
  }
+12 −0
Original line number Diff line number Diff line
@@ -38,6 +38,18 @@ Status layoutTextLTR(

  auto gx = x;
  auto gy = y;

  switch (halign) {
    case TextHAlign::LEFT:
      break;
    case TextHAlign::CENTER:
      gx -= line_length / 2;
      break;
    case TextHAlign::RIGHT:
      gx -= line_length;
      break;
  }

  for (const auto& gi : glyphs) {
    GlyphPlacement g;
    glyph_cb(GlyphPlacement {
Loading