Results 1 to 19 of 19

Thread: [RESOLVED] [2005] Embedding a True Type Font

Threaded View

  1. #1

    Thread Starter
    Member VJgamer's Avatar
    Join Date
    Jul 2006
    Posts
    40

    Resolved [RESOLVED] [2005] Embedding a True Type Font

    I am trying to embed a True Type font into one of my applications. The font is "Digital Readout Upright" which can be found at http://www.grsites.com/fonts/. I have read many articles on how to do this, and when I use this code it dosn't work.

    I have the following code:
    VB Code:
    1. Public Class Form1
    2.     Dim EmbedFonts As New PrivateFontCollection()
    3.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load        
    4.     Dim FontStream As IO.Stream = Me.GetType().Assembly.GetManifestResourceStream("EmbedFonts.DIGIREAD.TTF")
    5.         Dim FontLoc As System.IntPtr = Marshal.AllocCoTaskMem(FontStream.Length)
    6.         Dim FontData(FontStream.Length) As Byte
    7.         FontStream.Read(FontData, 0, FontStream.Length)
    8.         Marshal.Copy(FontData, 0, FontLoc, FontStream.Length)
    9.         EmbedFonts.AddMemoryFont(FontLoc, FontStream.Length)
    10.         FontStream.Close()
    11.         Dim FontStream As IO.Stream = Me.GetType().Assembly.GetManifestResourceStream("EmbedFonts.DIGIREAD.TTF")
    12.         Dim FontLoc As System.IntPtr = Marshal.AllocCoTaskMem(FontStream.Length)
    13.         Dim FontData(FontStream.Length) As Byte
    14.         FontStream.Read(FontData, 0, FontStream.Length)
    15.         Marshal.Copy(FontData, 0, FontLoc, FontStream.Length)
    16.         EmbedFonts.AddMemoryFont(FontLoc, FontStream.Length)
    17.         FontStream.Close()
    18.         Marshal.FreeCoTaskMem(FontLoc)
    19.         lblVolume.ForeColor = Color.FromArgb(0, 192, 0)
    20.         lblVolume.Font = New Font(EmbedFonts.Families(0), 31, FontStyle.Bold)
    21.     End Sub
    22. End Class

    My Project name is EmbedFonts, and the font is in the Solution Explorer and the filename is DIGIREAD.TTF. I have DIGIREAD.TTF's Build Property set to Embedded Resource. Also if I look at EmbedFonts.Families(0).Name property it is "Digital Readout Upright".

    The font in the the label lblVolume is still arial once the form loads.

    Any help would be greatly appreciated!
    Last edited by VJgamer; Aug 29th, 2006 at 05:27 PM.
    My Site: VJgamer's World | My Freeware: PCFinder 4.0 | FindMe 1.5

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