Announcement

Collapse
No announcement yet.

Font Size - Character Width

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Font Size - Character Width

    I am sure this has been asked and answered before but searching the forums, I find nothing so I thought I would ask again.

    Is there a font that is "Standard" and the character width vs height is the same (or some ratio thereof)???

    I am attempting to display a file in a textbox, that appears as it would in notepad, but either font, or format or something is getting in the way.

    Code Not shown I know, but not sure how to display an example. But from my knowledge (for over-exaggeration) lets say a character is 3 pixels wide and 5 pixels high. How would I show that same in a PB textbox, so that it appears the same as it would in whatever editor that created it??? (NotePad, WordPad, Office, OpenOffice, Corel, etc.....)

    Its simple text, and trying to avoid any formatting beyond $CRLF level of formatting....I just would like to make what is seen in one, appear as close to the same in the other....only problem is that I am missing something (or forgetting something)
    Engineer's Motto: If it aint broke take it apart and fix it

    "If at 1st you don't succeed... call it version 1.0"

    "Half of Programming is coding"....."The other 90% is DEBUGGING"

    "Document my code????" .... "WHYYY??? do you think they call it CODE? "

  • #2
    Courier New vs Times New Roman
    Courier New vs Times New Roman
    Furcadia, an interesting online MMORPG in which you can create and program your own content.

    Comment


    • #3
      I get the concept Colin (unless I am still missing it)
      in my case I am out to just show generic text (same size) (Hopefully same font, or if not then a way to detect the font from opening the file???)

      and then display the same in the textbox, as it would appear in the editor that created it.
      Engineer's Motto: If it aint broke take it apart and fix it

      "If at 1st you don't succeed... call it version 1.0"

      "Half of Programming is coding"....."The other 90% is DEBUGGING"

      "Document my code????" .... "WHYYY??? do you think they call it CODE? "

      Comment


      • #4
        and then display the same in the textbox, as it would appear in the editor that created it.
        [Smiley for 'scratching my head' goes here]

        Unless the text was created either in a standard format containing font info (e.g., rich text), or is in a proprietary format containing font info (eg., PDF, MS-Word), there is no such thing as "as it would appear in the editor that created it."

        MCM
        Michael Mattias
        Tal Systems Inc. (retired)
        Racine WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          MCM
          For example
          Code:
                 Z
                 |
                 | /        
                 |/      
          -------x------X 
                / 
               /   
              Y
          made in notepad, would appear in PB Textbox as
          Code:
                 Z
                 |
                   | /        
                 |/      
              -------x------X 
                / 
             /   
              Y
          or something similar

          Please note that ecapsulating in [ q u o t e ] [ / q u o t e ] stripped all spaces tabs or whatever (so a bad example) but encapsulating in [ c o d e ] [ / c o d e ] seemed to demo what I meant
          Engineer's Motto: If it aint broke take it apart and fix it

          "If at 1st you don't succeed... call it version 1.0"

          "Half of Programming is coding"....."The other 90% is DEBUGGING"

          "Document my code????" .... "WHYYY??? do you think they call it CODE? "

          Comment


          • #6
            Dunno, wild airy guess is that if you set the font for the textbox to be courier new, you should get the first example as shown, unless the file has tabs, in which case you'd need to guess the tab width for that particular document and make adjustments.
            Furcadia, an interesting online MMORPG in which you can create and program your own content.

            Comment


            • #7
              If you have fixed pitch information, use a monospaced font. (Courier New is monospaced).

              If you want to find monospaced fonts installed on the current system, use EnumFontFamiliesEx and set the two low-order bits of LOGFONT structure to FIXED_PITCH and list fonts that way.

              FWIW (this is a rerun), there are four fonts guaranteed to be installed on all Windows's systems (9x==>Vista)

              Courier New - monospaced serifed
              Times New Roman - proportional serifed
              Arial - proportional sans serif
              Symbol - weird stuff

              I think starting with XP there are some other fonts (Tahoma?) always installed.

              Also, you can get a handle to an installed fixed pitch font for DISPLAY use using GetStockObject(%ANSI_FIXED_FONT)
              Michael Mattias
              Tal Systems Inc. (retired)
              Racine WI USA
              [email protected]
              http://www.talsystems.com

              Comment


              • #8
                Thanx for the hints MCM
                (When it comes to graphics, or Fonts, I am clueless beyond Size, Bold, Italix, or Pixels, in a graphical world)

                I can see the difference if side by side, but to me, I would not know Times vs Courier by name if it jumped up and bit me.

                Taking my minor knowledge in the area
                Courier New - monospaced serifed
                Times New Roman - proportional serifed
                Arial - proportional sans serif
                Symbol - weird stuff
                Gleemed that MonoSpace would basically be same #pixels height and width reguardless of the character printed. and Proportional would be some ratio depending on the character printed.

                Because I was after a square block reguardless of the character within that block, I tried Courier New (Notepad format unknown at the time, and my program just saying "Courier New") and results were pretty close (off by a char or 2 from left to right (minor details)

                Then I copy-paste into the final program and sure enough it got botched.

                So I started thinking "Just the facts Ma'ammmm....just the facts" and set Notepad and my program to the same font. And Copy Paste botched again....so I set out to find what the end program was using.

                Set all 3 the same, and somewhat the same output no matter the program in question (makes sense right? they all use the same font (maybe not size) but same font)

                (Still not sure what "Serif" means...but that is up to researching)

                At least now I have something to work with, and maybe a solution.

                I do have to research but "GetStockObject(%ANSI_FIXED_FONT) " is that only valid from my own program? or can I somehow get the font that another program is using? (or am I confusing things????)
                Engineer's Motto: If it aint broke take it apart and fix it

                "If at 1st you don't succeed... call it version 1.0"

                "Half of Programming is coding"....."The other 90% is DEBUGGING"

                "Document my code????" .... "WHYYY??? do you think they call it CODE? "

                Comment


                • #9
                  Cliff, as others have said, Courier new is a fixed font. Others include
                  Generic DOS, MS Linedraw, and usually Terminal.

                  I got MS Linedraw and Generic DOS from Lance Edmonds when i got dllprint.
                  Im sure there are others (fixed fonts).
                  Client Writeup for the CPA

                  buffs.proboards2.com

                  Links Page

                  Comment


                  • #10
                    Explanation of "serif"

                    A "serif" is a part of a character. If you didn't know what a serif was, you might say that some characters have little protrusions that extend beyond the main stroke lines of the character. At the bottom, you might call them "feet", but they can also appear at other points, such as at the top of the uppercase characters "A", "S", "P", "W", etc.

                    The Arial font is "sans serif", from the French for "without serif". Note how there are no fancy little protrusions on any of the characters.



                    A font that has a "fixed width" uses the same width for every character. If you typed a line of "W"s and underneath a line of "i"s, the characters would align over each other because each is set using the same width. This is also called "mono-spaced", from the Latin "mono" for "single" (as in a single, indivisible unit). The Courier font is a monospaced font.

                    A font is "proportional" when each character is set on a line using its own width. Thus the character "w" takes more than twice the space on the line than the character "i". If you were to create the same two lines of characters one above the other, you'd either get many more i's on the line than w's, or if you typed the same number of characters in each line, the line of i's would be a lot shorter in overall length.


                    In the world of typesetting, there are many other font characteristics, but we don't often use them in ordinary screen-based programs. For example, there is "kerning", a way to reduce the spacing between a particular pair of characters, usually in order to improve their appearance. Without a kerning reduction, the "AW" pair could appear to have too much "air" between them, and some readers would hesitate, trying to determine if they were together or separate. (AWAY or A WAY) A kerning reduction would move the upper left arm of the W further to the left, to a point that is to the left of the right side of the A. That would give the effect of nestling the two characters a bit closer together, which is generally thought to be a more pleasant appearance, and makes them easier to read as a unit.


                    Fonts may also have "elisions": where two characters actually combine when they appear together. We don't use elisions in native English, but sometimes when translating certain words phonetically, we do. For example, you might see OE squashed together as if they were accidentally overprinting each other. It's not an accident - it's elision. The OE sound is common in German, such as in the name Goethe. We use two separate characters, but in German, it's the one, elided character: Œ Gœthe (I think that name actually gets some other diacritical marks, but I'm not sure which.)

                    I believe the language with the most elaborate elisions is Arabic. In 1979, I tested a typesetting program for Bobst/Varisystems that was capable of primary entry in either English or Arabic, and allowed insertions in either English or Arabic. Since English inserts L-to-R, and Arabic inserts R-to-L, the rules were incredibly complex, especially as they pertained to line breaks during an insert process. Anyway, in Arabic, almost every character has more than one form. Some get elided when the next character is set, and some continue to get elided as the second and subsequent characters get set. Beautiful to see! The guy who programmed it was Gavon Balharry, a genius, not to mention a really great person. (It seems he's still consulting in Switzerland...)
                    Added: I remembered this morning that the Arabic elisions were called something like "kashidas", but I haven't verified it yet.


                    So that's a bit of font background for you - if not immediately applicable, I hope you at least find it interesting...
                    Last edited by John Montenigro; 20 Mar 2009, 11:27 AM.

                    Comment


                    • #11
                      Fonts may also have "elisions": where two characters actually combine when they appear together. We don't use elisions in native English, but sometimes when translating certain words phonetically, we do. For example, you might see OE squashed together as if they were accidentally overprinting each other. It's not an accident - it's elision. The OE sound is common in German, such as in the name Goethe. We use two separate characters, but in German, it's the one, elided character: Œ Gœthe (I think that name actually gets some other diacritical marks, but I'm not sure which.)
                      In German vowel pairs: ae, oe and ue are frequently represented with a single letter with an umlaut (Latin: Diaeresis): ä, ö and ü and consonant pair: ss may be represented with: ß

                      Comment


                      • #12
                        > A "serif" is a part of a character. ...

                        Excellent explanation, both informative and well-written.

                        And to think it was (well, it SEEMS like) only yesterday you were a shy "newbie" asking beginning programmer questions.

                        Tempus sure does fugit when you're having fun.
                        Michael Mattias
                        Tal Systems Inc. (retired)
                        Racine WI USA
                        [email protected]
                        http://www.talsystems.com

                        Comment


                        • #13
                          the part about fonts that eludes me and still seen it all too often and hit home a bit

                          Fonts may also have "elisions": where two characters actually combine when they appear together.
                          could almost (if not explain) why a "=" sign would count as 2 characters in real spacing (depending on the font)

                          I guess my original question kinda went mute and point cause what I am working with is fixed (limited) and I was trying to match up (what you see is what you get)

                          turns out the final test (although same font) I am limited to a field about 1/2 (maybe a lil more) than what I was testing....so unless all fonts, sizes, and display match...my answer in this case is..."It Depends"
                          Engineer's Motto: If it aint broke take it apart and fix it

                          "If at 1st you don't succeed... call it version 1.0"

                          "Half of Programming is coding"....."The other 90% is DEBUGGING"

                          "Document my code????" .... "WHYYY??? do you think they call it CODE? "

                          Comment


                          • #14
                            Cliff,

                            Sorry, I thought it was apparant that the answer to your question had been given by the others who posted before me.

                            Simply stated, the answer is that you need to use a "monospaced" font such as Courier. The font contains the information that determines how each individual character is to be displayed.

                            Although you can select a different size, bolding, italic or not, and perhaps some other characteristics, these could be considered "external" settings. They do not change the basic shape of the characters in the font.

                            You will notice a difference in the basic character shapes from one font to the next - that's what makes them fonts! It's the overall style and "feel" that the font artist (yes, and they get paid big bucks for creating them) is trying to convey. That's why Goudy and Bookman and Times and Park Place exist - each conveys a different feel. One is scholarly, another businesslike, another freewheeling, stylish, and ritzy. They're intended for different uses and audiences. You can't sell soldering equipment to people using a Park Place font, but it might be great for selling brides' dresses...

                            So any program that displays or prints characters in a particular font, provided they are using the same size, bolding, italicization, will display precisely the same characters. Arial 10 bold will NOT look different in your PB program than in your Word document. Arial 10 bold will be the same everywhere.

                            Your question seemed concerned with the fact that when a particular font is not specified, the program may use an unexpected font that changes the way you expect to see the characters displayed. That's a different problem. You should be able to tell your program what font to use.


                            It sounds like you have seen your file displayed in Notepad and want your textbox to display the file in the same font. Here's the problem. Text files do not contain font specifications - only the characters themselves.

                            Word processor files contain the characters along with all the various information for formatting sections, pages, paragraphs, etc, down to individual characters.

                            If your program is trying to display a word procesor file, it needs to know how to interpret all that non-character information.

                            But if your program is trying to display just a file of characters, the choice of how to display those characters is between you, the program, and the OS.
                            Added: You need to find out which font that program uses as its default for plain text, then have your program use the same. I believe Notepad uses Courier Regular 10point.

                            PBCC defaults to using the console's screen font - a monospaced font.
                            PBWin, where it is not constrained by Windows controls, will permit you to select from whatever fonts are installed on the machine.

                            I don't know if you can change the display font of a textbox from the system default (which uses a proportional font) to a font of your choosing (which sounds like you want to use a monospaced font).

                            However, you may want to use a rich text control instead of a textbox. That will allow you to set the font, size, etc.
                            Last edited by John Montenigro; 20 Mar 2009, 11:24 AM.

                            Comment


                            • #15
                              Originally posted by Cliff Nichols View Post
                              the part about fonts that eludes me and still seen it all too often and hit home a bit

                              could almost (if not explain) why a "=" sign would count as 2 characters in real spacing (depending on the font)
                              No.

                              First, it's unclear what you mean by "real spacing".

                              Second, a character such as the equal sign would not have arbitrary widths or spacings - these are designed into the font. Within the use of that particular size, bolding, italicization, etc, and presuming that kerning or letterspacing has NOT been applied, the widths and spacings would always be constant.

                              What you are most likely observing is how a proportional font is displayed.

                              Rather than try to explain it here, and depending on how deep you want to go, I'd suggest you research font designs online. There's more material than you can imagine (or than I want to try to recreate here!).


                              For the short term, however, think of your monospaced plain text as existing in a grid of equal little boxes - all boxes exactly the same height and width, and each containing only one character.

                              The boxes around the characters in a proportional font are NOT all the same widths - they are "proportional" to the width of each character. Since the boxes of the grid are NOT all the same widths, the characters will not line up.


                              Bottom line: if characters are not lining up the way you want, switch to a monospaced font like Courier.

                              Comment


                              • #16
                                Bottom line: if characters are not lining up the way you want, switch to a monospaced font like Courier
                                OR... (the long way for sure)... use TextOut or DrawText to print characters one at a time at known equispaced (in pixels) locations.
                                Michael Mattias
                                Tal Systems Inc. (retired)
                                Racine WI USA
                                [email protected]
                                http://www.talsystems.com

                                Comment


                                • #17
                                  Originally posted by Michael Mattias View Post
                                  > A "serif" is a part of a character. ...

                                  Excellent explanation, both informative and well-written.

                                  And to think it was (well, it SEEMS like) only yesterday you were a shy "newbie" asking beginning programmer questions.

                                  Tempus sure does fugit when you're having fun.

                                  Thanks, Michael, I appreciate the feedback!

                                  I was doing Tech Writing for typesetting systems long before I learned programming... or was it during that experience that I began learning programming?? so, it's a topic with which I've had extensive experience.

                                  And I still ask newbie "beginning programmer questions" - there's much I have yet to learn. And, I'm pretty sure I was never shy...

                                  But if you need something explained, I'm your guy. Let me know if your program needs a good user manual or your business needs a process written up for people to be able to use easily, or you're trying to specify how your system should work! My rates are very reasonable!

                                  Comment

                                  Working...
                                  X