What is a hinting em size? (GlyphTypeface.GetGlyphOutline)

Answered What is a hinting em size? (GlyphTypeface.GetGlyphOutline)

  • 6 august 2012 10:03
     
     

    Hello,

    I wonder what should I pass to the Systém.Windows.Media.GlyphTypeface.GetGlyphOutline as a hintingEmSize parameter, since the size to hint for in points in MSDN does not help much. Moreover it seems this parameter is being ignored anyway. So what is the purpose or what was the intent with this?

    Thank you,

    Jan

Toate mesajele

  • 6 august 2012 14:52
     
     

    I have no idea what you are trying to do, but I think it is not important in order to provide some light here, hopefully.

    The EmSize is really "the size of the uppercase letter M".  Usually this is the widest and tallest letter in a font.  Whatever you are trying to do allows you to hint the potential size of this letter M so (I am guessing) the class/object/etc. can take an educated guess for size calculation, or scrollbar positioning, etc.


    Jose R. MCP
    Code Samples

  • 6 august 2012 14:57
     
     
    I just want to render a glyph and obviously need to pass a value there. I am not sure how the 'hint' I supply is supposed to influence the returned geometry...
  • 9 august 2012 14:08
    Proprietar
     
     
    As mentioned, EM size is the design unit size of an upper-case ‘M’ for the font.  The “EM square” is the reference grid on which glyphs are designed.  The typical size of the square (width and height) is 2048, so you should be fine just using that.  Since it is only a hint, it does not have to be exact, but again, this should be a match for most fonts.  Of you wanted to, you could obtain the actual value for a particular font by using the Win32 API, GetOutlineTextMetrics, and then look in the returned structure’s otmEMSquare field.

    Trevor Hancock (Microsoft)
    Please remember to "Mark As Answer" the replies that help.

  • 10 august 2012 12:42
     
     

    Thanks for your reply, but that's still not it. I do know what em is about, I just do not know what should the hint be.

    Your both solutions, i.e. use fixed value that most fonts use, or finding out the actual value, could have been done by the framework itself already, if it needs the value for anything. So what is the hint supposed to be used for, so that it does not need the exact value?


  • 10 august 2012 15:18
     
     

    Hello,

    http://www.microsoft.com/typography/tools/trtalr.aspx

    http://www.microsoft.com/typography/TrueTypeHintingVersus.mspx

    These documents are about the hint. Hinting is the grid fitting. There is example there say ,12pt font (72pt is 1 inch) on 96dpi display is shown on 16x16pixel that is 72/12 = 1/6 of inch for 96dpi display is 16pixels(96/6). Hinting is to fit font character to that grid because of division rounding(pixel are intergers and scaling font makes divisions). 

    The API says

    renderingEmSize The font size in drawing surface units.

    hintingEmSize  The size to hint for in points.

    I guest  to have 12pt on a 96dpi screen  renderingEmSize must me 16(surface units thatis  pixels) and hint must be 12(point ). Than you will have the hintered character on the  surface cordinates.

    Regards,




    • Editat de MDinc 10 august 2012 15:19
    • Editat de MDinc 10 august 2012 15:21
    • Editat de MDinc 10 august 2012 15:22
    •  
  • 10 august 2012 15:34
     
     

    Hello MDinc, thank you... but... the GetGlyphOutline returns a Geometry, i.e. vector data... so it should not do the hinting at all if I understand it correctly.

    Even if it was rasterizing, why would one want to "hint for" different size than render? Why it could not use the renderingEmSize?

  • 10 august 2012 16:46
     
     Răspuns

    Hello,

    The API returns  outline of the glyph in Drawing Surface units. Drawing surface(screen,printer) coordinates are intergers so the problem is actualy  scaling font to integer grid.  If you dump the model i gues you see path points are integer numbers.  a

    So rendering size is needed for rendering on to device pixel grid and hint size is font size in points. 

    If you want to render 12pt font to 96dpi surface then you use 16(16x16 pixel grid Msize ) for rendering or if you want to render to 72dpi surface then you will set 12 for renderingEmsize and 12 for hintsize. So 12pt font willbe hinted on surface. If the api knows your surface dpi the is no need that hint. Dont forget 12pt font is 12pt font its  exactly 1/6"  heigth font where ever you draw it on lcd, crt or, paper its height is always 1/6". Hint is for making the font look same. 

    Regards. 

    • Marcat ca răspuns de Jan Kučera 10 august 2012 17:26
    •  
  • 10 august 2012 17:25
     
     

    Okay, I see how hinting could be used if integer numbers were returned. DPI value would be as good as the hinting size, and I guess more intuitive for the callers to pass. It would make no sense to return it as a Geometry then, but it answers my question. 

    Thank you for your support!

    By the way, the API returns points in doubles.