'ImageMagic - C++: When trying to change font, I'm getting error

I'm trying to write text into image by this code:

Image image( "1920x1080", "black" );
image.font("-*-helvetica-medium-r-normal-*-*-120-*-*-*-*-iso8859-1");
image.draw(DrawableText(1700, 940, "10256"));

But getting error:

Magick: unable to open X server `(null)': Cannot assign requested address @ error/xwindow.c/XRenderImage/8916.
Magick: unable to open X server `(null)': Cannot assign requested address @ error/xwindow.c/XRenderImage/8916.
terminate called after throwing an instance of 'Magick::ErrorDraw'
  what():  Magick: non-conforming drawing primitive definition `text' @ error/draw.c/DrawImage/3265
Aborted

When the line with font change is ommited, the program runs as it should and generates image.

What kind of problem is that or how to solve it?

Running on: linux
Compiler: CMAKE
ImageMagic version: ImageMagick 6.9.7-4 Q16 x86_64 20170114


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source