How to set DefaultFont to custom font in OxyPlot?
Asked Answered
L

0

7

I am using OxyPlot in a WPF application to plot a simple LineSeries. I also defined Roboto as the standard font of my application. However my PlotView does not use this font but uses its default font Segoe UI.

The PlotModel offers a DefaultFont property to change this font. This property does not accept a FontFamily but only a string. So if I try to modify the font by entering a FontFamily name which is installed on my system it works:

var model = new PlotModel
{
     DefaultFont = "Verdana"
};

If I try to do the same with Roboto it does not:

var model = new PlotModel
{
     DefaultFont = "./Resources/Roboto/#Roboto"
};

or

var model = new PlotModel
{
     DefaultFont = "/MyNamespace;component/Resources/Roboto/#Roboto"
};

What am I missing here? Is there maybe another way to accomplish this?

Note: This is my first question, please tell me what I can improve in the future.

Looper answered 29/7, 2015 at 15:13 Comment(2)
I am fairly new to the whole OxyPlot thema, but maybe you can define the Font into the Window/UserControl.Resources? Maybe then will PlotModel find the Font?Cavorelievo
@Jonas did you manage to get this work?Dessau

© 2022 - 2025 — McMap. All rights reserved.