VuoImageText implementation.
Definition in file VuoImageText.cc.
Go to the source code of this file.
Classes | |
class | VuoFontClass |
A wrapper for VuoFont, so it can be used as a std::map key. More... | |
Macros | |
#define | ScreenToGL(x) (((x) / screenWidthInPixels) * 2.) |
Shortcut macro for converting to GL coordinates in VuoImageTextData_convertToVuoCoordinates function. More... | |
Typedefs | |
typedef std::vector< VuoPoint2d > | VuoCorners |
4 corners of a (non-axis-aligned) rectangle. More... | |
typedef std::pair< std::string, VuoFontClass > | VuoImageTextCacheDescriptor |
Text, font. More... | |
typedef std::pair< std::pair< VuoImage, VuoCorners >, double > | VuoImageTextCacheEntry |
((An image, its bounds), and the last time it was used) More... | |
typedef std::map< VuoImageTextCacheDescriptor, VuoImageTextCacheEntry > | VuoImageTextCacheType |
A pool of images. More... | |
Functions | |
bool | operator< (const VuoFontClass &a, const VuoFontClass &b) |
Returns true if a is less than b . More... | |
VuoImageTextData | VuoImageTextData_make () |
Initialize a new instance of VuoImageTextData. More... | |
void | VuoImageTextData_free (void *data) |
Free a VuoImageTextData pointer and it's contents. More... | |
static void | VuoImageTextCache_cleanup (void *blah) |
Purges expired images from the cache. More... | |
static void | VuoImageTextCache_init (void) |
Initializes the cache. More... | |
VuoReal | VuoImageText_getVerticalScale (VuoReal screenWidth, VuoReal backingScaleFactor) |
Get the vertical scaling used for text. More... | |
static CFArrayRef | VuoImageText_createCTLines (VuoText text, VuoFont font, VuoReal backingScaleFactor, VuoReal verticalScale, VuoReal rotation, VuoReal wrapWidth, bool includeTrailingWhiteSpace, CTFontRef *ctFont, CGColorRef *cgColor, CGColorSpaceRef *colorspace, VuoImageTextData textImageData, CGAffineTransform *outTransform) |
Formats the specified text for rendering using font and backingScaleFactor . More... | |
VuoRectangle | VuoImage_getTextRectangle (VuoText text, VuoFont font, VuoReal backingScaleFactor, VuoReal verticalScale, VuoReal rotation, float wrapWidth, bool includeTrailingWhiteSpace) |
Returns a rectangle (in points) that fully encloses the specified text when rendered with the specified font . More... | |
VuoImageTextData | VuoImage_getTextImageData (VuoText text, VuoFont font, VuoReal backingScaleFactor, VuoReal verticalScale, VuoReal rotation, bool includeTrailingWhiteSpace) |
Returns a struct containing all information necessary to calculate text and character size and placement when rendered. More... | |
VuoPoint2d | VuoImageText_getTextSize (VuoText text, VuoFont font, VuoPoint2d windowSize, VuoReal backingScaleFactor, bool includeTrailingWhiteSpace) |
Outputs the size in Vuo coordinates of a real-size text layer. More... | |
VuoReal | VuoImageText_getLineHeight (VuoFont font, VuoReal screenWidthInPixels, VuoReal backingScaleFactor) |
Get the line height of a font in Vuo coordinates. More... | |
void | VuoImageTextData_convertToVuoCoordinates (VuoImageTextData textData, VuoReal screenWidthInPixels, VuoReal backingScaleFactor) |
Convert VuoImageTextData from pixel coordinates to Vuo coordinates in place. More... | |
VuoPoint2d | VuoImageTextData_getPositionForLineIndex (VuoImageTextData textData, unsigned int lineIndex) |
Get the origin point of a line of text (bottom left point of first character billboard in line). More... | |
unsigned int | VuoImageTextData_getLineWithCharIndex (VuoImageTextData textData, unsigned int charIndex, unsigned int *lineStartCharIndex) |
Find the line index that the character at charIndex resides in. More... | |
VuoPoint2d | VuoImageTextData_getPositionForCharIndex (VuoImageTextData textData, unsigned int charIndex, unsigned int *lineIndex) |
Get the starting point for a character index (bottom left corner). More... | |
VuoRectangle * | VuoImageTextData_getRectsForHighlight (VuoImageTextData textData, unsigned int selectionStartIndex, unsigned int selectionLength, unsigned int *lineCount) |
Given a start index and length of selected characters return an array of VuoRectangles encompassing the selection. More... | |
unsigned int | VuoImageTextData_getCharIndexForLine (VuoImageTextData textData, unsigned int lineIndex) |
Get the index of the first character at line index. More... | |
VuoRectangle | VuoImageTextData_layoutRowAtIndex (VuoImageTextData textData, unsigned int index, unsigned int *charactersRemaining) |
Get a rect that contains a row of text starting at index. More... | |
int | VuoImageTextData_getNearestCharToPoint (VuoImageTextData textData, VuoPoint2d point) |
Return the character index (0 indexed) nearest to point, where point is relative to the pivot point of a text layer. More... | |
VuoImage | VuoImage_makeText (VuoText text, VuoFont font, float backingScaleFactor, float verticalScale, float rotation, float wrapWidth, VuoPoint2d *outCorners) |
Creates an image containing the specified text. More... | |
Variables | |
static VuoImageTextCacheType * | VuoImageTextCache |
A pool of images. More... | |
static dispatch_semaphore_t | VuoImageTextCache_semaphore |
Serializes access to VuoImageTextCache. More... | |
static dispatch_semaphore_t | VuoImageTextCache_canceledAndCompleted |
Signals when the last VuoImageTextCache cleanup has completed. More... | |
static volatile dispatch_source_t | VuoImageTextCache_timer = NULL |
Periodically cleans up VuoImageTextCache. More... | |
static double | VuoImageTextCache_timeout = 1.0 |
Seconds an image can remain in the cache unused, before it gets purged. More... | |
#define ScreenToGL | ( | x | ) | (((x) / screenWidthInPixels) * 2.) |
Shortcut macro for converting to GL coordinates in VuoImageTextData_convertToVuoCoordinates function.
Definition at line 452 of file VuoImageText.cc.
typedef std::vector<VuoPoint2d> VuoCorners |
4 corners of a (non-axis-aligned) rectangle.
Definition at line 111 of file VuoImageText.cc.
typedef std::pair<std::string, VuoFontClass> VuoImageTextCacheDescriptor |
Text, font.
Definition at line 112 of file VuoImageText.cc.
typedef std::pair<std::pair<VuoImage, VuoCorners>, double> VuoImageTextCacheEntry |
((An image, its bounds), and the last time it was used)
Definition at line 113 of file VuoImageText.cc.
typedef std::map<VuoImageTextCacheDescriptor, VuoImageTextCacheEntry> VuoImageTextCacheType |
A pool of images.
Definition at line 114 of file VuoImageText.cc.
bool operator< | ( | const VuoFontClass & | a, |
const VuoFontClass & | b | ||
) |
Returns true if a
is less than b
.
Definition at line 74 of file VuoImageText.cc.
VuoImageTextData VuoImage_getTextImageData | ( | VuoText | text, |
VuoFont | font, | ||
VuoReal | backingScaleFactor, | ||
VuoReal | verticalScale, | ||
VuoReal | rotation, | ||
bool | includeTrailingWhiteSpace | ||
) |
Returns a struct containing all information necessary to calculate text and character size and placement when rendered.
If text is null or empty, null is returned.
backingScaleFactor
, verticalScale
, rotation
arguments. Definition at line 413 of file VuoImageText.cc.
VuoRectangle VuoImage_getTextRectangle | ( | VuoText | text, |
VuoFont | font, | ||
VuoReal | backingScaleFactor, | ||
VuoReal | verticalScale, | ||
VuoReal | rotation, | ||
float | wrapWidth, | ||
bool | includeTrailingWhiteSpace | ||
) |
Returns a rectangle (in points) that fully encloses the specified text
when rendered with the specified font
.
Depending on the font's design (e.g., if the font is monospace), the rectangle may be larger than the actual glyphs.
backingScaleFactor
, verticalScale
, rotation
, wrapWidth
arguments. Definition at line 392 of file VuoImageText.cc.
VuoImage VuoImage_makeText | ( | VuoText | text, |
VuoFont | font, | ||
float | backingScaleFactor, | ||
float | verticalScale, | ||
float | rotation, | ||
float | wrapWidth, | ||
VuoPoint2d * | outCorners | ||
) |
Creates an image containing the specified text.
If outCorners
is not null, this function fills it with the text's 4 transformed bounds in pixels relative to the top-left of the image.
verticalScale
, rotation
, wrapwidth
, outCorners
arguments. Definition at line 739 of file VuoImageText.cc.
|
static |
Formats the specified text
for rendering using font
and backingScaleFactor
.
Definition at line 224 of file VuoImageText.cc.
VuoReal VuoImageText_getLineHeight | ( | VuoFont | font, |
VuoReal | screenWidthInPixels, | ||
VuoReal | backingScaleFactor | ||
) |
Get the line height of a font in Vuo coordinates.
Useful in cases where no text data is available (ie, you should prefer using textData->lineHeight where available).
Definition at line 458 of file VuoImageText.cc.
VuoPoint2d VuoImageText_getTextSize | ( | VuoText | text, |
VuoFont | font, | ||
VuoPoint2d | windowSize, | ||
VuoReal | backingScaleFactor, | ||
bool | includeTrailingWhiteSpace | ||
) |
Outputs the size in Vuo coordinates of a real-size text layer.
windowSize is in points.
Definition at line 436 of file VuoImageText.cc.
Get the vertical scaling used for text.
Definition at line 216 of file VuoImageText.cc.
|
static |
Purges expired images from the cache.
Definition at line 124 of file VuoImageText.cc.
|
static |
Initializes the cache.
Definition at line 168 of file VuoImageText.cc.
void VuoImageTextData_convertToVuoCoordinates | ( | VuoImageTextData | textData, |
VuoReal | screenWidthInPixels, | ||
VuoReal | backingScaleFactor | ||
) |
Convert VuoImageTextData from pixel coordinates to Vuo coordinates in place.
Definition at line 484 of file VuoImageText.cc.
void VuoImageTextData_free | ( | void * | data | ) |
Free a VuoImageTextData pointer and it's contents.
Definition at line 101 of file VuoImageText.cc.
unsigned int VuoImageTextData_getCharIndexForLine | ( | VuoImageTextData | textData, |
unsigned int | lineIndex | ||
) |
Get the index of the first character at line index.
Definition at line 648 of file VuoImageText.cc.
unsigned int VuoImageTextData_getLineWithCharIndex | ( | VuoImageTextData | textData, |
unsigned int | charIndex, | ||
unsigned int * | lineStartCharIndex | ||
) |
Find the line index that the character at charIndex resides in.
If lineStartCharIndex is not null, the character index of the first character on the found line is stored. In the event that charIndex is out of the bounds of textData, 0 or lineCounts - 1 is returned.
lineIndex
argument. Definition at line 548 of file VuoImageText.cc.
int VuoImageTextData_getNearestCharToPoint | ( | VuoImageTextData | textData, |
VuoPoint2d | point | ||
) |
Return the character index (0 indexed) nearest to point, where point is relative to the pivot point of a text layer.
Definition at line 674 of file VuoImageText.cc.
VuoPoint2d VuoImageTextData_getPositionForCharIndex | ( | VuoImageTextData | textData, |
unsigned int | charIndex, | ||
unsigned int * | lineIndex | ||
) |
Get the starting point for a character index (bottom left corner).
Definition at line 576 of file VuoImageText.cc.
VuoPoint2d VuoImageTextData_getPositionForLineIndex | ( | VuoImageTextData | textData, |
unsigned int | lineIndex | ||
) |
Get the origin point of a line of text (bottom left point of first character billboard in line).
Definition at line 519 of file VuoImageText.cc.
VuoRectangle* VuoImageTextData_getRectsForHighlight | ( | VuoImageTextData | textData, |
unsigned int | selectionStartIndex, | ||
unsigned int | selectionLength, | ||
unsigned int * | lineCount | ||
) |
Given a start index and length of selected characters return an array of VuoRectangles encompassing the selection.
Definition at line 599 of file VuoImageText.cc.
VuoRectangle VuoImageTextData_layoutRowAtIndex | ( | VuoImageTextData | textData, |
unsigned int | index, | ||
unsigned int * | charactersRemaining | ||
) |
Get a rect that contains a row of text starting at index.
The number of characters from index to line end is stored in length.
Definition at line 661 of file VuoImageText.cc.
VuoImageTextData VuoImageTextData_make | ( | ) |
Initialize a new instance of VuoImageTextData.
Definition at line 87 of file VuoImageText.cc.
|
static |
A pool of images.
Definition at line 115 of file VuoImageText.cc.
|
static |
Signals when the last VuoImageTextCache cleanup has completed.
Definition at line 117 of file VuoImageText.cc.
|
static |
Serializes access to VuoImageTextCache.
Definition at line 116 of file VuoImageText.cc.
|
static |
Seconds an image can remain in the cache unused, before it gets purged.
Definition at line 119 of file VuoImageText.cc.
|
static |
Periodically cleans up VuoImageTextCache.
Definition at line 118 of file VuoImageText.cc.