Skip to content

SymbolLayout

Namespace: ThinkGeo.Core.Styling

public struct SymbolLayout

Inheritance object → ValueType → SymbolLayout

Properties

TextOptional

text-optional: when the symbol has both, whether the icon may be placed on its own if the text will not fit.

public bool TextOptional { get; }

Property Value

bool

IconOptional

icon-optional: the same permission the other way round - the text may be placed without its icon.

public bool IconOptional { get; }

Property Value

bool

Placement

symbol-placement: whether the symbol sits at a point, repeats along a line, or sits once at a line's middle.

public SymbolPlacement Placement { get; }

Property Value

SymbolPlacement

TextAnchor

text-anchor: which part of the text box is put at the anchor point - Center by default; Bottom puts the text above the point.

public TextAnchor TextAnchor { get; }

Property Value

TextAnchor

TextFont

text-font as one stack name: the family, then the weight and slant words fontnik stacks use - "Noto Sans Bold Italic". How it is honoured depends on where glyphs come from. A style that names a glyph server sends the whole string to it, and the server's stacks decide. Without one the engine keeps the family and reads the trailing words itself (Thin through Black, Italic): a font file from first, then an installed family of that name matched at that weight, then the embedded Noto Sans in its regular, bold, italic and bold-italic faces; characters none of those cover fall through to a per-character system match. Nothing in that chain throws or leaves a gap - a name that resolves to nothing draws in Noto Sans - so is how to learn which step answered. The constructor overload taking a GeoFont writes the name from a classic font, so no caller has to know the spelling.

public string TextFont { get; }

Property Value

string

TextSize

text-size: the font size in screen pixels. Default 16.

public float TextSize { get; }

Property Value

float

TextMaxWidthEm

text-max-width: the width a line wraps at, in ems of SymbolLayout.TextSize; 0 does not wrap. Default 10.

public float TextMaxWidthEm { get; }

Property Value

float

TextLineHeight

text-line-height: the distance between wrapped lines, in ems of SymbolLayout.TextSize. Default 1.2.

public float TextLineHeight { get; }

Property Value

float

TextOffsetXEm

text-offset x: how far the text is moved right of its anchor, in ems of SymbolLayout.TextSize - not pixels: 1 at a 16-pixel size is 16 pixels. Negative moves it left.

public float TextOffsetXEm { get; }

Property Value

float

TextOffsetYEm

text-offset y: how far the text is moved down from its anchor, in ems of SymbolLayout.TextSize. Negative moves it up. For a label that follows a line, it is measured across the line.

public float TextOffsetYEm { get; }

Property Value

float

IconAnchor

icon-anchor: which part of the icon is put at the anchor point - Center by default; Bottom stands a pin on its point.

public TextAnchor IconAnchor { get; }

Property Value

TextAnchor

IconOffsetX

icon-offset x: how far the icon is moved right of its anchor, in screen pixels at an SymbolLayout.IconScale of 1.

public float IconOffsetX { get; }

Property Value

float

IconOffsetY

icon-offset y: how far the icon is moved down from its anchor, in screen pixels at an SymbolLayout.IconScale of 1.

public float IconOffsetY { get; }

Property Value

float

IconScale

icon-size: the factor the icon is drawn at - 1 is the image's own size, 2 twice it. Not pixels. Default 1.

public float IconScale { get; }

Property Value

float

TextAllowOverlap

text-allow-overlap: whether the text is drawn even where it collides with symbols already placed. Default false. SymbolLayout.IconAllowOverlap is the icon's.

public bool TextAllowOverlap { get; }

Property Value

bool

TextPadding

text-padding: the margin around the text's collision box, in screen pixels. Default 2.

public float TextPadding { get; }

Property Value

float

SymbolSpacing

Distance in pixels between repeated symbol placements along a line. MapLibre default: 250.

public float SymbolSpacing { get; }

Property Value

float

TextKeepUpright

Whether text should be flipped to stay upright when placed along a line running right-to-left. MapLibre default: true.

public bool TextKeepUpright { get; }

Property Value

bool

TextMaxAngleDegrees

Maximum cumulative bend angle allowed within a sliding label window for line-placed text. MapLibre: text-max-angle. Default 45 degrees.

public float TextMaxAngleDegrees { get; }

Property Value

float

IconAllowOverlap

Whether this symbol's icon is allowed to overlap other already-placed symbols. MapLibre: icon-allow-overlap. Default false.

public bool IconAllowOverlap { get; }

Property Value

bool

TextVariableAnchors

