question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

fontType property on TextBlock

See original GitHub issue
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

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.

image

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 style since we might want to use style for something else
  • Didn’t choose textStyle since can imagine this font style being useful in other places, like Actions, where the text property is called title rather than text, so font is applicable to both.
  • Didn’t choose fontStyle since in HTML/UWP/Android, fontStyle (or textStyle) is used for italic/bold, not font families
  • Didn’t choose fontFamily for reasons specified in a comment below
  • Didn’t choose font since 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

  1. A renderer must use correct inheritance of host config unspecified values
  2. For a given fontType, if the fontTypes.[specifiedStyle].[property] value exists, use its value
  3. Otherwise, if wasn’t default, see if the default has a value for that
  4. Otherwise, see if the deprecated property has a value for that
  5. Otherwise, use initial default value
  6. A renderer should support displaying the correct fontTypes

Auto-generated task status

  • Shared
  • .NET
  • Android
  • iOS
  • TS
  • UWP

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:18 (16 by maintainers)

github_iconTop GitHub Comments

1reaction
dclauxcommented, Dec 17, 2018

I am fine with the isMarkdown property as a solution. I would however call it useMarkdown, 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.

1reaction
dclauxcommented, Sep 14, 2018

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TextBlock.FontFamily Property (System.Windows.Controls)
A FontFamily object specifying the preferred font family, or a primary preferred font family with one or more fallback font families. The default...
Read more >
TextBlock.FontStyle Property (System.Windows.Controls)
Property Value​​ A member of the FontStyles class specifying the desired font style. The default is determined by the MessageFontStyle value.
Read more >
fontType property on TextBlock - microsoft/AdaptiveCards
Add new fontTypes property, which allows defining the font type for each type. Inside each, can set the fontFamily , and also the...
Read more >
Textblock text with multiple font properties
I have a textblock with text like this SOMEBOLDTEXT + SOMEITALICTEXT + SOMEUNDERLINEDTEXT in a single line How can I add this single...
Read more >
How is the attached property TextBlock.FontSize used?
1 Answer. TextBlock. FontSize is not an attached property, it's just a regular dependency property. The MSDN documentation is pretty good at ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found