Skip to content

Paragraph renderer for openFrameworks

Notifications You must be signed in to change notification settings

tyhenry/ofxParagraph

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ofxParagraph

A simple paragraph renderer for openFrameworks that allows you to set the alignment, width, indentation, leading and pixel based word spacing of paragraphs.

image

Installation

ofxParagraph uses ofxSmartFont for font management which allows you to safely share ofxParagraph fonts with the rest of your application.

This requires you to clone the repository recursively if you don't already have it installed.

git clone --recursive [email protected]:braitsch/ofxParagraph.git

Usage

Creating a paragraph is as simple as passing in a string and setting a width.

ofxParagraph paragraph = ofxParagraph(text, width);

And then assigning a font you'd like to use:

paragraph.setFont("fonts/helvetica_neue.ttf", 12)

Alternately you can pass in an ofxSmartFont instance:

shared_ptr<ofxSmartFont> helvetica_12;
paragraph.setFont(helvetica_12);

Once you've got some text, a width and a font you're ready to draw:

paragraph.draw();
// or specify a position //
paragraph.draw(int x, int y);

Customization

The following methods are available to customize any ofxParagraph instance.

void setText(string text)

void setWidth(int width)

void setFont(string file, int pointSize)

void setFont(std::shared_ptr<ofxSmartFont> font)

void setColor(ofColor color)

void setColor(int color) // e.g. 0x333333

void setPosition(int x, int y)

void setAlignment(ofxParagraph::Alignment align)

void setIndent(int indent)

void setLeading(int leading) // vertical spacing between lines //

void setSpacing(int spacing) // horizontal spacing between words //

You can also draw a border around paragraphs and boundaries around words.

void drawBorder(bool draw)

void drawBorder(ofColor color)

void setBorderPadding(int padding)

void drawWordBoundaries(bool draw)

And there are also a couple of handy getter functions just in case.

int getWidth()

int getHeight()

int getStringHeight(string s = "")

About

Paragraph renderer for openFrameworks

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 66.7%
  • Makefile 33.3%