CartoType API
Classes | Functions
CartoType::Svg Namespace Reference

Classes

class  MUnitConverter
class  TDimensionParam

Functions

CT_IMPORT TPaint Paint (const MString &aValue, CPointerArray< CPaintServer > *aPaintServer=NULL, CGState *aGState=NULL)
CT_IMPORT TResult Dimension (const TDimensionParam &aParam, TFixed &aDimension, const MString &aString)
CT_IMPORT TResult Opacity (int32 &aOpacity, const MString &aValue)
CT_IMPORT TResult AppendPathToOutline (COutline &aOutline, const MString &aPath, double aScale=64.0)
CT_IMPORT TResult Font (TFontSpec &aFontSpec, const Sax::MAttributes &aAttributes, const TDimensionParam &aParam)
CT_IMPORT TResult Font (TFontSpec &aFontSpec, const MString &aStyle, const TDimensionParam &aParam)
CT_IMPORT TResult AppendNumberListToArray (CArray< TFixed > &aArray, const MString &aNumberList)
CT_IMPORT CArray< TFixed > * NumberArray (TResult &aError, const MString &aString)

Detailed Description

The Svg namespace is a wrapper for functions to support Svg interpretation. Some of these functions are used in the Svg-like parts of the CartoType style sheet syntax.


Function Documentation

CT_EXPORT TResult CartoType::Svg::AppendPathToOutline ( COutline aOutline,
const MString aPath,
double  aScale = 64.0 
)

Append a path expressed in string form as an SVG path element to aOutline. Scale the coordinates by aScale. The default scale converts the coordinates to rounded 64ths: for example, 1.51 becomes 96.

CT_EXPORT TResult CartoType::Svg::Dimension ( const TDimensionParam &  aParam,
TFixed aDimension,
const MString aString 
)

Return a dimension read from aString, which must be a number of the form <integer part>=""> { '.' <fractional part>=""> } { <unit> | <percent sign>=""> }, optionally followed by one or two further numbers of the same form, separated by commas, representing minimum and maximum values.

The return value is in pixels and is clamped to the range aParam.iLow...aParam.iHigh inclusive; these values represent pixels.

If aParam.iAllowUnits is true the units 'pt', 'pc', 'cm', 'mm', 'in' are allowed, with the addition of any other unit supported by aParam.iUnitConverter; for example map style sheets add the unit 'm', which represents meters at the scale of the map. Dimensions are converted to pixels using the current pixel size.

If aParam.iAllowLimits is true 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.

If aParam.iAllowPercent is non-null, percentages are allowed and 100 represents the value aParam.iHundredPercent.

CT_EXPORT TResult CartoType::Svg::Font ( TFontSpec aFontSpec,
const Sax::MAttributes aAttributes,
const TDimensionParam &  aParam 
)

Set a font specification according to any relevant attributes in aAttributes.

CT_EXPORT TResult CartoType::Svg::Font ( TFontSpec aFontSpec,
const MString aStyle,
const TDimensionParam &  aParam 
)

Set a font specification according to a CSS font style specification in aStyle.

CT_EXPORT CArray< TFixed > * CartoType::Svg::NumberArray ( TResult aError,
const MString aString 
)

Create a number array from aString. If there are no numbers or an error occurs return NULL.

CT_EXPORT TResult CartoType::Svg::Opacity ( int32 &  aOpacity,
const MString aValue 
)

Convert a number from 0 to 1 in a string to an opacity level from 0 to 255.

CT_EXPORT TPaint CartoType::Svg::Paint ( const MString aValue,
CPointerArray< CPaintServer > *  aPaintServer = NULL,
CGState aGState = NULL 
)

Convert a color from a value in the form #RGB, #RRGGBB or #RRGGBBAA (in hex) or a color name, or a url in the form url(<url>), which is looked up in the array of named paint servers if one is provided.

If a named paint server is not found in aPaintServer, it is sought for among the sets of gradient parameters in aGState, if non-null, and a gradient object is created and appended to aGState.