Results 1 to 7 of 7

Thread: [RESOLVED] Font Size in MM

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2002
    Posts
    129

    Resolved [RESOLVED] Font Size in MM

    Hello,

    I have a strange problem which I am really struggling with, im making a type of CAD program which the user needs to specify a font size in mm.

    Everything seems to work ok but when I get the bounding box of the font it reports it as being less than the font height specified. I have pasted the code below. I hope someone here could help me.

    vb.net Code:
    1. Using G As Graphics = PictureBox1.CreateGraphics
    2.  
    3.             G.PageUnit = GraphicsUnit.Millimeter
    4.             G.InterpolationMode = InterpolationMode.HighQualityBicubic
    5.  
    6.             DPI = G.DpiY
    7.             Dim emSize As Single = txtHeight.Text.Replace("mm", "")
    8.  
    9.  
    10.             Using myPath2 As New GraphicsPath
    11.                 Dim DrawPoint As PointF = New PointF(4, 5)
    12.                 Dim myStringFormat As StringFormat = New StringFormat()
    13.  
    14.                 myPath2.AddString(txtText.Text, fntFont.Font.FontFamily, fntFont.Font.Style, emSize, DrawPoint, myStringFormat)
    15.  
    16.                 'Get all points
    17.                 PointsArr.AddRange(myPath2.PathData.Points)
    18.                 'Draw the text using coords
    19.  
    20.                 If loadXY5 = True Then
    21.                     myPath2.AddLines(XY5Points.ToArray)
    22.                 Else
    23.                     myPath2.AddLines(PointsArr.ToArray)
    24.                 End If
    25.  
    26.                 boundRect = myPath2.GetBounds()
    27.  
    28.                 PictureBox1.Invalidate()
    29.  
    30.             End Using
    31.  
    32.         End Using
    33.  
    34. lblBlankSize.Text = "Blank Size:- " & Math.Round(boundRect.Width) & " X " & Math.Round(boundRect.Height)
    Last edited by DanDanDan1; May 26th, 2010 at 11:12 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width