Esempio n. 1
0
// Loads a FreeType face.
void* FontProvider::LoadFace(const String& file_name)
{
	BitmapFontDefinitions *bm_face = new BitmapFontDefinitions();
	FontParser parser( bm_face );

	FileInterface* file_interface = GetFileInterface();
	FileHandle handle = file_interface->Open(file_name);

	if (!handle)
	{
		return NULL;
	}

	size_t length = file_interface->Length(handle);

	byte* buffer = new byte[length];
	file_interface->Read(buffer, length, handle);
	file_interface->Close(handle);

	StreamMemory* stream = new StreamMemory( buffer, length );
	stream->SetSourceURL( file_name );

	parser.Parse( stream );

	bm_face->Face.Source = file_name;
	return bm_face;
}
Esempio n. 2
0
// Loads a FreeType face.
void* FontDatabase::LoadFace(const String& file_name)
{
	FileInterface* file_interface = GetFileInterface();
	FileHandle handle = file_interface->Open(file_name);

	if (!handle)
	{
		return false;
	}

	// Seek to the end of the file so we can determine its size.
	if (!file_interface->Seek(handle, 0, SEEK_END))
	{
		file_interface->Close(handle);
		return false;
	}

	size_t length = file_interface->Tell(handle);
	file_interface->Seek(handle, 0, SEEK_SET);

	FT_Byte* buffer = new FT_Byte[length];
	file_interface->Read(buffer, length, handle);
	file_interface->Close(handle);

	return LoadFace(buffer, length, file_name, true);
}
	ModelLoader* ModelLoader::Create(
		ModelLoaderLoad load,
		ModelLoaderUnload unload)
	{
		auto loader = new ModelLoader( load, unload );
		auto internalLoader = new EffekseerRendererGL::ModelLoader(loader->GetFileInterface());
		loader->SetInternalLoader( internalLoader );
		return loader;
	}
// Closes the stream.
void StreamFile::Close()
{
	if (file_handle)
	{
		GetFileInterface()->Close(file_handle);
		file_handle = NULL;
	}

	length = 0;
}
Esempio n. 5
0
// Loads a FreeType face.
void* FontProvider::LoadFace(const String& file_name)
{
	FileInterface* file_interface = GetFileInterface();
	FileHandle handle = file_interface->Open(file_name);

	if (!handle)
	{
		return NULL;
	}

	size_t length = file_interface->Length(handle);

	FT_Byte* buffer = new FT_Byte[length];
	file_interface->Read(buffer, length, handle);
	file_interface->Close(handle);

	return LoadFace(buffer, (int)length, file_name, true);
}
/// Attempts to open the stream pointing at a given URL.
bool StreamFile::Open(const String& path)
{
	String url_safe_path = path.Replace(":", "|");
	SetStreamDetails(URL(url_safe_path), Stream::MODE_READ);

	if (file_handle)
		Close();

	// Fix the path if a leading colon has been replaced with a pipe.
	String fixed_path = path.Replace("|", ":");
	file_handle = GetFileInterface()->Open(fixed_path);
	if (!file_handle)
	{
		Log::Message(Log::LT_WARNING, "Unable to open file %s.", fixed_path.CString());
		return false;
	}

	GetLength();

	return true;
}
// Sets the stream position (in bytes).
bool StreamFile::Seek(long offset, int origin) const
{
	return GetFileInterface()->Seek(file_handle, offset, origin);
}
// Returns the position of the stream pointer (in bytes).
size_t StreamFile::Tell() const
{
	return GetFileInterface()->Tell(file_handle);
}
// Determines the length of the stream.
void StreamFile::GetLength()
{
	length = GetFileInterface()->Length(file_handle);
}
// Read from the stream.
size_t StreamFile::Read(void* buffer, size_t bytes) const
{
	return GetFileInterface()->Read(buffer, bytes, file_handle);
}