View Source Evision.FontFace (Evision v1.1.1)

Summary

Types

t()

Type that represents an FontFace struct.

Functions

loads default font

loads font at the specified path or with specified name.

loads new font face

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

sets the current variable font instance.

Types

@type t() :: %Evision.FontFace{ref: reference()}

Type that represents an FontFace struct.

  • ref. reference()

    The underlying erlang resource variable.

Functions

@spec fontFace() :: t() | {:error, String.t()}

loads default font

Return
  • self: Evision.FontFace.t()

Python prototype (for reference only):

FontFace() -> <FontFace object>
@spec fontFace(Keyword.t()) :: any() | {:error, String.t()}
@spec fontFace(binary()) :: t() | {:error, String.t()}

loads font at the specified path or with specified name.

Positional Arguments
  • fontPathOrName: String.either 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").
Return
  • self: Evision.FontFace.t()

Python prototype (for reference only):

FontFace(fontPathOrName) -> <FontFace object>
@spec getInstance(Keyword.t()) :: any() | {:error, String.t()}
@spec getInstance(t()) :: [integer()] | false | {:error, String.t()}

getInstance

Positional Arguments
  • self: Evision.FontFace.t()
Return
  • retval: bool
  • params: [integer()]

Python prototype (for reference only):

getInstance() -> retval, params
@spec getName(Keyword.t()) :: any() | {:error, String.t()}
@spec getName(t()) :: binary() | {:error, String.t()}

getName

Positional Arguments
  • self: Evision.FontFace.t()
Return

Python prototype (for reference only):

getName() -> retval
@spec set(Keyword.t()) :: any() | {:error, String.t()}
Link to this function

set(self, fontPathOrName)

View Source
@spec set(t(), binary()) :: boolean() | {:error, String.t()}

loads new font face

Positional Arguments
  • self: Evision.FontFace.t()
  • fontPathOrName: String
Return
  • retval: bool

Python prototype (for reference only):

set(fontPathOrName) -> retval
Link to this function

setBuiltinFont(named_args)

View Source
@spec setBuiltinFont(Keyword.t()) :: any() | {:error, String.t()}
Link to this function

setBuiltinFont(fontName, fontPath)

View Source
@spec setBuiltinFont(binary(), binary()) :: boolean() | {:error, String.t()}

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

Positional Arguments
  • fontName: String.

    the slot: "sans", "italic" or "uni".

  • fontPath: String.

    path 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.

Return
  • retval: bool

@return 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.

Python prototype (for reference only):

setBuiltinFont(fontName, fontPath) -> retval
@spec setInstance(Keyword.t()) :: any() | {:error, String.t()}
Link to this function

setInstance(self, params)

View Source
@spec setInstance(t(), [integer()]) :: boolean() | {:error, String.t()}

sets the current variable font instance.

Positional Arguments
  • self: Evision.FontFace.t()

  • params: [integer()].

    The 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).

Return
  • retval: bool

Python prototype (for reference only):

setInstance(params) -> retval