Permalink
Browse files

Added a tiny example and a getTextHeight() function.

  • Loading branch information...
1 parent f79ddb2 commit 92fc78c0246324a29553bb6e7a4181632ed7427b @roxlu roxlu committed Dec 27, 2010
Showing with 23 additions and 0 deletions.
  1. +5 −0 src/ofxPCPangoLayout.cpp
  2. +1 −0 src/ofxPCPangoLayout.h
  3. +6 −0 src/ofxPango.cpp
  4. +11 −0 src/ofxPango.h
View
@@ -44,6 +44,11 @@ void ofxPCPangoLayout::show() {
pango_cairo_show_layout(context->cr_context,pa_layout);
}
+float ofxPCPangoLayout::getTextHeight() {
+ PangoRectangle rect = getPixelExtents();
+ return rect.height;
+}
+
void ofxPCPangoLayout::setFontDescription(ofxPCPangoFontDescription oFont) {
pango_layout_set_font_description(pa_layout, oFont.pa_description);
}
View
@@ -23,6 +23,7 @@ class ofxPCPangoLayout {
void setFontDescription(ofxPCPangoFontDescription oFont);
int getWidth();
int getHeight();
+ float getTextHeight();
void setFont(std::string sFontDesc);
void fill(float fR, float fG, float fB, float fA = 1.0f);
void setTextColor(float fR, float fG, float fB, float fA = 1.0f);
View
@@ -11,6 +11,12 @@ ofxPCContext* ofxPango::createContextWithSurface(float fWidth, float fHeight) {
return context;
}
+/**
+ * A layout is used to align text onto a surface. For example if you want to
+ * right align text, you can use a layout together with a surface. This method
+ * sets up exactly what you need for this.
+ *
+ */
ofxPCPangoLayout* ofxPango::createLayout(float fWidth, float fHeight) {
ofxPCContext* context = createContextWithSurface(fWidth, fHeight);
ofxPCPangoLayout* layout = context->createPangoLayout();
View
@@ -12,6 +12,17 @@
*
* @author Diederick Huijbers <diederick@apollomedia.nl>
* @version 0.0.1 2010.07.03
+ *
+ * <example>
+ *
+ * layout = simple->getPango()->createLayout(width,height);
+ * layout->fill(0.0f, 0.0f, 0.0f, 0.0f);
+ * layout->setTextColor(1.0f, 1.0f,10.0f, 1.0f);
+ * layout->setText(oTweet.text);
+ * layout->show();
+ * ofImage img = layout->getImage();
+ *
+ * </example>
*/
#include <pango/pangocairo.h>

0 comments on commit 92fc78c

Please sign in to comment.