Uploaded image for project: 'FOP'
  1. FOP
  2. FOP-2858

[PATCH] FontUtil.guessStyle/guessWeight is passed java.awt.Font.getName() which can return localized name

Attach filesAttach ScreenshotAdd voteVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.5, 2.2, 2.3, 2.4, 2.6
    • None
    • Windows 10 Pro
    • Patch, Important

    Description

      When InstalledFontCollection enumerates OS provided Fonts, the style/weight is guessed from java.awt.Font.getName();

      Originally it was Font.getFontName() method, which FOP-1452 fixed to getName(). As written in description of FOP-1452:

      Attaching patch which uses
      Font.getName(), tested on Windows XP. Another possibility would be to use
      Font.getFontName(Locale.ENGLISH).

       The latter option is exactly what I think it should be changed to, as I now experience on my Windows 10 box (all in house experiences same), that Font.getName() will return localized texts for style/weight, for most fonts, when user.language=da.

      The attached patch only targets passing proper name to FontUtil.guessXXX methods, which are vital for proper rendering of preview and printing (ps) for these fonts.

      However Java2DGraphicsState.updateFont(...) is also subject to bug, as Font.getFontName() is used,

      {{ boolean updateName = (!mapper.getFontName().equals(}}
      {{ getGraph().getFont().getFontName()));}}

       

      effectively comparing Font.getName() with Font.getFontName() which will not always match.

      Attachments

        1. guess_from_en_locale.patch
          1 kB
          Mikael Andersen
        2. font.png
          16 kB
          Mikael Andersen
        3. InstalledFontCollectionTest.java
          2 kB
          Mikael Andersen
        4. output.txt
          10 kB
          Mikael Andersen

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            mkamka Mikael Andersen

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified

                Slack

                  Issue deployment