Dimensions are specified using numbers followed by optional units. A number without a unit refers to pixels. Sometimes units are not allowed, as for example in opacity levels, which are dimensionless. Where units are allowed, you can use any of the following:
- pt: printer's points of exactly 1/72in (sometimes called PostScript points).
- pc: printer's picas of 12pt.
- cm: centimeters.
- mm: millimeters.
- in: inches.
- m: map meters; that is, meters at the scale of the map, converted to pixels using the current map projection.
- %: a percentage of some value depending on context; for example, in the context of a road, percentages refer to the width of the road, allowing you to specify that a road name is 75% of the width of the road.
Limits
The dimension may optionally be followed by two more dimensions, separated by commas, giving the minimum and maximum values. For example, to set a font size to the equivalent of 500 map metres, but not less than 9pt or more than 64pt, use the dimension 500m,9pt,64pt. Limits must not be negative. A minus sign can occur only before the main dimension; if so, the dimension, with its limits, is evaluated as if it was positive, then negated.
Percentages
Percentages are allowed in the following dimension attributes:
- opacity, as a percentage of full opacity
- width in <highlight> elements, as a percentage of the width of the main line
- borderWidth, centerLineWidth, truncationAtStart and truncationAtEnd in <line> and <highlight> elements (but not in <shape> elements), as a percentage of the line width
- triangleSize and baselineOffset in <label> and <extraLabel> elements, as a percentage of the font size
- letter-spacing, word-spacing, glowWidth, glowOffsetX, glowOffsetY, wrapWidth and leading in <label> and <extraLabel> elements, as a percentage of the font size
- width and height in <repeatedSymbol>, <oneWayArrow>, <startSymbol> or <endSymbol> elements, as a percentage of the line width
- borderWidth, shadowWidth, shadowOffsetX, shadowOffsetY, lineBorderWidth and endWidth in <bridge> elements, as a percentage of the line width
- mouthWidth in <tunnel> elements, as a percentage of the line width
Logarithmic units
There are also some special units allowing you to scale features logarithmically so that their sizes are exaggerated at small scales. They are useful for making major roads stand out. While ordinary map-based dimensions (dimensions using the 'm' unit) scale smoothly as you zoom in or out, sometimes you need to use different proportions at different scales, and interpolate between them.
The format is
<size1>@<scale1>_<size2>@<scale2>
For example, '10m@5000_25m@25000' gives a size of 10 map metres at a scale of 1:5000, 25 map metres at a scale of 1:25000, and scales between them logarithmically. Outside the range, the end points of the range are used. Thus, for this example, 10 map metres is used for scales larger than 1:5000 and 25 map metres is used for scales smaller than 1:25,000.
Height gradient stop positions
The special unit ft-height converts height in feet, as used in some terrain-height array objects, to a value between 0 and 1 to be used as a height gradient ramp stop position.