Ordered list of anchor positions to try when placing text. The engine tries each in order and uses the first one whose text box does not collide. MapLibre: text-variable-anchor. Null or empty = use SymbolLayout.TextAnchor only.

public IReadOnlyList<TextAnchor> TextVariableAnchors { get; }

Property Value

IReadOnlyList<TextAnchor>

IconPadding

Padding around the icon collision box in pixels. MapLibre: icon-padding. Default 2.

public float IconPadding { get; }

Property Value

float

TextRotationAlignment

text-rotation-alignment: whether the text turns with the map (Map) or stays level on screen (Viewport) as the map rotates. A label that follows a line follows it under Map.

public SymbolRotationAlignment TextRotationAlignment { get; }

Property Value

SymbolRotationAlignment

IconRotationAlignment

icon-rotation-alignment: whether the icon turns with the map (Map) or stays level on screen (Viewport) as the map rotates.

public SymbolRotationAlignment IconRotationAlignment { get; }

Property Value

SymbolRotationAlignment

IconRotateDegrees

icon-rotate: the angle the icon is turned by, in degrees, clockwise positive, about its anchor.

public float IconRotateDegrees { get; }

Property Value

float

TextRotateDegrees

text-rotate: the angle a point-placed label is turned by on screen, in degrees, clockwise positive, about its anchor. A label that follows a line is turned by the line and does not read this.

public float TextRotateDegrees { get; }

Property Value

float

TextLetterSpacingEm

Extra spacing between text glyphs in EMs (fraction of text size). MapLibre: text-letter-spacing. Default 0.

public float TextLetterSpacingEm { get; }

Property Value

float

IconTextFit

Which axes of the icon stretch to the text box (icon-text-fit). When not None the icon quad and its collision box derive from the text box instead of the sprite's own dimensions.

public IconTextFit IconTextFit { get; }

Property Value

IconTextFit

IconTextFitPaddingTop

icon-text-fit-padding, CSS order: extra pixels above the fitted box.

public float IconTextFitPaddingTop { get; }

Property Value

float

IconTextFitPaddingRight

icon-text-fit-padding: extra pixels right of the fitted box.

public float IconTextFitPaddingRight { get; }

Property Value

float

IconTextFitPaddingBottom

icon-text-fit-padding: extra pixels below the fitted box.

public float IconTextFitPaddingBottom { get; }

Property Value

float

IconTextFitPaddingLeft

icon-text-fit-padding: extra pixels left of the fitted box.

public float IconTextFitPaddingLeft { get; }

Property Value

float

TextDecoration

The lines drawn under or through the text; TextDecoration.None for plain text. Where each line sits and how thick it is comes from the resolved font's own metrics, as it does in the classic renderer.

public TextDecoration TextDecoration { get; }

Property Value

TextDecoration

Constructors

SymbolLayout(SymbolPlacement, TextAnchor, string, float, float, float, float, float, TextAnchor, float, float, float, bool, float, float, bool, bool, IReadOnlyList<TextAnchor>, float, float, SymbolRotationAlignment, SymbolRotationAlignment, float, float, bool, bool, IconTextFit, float, float, float, float, TextDecoration, float)

SymbolLayout(SymbolPlacement placement, TextAnchor textAnchor, string textFont, float textSize, float textMaxWidthEm, float textLineHeight, float textOffsetXEm, float textOffsetYEm, TextAnchor iconAnchor, float iconOffsetX, float iconOffsetY, float iconScale, bool textAllowOverlap, float textPadding, float symbolSpacing, bool textKeepUpright, bool iconAllowOverlap, IReadOnlyList<TextAnchor> textVariableAnchors, float iconPadding, float textMaxAngleDegrees, SymbolRotationAlignment textRotationAlignment, SymbolRotationAlignment iconRotationAlignment, float iconRotateDegrees, float textLetterSpacingEm, bool textOptional, bool iconOptional, IconTextFit iconTextFit, float iconTextFitPaddingTop, float iconTextFitPaddingRight, float iconTextFitPaddingBottom, float iconTextFitPaddingLeft, TextDecoration textDecoration, float textRotateDegrees)

Parameters

placement SymbolPlacement

textAnchor TextAnchor

textFont string

textSize float

textMaxWidthEm float

textLineHeight float

textOffsetXEm float

textOffsetYEm float

iconAnchor TextAnchor

iconOffsetX float

iconOffsetY float

iconScale float

textAllowOverlap bool

textPadding float

symbolSpacing float

textKeepUpright bool

iconAllowOverlap bool

