HighTechTalks DotNet Forums  

Open Type font and gdi

Dotnet Framework (Drawing) microsoft.public.dotnet.framework.drawing


Discuss Open Type font and gdi in the Dotnet Framework (Drawing) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
mgonzales3
 
Posts: n/a

Default Open Type font and gdi - 09-20-2005 , 12:03 PM






I just bought a font from Adobe. It was a "oft" font which is open type.
I'm trying to create a bmp using a memory stream and is unable to find my
font. Any reason why this would so?

The exeption i get: Font cannot be found.

I searched my registry at:
SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Fonts

and its there.

Any ideas?


my code
----------------------------------
Sub CreateBMP()
Dim FullMICR As String = "C " & " C A123456A C123456C"
Dim textLength As Integer = FullMICR.Length
Dim fontSize As Integer = 12

' Set canvas width & height
Dim width As Integer
Dim height As Integer

width = (fontSize * textLength) + 15
height = fontSize + 10

' Initialize graphics
Dim pic As System.Drawing.Bitmap = New System.Drawing.Bitmap(width, height,
Drawing.Imaging.PixelFormat.Format32bppRgb)
Dim g As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(pic)


Dim myBrsh As SolidBrush
myBrsh = New SolidBrush(Color.Black)

'g.TextRenderingHint = g.TextRenderingHint.AntiAlias
pic.SetResolution(600, 600)

Dim fontFmly As New FontFamily("MicrStd(OpentType)")
Dim font As New Font(fontFmly, 12, FontStyle.Regular)

' Finally, draw the font
g.Clear(System.Drawing.Color.White)
g.DrawString(FullMICR, font, myBrsh, 0, 0)

' Convert image to a byte stream
Dim imageBytes() As Byte = Nothing
Dim memoryStream As System.IO.MemoryStream = New System.IO.MemoryStream

pic.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Bmp)

' close everything
memoryStream.Flush()
memoryStream.Close()

pic.Dispose()
pic = Nothing

imageBytes = memoryStream.ToArray()
memoryStream.Close()

Return (imageBytes)

Reply With Quote
  #2  
Old   
Oliver Sturm
 
Posts: n/a

Default Re: Open Type font and gdi - 09-21-2005 , 04:45 AM






mgonzales3 wrote:

Quote:
I just bought a font from Adobe. It was a "oft" font which is open type.
I'm trying to create a bmp using a memory stream and is unable to find my
font. Any reason why this would so?
Yes. The reason is that the .oft font you have is an OpenType font with
PostScript (Type1) outlines, as opposed to an OpenType font with TrueType
outlines. These are not currently supported by GDI+ and therefore by .NET.

This page explains about the OpenType flavors:
http://www.myfonts.com/info/opentype-flavors-ps-tt/


Oliver Sturm
--
Expert programming and consulting services available
See http://www.sturmnet.org (try /blog as well)


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.