Questions on Fontforge internal scripting

WAY KYIWAY KYI Posts: 111
edited July 28 in Type Design Software
Anyone know Fontforge internal scripting ( not python ) can you answer these questions, please???

GlyphInfo( "Width" ) and GlyphInfo( "VWidth" ) function calls return Numbers or strings? If number, is it integer, decimal, hex or other? Is Width the selected glyph's length ( Horizontal )? Is VWidth the height of selected glyph? If not how can you get the glyph's width and height? Thanks
Tagged:

Comments

  • Thomas PhinneyThomas Phinney Posts: 2,357
    I am not sure what you mean by “glyph’s length.” Some common width values one might want are:
    - the advance width
    - left and right sidebearings (white space)
    - the marking width, which is to say the advance width minus both left and right sidebearings
  • Michel BoyerMichel Boyer Posts: 120
    edited July 29
    WAY KYI said:

    GlyphInfo( "Width" ) and GlyphInfo( "VWidth" ) function calls return Numbers or strings? 
    Those are numbers. GlyphInfo("Width") is the advance width. I don't know what GlyphInfo("VWidth") is meant to represent. The only numbers the ff scripting language knows are Integers and Reals; 0x32 is an integer, it is just the integer 50 (written in the hexadecimal notation).

    As Thomas said, there is another notion of width, what he called the marking width. With GlyphInfo("BBox") FontForge returns a representation of the bounding box which is the smallest rectangle with horizontal basis that contains the glyph. It is a four number array; the first two numbers are the coordinates of the bottom left corner. The last two numbers are those of the top right corner.

    The marking width is the width of the bounding box.

    Here is a script which I called "metrics"


    And here is the trace of execution on a Gentium font that dates back from 2008.


    As we can see the em size is 2048. However the bounding box of that Aringacute glyph has corners (0,0) and (1266,2207) which means that the glyph extends way above the ascent line and even above the line at the 2048 y-coordinate. That last number occurring in the bounding box may be what you are looking for and I guess that  2207 could indeed be called the "height" of that Aringacute glyph.
  • WAY KYIWAY KYI Posts: 111
    I am not sure what you mean by “glyph’s length.” Some common width values one might want are:
    - the advance width
    - left and right sidebearings (white space)
    - the marking width, which is to say the advance width minus both left and right sidebearings
    Thank you very much Mr. Phinney and Michel Boyer . This is the information I am looking for. Thanks
  • WAY KYIWAY KYI Posts: 111
    edited July 30
    WAY KYI said:

    GlyphInfo( "Width" ) and GlyphInfo( "VWidth" ) function calls return Numbers or strings? 
    Those are numbers. GlyphInfo("Width") is the advance width. I don't know what GlyphInfo("VWidth") is meant to represent. The only numbers the ff scripting language knows are Integers and Reals; 0x32 is an integer, it is just the integer 50 (written in the hexadecimal notation).

    As Thomas said, there is another notion of width, what he called the marking width. With GlyphInfo("BBox") FontForge returns a representation of the bounding box which is the smallest rectangle with horizontal basis that contains the glyph. It is a four number array; the first two numbers are the coordinates of the bottom left corner. The last two numbers are those of the top right corner.

    The marking width is the width of the bounding box.

    Here is a script which I called "metrics"


    And here is the trace of execution on a Gentium font that dates back from 2008.


    As we can see the em size is 2048. However the bounding box of that Aringacute glyph has corners (0,0) and (1266,2207) which means that the glyph extends way above the ascent line and even above the line at the 2048 y-coordinate. That last number occurring in the bounding box may be what you are looking for and I guess that  2207 could indeed be called the "height" of that Aringacute glyph.
    Thank you very much!!! This is exactly what I wanted. Let me try and test on FF script. So, wdth = GlyphInfo( "BBox" [2] )  and Hgth = GlyphInfo( "BBox" [3] ) will give me what I wanted?? I will back to you later. Thanks again.
  • Michel BoyerMichel Boyer Posts: 120
    edited July 30
    WAY KYI said:
     So, wdth = GlyphInfo( "BBox" [2] )  and Hgth = GlyphInfo( "BBox" [3] ) will give me what I wanted?? I will back to you later. Thanks again.
    The marking width is the width of the bounding box which is

    GlyphInfo("BBox")[2]-GlyphInfo("BBox")[0],

    For the height, that depends on what you need. If you want to take into account the part of the glyph that goes below the baseline, say for the character "g", then the height is the height of the bounding box: GlyphInfo("BBox")[3] - GlyphInfo("BBox")[1].

    If you need the largest y value, then it is GlyphInfo("BBox")[3].


  • WAY KYIWAY KYI Posts: 111
    WAY KYI said:
     So, wdth = GlyphInfo( "BBox" [2] )  and Hgth = GlyphInfo( "BBox" [3] ) will give me what I wanted?? I will back to you later. Thanks again.
    The marking width is the width of the bounding box which is

    GlyphInfo("BBox")[2]-GlyphInfo("BBox")[0],

    For the height, that depends on what you need. If you want to take into account the part of the glyph that goes below the baseline, say for the character "g", then the height is the height of the bounding box: GlyphInfo("BBox")[3] - GlyphInfo("BBox")[1].

    If you need the largest y value, then it is GlyphInfo("BBoThanx")[3].


    Thank you. I was thinking that too. Some glyph goes below the base line and I need to add that distance to the BBox[3]. Thanks a lot for helping me.
  • Michel BoyerMichel Boyer Posts: 120
    edited July 30

    Here is an example to illustrate the case of the width. The glyph is Open-Sans "fraction". This is a grab from FontForge


    As we can see from the picture the advance width is 266 (the distance between the two vertical lines).

    We can also easily deduce from the picture that BBox is [-391, 0, 655, 1462].

    The width of the bounding box is 655 + 391 = 1046.

    On the other hand the graph also shows that the right sidebearing has value -389 (in black at the top of the graphic) and the left sidebearing has value -391 (in black at the bottom left).

    It follows that the advance width minus the sidebearings is

    266 - (-391) - (-389) = 1046

    So Thomas' definition gives the same result but as you can see, the sidebearings measure "negative" white spaces and the result 1046 is larger than the advance width of 266.



  • WAY KYIWAY KYI Posts: 111
    Mr. Michel Boyer, this illustration give me the whole picture and I learn alot from you. Thank you very much for your help. You have corrected what I am thinking of moving glyph to another place based on the height and width. Instead, I should based on current location co-ordinate values along with the width and the height of the glyph. Thanks
Sign In or Register to comment.