Skip to content

Attr.Txt

Text-specific attributes

DaxLib.SVG.Attr.Txt( fontFamily, fontSize, fontWeight, fontStyle, textAnchor, baseline, textDecoration, letterSpacing, wordSpacing )
Parameter Type Required Description
fontFamily STRING Font family for text. Omitted if not specified
fontSize INT64 Font size for text. Omitted if not specified
fontWeight STRING Weight ("normal", "bold", "lighter", "100-900"). Omitted if not specified
fontStyle STRING Style ("normal", "italic", "oblique"). Omitted if not specified
textAnchor STRING Anchor ("start", "middle", "end"). Omitted if not specified
baseline STRING Dominant baseline. Omitted if not specified
textDecoration STRING Decoration ("none", "underline", "overline", "line-through"). Omitted if not specified
letterSpacing STRING Space between letters. Omitted if not specified
wordSpacing STRING Space between words. Omitted if not specified

STRING An attribute string that can be used directly in SVG text elements

DaxLib.SVG.Attr.Txt("Arial, sans-serif", 14, "bold", "normal", "middle", "middle", "none", "", "")
// Returns "font-family='Arial, sans-serif' font-size='14' font-weight='bold' font-style='normal' text-anchor='middle' dominant-baseline='middle' text-decoration='none'"
function 'DaxLib.SVG.Attr.Txt' =
        (
            fontFamily: STRING,
            fontSize: INT64,
            fontWeight: STRING,
            fontStyle: STRING,
            textAnchor: STRING,
            baseline: STRING,
            textDecoration: STRING,
            letterSpacing: STRING,
            wordSpacing: STRING
        ) =>

            IF( NOT ISBLANK( fontFamily ),     "font-family='" & fontFamily & "' ") &
            IF( NOT ISBLANK( fontSize ),       "font-size='" & fontSize & "' ") &
            IF( NOT ISBLANK( fontWeight ),     "font-weight='" & fontWeight & "' ") &
            IF( NOT ISBLANK( fontStyle ),      "font-style='" & fontStyle & "' ") &
            IF( NOT ISBLANK( textAnchor ),     "text-anchor='" & textAnchor & "' ") &
            IF( NOT ISBLANK( baseline ),       "dominant-baseline='" & baseline & "' ") &
            IF( NOT ISBLANK( textDecoration ), "text-decoration='" & textDecoration & "' ") &
            IF( NOT ISBLANK( letterSpacing ),  "letter-spacing='" & letterSpacing & "' ") &
            IF( NOT ISBLANK( wordSpacing ),    "word-spacing='" & wordSpacing & "' ")