[Approved] Font Rendering Issues (1 Viewer)

offbyone

Development Group
  • Team MediaPortal
  • April 26, 2008
    3,981
    3,703
    Stuttgart
    Germany Germany
    Country flag
    • Thread starter
    • Moderator
    • #1
    After doing the News plugin I noticed that some pixels at the bottom of a Label are always clipped away when it is just a single line and has no margin. This shouldn't happen, so I dug into the code and think I found where the problem is coming from. The calculation of a text's height is not taking the full possible height into account. I did a small change and the result can be on the screenshots below. I simply added a very large label and set the background to black so we can see what the bounding box is .
    First pic shows current status, second after the fix. It also fixes the problem that single line labels are not exactly centered.
    I am not sure if the fix is correct, I haven't fully understood the font rendering yet, so someone with more knowledge in this are should check this (/me looks at @Albert).

    On a sidenote: a newer freetype binary is available (2.4.2 for win) and works fine with MP2.
     

    Attachments

    morpheus_xx

    Lead Dev MP2
  • Team MediaPortal
  • March 24, 2007
    11,397
    6,966
    Germany Germany
    Country flag
    The results on screenshoots look good.

    I did not check the current code yet and don't understand the changes in your patch, can you explain this more detailed, please?
    _charSet.MaxHeight = (int)Math.Ceiling(_charSet.RenderedSize * (face.bbox.yMax + Math.Abs(face.bbox.yMin)) / (double)face.height);
    • Why you calc with Math.Abs()?
    • Does this mean, that single line labels can be of different height, depending on the contained characters?
     

    offbyone

    Development Group
  • Team MediaPortal
  • April 26, 2008
    3,981
    3,703
    Stuttgart
    Germany Germany
    Country flag
    • Thread starter
    • Moderator
    • #3
    face is a struct from the freetype lib.
    face.bbox.yMin is negative and in order to get the correct max height I need to add yMax and yMin.
    From the freetype docs, it said that the bbox is the maximum enclosing of all characters in the font.
    The old code did not ever look at the bbox, only at height and ascender which seems was not the total a character can be when ascender and descender are taken into account.

    I had some fun with this: http://en.wikipedia.org/wiki/Typeface_anatomy
    and this: http://www.freetype.org/freetype2/documentation.html
     

    morpheus_xx

    Lead Dev MP2
  • Team MediaPortal
  • March 24, 2007
    11,397
    6,966
    Germany Germany
    Country flag
    We recently changed the text size calculation method that fixes the issues shown in images above. But now we have another problem when other fonts are used (here: MayaTypeUI): the new textsizes are calculated way too small :(

    For example see both screenshots, before and after font fix

    01_original_MayaTypeUI.png 02_AfterFontFix_MayaTypeUI.png

    I've added an extended patch, it works for both fonts.
     

    Attachments

    Albert

    MP2 Developer
  • Premium Supporter
  • February 18, 2008
    1,297
    1,130
    41
    Freiburg im Breisgau, Germany
    Germany Germany
    The last fix from october 27th was nonsense. Font calculation is a difficult subject. I am no expert in this, but I tried a better fix for the problem shown above. See branch FIX_FontHeightCalculation. offbyone and morpheus, can you please test if my fix fixes your problems? Thanks!
     

    offbyone

    Development Group
  • Team MediaPortal
  • April 26, 2008
    3,981
    3,703
    Stuttgart
    Germany Germany
    Country flag
    • Thread starter
    • Moderator
    • #7
    Tested your branch and couldn't find problematic rendering in the News plugin or anywhere I looked (Default and Reflexion skin).
    Didn't check the code, but as I said in the beginning - my fix was only a hack :)
     

    Albert

    MP2 Developer
  • Premium Supporter
  • February 18, 2008
    1,297
    1,130
    41
    Freiburg im Breisgau, Germany
    Germany Germany
    After some reading of font theory, I just reworked the branch again. In fact, the original code was correct, it only subtracted a fixed pixel from all text heights which produced the problem of the cut y's and g's.
    I removed this fixed value and added a fixed pixel to ensure there's enough place around the text to be completely rendered. I also changed some method names which were not correct and I improved some comments.
    Please check the Fix_FontHeightCalculation branch again!
     

    morpheus_xx

    Lead Dev MP2
  • Team MediaPortal
  • March 24, 2007
    11,397
    6,966
    Germany Germany
    Country flag
    Will check later today! I'm so happy that (if?) I don't need to tweak "hundreds" of skin styles :D
     

    Users Who Are Viewing This Thread (Users: 0, Guests: 1)

    OP Similar threads Forum Replies Date
    F Audio render and font error in my logs General Support 2
    S [solved] Live TV subtitle issue if not using 100% font General 31
    ajs [fixed] 4936 - Strange behavior of the font in the skin MediaPortal 1 35
    D Font size reduced. help. Skins and Plugins Installer (MPEI) 0
    doskabouter 1.23.0 Slow rendering times Bugreports 44
    C ARC Audio Renderer Changer: wo kann man es konfigurieren? Video & DVD 15
    A AAC 2.0 going out of sync Codecs, External Players 2
    1gkar A Couple of {On-going} Issues Within Various MP Versions General Support 4
    R MP2 GUI Issues General 7
    morpheus_xx [WiP] WIP 2.3 Fanart issues? MediaPortal 2 13
    morpheus_xx [Help Me!] Build issues on TeamCity MediaPortal 2 1
    W Not finding/matching new series - thetvdb issue? My TVSeries 3
    J [fixed] Import issue with alternate movie title matching the name of another movie Submit: Bug Reports 7
    1gkar Latest Intel HD4600 Drivers Issue General Support 1
    J Odd issues with Freesat EPG - MP2 General 18
    DHosein Mediaportal & Antimalware Service High CPU issue General Support 2
    J MediaPortal TV Server and Kodi media source issues General 9
    S Movie navigation issues in MP2 General 8
    cbr954rr Issue BOOTSUWRNQ with online videos? Plugin Development 1
    2BitSculptor MP1.23 release mediainfo issue? MediaPortal 1 Talk 4
    A TV Channel Combination - case issue Television (MyTV frontend and TV-Server) 0
    Edwardfc [solved] Mp 2.2.1 Configuration Issues - Goes to Sleep while playing Music General 6
    G Amazon Prime (Online Videos) Issue Plugin Development 6
    joecrow 1.22.0 MPE Manager issues. 1.22 5
    M [solved] MP2 v 2.2.1 Issue - Registry Key not created General 5
    Top Bottom