Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8286645

Font.loadFont(String,double) fails because it does not correctly decode the URL

XMLWordPrintable

    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      Windows Temurin 17

      A DESCRIPTION OF THE PROBLEM :
      URL.getFile() returns a URL encoded string. It must be decoded to get a usable file name.

      URL decode this line:
      https://github.com/openjdk/jfx/blob/e24eeceb28741f4a044ea2cb0cb23a1174b27c66/modules/javafx.graphics/src/main/java/javafx/scene/text/Font.java#L470

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Font.loadFont("file:/C:/path%20with%20spaces/font.ttf", 12);

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      It returns a loaded font
      ACTUAL -
      It returns null

      ---------- BEGIN SOURCE ----------
      Font.loadFont("file:/C:/path%20with%20spaces/font.ttf", 12);
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Open input stream and load fonts like that. Doesn't help CSS though.

      FREQUENCY : always


        1. Bug.java
          1 kB
        2. Capture.PNG
          Capture.PNG
          6 kB
        3. OpenSans-Regular.ttf
          212 kB

            pnarayanaswa Praveen Narayanaswamy
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: