AdaptiveCards: fontType property on TextBlock
| Release | Renderer status | Tasks status |
|---|---|---|
| 1.2 | ✔️ .NET (#1967) ✔️ Android (#1964) ✔️ iOS (#1965) ✔️ TS (#2430) ✔️ UWP (#1963) |
✔️ Shared (#1962) |
Solves requests
- Monospace blocks of text (#1982)
- OPEN ISSUE: Would we need author ability to disable markdown so that spaces are preserved? Replacing them with
would be a huge amount of bloat
- OPEN ISSUE: Would we need author ability to disable markdown so that spaces are preserved? Replacing them with
Solution
Add an additional fontType property to TextBlocks, with configurable fonts for each possible fontType value in host config. Monospace blocks of text can be achieved by using a container with emphasis style.

Schema
New property on TextBlock
| Property | Type | Required | Description |
|---|---|---|---|
| fontType | FontType | false | Changes the font style |
FontType
| Value | Description |
|---|---|
| default | The default font type |
| monospace | The monospace font type |
Markup:
{
"type": "TextBlock",
"size": "large",
"weight": "bolder",
"text": "14,411 ft",
"fontType": "monospace"
}
Why “fontType”?
- Didn’t choose just
stylesince we might want to usestylefor something else - Didn’t choose
textStylesince can imagine this font style being useful in other places, like Actions, where the text property is calledtitlerather thantext, sofontis applicable to both. - Didn’t choose
fontStylesince in HTML/UWP/Android, fontStyle (or textStyle) is used for italic/bold, not font families - Didn’t choose
fontFamilyfor reasons specified in a comment below - Didn’t choose
fontsince font is supposed to be a collection of fontFamily + size + weights
Host Config
Add new fontTypes property, which allows defining the font type for each type. Inside each, can set the fontFamily, and also the font sizes, since different fonts may appear larger or smaller. Can set font weights for same reason.
If some properties on a style aren’t specified, inherits the properties from the default style.
Deprecate existing fontFamily, fontSizes, and fontWeights properties in exchange for the new fontTypes.
If a host didn’t provide the default style but provided the old deprecated properties, those old deprecated properties should be utilized as the default style (and those should be inherited to other styles that also aren’t specified).
{
"fontTypes": {
"default": {
"fontFamily": "Arial, sans-serif",
"fontSizes": {
"small": 12,
"default": 14,
"medium": 17,
"large": 21,
"extraLarge": 26
},
"fontWeights": {
"lighter": 200,
"default": 400,
"bolder": 600
}
},
"monospace": {
"fontFamily": "Consolas, serif",
"fontSizes": {
"small": 12,
"default": 14,
"medium": 17,
"large": 21,
"extraLarge": 26
},
"fontWeights": {
"lighter": 200,
"default": 400,
"bolder": 600
}
}
}
}
Down-level impact
Low. Text appears and displays pretty well. It simply doesn’t have the correct font family.
Host burden
Medium. Changes in structure of host config.
Renderer Requirements
- A renderer must use correct inheritance of host config unspecified values
- For a given fontType, if the
fontTypes.[specifiedStyle].[property]value exists, use its value - Otherwise, if wasn’t
default, see if thedefaulthas a value for that - Otherwise, see if the deprecated property has a value for that
- Otherwise, use initial default value
- A renderer should support displaying the correct fontTypes
Auto-generated task status
- Shared
- .NET
- Android
- iOS
- TS
- UWP
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 18 (16 by maintainers)
Commits related to this issue
- [Schema] Add fontType to TextBlock Spec #1078 — committed to microsoft/AdaptiveCards by paulcam206 5 years ago
- Schema/site/tooling updates for 1.2 (#3043) * Create Image.md * Update Image.md * Update Image.md * More specs * Media element * Trying to get auto generate working * Closer! * [... — committed to microsoft/AdaptiveCards by andrewleader 5 years ago
I am fine with the
isMarkdownproperty as a solution. I would however call ituseMarkdown, and I would also consider adding it to all containers (including the card itself) to make it easy to disable markdown for all or part of the card in one shot.@matthidinger looking to hearing from you about the need for a “display” font. Adding this just for Bing and for that particular scenario doesn’t feel right to me.
Looks good for me overall. Only thing is I’m no fan of the term “display” - whether you use the default, display or monospace font styles, they are all for “display”. I suggest we go for something like “alternate” or similar.