Function ScaledFont.textToTextGlyph

Converts UTF-8 text to an array of glyphs, optionally with cluster mapping, that can be used to render later using ScaledFont.

If glyphBuffer initially points to a non-empty array, that array is used as a glyph buffer. If the provided glyph array is too short for the conversion, a new glyph array is allocated and returned.

If clusterBuffer is not empty a cluster mapping will be computed. The semantics of how cluster array allocation works is similar to the glyph array. That is, if clusterBuffer initially points to a non-empty array, that array is used as a cluster buffer. If the provided cluster array is too short for the conversion, a new cluster array is allocated and returned.

In the simplest case, glyphs and clusters can be omitted or set to an empty array and a suitable array will be allocated. In code

auto glyphs = scaled_font.textToTextGlyph(x, y, text);
cr.showTextGlyphs(glyphs);

If no cluster mapping is needed

auto glyphs = scaled_font.textToGlyphs(x, y, text);
cr.showGlyphs(glyphs);

If stack-based glyph and cluster arrays are to be used for small arrays

Glyph[40] stack_glyphs;
TextCluster[40] stack_clusters;
auto glyphs = scaled_font.textToTextGlyph(x, y, text, stack_glyphs, stack_clusters);
cr.showTextGlyphs(glyphs);

The output values can be readily passed to Context.showTextGlyphs() Context.showGlyphs(), or related functions, assuming that the exact same ScaledFont is used for the operation.

Prototypes

TextGlyph textToTextGlyph(
  double x,
  double y,
  string text,
  cairo_glyph_t[] glyphBuffer = [],
  cairo_text_cluster_t[] clusterBuffer = []
);

TextGlyph textToTextGlyph(
  Point!(double) p1,
  string text,
  cairo_glyph_t[] glyphBuffer = [],
  cairo_text_cluster_t[] clusterBuffer = []
);

Parameters

NameDescription
x X position to place first glyph
y Y position to place first glyph

Authors

Johannes Pfau cairoD
Andrej Mitrovic cairoD
cairo team cairo

Copyright

License

cairoD wrapper/bindings Boost License 1.0
cairo LGPL 2.1 / MPL 1.1