This modules is to draw UTF-8 strings with freetype/harfbuzz.
- Install freetype2 and harfbuzz in your system.
- Create FreeType2 instance with createFreeType2() function.
- Load font file with loadFontData() function.
- Draw text with putText() function.
- If thickness parameter is negative, drawing glyph is filled.
- If thickness parameter is positive, drawing glyph is outlined with thickness.
- If line_type parameter is 16(or CV_AA), drawing glyph is smooth.
§ createFreeType2()
Create FreeType2 Instance.
The function createFreeType2 create instance to draw UTF-8 strings.
§ loadFontData()
virtual void cv::freetype::FreeType2::loadFontData |
( |
String |
fontFileName, |
|
|
int |
id |
|
) |
| |
|
pure virtual |
Load font data.
The function loadFontData loads font data.
- Parameters
-
fontFileName | FontFile Name |
id | face_index to select a font faces in a single file. |
§ putText()
virtual void cv::freetype::FreeType2::putText |
( |
InputOutputArray |
img, |
|
|
const String & |
text, |
|
|
Point |
org, |
|
|
int |
fontHeight, |
|
|
Scalar |
color, |
|
|
int |
thickness, |
|
|
int |
line_type, |
|
|
bool |
bottomLeftOrigin |
|
) |
| |
|
pure virtual |
Draws a text string.
The function putText renders the specified text string in the image. Symbols that cannot be rendered using the specified font are replaced by "Tofu" or non-drawn.
- Parameters
-
img | Image. |
text | Text string to be drawn. |
org | Bottom-left/Top-left corner of the text string in the image. |
fontHeight | Drawing font size by pixel unit. |
color | Text color. |
thickness | Thickness of the lines used to draw a text when negative, the glyph is filled. Otherwise, the glyph is drawn with this thickness. |
line_type | Line type. See the line for details. |
bottomLeftOrigin | When true, the image data origin is at the bottom-left corner. Otherwise, it is at the top-left corner. |
§ setSplitNumber()
virtual void cv::freetype::FreeType2::setSplitNumber |
( |
int |
num | ) |
|
|
pure virtual |
Set Split Number from Bezier-curve to line.
The function setSplitNumber set the number of split points from bezier-curve to line. If you want to draw large glyph, large is better. If you want to draw small glyph, small is better.
- Parameters
-
num | number of split points from bezier-curve to line |