How to change the list of fonts in the C1Toolbar

Posted by: khawari on 7 August 2017, 6:21 am EST

  • Posted 7 August 2017, 6:21 am EST

    anyone know how to change the list of available fonts in the C1Toolbar?

  • Posted 7 August 2017, 6:21 am EST

    That list is hardcoded in the current implementation. You would have to modify the toolbar source, you can download it from here.

    We will try to provide a better solution in a future release.

  • Posted 7 August 2017, 6:21 am EST

    That exception is happening because you probably have the xml namespace "C1_Silverlight_RichTextBox" defined in App.xaml pointing to the C1.Silverlight.RichTextBox.Toolbar assembly, you should change it to RichTextBox.Toolbar.

    We had to change the name of the assembly because otherwise we couldn't release the source and have it compatible with the current release of C1.Silverlight. The source included in the next proper release will generate a C1.Silverlight.RichTextBox.Toolbar assembly again. Sorry for the inconvenience.

  • Posted 7 August 2017, 6:21 am EST

    Thanks for all your help.

    So the C1RichTextBox unlike the normal TextBox doesn't have the FontSource property which allows one to use custom fonts downloaded on demand. Can you recommend any other alternatives?

    Thanks

    reference: (from: http://msdn.microsoft.com/en-us/library/cc189021(VS.95).aspx)

    FontSource

    You can also retrieve fonts from downloaded packages, which are added to the font source collection for text display elements, such as TextBox and TextBlock. The mechanism for getting fonts for a font source is slightly different. You request the package that contains the fonts as a stream (by using OpenReadAsync(Uri)). After handling OpenReadCompleted, retain a reference to the stream. Use the stream as the constructor parameter for FontSource (FontSource constructor). All font sources in the package are available and are added to the font collection in the FontSource. You do not have to specify a part by name. Constructing a FontSource turns the parts into collection items, with the font name / part name becoming the key for the font source of an individual font in the collection. Then you set FontSource properties, such as FontSource, with the FontSource object. You specify specific font names when you set the FontFamily properties on various types and the corresponding font is obtained from the font source collection.

  • Posted 7 August 2017, 6:21 am EST

    Thanks you for the source.

    i downloaded it. added it the solution. compiled the toolbar proj (successfully). removed the (*toolbar*.dll) reference from the app project and add the (toolbar proj) reference with in the main app project. compiled the solution (successfully). however when i run it i get the following runtime exception:

    System.Windows.Markup.XamlParseException occurred

    Message="Invalid attribute value C1_Silverlight_RichTextBox:C1SimpleColorPicker for property TargetType. [Line: 1465 Position: 49]"

    LineNumber=1465

    LinePosition=49

    StackTrace:

    at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)

    InnerException:

    When i switch back to the (*toolbar* dll) reference it don't throw runtime exception. One thing to note:

    the projects generates a dll with following name: RichTextBox.Toolbar.dll

    where as the original dll was named C1.Silverlight.RichTextBox.Toolbar.dll

    The autogenerate file: app.g.cs that throws the exception:

    namespace WebConsole2.Silverlight {

    public partial class App : System.Windows.Application {

    private bool _contentLoaded;

    ///

    /// InitializeComponent

    ///

    [System.Diagnostics.DebuggerNonUserCodeAttribute()]

    public void InitializeComponent() {

    if (_contentLoaded) {return;

    }

    _contentLoaded = true;

    System.Windows.Application.LoadComponent(this, new System.Uri("/WebConsole2.Silverlight;component/App.xaml", System.UriKind.Relative));

    }

    }

    }

  • Posted 7 August 2017, 6:21 am EST

    RichTextBox doesn't currently support custom fonts, we will add it in a future release.

  • Posted 7 August 2017, 6:21 am EST

    Can you please tell me when can i expect that release. Also if we purchase your controls do they come with the source so if i wanted to add that functionality i can do so myself.

  • Posted 7 August 2017, 6:21 am EST

    Hopefully before the end of the year, unless we run into implementation difficulties.

    As for the source code, we do make that available separately from the studio (there's an extra charge for it, and I don't know how much it is; if you're interested, please write to sales@componentone.com).

    Thanks!

    PS: Thanks for bringing this to our attention.

  • Posted 7 August 2017, 6:21 am EST

    Have you guys ever gotten around to implementing FontSource in RichTextBox. I would also like to be able to use this functionality, and have not found any references to FontSource, or any other way to dynamically load a font and use it in the RichTextBox, even though this post is pretty old.

    Thanks.

  • Posted 7 August 2017, 6:21 am EST

    We haven't added FontSource support. We do support embedded fonts loaded with a FontFamily object. I think it is possible to dynamically load a font using that. You can pack the fonts in assemblies, then download them in your running application and load them. Our ControlExplorer sample does this, check out the C1AssemblyLoader class in the sample if you want to try this.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels