format

Returns formatted text containing annotations for use in mixed-format text-field entries.

To build the expression, use formatEntry.

"format" expression can be used, for example, with the textField and accepts unlimited numbers of formatted sections.

Each section consist of the input, the displayed text, and options, like font-scale and text-font.

Example usage:


SymbolLayer symbolLayer = new SymbolLayer("layer-id", "source-id");
symbolLayer.setProperties(
  textField(
    format(
      formatEntry(
        get("header_property"),
        formatFontScale(2.0),
        formatTextFont(new String[] {"DIN Offc Pro Regular", "Arial Unicode MS Regular"})
      ),
      formatEntry(concat(literal("\n"), get("description_property")), formatFontScale(1.5))
    )
  )
);

Return

expression

Parameters

formatEntries

format entries

See also

<a href="https://maplibre.org/maplibre-style-spec/expressions/#types-format">Style specification</a>