locked
Open Type fonts in vb.net or C# RRS feed

  • Question

  • User1391328907 posted
    Hi I have been trying to use the open type fonts (.otf files) purchased from Adobe for one of our asp.net web applications. Even after i installed those fonts, Either installedfontcollection is not getting those fonts or using Privatefontcollection also i am not able to add those fonts. When i use addfontfile method, it says, file not found. Please advice.
    Thursday, January 15, 2004 1:58 PM

All replies

  • User1451426431 posted

     Hi ..

    even I am facing the same problem ... did you by any chance get the answer?

    itsUrDAY 

     

     

    Wednesday, December 26, 2007 10:56 AM
  • User1182280274 posted

    try this:

    Public Class TypeFont
        Const GDI32 As String = "gdi32.dll"
        Const USER32 As String = "user32.dll"
    
        <DllImport(GDI32)>
        Public Shared Function CreateFont(ByVal nHeight As Integer,
                                          ByVal nWidth As Integer,
                                          ByVal nEscapement As Integer,
                                          ByVal nOrientation As Integer,
                                          ByVal fnWeight As Integer,
                                          ByVal fdwItalic As Integer,
                                          ByVal fdwUnderline As Integer,
                                          ByVal fdwStrikeOut As Integer,
                                          ByVal fdwCharSet As Integer,
                                          ByVal fdwOutputPrecision As Integer,
                                          ByVal fdwClipPrecision As Integer,
                                          ByVal fdwQuality As Integer,
                                          ByVal fdwPitchAndFamily As Integer,
                                          ByVal lpszFace As String) As Integer
        End Function
        Shared Function CreateFont(FontName As String, FontSize As Integer, Optional ByVal Escapement As Integer = 0, Optional ByVal Orientation As Integer = 0, Optional ByVal FontWeight As Integer = 0, Optional ByVal IsItalic As Integer = 0, Optional ByVal Underline As Integer = 0, Optional ByVal StrikeOut As Integer = 0, Optional ByVal Charset As Integer = 0, Optional ByVal OutputPrecision As Integer = 0, Optional ByVal ClipPrecision As Integer = 0, Optional ByVal Quality As Integer = 5, Optional ByVal PitchAndFamily As Integer = 0) As Font
            Return Font.FromHfont(CreateFont(FontSize, 0, Escapement, Orientation, FontWeight, IsItalic, Underline, StrikeOut, Charset, OutputPrecision, ClipPrecision, Quality, 1, FontName))
        End Function
    End Class

    Using:

    Control.Font = TypeFont.CreateFont("XXXX", YYYY)

    XXXX = Font Name

    YYYY = Font Size (Pixel)

    I hope it helped!

    Saturday, July 28, 2018 2:49 PM