Results 1 to 23 of 23

Thread: [RESOLVED] Fonts and VB

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2014
    Posts
    553

    Resolved [RESOLVED] Fonts and VB

    Can any valid Windows Font be used with VB programs?

    I've tried a few fonts from the web, but not all seem to work and I wasn't sure if I just download some bad files or if I need to use a specific type of font.

    Thanks.

  2. #2
    Fanatic Member Spooman's Avatar
    Join Date
    Mar 2017
    Posts
    868

    Re: Fonts and VB

    Stuck

    Short answer .. I dunno.

    But ..
    • Which fonts worked?
    • Which didn't?
    • Where did you store them?
    • How did you "call" them?


    Spoo

  3. #3
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,909

    Re: Fonts and VB

    Hi Stuck,

    Are the fonts you downloaded true type fonts (.TTF)? I don't use all that many different fonts, but I do use a few. And I find it strange that you're having problems.

    I've always thought that fonts, especially TTF, work at a level lower than the VB6 language. At some point, all fonts have to be rendered into pixels, but I just always felt like that was done by Windows, so the particular font shouldn't matter to VB6.

    Something else I'd test is to see if these fonts work in something like Word (or Wordpad). You may have just gotten some funky font files. Sometimes, font makers will put funky stuff in the font file until you purchase a full version.

    Maybe those thoughts will help,
    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.

  4. #4
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,669

    Re: Fonts and VB

    I agree: first check if the fonts that you installed work with other programs.

    You need to install the fonts, not just copy them.
    To install a font, go to the control panel, Fonts, menu File, Install new font, and follow the steps.

  5. #5
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,909

    Re: Fonts and VB

    Actually, all later versions of Windows (Vista does it) will auto-install fonts if they're drug into the C:\Windows\Fonts folder. That's one of those tricky things that Windows does.

    Too bad it doesn't do something similar with C:\Windows\System32 (or C:\Windows\SysWOW64) and OCX files.

    @Eduardo: You do make a good point though. @Stuck: You are somehow getting your fonts into the C:\Windows\Fonts folder, right?
    Last edited by Elroy; Sep 19th, 2017 at 01:44 PM.
    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.

  6. #6
    Frenzied Member
    Join Date
    Apr 2012
    Posts
    1,272

    Re: Fonts and VB

    Quote Originally Posted by Eduardo- View Post
    I agree: first check if the fonts that you installed work with other programs.

    You need to install the fonts, not just copy them.
    Actually, you can use fonts without installing them, using something lilke

    Code:
    Option Explicit
    Private Declare Function AddFontResourceEx Lib "gdi32" Alias "AddFontResourceExA" (ByVal sFIleName As String, ByVal lFlags As Long, ByVal lReserved As Long) As Long
    
    Private Const FR_PRIVATE As Long = &H10
    
    Public Function InstallFont(pFontPath As String) As Long
     InstallFont = AddFontResourceEx(pFontPath, FR_PRIVATE, 0&)
    End Function
    
    
    Private Sub Form_Load()
    Dim MyReusableFont As StdFont
    
       InstallFont "C:\MyFont.ttf"
       Set MyReusableFont = New StdFont
       With MyReusableFont
          .Name = "MyFont"
          .Bold = True
          .Size = 24
       End With
    
       Set Text1.Font = MyReusableFont
       Set RichTextBox1.Font = MyReusableFont
    End Sub
    If you don't know where you're going, any road will take you there...

    My VB6 love-children: Vee-Hive and Vee-Launcher

  7. #7
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,669

    Re: Fonts and VB

    Quote Originally Posted by ColinE66 View Post
    Actually, you can use fonts without installing them, using something lilke

    Code:
    Option Explicit
    Private Declare Function AddFontResourceEx Lib "gdi32" Alias "AddFontResourceExA" (ByVal sFIleName As String, ByVal lFlags As Long, ByVal lReserved As Long) As Long
    
    Private Const FR_PRIVATE As Long = &H10
    
    Public Function InstallFont(pFontPath As String) As Long
     InstallFont = AddFontResourceEx(pFontPath, FR_PRIVATE, 0&)
    End Function
    
    
    Private Sub Form_Load()
    Dim MyReusableFont As StdFont
    
       InstallFont "C:\MyFont.ttf"
       Set MyReusableFont = New StdFont
       With MyReusableFont
          .Name = "MyFont"
          .Bold = True
          .Size = 24
       End With
    
       Set Text1.Font = MyReusableFont
       Set RichTextBox1.Font = MyReusableFont
    End Sub
    Yes, I know, I was talking about the normal case.

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2014
    Posts
    553

    Re: Fonts and VB

    This is the first time I've ever tried using a non-standard font and I believe that I have installed it properly as I am able to access it with other programs.

    I just recently install Service Pack 6 for Visual Basic, but other then that no other modification have been done for some time with my System.

    I am very reluctant to download anything so searching and loading new fonts does not exactly make me feel all that warm and fuzzy. Basically I'm suspicious of every website and any files that I add to my system.

    It started out sounding so simple, search for a specific font to use with a custom program written in VB.

    Here is a picture of the font I've been searching for.


    Name:  Font_Image.PNG
