Followers 0

# FW1FontWrapper in SlimDX

## 9 posts in this topic

hi,

Has anyone used FW1FontWrapper.dll for rendering text in SlimDx(C#)?

indeed is this possible ,if yes how can i do that??

Edited by hossainiir
0

##### Share on other sites

I haven't done this, but from my understanding of the fw1 library it is more or less just generating a texture to hold the glyphs, and then those glyphs can be used for putting text into a rendered scene by just using textured quads.  Have you tried to adapt this technique, or is something tripping you up?

0

##### Share on other sites

The interface is a C++ class, which you can't directly consume in a C# project. You would need to either write a managed wrapper for the library in C++/CLI (this is what SlimDX does for DirectX), or you can create a "flat" API consisting of just C functions (no classes) that you can call with p/invoke. The first option can be pretty difficult if you've never done it before, C++/CLI is fairly obscure and it can be tricky even if you're experienced with C++. The latter is easier if the interface is simple, but you'd still need some working knowledge of C/C++ in order to write it and set up the DLL correctly.

0

##### Share on other sites

Thanks for replay ,

i want to render unicode char like persian chars, the problem is that in this kind of language letters may stick together, unlike latin letters that never stick together.

for example in english we have s and S but in persian we have ? ?? ?(indeed S = ?).

Sometimes it is hard to handle, but using this library is very simple.

0

##### Share on other sites

The interface is a C++ class, which you can't directly consume in a C# project. You would need to either write a managed wrapper for the library in C++/CLI (this is what SlimDX does for DirectX), or you can create a "flat" API consisting of just C functions (no classes) that you can call with p/invoke. The first option can be pretty difficult if you've never done it before, C++/CLI is fairly obscure and it can be tricky even if you're experienced with C++. The latter is easier if the interface is simple, but you'd still need some working knowledge of C/C++ in order to write it and set up the DLL correctly.

Thanks,

I've already called just method and function from C++ dll not creating interfaces from C++ dll, can you help me ?.

0

##### Share on other sites

Do you want to do it with C functions or as a class?

I made an example with another DLL that exports C functions that uses the wrapper, and a C# class that can use it: http://www.rufelt.com/fw1fontwrapper/csharp/

Download FW1CWrapper.zip and extract the appropriate DLL together with the usual FW1FontWrapper.dll and use the source in FW1Wrapper.cs to use the DLLs from C#.

I haven't tested this extensively and I don't have very much experience in C# or interop, but it seems to work fine, as long as you compile with x86 or x64 and use the appropriate DLL.

Then in SlimDX you can do this:

[source]

using FW1;

...

IntPtr devicePtr = device.ComPointer;
IntPtr contextPtr = device.ImmediateContext.ComPointer;

FW1Wrapper fontWrapper = new FW1Wrapper(devicePtr, "Arial");

...

fontWrapper.DrawString(contextPtr, "a string", "Courier New", 64.0f, x, y, 0xffffffff, FW1Wrapper.Center);

[/source]

I've only done the most common functions.

1

##### Share on other sites

Thanks Erik!

I want to do with class ,l will try this.

,

0

##### Share on other sites

I got this error "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

at the following line of code:

IntPtr pFW1FontWrapper = C_FW1_CreateFontWrapper(pDevice11,fontFamily,locale,mipLevels,anisotropicFiltering,disableGeometryShader);


0

##### Share on other sites

Are both the FW1FontWrapper.dll and FW1CWrapper.dll files in the directory for your .exe?

Also, are they both matching x86 or x64, and not different, and have you chosen the same x86 or x64 target when building your C# program?

I tried it on the SlimDX MiniTri sample and it worked there for me. If I select the "Any" target instead of x86 or x64 it doesn't work though, I think you need a different method for that.

0

##### Share on other sites

With x64 i got no error but nothing rendered!!!

0

## Create an account

Register a new account