Skip to content
Roman Shapiro edited this page Sep 3, 2022 · 7 revisions

All widgets except TextBox do support FontStashSharp rich text syntax. I.e. if we following MML:

<Project>
  <Panel>
    <Label Text="/c[red]First /cd/tuline/n/c[blue]/tdSecond /cd/tsLine" HorizontalAlignment="Center" VerticalAlignment="Center" />
  </Panel>
</Project>

It would be rendered:

image

Or if we take MML:

<Project>
  <Panel>    
   <TextButton Text="E=mc/v[-8]2/n/vdMass–energy equivalence." HorizontalAlignment="Center" VerticalAlignment="Center"/>
  </Panel>
</Project>

It would result in:

image

If we want to use commands that require external resources('/f' and '/f'), then we would need to set RichTextDefaults.FontResolver and RichTextDefaults.ImageResolver.

However there are special rules for the rtf resource resolving when using MyraPad. It requires resources to be either available in the same folder as the edited xmmp file. Or the resource folder path must be specified in the attribute DesignerRtfAssetsPath of the root tag Project. The resource folder path could be either absolute or relative to the location of the edited xmmp. I.e. if we load following MML in the MyraPad:

<Project DesignerRtfAssetsPath="../../../tiles/releases/Nov-2015/dngn/trees">
  <Project.ExportOptions />
  <Panel>
    <TabControl HorizontalAlignment="Center" VerticalAlignment="Center" Height="260" GridRow="1">
      <TabItem Text="/i[mangrove1.png] /v[8]First Tab" />
      <TabItem Text="/i[mangrove2.png] /v[8]/tsSecond Tab" />
      <TabItem Text="/i[mangrove3.png] /v[8]/tuThird Tab" />
    </TabControl>
  </Panel>
</Project>

It would render following(assuming we have corresponding images mangrove*.png in the corresponding folder): image

The '/f' command parameter must be passed in form 'fontFileName, size'. I.e. if we load following MML:

<Project DesignerRtfAssetsPath="C:\Windows\Fonts">
  <Project.ExportOptions />
  <Panel>
    <Label Text="Text in default font./n/f[arialbd.ttf, 24]Bold and smaller font. /f[ariali.ttf, 48]Italic and larger font./n/fdBack to the default font." HorizontalAlignment="Center" VerticalAlignment="Center" />
  </Panel>
</Project>

It would render following: image

Note. Above resources resolving works only in MyraPad.

Clone this wiki locally