OpenCV for Unity 3.0.5
Enox Software / Please refer to OpenCV official document ( http://docs.opencv.org/5.0/index.html ) for the details of the argument of the method.
Loading...
Searching...
No Matches
OpenCVForUnity.ImgprocModule.FontFace Class Reference

Wrapper on top of a truetype/opentype/etc font, i.e. Freetype's FT_Face. More...

Public Member Functions

 FontFace ()
 loads default font
 
 FontFace (string fontPathOrName)
 loads font at the specified path or with specified name.
 
bool getInstance (MatOfInt _params)
 
string getName ()
 
IntPtr getNativeObjAddr ()
 
bool set (string fontPathOrName)
 loads new font face
 
bool setInstance (MatOfInt _params)
 sets the current variable font instance.
 
- Public Member Functions inherited from OpenCVForUnity.DisposableObject
void Dispose ()
 Releases resources used by this object.
 
void ThrowIfDisposed ()
 Throws ObjectDisposedException if this object has been disposed.
 

Static Public Member Functions

static FontFace __fromPtr__ (IntPtr addr)
 
static bool setBuiltinFont (string fontName, string fontPath)
 Provides or replaces one of the built-in font slots with an external font file.
 
- Static Public Member Functions inherited from OpenCVForUnity.DisposableObject
static IntPtr ThrowIfNullIntPtr (IntPtr ptr)
 Returns the native pointer, or throws CoreModule.CvException if it is zero.
 

Protected Member Functions

override void Dispose (bool disposing)
 
- Protected Member Functions inherited from OpenCVForUnity.DisposableOpenCVObject
 DisposableOpenCVObject ()
 Initializes a new instance with a zero native pointer and dispose enabled.
 
 DisposableOpenCVObject (bool isEnabledDispose)
 Initializes a new instance with a zero native pointer.
 
 DisposableOpenCVObject (IntPtr ptr)
 Initializes a new instance with the specified native pointer and dispose enabled.
 
 DisposableOpenCVObject (IntPtr ptr, bool isEnabledDispose)
 Initializes a new instance with the specified native pointer.
 
- Protected Member Functions inherited from OpenCVForUnity.DisposableObject
 DisposableObject ()
 Initializes a new instance with dispose enabled.
 
 DisposableObject (bool isEnabledDispose)
 Initializes a new instance.
 

Additional Inherited Members

- Package Attributes inherited from OpenCVForUnity.DisposableOpenCVObject
- Properties inherited from OpenCVForUnity.DisposableObject
bool IsDisposed [get, protected set]
 
bool IsEnabledDispose [get, set]
 

Detailed Description

Wrapper on top of a truetype/opentype/etc font, i.e. Freetype's FT_Face.

The class is used to store the loaded fonts; the font can then be passed to the functions putText and getTextSize.

Constructor & Destructor Documentation

◆ FontFace() [1/2]

OpenCVForUnity.ImgprocModule.FontFace.FontFace ( )

loads default font

◆ FontFace() [2/2]

OpenCVForUnity.ImgprocModule.FontFace.FontFace ( string fontPathOrName)

loads font at the specified path or with specified name.

Parameters
fontPathOrNameeither path to a custom font file (.ttf/.otf, optionally gzip-compressed) or the name of one of the built-in font slots:
  • "sans": the default font (Rubik, always compiled in);
  • "italic": Rubik Italic, compiled in only if OpenCV was built with WITH_ITALICFONT=ON; otherwise it can be provided with setBuiltinFont(), and if it is not available, "italic" silently resolves to "sans";
  • "uni": WenQuanYi Micro Hei (CJK), compiled in only with WITH_UNIFONT=ON; otherwise provide it with setBuiltinFont(), or loading fails. The built-in slots also serve as the fallback chain: characters missing from the user's font are taken from "sans", then "italic", then "uni". Empty fontPathOrName means the default embedded font ("sans").

Member Function Documentation

◆ __fromPtr__()

static FontFace OpenCVForUnity.ImgprocModule.FontFace.__fromPtr__ ( IntPtr addr)
static

◆ Dispose()

override void OpenCVForUnity.ImgprocModule.FontFace.Dispose ( bool disposing)
protectedvirtual

◆ getInstance()

bool OpenCVForUnity.ImgprocModule.FontFace.getInstance ( MatOfInt _params)

◆ getName()

string OpenCVForUnity.ImgprocModule.FontFace.getName ( )

◆ getNativeObjAddr()

IntPtr OpenCVForUnity.ImgprocModule.FontFace.getNativeObjAddr ( )

◆ set()

bool OpenCVForUnity.ImgprocModule.FontFace.set ( string fontPathOrName)

loads new font face

◆ setBuiltinFont()

static bool OpenCVForUnity.ImgprocModule.FontFace.setBuiltinFont ( string fontName,
string fontPath )
static

Provides or replaces one of the built-in font slots with an external font file.

Parameters
fontNamethe slot: "sans", "italic" or "uni".
fontPathpath to a .ttf/.otf font (optionally gzip-compressed, e.g. .ttf.gz). An empty path restores the compiled-in font of that slot (if any), otherwise the slot becomes empty.
Returns
false if the slot name is unknown or the font file cannot be loaded (the registry is left unchanged).

This is the way to get CJK text or a true italic when OpenCV is built without WITH_UNIFONT / WITH_ITALICFONT (the defaults), e.g. cv::FontFace::setBuiltinFont("uni", "/usr/share/fonts/NotoSansCJK-Regular.ttc"). The registered font participates in the automatic fallback chain like the compiled-in one would. The change is global (all threads) and applies to FontFace objects created afterwards; existing FontFace objects keep the font they were created with.

◆ setInstance()

bool OpenCVForUnity.ImgprocModule.FontFace.setInstance ( MatOfInt _params)

sets the current variable font instance.

Parameters
paramsThe list of pairs key1, value1, key2, value2, ..., e.g. ‘myfont.setInstance({CV_FOURCC('w’,'g','h','t'), 400<<16, CV_FOURCC('s','l','n','t'), -(15<<16)});` Note that the parameter values are specified in 16.16 fixed-point format, that is, integer values need to be shifted by 16 (or multiplied by 65536).

The documentation for this class was generated from the following file: