Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSvgGenerator how to display medium weight font via SVG file?

QSvgGenerator how to display medium weight font via SVG file?

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 1.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mireiner
    wrote on 4 Mar 2017, 17:44 last edited by mireiner 3 Apr 2017, 19:51
    #1

    Hi there,

    does anyone know a workaround of this QSvgGenerator Qt Bug?
    https://bugreports.qt.io/browse/QTBUG-55780 (Please vote this up)

    I simply want to display a medium weight font (for example 'Roboto Medium' font) via SVG file. SVG font-weight=500 is the value for medium fonts.

    Todays Browser recognize SVG font-weight values that are full hundreds: 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900.
    (For example 400=Normal, 500=Medium, 700=Bold etc.)

    Unfortunately QSvgGenerator converts QFont::Weight (0-99) values just by multiplying them by ten to get the resulting SVG font-weight values (100-900).

    Only the QFont::Weight constants: QFont::Light, QFont::Normal and QFont::Bold are not done this way. They are converted to valid values of full hundreds. For example QFont::Normal (QFont::Weight=50) is converted to SVG font-weight=400 (Normal).

    The problem is:
    QSvgGenerator converts QFont::Medium constant (Font::Weight=57) to SVG font-weight=570, which is a non valid SVG font-weight value.
    QSvgGeberator converts QFont::Weight=50 set by number to SVG font-weight=400 (Normal).

    The latter happens because QSvgGenerator converts the QFont::Normal constant (QFont::Weight=50) to SVG font-weight=400 (see example above).

    Is there any working solution to force QSvgGenerator to set the SVG property font-weight=500 for a medium font?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 4 Mar 2017, 21:55 last edited by
      #2

      Hi,

      Did you saw the "inline" patch proposed by the original poster ? Apply it to the QtSvg module and build it. You don't need to build the whole of Qt, just that module.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      M 1 Reply Last reply 4 Mar 2017, 23:00
      1
      • S SGaist
        4 Mar 2017, 21:55

        Hi,

        Did you saw the "inline" patch proposed by the original poster ? Apply it to the QtSvg module and build it. You don't need to build the whole of Qt, just that module.

        M Offline
        M Offline
        mireiner
        wrote on 4 Mar 2017, 23:00 last edited by mireiner 3 Apr 2017, 23:03
        #3

        @SGaist
        Yes I saw the patch.

        Today I tried to build just the svg module. Never build any Qt module from source before. But although the svg module is a small package I wasn't able to build the Qt5Svg.dll which is needed for Windows. I did not setup any extra things like paths or so for the build process. Could this be the problem?

        There are more than one *.pro file in the package.

        Building qtsvg.pro in the 'qtsvg' base directory I got error messages just by opening the project file: 'Project MESSAGE: cmake executable not found. Not running CMake unit tests'.

        Building svg.pro in 'qtsvg/src' went fine. All *.obj files were sucessfully build but no Qt5Svg.dll which is needed for Windows.

        Do you know what the problem might be?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 4 Mar 2017, 23:16 last edited by
          #4

          qtsvg.pro is the right to open. That just a warning that you can safely ignore.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • M Offline
            M Offline
            mireiner
            wrote on 5 Mar 2017, 00:30 last edited by mireiner 3 May 2017, 00:49
            #5

            @SGaist
            It worked, thank you very much!!

            Build option: Shadow-Build was the problem. By default it is turned on. After deactivation of Shadow-Build the Qt5Svg.dll build just fine.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 5 Mar 2017, 20:22 last edited by
              #6

              Great !

              Happy coding :)

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1

              1/6

              4 Mar 2017, 17:44

              • Login

              • Login or register to search.
              1 out of 6
              • First post
                1/6
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved