[libbluray-devel] BDFontMetrics: use Font.fontFile

hpi1 git at videolan.org
Sun Nov 23 13:19:56 CET 2014


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Fri Nov 21 13:46:49 2014 +0200| [cd552fd933562093ab80eabb43438b52db1d5ab4] | committer: hpi1

BDFontMetrics: use Font.fontFile

No need to register fonts.
Fixes drawing with on-disc and stream fonts.

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=cd552fd933562093ab80eabb43438b52db1d5ab4
---

 src/libbluray/bdj/java/java/awt/BDFontMetrics.java |   36 +++-----------------
 src/libbluray/bdj/java/java/awt/Font.java          |    2 +-
 2 files changed, 5 insertions(+), 33 deletions(-)

diff --git a/src/libbluray/bdj/java/java/awt/BDFontMetrics.java b/src/libbluray/bdj/java/java/awt/BDFontMetrics.java
index 2a2f9d5..e6a205a 100644
--- a/src/libbluray/bdj/java/java/awt/BDFontMetrics.java
+++ b/src/libbluray/bdj/java/java/awt/BDFontMetrics.java
@@ -31,7 +31,6 @@ public class BDFontMetrics extends FontMetrics {
     private static long ftLib = 0;
     private static long fcLib = 0;
     private static Map  systemFontNameMap = null;
-    private static Map  discFontNameMap = new HashMap();
 
     private static final Logger logger = Logger.getLogger(BDFontMetrics.class.getName());
 
@@ -114,8 +113,6 @@ public class BDFontMetrics extends FontMetrics {
         if (systemFontNameMap == null) {
             initSystemFonts();
         }
-
-        discFontNameMap = new HashMap();
     }
 
     public synchronized static void shutdown() {
@@ -145,8 +142,10 @@ public class BDFontMetrics extends FontMetrics {
         if (fm == null || fm.ftFace == 0) {
             /* See if a font metrics of the same native name and size has already been loaded.
              If it has then we use that one. */
-            String nativeName = (String)discFontNameMap.get(font.getName().toLowerCase() + "." + font.getStyle());
-            if (nativeName == null) {
+            String nativeName;
+            if (font.fontFile != null) {
+                nativeName = font.fontFile.getPath();
+            } else {
                 nativeName = (String)systemFontNameMap.get(font.getName().toLowerCase() + "." + font.getStyle());
                 if (nativeName == null) {
                     nativeName = (String)systemFontNameMap.get("default." + font.getStyle());
@@ -181,36 +180,9 @@ public class BDFontMetrics extends FontMetrics {
                 fontNames.add(fontname);
         }
 
-        fonts = discFontNameMap.keySet().iterator();
-        while (fonts.hasNext()) {
-            String fontname = stripAttributes((String)fonts.next());
-            if (!fontNames.contains(fontname))
-                fontNames.add(fontname);
-        }
-
         return (String[])fontNames.toArray(new String[fontNames.size()]);
     }
 
-    public synchronized static void registerFont(String name, int style, String path) {
-        File f = new File(path);
-        path = f.getAbsolutePath();
-        if (path != null) {
-            name = name.toLowerCase() + "." + style;
-            discFontNameMap.put(name, path);
-        }
-    }
-
-    public synchronized static boolean registerFont(File f) {
-        //TODO
-        logger.unimplemented("registerFont");
-        return false;
-    }
-
-    public synchronized static void unregisterFont(String name, int style) {
-        name = name.toLowerCase() + "." + style;
-        discFontNameMap.remove(name);
-    }
-
     private long ftFace = 0;
     private int ascent = 0;
     private int descent = 0;
diff --git a/src/libbluray/bdj/java/java/awt/Font.java b/src/libbluray/bdj/java/java/awt/Font.java
index 4bf3042..a126bc5 100644
--- a/src/libbluray/bdj/java/java/awt/Font.java
+++ b/src/libbluray/bdj/java/java/awt/Font.java
@@ -228,7 +228,7 @@ public class Font implements java.io.Serializable {
         setFamily();
     }
 
-    private static void parseStyle(String styleName) {
+    private static int parseStyle(String styleName) {
         int style = PLAIN;
 
         if (styleName != null && styleName.length() > 0) {



More information about the libbluray-devel mailing list