textVariableAnchors IReadOnlyList<TextAnchor>

iconPadding float

textMaxAngleDegrees float

textRotationAlignment SymbolRotationAlignment

iconRotationAlignment SymbolRotationAlignment

iconRotateDegrees float

textLetterSpacingEm float

textOptional bool

iconOptional bool

iconTextFit IconTextFit

iconTextFitPaddingTop float

iconTextFitPaddingRight float

iconTextFitPaddingBottom float

iconTextFitPaddingLeft float

textDecoration TextDecoration

textRotateDegrees float

SymbolLayout(SymbolPlacement, TextAnchor, GeoFont, float, float, float, float, TextAnchor, float, float, float, bool, float, float, bool, bool, IReadOnlyList<TextAnchor>, float, float, SymbolRotationAlignment, SymbolRotationAlignment, float, float, bool, bool, IconTextFit, float, float, float, float, float)

The same layout, with the font given as the GeoFont a classic TextStyle carries. Its family and its Bold / Italic / Black flags become the stack name SymbolLayout.TextFont holds - "Arial Bold Italic" - GeoFont.Size becomes SymbolLayout.TextSize unchanged, which is the size the classic renderer draws it at too, and Underline and Strikeout become SymbolLayout.TextDecoration.

SymbolLayout(SymbolPlacement placement, TextAnchor textAnchor, GeoFont font, float textMaxWidthEm, float textLineHeight, float textOffsetXEm, float textOffsetYEm, TextAnchor iconAnchor, float iconOffsetX, float iconOffsetY, float iconScale, bool textAllowOverlap, float textPadding, float symbolSpacing, bool textKeepUpright, bool iconAllowOverlap, IReadOnlyList<TextAnchor> textVariableAnchors, float iconPadding, float textMaxAngleDegrees, SymbolRotationAlignment textRotationAlignment, SymbolRotationAlignment iconRotationAlignment, float iconRotateDegrees, float textLetterSpacingEm, bool textOptional, bool iconOptional, IconTextFit iconTextFit, float iconTextFitPaddingTop, float iconTextFitPaddingRight, float iconTextFitPaddingBottom, float iconTextFitPaddingLeft, float textRotateDegrees)

Parameters

placement SymbolPlacement

textAnchor TextAnchor

font GeoFont

textMaxWidthEm float

textLineHeight float

textOffsetXEm float

textOffsetYEm float

iconAnchor TextAnchor

iconOffsetX float

iconOffsetY float

iconScale float

textAllowOverlap bool

textPadding float

symbolSpacing float

textKeepUpright bool

iconAllowOverlap bool

textVariableAnchors IReadOnlyList<TextAnchor>

iconPadding float

textMaxAngleDegrees float

textRotationAlignment SymbolRotationAlignment

iconRotationAlignment SymbolRotationAlignment

iconRotateDegrees float

textLetterSpacingEm float

textOptional bool

iconOptional bool

iconTextFit IconTextFit

iconTextFitPaddingTop float

iconTextFitPaddingRight float

iconTextFitPaddingBottom float

iconTextFitPaddingLeft float

textRotateDegrees float

Methods

FromTextStyle(TextStyle, SymbolPlacement)

The layout of a classic TextStyle, placed as says - SymbolPlacement.Point for points and polygons, SymbolPlacement.Line for lines, or SymbolPlacement.LineCenter for a line labelled once, horizontally. The font is the style's GeoFont, size and all. PositionStyle.TextPlacement says which side of the point the text sits on, so the anchor is the opposite corner of the text box; AutoPlacement tries every anchor in turn, the way the classic best-placement search did. Pixel offsets become ems of the font size, and TextStyle.WrapWidth becomes text-max-width in the same units - zero stays zero, no wrapping. A line label's PositionStyle.OffsetFromLine joins the y offset: text-offset's y is measured across the line for a label that follows it, which is what the classic renderer does with OffsetFromLine, positive on the same side. A horizontal line label takes it straight down the screen, as the classic renderer does for a level line. PositionStyle.OverlappingRule is text-allow-overlap. Point labels stay screen-aligned under rotation, as classic labels are; line labels follow the line. A point label's becomes text-rotate, with its sign turned: the classic renderer turns a label counter-clockwise for a positive angle, and text-rotate turns clockwise. Masks, leader lines and duplicate rules have no layout equivalent and are not carried here (a mask is fitted to the text by the translator).

SymbolLayout FromTextStyle(TextStyle style, SymbolPlacement placement)

Parameters

style TextStyle

placement SymbolPlacement

Returns

SymbolLayout