Results 1 to 8 of 8

Thread: Add-In to Replace Fonts

  1. #1

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,852

    Add-In to Replace Fonts

    Here's a little Add-In I wrote, primarily for replacing all the MS Sans Serif fonts in large projects I've got, and I thought I'd share. It does allow you to replace any screen-available font with any other screen-available font. It's been something I've wanted/needed to do for some time.

    Here's a screenshot:

    Name:  ReplaceFont.png
Views: 1895
Size:  7.9 KB

    Let me give some caveats to start:

    • I haven't tested it for any MDI-type projects, and I'm not sure what it'll do in those situations.
    • I always use my IDE in a SDI mode, but I don't think that should make any difference.
    • I didn't do the work to make an IDE Toolbar button for it. However, once it's loaded, it'll appear as a menu sub-item on the Add-Ins menu. If you click the "Hide Me" button on the interface, just click the "Replace Font" sub-menu item, and it'll re-appear.


    Also, let me talk a bit about Add-Ins for the uninitiated. There are a couple of different ways to execute this Add-In: One, you can just load it in the IDE and execute it. When you do this, it'll execute but nothing much will happen. However, if you load a second copy of the IDE and then call up your Add-In Manager, you'll see this Add-In. If you Load it, you'll then see the Add-In. However, all of this is more-or-less a mode for debugging the Add-In.

    The second way to use it is to compile it. It'll make an Add-In-type ActiveX DLL. And, the mere act of compiling it will also register it. Just because I'm a nice guy, I've also included two little DLLReg.vbs & DLLUnreg.vbs scripts. If you drag the compiled DLL onto either of those scripts, it'll register/unregister it. If you compiled it, but didn't compile it where you want it to permanently reside, this will allow you a way to move it (unregister, move the DLL, re-register). Personally, I have a VB6_Addins folder in my Microsoft Visual Studio folder, and that's where I keep these DLLs. Also, the act of compiling will create a couple of other files (ReplaceFont.exp & ReplaceFont.lib), but those aren't needed and can be deleted. Just don't delete the source files (ReplaceFont.vbp, ReplaceFont.frm/x, ReplaceFont.Dsr).

    Let me say a bit about the features too:

    • If you specify controls (in addition to forms), it will go through all controls of the form, regardless of whether or not they're nested in containers.
    • The "List w Font" button doesn't actually do anything to your project. However, it goes through all the forms and controls, and makes a list of the forms that have the "From" font somewhere on them. It's just a way to get an idea of what the "Do The Font Replacement(s)" button will do if you click it.
    • The "Segoe" and "Microsoft Sans Serif" buttons are just a couple of quick options for filling in the "To" font.


    UPDATE (July 1, 2018, version 1.01): Fixed the tab order, alphabetized (sorted) the ComboBoxes, added an option to cover CTL & PAG files in addition to FRM files.

    Enjoy,
    Elroy
    Attached Files Attached Files
    Last edited by Elroy; Jul 1st, 2018 at 09:59 AM.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  2. #2

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,852

    Re: Add-In to Replace Fonts

    As a further note, this could rather trivially be turned into an Add-In that could stay loaded and instantly change the MS Sans Serif font of any new form to whatever you wanted.

    I thought about that, but I don't really mind the "manual" approach that I took with this Add-In, not wanting to do things behind-the-scenes too much.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  3. #3
    Junior Member
    Join Date
    Jun 2017
    Posts
    26

    Re: Add-In to Replace Fonts

    This is incredibly useful for modernizing old projects that now run on a newer OS.

    What would be really useful is a font size option for today's higher res monitors.

  4. #4

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,852

    Re: Add-In to Replace Fonts

    Quote Originally Posted by cidtek View Post
    What would be really useful is a font size option for today's higher res monitors.
    Cidtek,

    I don't have all the details on the tip of my tongue, but this is really better covered with some manifesting, and telling your program to be DPI (and scalable) aware. LaVolpe (and others) have covered this in detail, and I'd encourage you to look into their work.

    The MS Sans Serif stuff isn't a True-Type font (TTF), and not even distributed on all versions of Windows 10. That's one reason it's important to get rid of it (with my utility). However, once that's done, then you can take advantage of all the DPI aware stuff.

    Best Regards,
    Elroy
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  5. #5
    Junior Member
    Join Date
    Jun 2017
    Posts
    26

    Re: Add-In to Replace Fonts

    Quote Originally Posted by Elroy View Post
    Cidtek,

    The MS Sans Serif stuff isn't a True-Type font (TTF), and not even distributed on all versions of Windows 10. That's one reason it's important to get rid of it (with my utility). However, once that's done, then you can take advantage of all the DPI aware stuff.
    Ms Sans Serif also was default sized at 8pt in VB6 which was OK back when the app was written. Now days Segui UI 10 point is the norm and that's what my customers want on a very old mature app. I can change the fonts in code but I need to see them in the IDE for control sizing.

  6. #6

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,852

    Re: Add-In to Replace Fonts

    cidtek,

    I'll look into this when I get some time. It probably wouldn't be too difficult, just following the same looping logic that the font name is following.

    However, just thinking through it, how would you want it to work? Would you want it to just change the MS Sans Serif 8pt to 10pt when they're found (on a specified option, of course)?

    Or, before getting started, would you want to specify how many font points increase you want? And then, we it finds a MS Sans Serif, it replaces it and also increases the size by the points you've specified?

    Would it also change the font size for fonts that aren't MS Sans Serif?

    --------------

    The more I think about this, it sounds like an entirely separate utility ... possibly working like this:

    • The interface looks much like the above.
    • But it only changes font sizes.
    • You can optionally specify a specific font name to target, or target all fonts.
    • You can optionally specify a specific font size to target, or target all sizes.
    • You specify how many points to increase (or decrease) the targeted font(s).

    Best Regards,
    Elroy
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  7. #7
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,995

    Re: Add-In to Replace Fonts

    Hello, my Project examiner already does this (allows to change any font name/size to any other font name/size).

  8. #8
    Junior Member
    Join Date
    Jun 2017
    Posts
    26

    Re: Add-In to Replace Fonts

    I already made a change to force size 10 but I think I will add a few options such as 8,9,10,11,12 in a droplist.

    Basically I came to same the ideas that you also put forth in your revision ideas list.

    I added Stay On Top code and am thinking of saving to registry the last font chosen and then removing the quick option buttons. My justification is my projects have a clean look with one font and it is most likely the same font I selected the last time I used the add-in.

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