DISTRHO Plugin Framework
|
#include <NanoVG.hpp>
Classes | |
struct | GlyphPosition |
struct | Paint |
struct | TextRow |
Public Types | |
enum | CreateFlags { CREATE_ANTIALIAS = 1 << 0 , CREATE_STENCIL_STROKES = 1 << 1 , CREATE_DEBUG = 1 << 2 } |
enum | ImageFlags { IMAGE_GENERATE_MIPMAPS = 1 << 0 , IMAGE_REPEAT_X = 1 << 1 , IMAGE_REPEAT_Y = 1 << 2 , IMAGE_FLIP_Y = 1 << 3 , IMAGE_PREMULTIPLIED = 1 << 4 } |
enum | Align { ALIGN_LEFT = 1 << 0 , ALIGN_CENTER = 1 << 1 , ALIGN_RIGHT = 1 << 2 , ALIGN_TOP = 1 << 3 , ALIGN_MIDDLE = 1 << 4 , ALIGN_BOTTOM = 1 << 5 , ALIGN_BASELINE = 1 << 6 } |
enum | LineCap { BUTT , ROUND , SQUARE , BEVEL , MITER } |
enum | Solidity { SOLID = 1 , HOLE = 2 } |
enum | Winding { CCW = 1 , CW = 2 } |
typedef int | FontId |
Public Member Functions | |
NanoVG (int flags=CREATE_ANTIALIAS) | |
NanoVG (NVGcontext *context) | |
virtual | ~NanoVG () |
NVGcontext * | getContext () const noexcept |
void | beginFrame (const uint width, const uint height, const float scaleFactor=1.0f) |
void | beginFrame (Widget *const widget) |
void | cancelFrame () |
void | endFrame () |
void | save () |
void | restore () |
void | reset () |
void | strokeColor (const Color &color) |
void | strokeColor (const int red, const int green, const int blue, const int alpha=255) |
void | strokeColor (const float red, const float green, const float blue, const float alpha=1.0f) |
void | strokePaint (const Paint &paint) |
void | fillColor (const Color &color) |
void | fillColor (const int red, const int green, const int blue, const int alpha=255) |
void | fillColor (const float red, const float green, const float blue, const float alpha=1.0f) |
void | fillPaint (const Paint &paint) |
void | miterLimit (float limit) |
void | strokeWidth (float size) |
void | lineCap (LineCap cap=BUTT) |
void | lineJoin (LineCap join=MITER) |
void | globalAlpha (float alpha) |
void | globalTint (Color tint) |
void | resetTransform () |
void | transform (float a, float b, float c, float d, float e, float f) |
void | translate (float x, float y) |
void | rotate (float angle) |
void | skewX (float angle) |
void | skewY (float angle) |
void | scale (float x, float y) |
void | currentTransform (float xform[6]) |
NanoImage::Handle | createImageFromFile (const char *filename, ImageFlags imageFlags) |
NanoImage::Handle | createImageFromFile (const char *filename, int imageFlags) |
NanoImage::Handle | createImageFromMemory (const uchar *data, uint dataSize, ImageFlags imageFlags) |
NanoImage::Handle | createImageFromMemory (const uchar *data, uint dataSize, int imageFlags) |
NanoImage::Handle | createImageFromRawMemory (uint w, uint h, const uchar *data, ImageFlags imageFlags, ImageFormat format) |
NanoImage::Handle | createImageFromRawMemory (uint w, uint h, const uchar *data, int imageFlags, ImageFormat format) |
NanoImage::Handle | createImageFromRGBA (uint w, uint h, const uchar *data, ImageFlags imageFlags) |
NanoImage::Handle | createImageFromRGBA (uint w, uint h, const uchar *data, int imageFlags) |
NanoImage::Handle | createImageFromTextureHandle (GLuint textureId, uint w, uint h, ImageFlags imageFlags, bool deleteTexture=false) |
NanoImage::Handle | createImageFromTextureHandle (GLuint textureId, uint w, uint h, int imageFlags, bool deleteTexture=false) |
Paint | linearGradient (float sx, float sy, float ex, float ey, const Color &icol, const Color &ocol) |
Paint | boxGradient (float x, float y, float w, float h, float r, float f, const Color &icol, const Color &ocol) |
Paint | radialGradient (float cx, float cy, float inr, float outr, const Color &icol, const Color &ocol) |
Paint | imagePattern (float ox, float oy, float ex, float ey, float angle, const NanoImage &image, float alpha) |
void | scissor (float x, float y, float w, float h) |
void | intersectScissor (float x, float y, float w, float h) |
void | resetScissor () |
void | beginPath () |
void | moveTo (float x, float y) |
void | lineTo (float x, float y) |
void | bezierTo (float c1x, float c1y, float c2x, float c2y, float x, float y) |
void | quadTo (float cx, float cy, float x, float y) |
void | arcTo (float x1, float y1, float x2, float y2, float radius) |
void | closePath () |
void | pathWinding (Winding dir) |
void | arc (float cx, float cy, float r, float a0, float a1, Winding dir) |
void | rect (float x, float y, float w, float h) |
void | roundedRect (float x, float y, float w, float h, float r) |
void | ellipse (float cx, float cy, float rx, float ry) |
void | circle (float cx, float cy, float r) |
void | fill () |
void | stroke () |
FontId | createFontFromFile (const char *name, const char *filename) |
FontId | createFontFromMemory (const char *name, const uchar *data, uint dataSize, bool freeData) |
FontId | findFont (const char *name) |
void | fontSize (float size) |
void | fontBlur (float blur) |
void | textLetterSpacing (float spacing) |
void | textLineHeight (float lineHeight) |
void | textAlign (Align align) |
void | textAlign (int align) |
void | fontFaceId (FontId font) |
void | fontFace (const char *font) |
float | text (float x, float y, const char *string, const char *end) |
void | textBox (float x, float y, float breakRowWidth, const char *string, const char *end=nullptr) |
float | textBounds (float x, float y, const char *string, const char *end, Rectangle< float > &bounds) |
void | textBoxBounds (float x, float y, float breakRowWidth, const char *string, const char *end, float bounds[4]) |
int | textGlyphPositions (float x, float y, const char *string, const char *end, GlyphPosition &positions, int maxPositions) |
void | textMetrics (float *ascender, float *descender, float *lineh) |
int | textBreakLines (const char *string, const char *end, float breakRowWidth, TextRow &rows, int maxRows) |
virtual bool | loadSharedResources () |
Static Public Member Functions | |
static void | transformIdentity (float dst[6]) |
static void | transformTranslate (float dst[6], float tx, float ty) |
static void | transformScale (float dst[6], float sx, float sy) |
static void | transformRotate (float dst[6], float a) |
static void | transformSkewX (float dst[6], float a) |
static void | transformSkewY (float dst[6], float a) |
static void | transformMultiply (float dst[6], const float src[6]) |
static void | transformPremultiply (float dst[6], const float src[6]) |
static int | transformInverse (float dst[6], const float src[6]) |
static void | transformPoint (float &dstx, float &dsty, const float xform[6], float srcx, float srcy) |
static float | degToRad (float deg) |
static float | radToDeg (float rad) |
NanoVG class.
This class exposes the NanoVG drawing API. All calls should be wrapped in beginFrame() and endFrame().
NanoVG contains state which represents how paths will be rendered. The state contains transform, fill and stroke styles, text and font styles, and scissor clipping.
Fill and stroke render style can be either a solid color or a paint which is a gradient or a pattern. Solid color is simply defined as a color value, different kinds of paints can be created using linearGradient(), boxGradient(), radialGradient() and imagePattern().
Current render style can be saved and restored using save() and restore().
The paths, gradients, patterns and scissor region are transformed by an transformation matrix at the time when they are passed to the API. The current transformation matrix is a affine matrix: [sx kx tx] [ky sy ty] [ 0 0 1] Where: sx,sy define scaling, kx,ky skewing, and tx,ty translation. The last row is assumed to be 0,0,1 and is not stored.
Apart from resetTransform(), each transformation function first creates specific transformation matrix and pre-multiplies the current transformation by it.
Current coordinate system (transformation) can be saved and restored using save() and restore().
NanoVG allows you to load jpg, png, psd, tga, pic and gif files to be used for rendering. In addition you can upload your own image. The image loading is provided by stb_image.
NanoVG supports four types of paints: linear gradient, box gradient, radial gradient and image pattern. These can be used as paints for strokes and fills.
Scissoring allows you to clip the rendering into a rectangle. This is useful for various user interface cases like rendering a text edit or a timeline.
Drawing a new shape starts with beginPath(), it clears all the currently defined paths. Then you define one or more paths and sub-paths which describe the shape. The are functions to draw common shapes like rectangles and circles, and lower level step-by-step functions, which allow to define a path curve by curve.
NanoVG uses even-odd fill rule to draw the shapes. Solid shapes should have counter clockwise winding and holes should have counter clockwise order. To specify winding of a path you can call pathWinding(). This is useful especially for the common shapes, which are drawn CCW.
Finally you can fill the path using current fill style by calling fill(), and stroke it with current stroke style by calling stroke().
The curve segments and sub-paths are transformed by the current transform.
NanoVG allows you to load .ttf files and use the font to render text.
The appearance of the text can be defined by setting the current text style and by specifying the fill color. Common text and font settings such as font size, letter spacing and text align are supported. Font blur allows you to create simple text effects such as drop shadows.
At render time the font face can be set based on the font handles or name.
Font measure functions return values in local space, the calculations are carried in the same resolution as the final rendering. This is done because the text glyph positions are snapped to the nearest pixels sharp rendering.
The local space means that values are not rotated or scale as per the current transformation. For example if you set font size to 12, which would mean that line height is 16, then regardless of the current scaling and rotation, the returned line height is always 16. Some measures may vary because of the scaling since aforementioned pixel snapping.
While this may sound a little odd, the setup allows you to always render the same way regardless of scaling. i.e. following works regardless of scaling:
Note: currently only solid color fill is supported for text.
enum NanoVG::CreateFlags |
NanoVG::NanoVG | ( | int | flags = CREATE_ANTIALIAS | ) |
Constructor.
|
explicit |
Constructor reusing a NanoVG context, used for subwidgets. Context will not be deleted on class destructor.
|
virtual |
Destructor.
|
inlinenoexcept |
Get the NanoVG context. You should not need this under normal circumstances.
void NanoVG::beginFrame | ( | const uint | width, |
const uint | height, | ||
const float | scaleFactor = 1.0f |
||
) |
Begin drawing a new frame.
void NanoVG::beginFrame | ( | Widget *const | widget | ) |
Begin drawing a new frame inside a widget.
void NanoVG::cancelFrame | ( | ) |
Cancels drawing the current frame.
void NanoVG::endFrame | ( | ) |
Ends drawing flushing remaining render state.
void NanoVG::save | ( | ) |
Pushes and saves the current render state into a state stack. A matching restore() must be used to restore the state.
void NanoVG::restore | ( | ) |
Pops and restores current render state.
void NanoVG::reset | ( | ) |
Resets current render state to default values. Does not affect the render state stack.
void NanoVG::strokeColor | ( | const Color & | color | ) |
Sets current stroke style to a solid color.
void NanoVG::strokeColor | ( | const int | red, |
const int | green, | ||
const int | blue, | ||
const int | alpha = 255 |
||
) |
Sets current stroke style to a solid color, made from red, green, blue and alpha numeric values. Values must be in [0..255] range.
void NanoVG::strokeColor | ( | const float | red, |
const float | green, | ||
const float | blue, | ||
const float | alpha = 1.0f |
||
) |
Sets current stroke style to a solid color, made from red, green, blue and alpha numeric values. Values must in [0..1] range.
void NanoVG::strokePaint | ( | const Paint & | paint | ) |
Sets current stroke style to a paint, which can be a one of the gradients or a pattern.
void NanoVG::fillColor | ( | const Color & | color | ) |
Sets current fill style to a solid color.
void NanoVG::fillColor | ( | const int | red, |
const int | green, | ||
const int | blue, | ||
const int | alpha = 255 |
||
) |
Sets current fill style to a solid color, made from red, green, blue and alpha numeric values. Values must be in [0..255] range.
void NanoVG::fillColor | ( | const float | red, |
const float | green, | ||
const float | blue, | ||
const float | alpha = 1.0f |
||
) |
Sets current fill style to a solid color, made from red, green, blue and alpha numeric values. Values must in [0..1] range.
void NanoVG::fillPaint | ( | const Paint & | paint | ) |
Sets current fill style to a paint, which can be a one of the gradients or a pattern.
void NanoVG::miterLimit | ( | float | limit | ) |
Sets the miter limit of the stroke style. Miter limit controls when a sharp corner is beveled.
void NanoVG::strokeWidth | ( | float | size | ) |
Sets the stroke width of the stroke style.
void NanoVG::lineCap | ( | LineCap | cap = BUTT | ) |
Sets how the end of the line (cap) is drawn, Can be one of: BUTT, ROUND, SQUARE.
void NanoVG::lineJoin | ( | LineCap | join = MITER | ) |
Sets how sharp path corners are drawn. Can be one of MITER, ROUND, BEVEL.
void NanoVG::globalAlpha | ( | float | alpha | ) |
Sets the transparency applied to all rendered shapes. Already transparent paths will get proportionally more transparent as well.
void NanoVG::globalTint | ( | Color | tint | ) |
Sets the color tint applied to all rendered shapes.
void NanoVG::resetTransform | ( | ) |
Resets current transform to a identity matrix.
void NanoVG::transform | ( | float | a, |
float | b, | ||
float | c, | ||
float | d, | ||
float | e, | ||
float | f | ||
) |
Pre-multiplies current coordinate system by specified matrix. The parameters are interpreted as matrix as follows: [a c e] [b d f] [0 0 1]
void NanoVG::translate | ( | float | x, |
float | y | ||
) |
Translates current coordinate system.
void NanoVG::rotate | ( | float | angle | ) |
Rotates current coordinate system. Angle is specified in radians.
void NanoVG::skewX | ( | float | angle | ) |
Skews the current coordinate system along X axis. Angle is specified in radians.
void NanoVG::skewY | ( | float | angle | ) |
Skews the current coordinate system along Y axis. Angle is specified in radians.
void NanoVG::scale | ( | float | x, |
float | y | ||
) |
Scales the current coordinate system.
void NanoVG::currentTransform | ( | float | xform[6] | ) |
Stores the top part (a-f) of the current transformation matrix in to the specified buffer. [a c e] [b d f] [0 0 1]
|
static |
The following functions can be used to make calculations on 2x3 transformation matrices. A 2x3 matrix is represented as float[6]. Sets the transform to identity matrix.
|
static |
Sets the transform to translation matrix
|
static |
Sets the transform to scale matrix.
|
static |
Sets the transform to rotate matrix. Angle is specified in radians.
|
static |
Sets the transform to skew-x matrix. Angle is specified in radians.
|
static |
Sets the transform to skew-y matrix. Angle is specified in radians.
|
static |
Sets the transform to the result of multiplication of two transforms, of A = A*B.
|
static |
Sets the transform to the result of multiplication of two transforms, of A = B*A.
|
static |
Sets the destination to inverse of specified transform. Returns 1 if the inverse could be calculated, else 0.
|
static |
Transform a point by given transform.
|
static |
Convert degrees to radians.
|
static |
Convert radians to degrees.
NanoImage::Handle NanoVG::createImageFromFile | ( | const char * | filename, |
ImageFlags | imageFlags | ||
) |
Creates image by loading it from the disk from specified file name.
NanoImage::Handle NanoVG::createImageFromFile | ( | const char * | filename, |
int | imageFlags | ||
) |
Creates image by loading it from the disk from specified file name. Overloaded function for convenience.
NanoImage::Handle NanoVG::createImageFromMemory | ( | const uchar * | data, |
uint | dataSize, | ||
ImageFlags | imageFlags | ||
) |
Creates image by loading it from the specified chunk of memory.
NanoImage::Handle NanoVG::createImageFromMemory | ( | const uchar * | data, |
uint | dataSize, | ||
int | imageFlags | ||
) |
Creates image by loading it from the specified chunk of memory. Overloaded function for convenience.
NanoImage::Handle NanoVG::createImageFromRawMemory | ( | uint | w, |
uint | h, | ||
const uchar * | data, | ||
ImageFlags | imageFlags, | ||
ImageFormat | format | ||
) |
Creates image from specified raw format image data.
NanoImage::Handle NanoVG::createImageFromRawMemory | ( | uint | w, |
uint | h, | ||
const uchar * | data, | ||
int | imageFlags, | ||
ImageFormat | format | ||
) |
Creates image from specified raw format image data. Overloaded function for convenience.
NanoImage::Handle NanoVG::createImageFromRGBA | ( | uint | w, |
uint | h, | ||
const uchar * | data, | ||
ImageFlags | imageFlags | ||
) |
Creates image from specified RGBA image data.
NanoImage::Handle NanoVG::createImageFromRGBA | ( | uint | w, |
uint | h, | ||
const uchar * | data, | ||
int | imageFlags | ||
) |
Creates image from specified RGBA image data. Overloaded function for convenience.
NanoImage::Handle NanoVG::createImageFromTextureHandle | ( | GLuint | textureId, |
uint | w, | ||
uint | h, | ||
ImageFlags | imageFlags, | ||
bool | deleteTexture = false |
||
) |
Creates image from an OpenGL texture handle.
NanoImage::Handle NanoVG::createImageFromTextureHandle | ( | GLuint | textureId, |
uint | w, | ||
uint | h, | ||
int | imageFlags, | ||
bool | deleteTexture = false |
||
) |
Creates image from an OpenGL texture handle. Overloaded function for convenience.
Paint NanoVG::linearGradient | ( | float | sx, |
float | sy, | ||
float | ex, | ||
float | ey, | ||
const Color & | icol, | ||
const Color & | ocol | ||
) |
Creates and returns a linear gradient. Parameters (sx,sy)-(ex,ey) specify the start and end coordinates of the linear gradient, icol specifies the start color and ocol the end color. The gradient is transformed by the current transform when it is passed to fillPaint() or strokePaint().
Paint NanoVG::boxGradient | ( | float | x, |
float | y, | ||
float | w, | ||
float | h, | ||
float | r, | ||
float | f, | ||
const Color & | icol, | ||
const Color & | ocol | ||
) |
Creates and returns a box gradient. Box gradient is a feathered rounded rectangle, it is useful for rendering drop shadows or highlights for boxes. Parameters (x,y) define the top-left corner of the rectangle, (w,h) define the size of the rectangle, r defines the corner radius, and f feather. Feather defines how blurry the border of the rectangle is. Parameter icol specifies the inner color and ocol the outer color of the gradient. The gradient is transformed by the current transform when it is passed to fillPaint() or strokePaint().
Paint NanoVG::radialGradient | ( | float | cx, |
float | cy, | ||
float | inr, | ||
float | outr, | ||
const Color & | icol, | ||
const Color & | ocol | ||
) |
Creates and returns a radial gradient. Parameters (cx,cy) specify the center, inr and outr specify the inner and outer radius of the gradient, icol specifies the start color and ocol the end color. The gradient is transformed by the current transform when it is passed to fillPaint() or strokePaint().
Paint NanoVG::imagePattern | ( | float | ox, |
float | oy, | ||
float | ex, | ||
float | ey, | ||
float | angle, | ||
const NanoImage & | image, | ||
float | alpha | ||
) |
Creates and returns an image pattern. Parameters (ox,oy) specify the left-top location of the image pattern, (ex,ey) the size of one image, angle rotation around the top-left corner, image is handle to the image to render. The gradient is transformed by the current transform when it is passed to fillPaint() or strokePaint().
void NanoVG::scissor | ( | float | x, |
float | y, | ||
float | w, | ||
float | h | ||
) |
Sets the current scissor rectangle. The scissor rectangle is transformed by the current transform.
void NanoVG::intersectScissor | ( | float | x, |
float | y, | ||
float | w, | ||
float | h | ||
) |
Intersects current scissor rectangle with the specified rectangle. The scissor rectangle is transformed by the current transform. Note: in case the rotation of previous scissor rect differs from the current one, the intersection will be done between the specified rectangle and the previous scissor rectangle transformed in the current transform space. The resulting shape is always rectangle.
void NanoVG::resetScissor | ( | ) |
Reset and disables scissoring.
void NanoVG::beginPath | ( | ) |
Clears the current path and sub-paths.
void NanoVG::moveTo | ( | float | x, |
float | y | ||
) |
Starts new sub-path with specified point as first point.
void NanoVG::lineTo | ( | float | x, |
float | y | ||
) |
Adds line segment from the last point in the path to the specified point.
void NanoVG::bezierTo | ( | float | c1x, |
float | c1y, | ||
float | c2x, | ||
float | c2y, | ||
float | x, | ||
float | y | ||
) |
Adds cubic bezier segment from last point in the path via two control points to the specified point.
void NanoVG::quadTo | ( | float | cx, |
float | cy, | ||
float | x, | ||
float | y | ||
) |
Adds quadratic bezier segment from last point in the path via a control point to the specified point.
void NanoVG::arcTo | ( | float | x1, |
float | y1, | ||
float | x2, | ||
float | y2, | ||
float | radius | ||
) |
Adds an arc segment at the corner defined by the last path point, and two specified points.
void NanoVG::closePath | ( | ) |
Closes current sub-path with a line segment.
void NanoVG::pathWinding | ( | Winding | dir | ) |
Sets the current sub-path winding.
void NanoVG::arc | ( | float | cx, |
float | cy, | ||
float | r, | ||
float | a0, | ||
float | a1, | ||
Winding | dir | ||
) |
Creates new circle arc shaped sub-path. The arc center is at cx,cy, the arc radius is r, and the arc is drawn from angle a0 to a1, and swept in direction dir (NVG_CCW or NVG_CW). Angles are specified in radians.
void NanoVG::rect | ( | float | x, |
float | y, | ||
float | w, | ||
float | h | ||
) |
Creates new rectangle shaped sub-path.
void NanoVG::roundedRect | ( | float | x, |
float | y, | ||
float | w, | ||
float | h, | ||
float | r | ||
) |
Creates new rounded rectangle shaped sub-path.
void NanoVG::ellipse | ( | float | cx, |
float | cy, | ||
float | rx, | ||
float | ry | ||
) |
Creates new ellipse shaped sub-path.
void NanoVG::circle | ( | float | cx, |
float | cy, | ||
float | r | ||
) |
Creates new circle shaped sub-path.
void NanoVG::fill | ( | ) |
Fills the current path with current fill style.
void NanoVG::stroke | ( | ) |
Fills the current path with current stroke style.
FontId NanoVG::createFontFromFile | ( | const char * | name, |
const char * | filename | ||
) |
Creates font by loading it from the disk from specified file name. Returns handle to the font.
FontId NanoVG::createFontFromMemory | ( | const char * | name, |
const uchar * | data, | ||
uint | dataSize, | ||
bool | freeData | ||
) |
Creates font by loading it from the specified memory chunk. Returns handle to the font.
FontId NanoVG::findFont | ( | const char * | name | ) |
Finds a loaded font of specified name, and returns handle to it, or -1 if the font is not found.
void NanoVG::fontSize | ( | float | size | ) |
Sets the font size of current text style.
void NanoVG::fontBlur | ( | float | blur | ) |
Sets the blur of current text style.
void NanoVG::textLetterSpacing | ( | float | spacing | ) |
Sets the letter spacing of current text style.
void NanoVG::textLineHeight | ( | float | lineHeight | ) |
Sets the proportional line height of current text style. The line height is specified as multiple of font size.
void NanoVG::textAlign | ( | Align | align | ) |
Sets the text align of current text style.
void NanoVG::textAlign | ( | int | align | ) |
Sets the text align of current text style. Overloaded function for convenience.
void NanoVG::fontFaceId | ( | FontId | font | ) |
Sets the font face based on specified id of current text style.
void NanoVG::fontFace | ( | const char * | font | ) |
Sets the font face based on specified name of current text style.
float NanoVG::text | ( | float | x, |
float | y, | ||
const char * | string, | ||
const char * | end | ||
) |
Draws text string at specified location. If end is specified only the sub-string up to the end is drawn.
void NanoVG::textBox | ( | float | x, |
float | y, | ||
float | breakRowWidth, | ||
const char * | string, | ||
const char * | end = nullptr |
||
) |
Draws multi-line text string at specified location wrapped at the specified width. If end is specified only the sub-string up to the end is drawn. White space is stripped at the beginning of the rows, the text is split at word boundaries or when new-line characters are encountered. Words longer than the max width are slit at nearest character (i.e. no hyphenation).
float NanoVG::textBounds | ( | float | x, |
float | y, | ||
const char * | string, | ||
const char * | end, | ||
Rectangle< float > & | bounds | ||
) |
Measures the specified text string. The bounds value are [xmin,ymin, xmax,ymax]. Returns the horizontal advance of the measured text (i.e. where the next character should drawn). Measured values are returned in local coordinate space.
void NanoVG::textBoxBounds | ( | float | x, |
float | y, | ||
float | breakRowWidth, | ||
const char * | string, | ||
const char * | end, | ||
float | bounds[4] | ||
) |
Measures the specified multi-text string. Parameter bounds should be a pointer to float[4], if the bounding box of the text should be returned. The bounds value are [xmin,ymin, xmax,ymax] Measured values are returned in local coordinate space.
int NanoVG::textGlyphPositions | ( | float | x, |
float | y, | ||
const char * | string, | ||
const char * | end, | ||
GlyphPosition & | positions, | ||
int | maxPositions | ||
) |
Calculates the glyph x positions of the specified text. If end is specified only the sub-string will be used. Measured values are returned in local coordinate space.
void NanoVG::textMetrics | ( | float * | ascender, |
float * | descender, | ||
float * | lineh | ||
) |
Returns the vertical metrics based on the current text style. Measured values are returned in local coordinate space.
int NanoVG::textBreakLines | ( | const char * | string, |
const char * | end, | ||
float | breakRowWidth, | ||
TextRow & | rows, | ||
int | maxRows | ||
) |
Breaks the specified text into lines. If end is specified only the sub-string will be used. White space is stripped at the beginning of the rows, the text is split at word boundaries or when new-line characters are encountered. Words longer than the max width are slit at nearest character (i.e. no hyphenation).
|
virtual |
Load DPF's internal shared resources for this NanoVG class.