J
Jon Finch
Hi All this is a follow up to a post I did a few days back regarding reading
a font from an assembly into a memory font object.
The only thing I am stuck on is getting the actual memory size of a byte
array so that I can allocate the memory for the pointer..
Here's the code
'Load the font from the assembly
Public myFonts As New PrivateFontCollection()
Dim asm As [Assembly] = Me.GetType.Assembly
Dim stm As Stream =
asm.GetManifestResourceStream("CreativeTools.FtraBk__.ttf")
Dim buffer(Convert.ToInt32(stm.Length)) As Byte
stm.Read(buffer, 0, Convert.ToInt32(stm.Length))
buffer.Length) <<
Marshal.Copy(buffer, 0, pi, buffer.Length)
myFonts.AddMemoryFont(pi, buffer.Length)
Marshal.FreeHGlobal(pi)
--
The line I am having problems with is the
Dim pi As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(byte) *
buffer.Length)
I have tried
Dim pi As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(buffer) *
buffer.Length)
Dim pi As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(buffer.getType) *
buffer.Length)
Dim pi As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf( buffer.Length) )
Dim pi As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(buffer)
Dim pi As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf([Byte]) *
buffer.Length)
All to no avail! So how do I get the memory size of a byte array??
Any help would be greatly appreciated
All the best,
Jon
a font from an assembly into a memory font object.
The only thing I am stuck on is getting the actual memory size of a byte
array so that I can allocate the memory for the pointer..
Here's the code
'Load the font from the assembly
Public myFonts As New PrivateFontCollection()
Dim asm As [Assembly] = Me.GetType.Assembly
Dim stm As Stream =
asm.GetManifestResourceStream("CreativeTools.FtraBk__.ttf")
Dim buffer(Convert.ToInt32(stm.Length)) As Byte
stm.Read(buffer, 0, Convert.ToInt32(stm.Length))
buffer.Length) <<
Marshal.Copy(buffer, 0, pi, buffer.Length)
myFonts.AddMemoryFont(pi, buffer.Length)
Marshal.FreeHGlobal(pi)
--
The line I am having problems with is the
Dim pi As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(byte) *
buffer.Length)
I have tried
Dim pi As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(buffer) *
buffer.Length)
Dim pi As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(buffer.getType) *
buffer.Length)
Dim pi As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf( buffer.Length) )
Dim pi As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(buffer)
Dim pi As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf([Byte]) *
buffer.Length)
All to no avail! So how do I get the memory size of a byte array??
Any help would be greatly appreciated
All the best,
Jon