Table of Contents

Method GetTextSize

Namespace
OpenCvSharp
Assembly
OpenCvSharp.dll

GetTextSize(string, HersheyFonts, double, int, out int)

returns bounding box of the text string

public static Size GetTextSize(string text, HersheyFonts fontFace, double fontScale, int thickness, out int baseLine)

Parameters

text string

Input text string.

fontFace HersheyFonts

Font to use, see #HersheyFonts.

fontScale double

Font scale factor that is multiplied by the font-specific base size.

thickness int

Thickness of lines used to render the text. See #putText for details.

baseLine int

baseLine y-coordinate of the baseline relative to the bottom-most text

Returns

Size

The size of a box that contains the specified text.

GetTextSize(Size, string, Point, FontFace, int, int, PutTextFlags, Range?)

Calculates the bounding rect for the text rendered with the specified TrueType font (OpenCV 5).

public static Rect GetTextSize(Size imgsize, string text, Point org, FontFace fontFace, int size, int weight = 0, PutTextFlags flags = PutTextFlags.AlignLeft, Range? wrap = null)

Parameters

imgsize Size

Size of the target image; can be empty.

text string

Text string to be measured (UTF-8 / Unicode is supported).

org Point

Bottom-left corner of the first character (see PutTextFlags).

fontFace FontFace

The font to use for the text.

size int

Font size in pixels (by default) or pts.

weight int

Font weight, 100..1000. 0 uses the default/instance weight.

flags PutTextFlags

Various flags, see PutTextFlags.

wrap Range?

Optional text wrapping range. Null uses the default behavior.

Returns

Rect

The bounding rectangle of the text.