#include <iostream>
#include <pango/pangocairo.h>

int main(int argc, char** argv)
{
  PangoContext* context = pango_font_map_create_context(pango_cairo_font_map_get_default());
  PangoLayout* layout = pango_layout_new(context);
  if (layout == nullptr)
    return 1;

  // Demonstrates the problems with quotes.
  // The unicode standard says there should be a boundary after broken." but there isn't.
  pango_layout_set_text(layout, "John said, \"Sentence boundaries are broken.\"  Marie was not amused.", -1);

  gint n_attrs = 0;
  PangoLogAttr const* attrs = pango_layout_get_log_attrs_readonly(layout, &n_attrs);
  
  std::cout << "\n==Quote test==========\n"; 
  for (gint a = 0; a < n_attrs; ++a) {
    if (attrs[a].is_sentence_boundary)
      std::cout << "boundary at: " << a << "\n";
  }

  // Demonstrates the problems with ideographic full stop (applies to all CJK punctuation).
  // Should be a boundary at both 。 but there isn't.
  pango_layout_set_text(layout, u8"风向转变时,有人筑墙,有人造风车。師傅領進門，修行在個人。", -1);
 
  std::cout << "\n==CJK test==========\n"; 
  attrs = pango_layout_get_log_attrs_readonly(layout, &n_attrs);
  for (gint a = 0; a < n_attrs; ++a) {
    if (attrs[a].is_sentence_boundary)
      std::cout << "boundary at: " << a << "\n";
  }
  
  return 0;
}
