Sign in to follow this  
surtax

D3D DrawText Vb.net Arabic Problem!

Recommended Posts

I am having some problems rendering text in my program. I wrote an independent program to illustrate the problem. For some reason when using Direct3d.Font.Drawtext method with Arabic characters it comes out really wierd. For example when I try the following: Dim testFont As System.Drawing.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.5F, Fontstyle.Regular, GraphicsUnit.Point, 178, False) Dim Font2_ As Direct3D.Font = New Direct3D.Font(device, testFont) Font2_.DrawText(Nothing, "مرجع شامل", New System.Drawing.Rectangle(3, 2, 338, 40), DrawTextFormat.RightToLeftReading, Color.Black) It'll come out in reverse and doubled. Ie. "This Example" will come out as "ThissihT ExampleelpmaxE" Another strange thing I've noticed is that for some reason reducing the font size below to 10.4 will get rid of the doubling up. Please try the following code to see what I mean: device.BeginScene() 'all drawings after this line Dim workingFont As System.Drawing.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.4F) Dim buggedFont As System.Drawing.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.5F) Dim Font_ As Direct3D.Font = New Direct3D.Font(device, workingFont) Dim Font2_ As Direct3D.Font = New Direct3D.Font(device, buggedFont) Dim Font3_ = New Direct3D.Font(device, 0, 0, FontWeight.Normal, 1, False, CharacterSet.Default, Precision.String, FontQuality.ClearTypeNatural, PitchAndFamily.DefaultPitch Or PitchAndFamily.FamilyDoNotCare, "Arabic") Font_.DrawText(Nothing, "اما اق ", 0, 0, Color.White) 'Appears different in editor but for some reason cant post it like that here. The arabic should be the second parameter Font2_.DrawText(Nothing, "اما اق", 0, 15, Color.White) 'Appears different in editor but for some reason cant post it like that here. The arabic should be the second parameter Font3_.DrawText(Nothing, "اما اق", RECT, DrawTextFormat.RightToLeftReading, Color.White) device.EndScene() 'all drawings before this line device.Present() All 3 draw texts have the same string being passed into it yet all three print different characters. Any help will be appreciated! The entire code ----------------------------------- Imports Microsoft.DirectX Imports Microsoft.DirectX.Direct3D Public Class Form1 Private device As Direct3D.Device Private RECT As New System.Drawing.Rectangle(0, 30, 338, 40) Public Sub Initialize() Dim present As PresentParameters = New PresentParameters present.Windowed = True 'we?ll draw on a window present.SwapEffect = SwapEffect.Discard 'discuss later device = New Direct3D.Device(0, DeviceType.Hardware, Me, CreateFlags.SoftwareVertexProcessing, present) End Sub Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Me.Setstyle(Controlstyles.AllPaintingInWmPaint Or Controlstyles.Opaque, True) 'Do not draw form?s background Initialize() End Sub Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint device.BeginScene() 'all drawings after this line Dim workingFont As System.Drawing.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.4F) Dim buggedFont As System.Drawing.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.5F) Dim Font_ As Direct3D.Font = New Direct3D.Font(device, workingFont) Dim Font2_ As Direct3D.Font = New Direct3D.Font(device, buggedFont) Dim Font3_ = New Direct3D.Font(device, 0, 0, FontWeight.Normal, 1, False, CharacterSet.Default, Precision.String, FontQuality.ClearTypeNatural, PitchAndFamily.DefaultPitch Or PitchAndFamily.FamilyDoNotCare, "Arabic") Font_.DrawText(Nothing, "اما اق ", 0, 0, Color.White) Font2_.DrawText(Nothing, "اما اق", 0, 15, Color.White) Font3_.DrawText(Nothing, "اما اق", RECT, DrawTextFormat.RightToLeftReading, Color.White) device.EndScene() 'all drawings before this line device.Present() Me.Invalidate() 'redraw End Sub End Class A link to someone with the same problem, dont understand the solution - http://groups.google.com/group/microsoft.public.vb.directx/browse_thread/thread/57b639607568ce7a/1f48515ab7cb60a9?lnk=gst&q=arabic#1f48515ab7cb60a9

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this