[RFC PATCH 3/3] kernel-shark: Add text rendering to the plotting example

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



run:
kernel-shark/bin/dplot -s

And if the font file is loaded successfully you will see "Hello Kernel!"
rendered.

Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@xxxxxxxxx>
---
 kernel-shark/examples/dataplot.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/kernel-shark/examples/dataplot.cpp b/kernel-shark/examples/dataplot.cpp
index 94841e7..1f06dc9 100644
--- a/kernel-shark/examples/dataplot.cpp
+++ b/kernel-shark/examples/dataplot.cpp
@@ -27,6 +27,9 @@ using namespace std;
 
 #define default_file (char*)"trace.dat"
 
+struct ksplot_font font;
+const char *font_file = "/usr/share/fonts/truetype/msttcorefonts/times.ttf";
+
 struct kshark_trace_histo	histo;
 vector<KsPlot::Graph *>		graphs;
 
@@ -72,6 +75,11 @@ void drawShapes()
 	r.setFill(false);
 	r.draw();
 
+	if (ksplot_init_font(&font, 60, font_file)) {
+		struct ksplot_color col = {100, 255, 0};
+		ksplot_print_text(&font, &col, 250, 70, "Hello Kernel!");
+	}
+
 	glFlush();
 }
 
-- 
2.20.1




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux