Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19
  1. #16
    Cryptonic's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    United Provinces of Canada
    Posts
    1,313
    Reputation
    44
    Thanks
    190
    My Mood
    Bored
    Quote Originally Posted by Brinuz View Post


    Well thats your created objected, its empty, wasnt even considering it.
    Why dont you just add it to that collection, and then use it on the whole app with the cycle I told you so?
    To include the font with the app, add it to resources for example.

    Ill write a quick example for ya in a moment


    ---------- Post added at 12:49 AM ---------- Previous post was at 12:04 AM ----------

    Ok, Added a .ttf to the resources and then,

    Basically this initializes the font from resources and adds it into memory to be able to use:
    AddFontMemResourceEx: AddFontMemResourceEx function
    (Adds it to the system)

    Code:
                FontFamily fontFamily;
                PrivateFontCollection pfc = new PrivateFontCollection();
                GCHandle pMem = GCHandle.Alloc(Properties.Resources.The_Amazing_Spider_Man, GCHandleType.Pinned);
                IntPtr fontPtr = pMem.AddrOfPinnedObject();
                pfc.AddMemoryFont(fontPtr, Properties.Resources.The_Amazing_Spider_Man.Length);
                uint pcFonts = 0; //useless
                AddFontMemResourceEx(fontPtr, (uint)Properties.Resources.The_Amazing_Spider_Man.Length, IntPtr.Zero, ref pcFonts);
                pMem.Free(); //Free unsafe memory
    
                fontFamily = pfc.Families[0];
    For use, just as I said before

    Code:
                for (int i = 0; i < this.Controls.Count; i++)
                    this.Controls[i].Font = new Font(fontFamily, 10, FontStyle.Regular);
    (You can declare <fontFamily> globally to use it everywhere on the app with the previous cycle)

    PS: There might be a easier way around, never played with fonts before so.
    Are you coding this all in C#? This is getting confusing.
    ...and the AddFontMemResourceEx function is in C++

    You also need - Imports System.Runtime.InteropServices
    But, there's still some errors, since I don't have the AddFontMemResourceEx..

    This seems just too much just for a font.. Maybe I'll just have them install the font manually. Unless there's an easier way

  2. #17
    'Bruno's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Portugal
    Posts
    2,883
    Reputation
    290
    Thanks
    1,036
    My Mood
    Busy
    Quote Originally Posted by PepsiXHacker View Post

    Are you coding this all in C#? This is getting confusing.
    ...and the AddFontMemResourceEx function is in C++

    You also need - Imports System.Runtime.InteropServices
    But, there's still some errors, since I don't have the AddFontMemResourceEx..

    This seems just too much just for a font.. Maybe I'll just have them install the font manually. Unless there's an easier way
    C# is the same as VB. Just used to it.
    AddFontMemResourceEx is not a c++ function. Is a windows function. You need to write the function signature:
    pinvoke.net: AddFontMemResourceEx (gdi32)

    Code:
    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 IntPt
    Yes it is indeed a lot of trouble. And it would be easier just to install the font and thats it. Nontheless the application needs to recognize it first.

    But if you search the web, there isn't that many options, and honestly this is not that much complicated

    In the end I wonder, why are you not using a normal font?
    Last edited by 'Bruno; 08-24-2012 at 06:46 PM.
    Light travels faster than sound. That's why most people seem bright until you hear them speak.

  3. #18
    Cryptonic's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    United Provinces of Canada
    Posts
    1,313
    Reputation
    44
    Thanks
    190
    My Mood
    Bored
    Quote Originally Posted by Brinuz View Post


    C# is the same as VB. Just used to it.
    AddFontMemResourceEx is not a c++ function. Is a windows function. You need to write the function signature:
    pinvoke.net: AddFontMemResourceEx (gdi32)

    Code:
    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 IntPt
    Yes it is indeed a lot of trouble. And it would be easier just to install the font and thats it. Nontheless the application needs to recognize it first.

    But if you search the web, there isn't that many options, and honestly this is not that much complicated

    In the end I wonder, why are you not using a normal font?
    lmao, because, for one, every time you someone releasing a program without a good UI, they always complain. The font is part of the UI.

    And.. just because the font is plain sexy. My question is, why doesn't every computer come with century gothic...?

  4. #19
    'Bruno's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Portugal
    Posts
    2,883
    Reputation
    290
    Thanks
    1,036
    My Mood
    Busy
    I wouldnt blade someones GUI over a font, as long as they dont use somewierd fuked up font, its irrelevant imo.
    Light travels faster than sound. That's why most people seem bright until you hear them speak.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. how to install shoutcast on linux
    By GG2GG in forum Programming Tutorials
    Replies: 2
    Last Post: 12-24-2008, 04:22 AM
  2. Replies: 0
    Last Post: 10-09-2007, 04:05 PM
  3. how to install vb6???
    By 123456789987654321 in forum WarRock - International Hacks
    Replies: 4
    Last Post: 06-04-2007, 02:35 AM
  4. How to install trainer maker kit?
    By scooby107 in forum WarRock - International Hacks
    Replies: 13
    Last Post: 04-29-2007, 12:26 PM
  5. how do you add fonts in PS
    By darkone1149 in forum Art & Graphic Design
    Replies: 2
    Last Post: 02-06-2006, 05:32 PM