Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

German Umlauts are not recognized by qt Text Item.



  • Hi all,

    i have a Rectangle Parent item and Text child Item inside it.
    the rectangle box has fixed width . The text is assigned with a fixed font size. the text of Text item varies. in order to fit long strings inside the Parent rectangle , i used property fontSizeMode: Text.Fit for Text item. so that font size will be adjusted to fit inside the rectangle.

    it is working fine with all the characters except German umlauts.
    for example ,if my text is "Over" in english , it is translated to "Über".
    In English in my code over text can't be fit inside rectangle with given font, hence qt reduces the font size using the Text.Fit property.
    In German in my code Über text can't be fit inside rectangle with given font, hence qt reduces the font size using the Text.Fit property.
    here qt is treating character Ü as english U and doing the font size adjustment without considering two dots above.
    so when i execute the code, the two dots in Umlaut character are coming above rectangle.

    0_1550149863341_dab3cfce-decf-414f-85ff-11930a7a1419-image.png

    regards,
    ayyappa.



  • anyone know how to resolve this, is there way to recognize if the character having added glyphs on the top using TextMetrics or any other Qt library item?


  • Moderators

    @AYYAPPA
    Maybe the font itself already has incorrect metrics? have you tried another font?

    Also the docs for fontSizeMode property say:

    The font size of fitted text has a minimum bound specified by the minimumPointSize or minimumPixelSize property and maximum bound specified by either the font.pointSize or font.pixelSize properties.

    did you check those minimum properties?



  • @raven-worx thanks for the response.
    i am extremely sorry to inform you that , this is not mistake from Qt, it's a mistake from my end , bad code.

    i anchor text items using baseline hence i usually don't use height property.
    so when i said fontSizeMode: Text.Fit ,Qt doesn't know height of Text Item to fit the text inside and assigning some height base don font size and font family.

    now i have externally set height for TextItem same as the boundary rectangle height and its working perfect and glyphs are displayed inside boundary.

    i am closing this issue as it is resolved. thanks for your help again.


Log in to reply