The OpenD Programming Language

ScaledFont.textToGlyphs

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.

  1. Glyph[] textToGlyphs(double x, double y, string text, Glyph[] glyphBuffer)
  2. Glyph[] textToGlyphs(Point!double p1, string text, Glyph[] glyphBuffer)
    class ScaledFont
    Glyph[]
    textToGlyphs
    (
    Point!double p1
    ,
    string text
    ,
    Glyph[] glyphBuffer = []
    )

Meta