Kan geen terminal font kiezen

Status
Niet open voor verdere reacties.

geenID

Gebruiker
Lid geworden
1 jul 2009
Berichten
312
Hallo

Ik heb een probleem met de lettertype:
Ik kan alleen maar "true-type font" gebruiken in vb 2010. Maar ik zou graag een Terminal Font willen gebruiken.
Het gaat om de volgende lettertype:digital-graphics-labs_bitwise


Wie weet een oplossing?
 
Laatst bewerkt:
@GeenID,

Hallo :D

maybe kan ik je helpen.
hoe wil je deze gebruiken? ik wil hiermee zeggen wil je deze uit je resource gebruiken
in plaats van deze naar windows/fonts te kopiëren

Of heb ik je verkeerd voor.

Ik wacht op je reply.

Dummy1912
 
Maakt niet hoe denk ik, als ik het maar kan gebruiken :)

Dus vanuit resources of windows font map
 
vanuit de resource :D

weet je hoe je de font moet gebruiken uit de resource?

Dummy1912
 
ja , een beetje. Maar kan je het toch uitleggen voor de zekerheid?
 
hey,

ok geen probleem
eerst voeg je die font in je resource

dan gebruik je de volgende code:

Code:
Private Shared _EmbeddedFonts As Drawing.Text.FontCollection
    Private Shared FontArray() As String = {"chp-fire.ttf"}

Dim FntFC As Drawing.Text.PrivateFontCollection = GetFont(FontArray)


#Region " Load Font From Recource "
    Private Declare Auto Function AddFontMemResourceEx Lib "Gdi32.dll" _
   (ByVal pbFont As IntPtr, ByVal cbFont As Integer, _
   ByVal pdv As Integer, ByRef pcFonts As Integer) As IntPtr

    Public Function GetFont(ByVal FontResource() As String) As  _
        Drawing.Text.PrivateFontCollection
        'Get the namespace of the application    
        Dim NameSpc As String = _
            Reflection.Assembly.GetExecutingAssembly().GetName().Name.ToString()
        Dim FntStrm As IO.Stream
        Dim FntFC As New Drawing.Text.PrivateFontCollection
        Dim i As Integer
        For i = 0 To FontResource.GetUpperBound(0)
            'Get the resource stream area where the font is located
            FntStrm = _
        Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream( _
        NameSpc + "." + FontResource(i))
            'Load the font off the stream into a byte array
            Dim ByteStrm(CType(FntStrm.Length, Integer)) As Byte
            FntStrm.Read(ByteStrm, 0, Int(CType(FntStrm.Length, Integer)))
            'Allocate some memory on the global heap
            Dim FntPtr As IntPtr = _
                Runtime.InteropServices.Marshal.AllocHGlobal( _
                Runtime.InteropServices.Marshal.SizeOf(GetType(Byte)) * _
                    ByteStrm.Length)
            'Copy the byte array holding the font into the allocated memory.
            Runtime.InteropServices.Marshal.Copy(ByteStrm, 0, _
                FntPtr, ByteStrm.Length)
            'Add the font to the PrivateFontCollection
            FntFC.AddMemoryFont(FntPtr, ByteStrm.Length)
            Dim pcFonts As Int32
            pcFonts = 1
            AddFontMemResourceEx(FntPtr, ByteStrm.Length, 0, pcFonts)
            'Free the memory
            Runtime.InteropServices.Marshal.FreeHGlobal(FntPtr)
        Next
        Return FntFC
    End Function
#End Region

dan doe je bij form_load

Code:
  Label4.Font = New Font(FntFC.Families(0), 40, FontStyle.Bold, GraphicsUnit.Point)
'of als je de hele form wilt met die font dan doe je

       Me.Text = New Font(FntFC.Families(0), 40, FontStyle.Bold, GraphicsUnit.Point)

hoop dat dit je geholpen heeft

Dummy1912
 
Hoi GeenID,

Je plaats de eerste code gewoon onder de public class JE FORM NAAM

Dummy1912
 
Sorry dat ik een tijdje niet kon reageren, want me pc moest (alweer) naar de computer winkel wegens een crash...

Maar nu werkt het, met jou hulp :)

Dus heel erg bedankt :D
 
graag gedaan GeenID :D

blij om te kunnen helpen.

Ja crash heb ik al 1x mee gemaakt
niet grappig :(

Dummy1912
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan