+ memset(framebuf, 0, 800*600*4);
+
+ pqxx::work t(conn, "trx");
+
+ // fetch all songs
+ pqxx::result res( t.exec("SELECT * FROM songs WHERE title LIKE 'M%'") );
+ unsigned y = 0;
+ for (pqxx::result::const_iterator i = res.begin(); i != res.end(); ++i) {
+ my_draw_text(i["title"].as(widestring()), framebuf, 0, y, 1, 255, 255, 255, fonts);
+ y += 20;
+// std::fprintf(stderr, "%s\n", i["title"].c_str());
+ }
+ t.commit();
+
+ ptc_update(framebuf);
+ sleep(1);
+}
+
+void init_freetype()
+{
+ FT_Library library;
+ FT_Face face;
+ if (FT_Init_FreeType(&library))
+ throw std::runtime_error("FreeType init failed.");
+
+ // Georgia
+ if (FT_New_Face(library, "/usr/share/fonts/truetype/msttcorefonts/Georgia.ttf", 0, &face))
+ throw std::runtime_error("Face opening failed.");
+ if (FT_Set_Char_Size(face, 0, 12 * 64, 96, 96))
+ throw std::runtime_error("Size set failed.");
+ fonts.push_back(face);
+
+ // FreeSerif
+ if (FT_New_Face(library, "/usr/share/fonts/truetype/freefont/FreeSerif.ttf", 0, &face)) {
+ std::fprintf(stderr, "Warning: Couldn't open FreeSerif, some glyphs might not be available\n");
+ } else {
+ if (FT_Set_Char_Size(face, 0, 12 * 64, 96, 96))
+ throw std::runtime_error("Size set failed.");
+ fonts.push_back(face);
+ }
+
+ // Arial Unicode MS
+ if (FT_New_Face(library, "arialuni.ttf", 0, &face)) {
+ std::fprintf(stderr, "Warning: Couldn't open Arial Unicode MS, some glyphs might not be available\n");
+ } else {
+ if (FT_Set_Char_Size(face, 0, 12 * 64, 96, 96))
+ throw std::runtime_error("Size set failed.");
+ fonts.push_back(face);
+ }
+}