FW1FontWrapper in SlimDX

Started by
8 comments, last by hossainiir 11 years, 2 months ago

hi,

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

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

See http://fw1.codeplex.com/

???? ?? ??? ????

Persian Gulf

Advertisement

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?

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 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.

???? ?? ??? ????

Persian Gulf

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 ?.

???? ?? ??? ????

Persian Gulf

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.

Thanks Erik!

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

,

???? ?? ??? ????

Persian Gulf

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);

???? ?? ??? ????

Persian Gulf

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.

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

???? ?? ??? ????

Persian Gulf

This topic is closed to new replies.

Advertisement