|
NPWText.h File ReferenceHelper functions for text layout.
More...
#include "NPWBase.h"
#include "NPWGraphics.h"
Go to the source code of this file.
|
Data Structures |
struct | NPWFont |
| Font metrics. More...
|
struct | NPWRGBColor |
| RGB color. More...
|
struct | NPWCharStyle |
| Character style. More...
|
struct | NPWParFormat |
| Paragraph format. More...
|
struct | NPWMarkupCBEntry |
| Element of table of markup callbacks. More...
|
struct | NPWTextLayoutState |
| State of text layout. More...
|
Typedefs |
typedef NPWMarkupActionFlag(* | NPWMarkupCB )(void *userData, NPWConstText t, NPWInt len, NPWInt *count, NPWCharStyle *style, NPWParFormat *parFormat) |
| Callback to decode text markup.
|
Enumerations |
enum | NPWCharVertAlignment { kNPWCharVertAlignmentNormal = 0,
kNPWCharVertAlignmentSubscript,
kNPWCharVertAlignmentSuperscript
} |
| Vertical character alignment. More...
|
enum | NPWAlignment { kNPWAlignmentLeft = 0,
kNPWAlignmentCenter,
kNPWAlignmentRight,
kNPWAlignmentJustify
} |
| Horizontal alignment. More...
|
enum | NPWMarkupActionFlag {
kNPWMarkupActionFlagNop = 0,
kNPWMarkupActionFlagNotRecognized = 1,
kNPWMarkupActionFlagEndOfPar = 2,
kNPWMarkupActionFlagNewStyle = 4,
kNPWMarkupActionFlagNewParFormat = 8,
kNPWMarkupActionFlagSuspend = 16
} |
| Action flags of markup callbacks. More...
|
Functions |
NPWErr | NPWTextFont (NPWFont *font, NPWConstText name, NPWFloat size) |
| Initialize a font by name and size.
|
void | NPWTextSize (NPWFont const *font, NPWConstText str, NPWInt len, NPWFloat *width, NPWFloat *height) |
| Calculate size of text.
|
NPWConstText | NPWFindFont (NPWCharStyle const *charStyle, NPWFont *font) |
| Find a font by name and style.
|
void | NPWFontMetrics (NPWFont const *font, NPWFloat *ascender, NPWFloat *descender, NPWFloat *xHeight) |
| Get font metrics.
|
NPWBoolean | NPWBreakNextLine (NPWConstText str, NPWInt len, NPWInt start, NPWFloat lineMaxWidth, NPWMarkupCBEntry const markupCBTable[], NPWInt *lineBr, NPWFloat *lineWidth, NPWInt *nSpaces, NPWBoolean *suspended, NPWCharStyle *style, NPWParFormat *parFormat) |
| Find next line break and compute length and number of spaces.
|
void | NPWTextLayoutInit (NPWTextLayoutState *state, NPWMarkupCBEntry const markupCBTable[]) |
| Initialize text layout state.
|
void | NPWLayoutSetDefaultCharStyle (NPWTextLayoutState *state, NPWCharStyle const *style) |
| Set default character style in text layout state.
|
void | NPWLayoutSetDefaultParagraphStyle (NPWTextLayoutState *state, NPWParFormat const *parFormat) |
| Set default paragraph format in text layout state.
|
void | NPWTextLayoutSetPosition (NPWTextLayoutState *state, NPWFloat x, NPWFloat y) |
| Set position of next line of text in text layout state.
|
void | NPWTextLayoutSetLineWidths (NPWTextLayoutState *state, NPWFloat const lmw[], NPWInt n) |
| Set array of maximum line widths.
|
void | NPWTextLayoutSetBottom (NPWTextLayoutState *state, NPWFloat bottom) |
| Set lower limit of text along y axis.
|
void | NPWTextLayoutSetText (NPWTextLayoutState *state, NPWConstText str, NPWInt len) |
| Set text.
|
NPWErr | NPWTextLayoutWrite (NPW *pdf, NPWTextLayoutState *state) |
| Write formatted text.
|
NPWErr | NPWTextLayoutVerticalSkip (NPWTextLayoutState *state, NPWFloat v, NPWFloat *ylow) |
| Reserve some space in text layout.
|
NPWErr | NPWTextWrite (NPW *pdf, NPWConstText str, NPWInt len, NPWFloat x, NPWFloat y, NPWCharStyle const *style, NPWAlignment alignment) |
| Write simple styeled text.
|
Detailed Description
Helper functions for text layout.
- Author:
- Yves Piguet. Copyright 2008-2010, Yves Piguet
Definition in file NPWText.h.
Typedef Documentation
Callback to decode text markup.
- Parameters:
-
[in,out] | userData | callback-specific data |
[in] | t | text whose beginning is analyzed |
[in] | len | length of t |
[out] | count | number of characters of markup |
[in,out] | style | character style |
[in,out] | parFormat | paragraph format |
- Returns:
- kNPWMarkupActionFlagNotRecognized if no markup has been recognized, or flags describing the markup effect
Definition at line 93 of file NPWText.h.
Enumeration Type Documentation
Horizontal alignment.
- Enumerator:
-
kNPWAlignmentLeft |
flush left |
kNPWAlignmentCenter |
center |
kNPWAlignmentRight |
flush right |
kNPWAlignmentJustify |
justification |
Definition at line 54 of file NPWText.h.
Vertical character alignment.
- Enumerator:
-
kNPWCharVertAlignmentNormal |
normal text |
kNPWCharVertAlignmentSubscript |
subscript |
kNPWCharVertAlignmentSuperscript |
superscript |
Definition at line 25 of file NPWText.h.
Action flags of markup callbacks.
- Enumerator:
-
kNPWMarkupActionFlagNop |
no action |
kNPWMarkupActionFlagNotRecognized |
no recognized markup |
kNPWMarkupActionFlagEndOfPar |
end of paragraph |
kNPWMarkupActionFlagNewStyle |
new character style |
kNPWMarkupActionFlagNewParFormat |
new paragraph format |
kNPWMarkupActionFlagSuspend |
end of par + suspend text rendering with kNPWErrSuspended |
Definition at line 73 of file NPWText.h.
Function Documentation
NPWBoolean NPWBreakNextLine |
( |
NPWConstText |
str, |
|
|
NPWInt |
len, |
|
|
NPWInt |
start, |
|
|
NPWFloat |
lineMaxWidth, |
|
|
NPWMarkupCBEntry const |
markupCBTable[], |
|
|
NPWInt * |
lineBr, |
|
|
NPWFloat * |
lineWidth, |
|
|
NPWInt * |
nSpaces, |
|
|
NPWBoolean * |
suspended, |
|
|
NPWCharStyle * |
style, |
|
|
NPWParFormat * |
parFormat | |
|
) |
| | |
Find next line break and compute length and number of spaces.
- Parameters:
-
[in] | str | text |
[in] | len | length of text (c-string if < 0); stops at first linefeed |
[in] | start | offset of first character in str |
[in] | lineMaxWidth | max width of line; no line break if negative, just compute line width and spaces for alignment |
[in] | markupCBTable | table of markup callbacks |
[out] | lineBr | offset of next line break |
[out] | lineWidth | width of next line (without trailing spaces) |
[out] | nSpaces | number of spaces (excluding trailing space) |
[in,out] | suspended | set to TRUE if a markup callback has returned kNPWMarkupActionFlagSuspend |
[in,out] | style | initial character style |
[in,out] | parFormat | initial paragraph format |
- Returns:
- TRUE if next line is found, FALSE if end-of-text
Definition at line 508 of file NPWText.c.
Find a font by name and style.
- Parameters:
-
[in] | charStyle | font and character style |
[out] | font | AFM metrics |
- Returns:
- font reference to be used in PDF
Definition at line 461 of file NPWText.c.
Get font metrics.
- Parameters:
-
[in] | font | AFM metrics |
[out] | ascender | ascender (not retrieved if NULL) |
[out] | descender | descender (not retrieved if NULL) |
[out] | xHeight | x-height (not retrieved if NULL) |
Definition at line 495 of file NPWText.c.
Set default character style in text layout state.
- Parameters:
-
[in,out] | state | text layout state |
[in] | style | default character style |
Definition at line 633 of file NPWText.c.
Set default paragraph format in text layout state.
- Parameters:
-
[in,out] | state | text layout state |
[in] | parFormat | default paragraph style |
Definition at line 639 of file NPWText.c.
Initialize a font by name and size.
- Parameters:
-
[out] | font | font |
[in] | name | font dictionary name (NPWFontNameCourier etc.) |
[in] | size | font size in points |
- Returns:
- kNPWErrOk for success, else error code
Definition at line 430 of file NPWText.c.
Initialize text layout state.
- Parameters:
-
[out] | state | text layout state |
[in] | markupCBTable | table of markup callbacks |
Definition at line 606 of file NPWText.c.
Set lower limit of text along y axis.
- Parameters:
-
[in,out] | state | text layout state |
[in] | bottom | lower limit of text |
Definition at line 659 of file NPWText.c.
Set array of maximum line widths.
- Parameters:
-
[in,out] | state | text layout state |
[in] | lmw | array of line maximum widths |
[in] | n | number of elements in lmw (last element is replicated) |
Definition at line 652 of file NPWText.c.
Set position of next line of text in text layout state.
- Parameters:
-
[in,out] | state | text layout state |
[in] | x | left margin |
[in] | y | base line of first line |
Definition at line 645 of file NPWText.c.
Set text.
- Parameters:
-
[in,out] | state | text layout state |
[in] | str | text |
[in] | len | text length |
Definition at line 665 of file NPWText.c.
Reserve some space in text layout.
- Parameters:
-
[in,out] | state | text layout state |
[in] | v | vertical distance to skip |
[out] | ylow | y coordinate of free space bottom (base line one line above where next line will be displayed; free space top is the base line of previous line; not returned in NULL) |
- Returns:
- kNPWErrOk for success, kNPWErrIncomplete if not enough space (y exceeds bottom), else error code
Definition at line 901 of file NPWText.c.
Write formatted text.
- Parameters:
-
| pdf | reference to NPW structure |
[in,out] | state | text layout state |
- Returns:
- kNPWErrOk for success, kNPWErrIncomplete if more text to write (y exceeds bottom), else error code
Definition at line 677 of file NPWText.c.
Calculate size of text.
- Parameters:
-
[in] | font | font |
[in] | str | text |
[in] | len | length of text, or -1 if str is null-terminated |
[out] | width | text width if not NULL |
[out] | height | text height if not NULL |
Definition at line 444 of file NPWText.c.
Write simple styeled text.
- Parameters:
-
| pdf | reference to NPW structure |
[in] | str | text |
[in] | len | length of text, or -1 if str is null-terminated |
[in] | x | position along x axis |
[in] | y | position along y axis |
[in] | style | character style |
[in] | alignment | horizontal alignment (kNPWAlignmentLeft, kNPWAlignmentCenter, or kNPWAlignmentRight) |
- Returns:
- kNPWErrOk for success, else error code
Definition at line 912 of file NPWText.c.
|
Generated by Doxygen.
Copyright 2007-2010, Yves Piguet.
All rights reserved.
|
|