The only way to achieve that is by implementing a
custom provider. You have to set them at the same time, but default implementations are available in
LocalXamlProvider,
LocalTextureProvider and
LocalFontProvider implementation classes respectively.
We plan to include all the sources in the new application framework we are working on. For now, here you can find the default implementation for the font provider:
////////////////////////////////////////////////////////////////////////////////////////////////////
// Noesis Engine - http://www.noesisengine.com
// Copyright (c) 2009-2010 Noesis Technologies S.L. All Rights Reserved.
////////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef __DRAWING_LOCALFONTPROVIDER_H__
#define __DRAWING_LOCALFONTPROVIDER_H__
#include <Noesis.h>
#include <NsDrawing/CachedFontProvider.h>
#include <NsDrawing/LocalFontProviderApi.h>
namespace Noesis
{
namespace Drawing
{
////////////////////////////////////////////////////////////////////////////////////////////////////
/// A font provider that searches fonts in local directories
////////////////////////////////////////////////////////////////////////////////////////////////////
class NS_DRAWING_LOCALFONTPROVIDER_API LocalFontProvider: public CachedFontProvider
{
public:
LocalFontProvider(const NsChar* rootPath);
private:
/// From CachedFontProvider
//@{
void ScanFolder(const NsChar* folder) override;
Ptr<Core::Stream> OpenFont(const NsChar* folder, const NsChar* filename) const override;
//@}
void ScanFolder(const NsChar* path, const NsChar* folder, const NsChar* ext);
private:
NsChar mRootPath[PATH_MAX];
};
}
}
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////
// Noesis Engine - http://www.noesisengine.com
// Copyright (c) 2009-2010 Noesis Technologies S.L. All Rights Reserved.
////////////////////////////////////////////////////////////////////////////////////////////////////
#include <NsDrawing/LocalFontProvider.h>
#include <NsCore/File.h>
#include <NsCore/Find.h>
#include <NsCore/Stream.h>
#include <NsCore/LoggerMacros.h>
using namespace Noesis;
using namespace Noesis::Core;
using namespace Noesis::Drawing;
////////////////////////////////////////////////////////////////////////////////////////////////////
LocalFontProvider::LocalFontProvider(const NsChar* rootPath)
{
String::Copy(mRootPath, sizeof(mRootPath), rootPath);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void LocalFontProvider::ScanFolder(const NsChar* folder)
{
NsChar uri[PATH_MAX] = "";
if (!String::IsNullOrEmpty(mRootPath))
{
String::Copy(uri, sizeof(uri), mRootPath);
String::Append(uri, sizeof(uri), "/");
}
String::Append(uri, sizeof(uri), folder);
ScanFolder(uri, folder, ".ttf");
ScanFolder(uri, folder, ".otf");
}
////////////////////////////////////////////////////////////////////////////////////////////////////
Ptr<Stream> LocalFontProvider::OpenFont(const NsChar* folder, const NsChar* filename) const
{
NsChar uri[PATH_MAX] = "";
if (!String::IsNullOrEmpty(mRootPath))
{
String::Copy(uri, sizeof(uri), mRootPath);
String::Append(uri, sizeof(uri), "/");
}
String::Append(uri, sizeof(uri), folder);
String::Append(uri, sizeof(uri), "/");
String::Append(uri, sizeof(uri), filename);
if (File::IsFile(uri))
{
return File::OpenStream(uri);
}
return 0;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void LocalFontProvider::ScanFolder(const NsChar* path, const NsChar* folder, const NsChar* ext)
{
FindData findData;
if (FindFirst(path, ext, findData))
{
do
{
RegisterFont(folder, findData.filename);
}
while (FindNext(findData));
Core::FindClose(findData);
}
}