Page 1 of 1

[C++] Custom FontProvider

Posted: 26 Apr 2017, 10:24
by realesmedia
Described custom FontProvider derived from Noesis::CachedFontProvider with overriden functions:
public:
	void ScanFolder(const NsChar* folder) override;
	Noesis::Ptr<Noesis::Core::Stream> OpenFont(const NsChar* folder, const NsChar* id) const  override;
Using root path "C:\#Arial" shows correct font in application, but "C:\fonts\#Arial" not load font. Both path have arial.ttf file.

Re: [C++] Custom FontProvider

Posted: 26 Apr 2017, 15:51
by realesmedia
First problem has solved.

Have a new one.
Change provider.
resourceProvider.fontProvider = new ui::MyFontProvider("c:/xaml");
XAML:
<TextBlock text="path Themes\Fonts\#Arial" FontFamily="Themes\Fonts\#Arial"/>
<TextBlock text="path c:\xaml\Themes\Fonts\#Arial" FontFamily="c:\xaml\Themes\Fonts\#Arial"/>
First text block have incorrect font.
All are good with second block.
Debug shows RegisterFont() got same params.

Re: [C++] Custom FontProvider

Posted: 26 Apr 2017, 16:32
by realesmedia
1. XAML have absolute font path. RegisterFont() get absolute font path. Works good.
2. XAML have relative font path. RegisterFont() get absolute font path. Doesn't work.
So, my opinion that MatchFont from parent class somehow saves info about baseUri and try to register with relative path instead of using my absolute path from RegisterFont() param.
Can you provide me sample implementation of MatchFont()? I can't call parent function because it's private.

Re: [C++] Custom FontProvider

Posted: 28 Apr 2017, 22:29
by jsantos
Could you please paste here the full implementation of your font provider?