Views: 2541
Size:  12.4 KB


    I located a close example called Dymaxion which is a True Type Font which I found on 1001Fonts website, and here is what it looks like.


    Name:  Dymaxion_Example.jpg
Views: 2541
Size:  6.2 KB


    This all seemed very simple and straight forward, and the font I found looks to be similar in appearance and style. The License for the font states that it free to use for both personal and commercial royalty free.

    The font can be found here:

    http://www.1001fonts.com/dymaxionscript-font.html

    If anybody knows of other fonts which are similar or perhaps even a better match then the one I found, I'd be interested in trying to download and try them to see if they might work.

    Thanks.
    Last edited by stuck-n-past; Sep 19th, 2017 at 02:49 PM.

  9. #9
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,669

    Re: Fonts and VB

    I was able to install it and here is a screenshot of a form:

    Name:  Font.JPG
Views: 2604
Size:  17.8 KB

  10. #10
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Fonts and VB

    Seems to work fine for me:

    Name:  sshot.png
Views: 2579
Size:  3.0 KB

    First label has 26pt font, second 12 pt font.

    Aside from the font being teensy for whatever reason it looks ok though it is missing everything but the printable ASCII subset. Depending on your locale settings there might be issues with its omission of accented Roman characters.

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2014
    Posts
    553

    Re: Fonts and VB

    Hey guys thanks so much for doing that, installing the font and testing it.

    Curious, did you load the font through the system or programmatically using the example code above?

    Dilettante: I noticed something a little odd when I was viewing a project related file with WordPad using the Dymaxion font as some of the special characters were missing but I didn't think that would be enough to keep my VB program from working. I'm going to try and find another similar font and try loading it.

    It looks as if I'm heading down the rabbit hole once again. It's only Tuesday and I've already had a heck of a week.

  12. #12
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,909

    Re: Fonts and VB

    Say Stuck, recognize that Dilettante's caveats are with the font you've chosen, and not VB6. For other locales, that font is going to have problems regardless of what program is using it.
    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.

  13. #13
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Fonts and VB

    I tested by installing the font, not by trying to use it as a private font.

  14. #14

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2014
    Posts
    553

    Re: Fonts and VB

    Elroy, starting to sound like it's time to find another font regardless of whether I can get this one to load or not.

    Do fonts have any sort of category or standard as to how complete or compatible they might be for all possible locale settings?

  15. #15
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,909

    Re: Fonts and VB

    Hi Stuck,

    Well, that's a bit of a loaded question. I'm not sure there's any font that's going to be totally "complete". However, you can find fonts that have a relatively complete ANSI character set that will address all the romantic languages. (That's the languages that have an alphabet that sounds something like our ABCs.) But there are many non-romantic languages around. If you find a font that has the entire Unicode (UTF16) character-set in it, that'll be about as complete as I'd think you would ever find. However, I'm not even sure I've seen a font that's even that complete.

    So, as you see, to answer that question, you really have to make some decisions about what you're going to use it for, and how widely (culturally/linguistically) you expect your program to be distributed. For me, I'm personally quite tied to the ASCII (English alphabet), even though I have users in Montreal and and also a couple of Spanish speaking locales. Mexico City is also discussing an installation.

    Actually, let me take that back. There's a questionnaire's section to my software, and I do have both Spanish and French versions for some of those questionnaires, and they do use the standard fonts.

    Therefore, a full ANSI font (ASCII with the addition of characters with the tildes, accents, and such) gets it done for me.

    Good Luck,
    Elroy

    EDIT1: I haven't really done thorough research, but I do believe all the fonts that come with Windows are complete with respect to tildes and accents, but not necessarily for all the non-romantic characters.

    EDIT2: And, before someone calls me on it, I probably should have said "Greco-Roman languages" rather than "Romantic languages". There is a category for roman languages, but it's a bit different than what I was trying to talk about. I'm just talking about those languages that have a somewhat familiar sounding alphabet: ABC, Alpha Beta Gamma (not sure where C went, but it counts).
    Last edited by Elroy; Sep 19th, 2017 at 04:47 PM.
    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.

  16. #16
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,669

    Re: Fonts and VB

    For Spanish special characters it seems to be fine:

    Name:  spChars.JPG
Views: 2510
Size:  4.9 KB

  17. #17

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2014
    Posts
    553

    Re: Fonts and VB

    This is one of those situations where it seems like the special font while nice, might be a little bit more then it's worth. As I am removed from the end product, I'm finding it hard to recommend continuing with the use of a 3rd party font and at the same time provide any sort of a guarantee that it won't come back to bite them later down the road, especially with my limited knowledge of custom fonts.

    With that said, if I'm using 'standard' Microsoft fonts such as "MS Sans Serif", will that work in most locale settings?

  18. #18
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,669

    Re: Fonts and VB

    Quote Originally Posted by stuck-n-past View Post
    This is one of those situations where it seems like the special font while nice, might be a little bit more then it's worth. As I am removed from the end product, I'm finding it hard to recommend continuing with the use of a 3rd party font and at the same time provide any sort of a guarantee that it won't come back to bite them later down the road, especially with my limited knowledge of custom fonts.

    With that said, if I'm using 'standard' Microsoft fonts such as "MS Sans Serif", will that work in most locale settings?
    What will be the font for, in the first place?

  19. #19

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2014
    Posts
    553

    Re: Fonts and VB

    So has anybody ever run across a Windows warning message like this:


    Delete...

    Windows is currently working with a file.

    Either wait for Windows to finish, or close it before you quit Windows.

    When adding a new disk, I went to shutdown and got the above message with noway around it but to force a restart. Once the system came back up, and after checking for any viruses, VB decided to play nice and loaded the font. Haven't a clue to what file was being used by Windows but its a good bet it was related to the font problem I was having.

    Typical, once I've decided not to use the font, I get it to load!

    Hey thanks for all of the help, I think I'm going to stick with standard Microsoft fonts just to play it safe, I know what a cop-out.

  20. #20

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2014
    Posts
    553

    Re: Fonts and VB

    Eduardo - The font was being used for title-headings on all of the project forms, not the normal Windows title-bar text, but an application specific title that appears on all of the programs windows.

  21. #21
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,669

    Re: Fonts and VB

    Quote Originally Posted by stuck-n-past View Post
    Eduardo - The font was being used for title-headings on all of the project forms, not the normal Windows title-bar text, but an application specific title that appears on all of the programs windows.
    If you can stay with MS standard fonts it's good, but if you still want to go the way of using that font, first think what texts will be displayed with the font.
    If the titles are in English you'll be fine.

    But take into account that you'll have to install the font and register it on the target Windows with the installer of your program, or otherwise use it as a private font with the code above. Still, you'll have to ship it with the program.

    None of these is neccesary if you use standard fonts.
    But still with standard fonts, not all the fonts are in all version of Windows.

    There are some fonts that are universal on Windows.
    I use "Arial", "Microsoft Sans Serif" (Not "Ms Sans Serif") and sometimes "Small fonts".

    If Windows doesn't have a font, it will try to replace it with a most similar one, but I don't know how it knows the features of a font that it doesn't have (I guess that this information would need to be stored in the program that uses it in some way, so Windows can find the most similar font that it has, anyone reading this knows?).

  22. #22

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2014
    Posts
    553

    Re: Fonts and VB

    Eduardo - Thanks for all of the information, I'm keeping it simple and standard fonts win hands down.

  23. #23
    New Member
    Join Date
    Dec 2021
    Posts
    7

    Re: [RESOLVED] Fonts and VB

    ..... How to delete this post?

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