[libbluray-devel] Fix java.awt.Component.getFontMetric() with some J2SE versions
hpi1
git at videolan.org
Mon Mar 9 09:56:22 CET 2015
libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Fri Mar 6 10:22:02 2015 +0200| [7b085136bbae0e657a0ac1964f93efff0c3d778b] | committer: hpi1
Fix java.awt.Component.getFontMetric() with some J2SE versions
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=7b085136bbae0e657a0ac1964f93efff0c3d778b
---
src/libbluray/bdj/java/java/awt/BDFontMetrics.java | 11 +++-
.../bdj/java/sun/font/FontDesignMetrics.java | 55 ++++++++++++++++++++
2 files changed, 65 insertions(+), 1 deletion(-)
diff --git a/src/libbluray/bdj/java/java/awt/BDFontMetrics.java b/src/libbluray/bdj/java/java/awt/BDFontMetrics.java
index 4c43356..217c0a2 100644
--- a/src/libbluray/bdj/java/java/awt/BDFontMetrics.java
+++ b/src/libbluray/bdj/java/java/awt/BDFontMetrics.java
@@ -30,7 +30,7 @@ import java.util.Map;
import org.videolan.Logger;
-public class BDFontMetrics extends FontMetrics {
+public class BDFontMetrics extends sun.font.FontDesignMetrics {
static final long serialVersionUID = -4956160226949100590L;
private static long ftLib = 0;
@@ -175,6 +175,15 @@ public class BDFontMetrics extends FontMetrics {
return fm;
}
+ static {
+ sun.font.FontDesignMetrics.setGetFontMetricsAccess(
+ new sun.font.FontDesignMetrics.GetFontMetricsAccess() {
+ public sun.font.FontDesignMetrics getFontMetrics(Font font) {
+ return BDFontMetrics.getFontMetrics(font);
+ }
+ });
+ }
+
static String stripAttributes(String fontname) {
int dotidx;
if ((dotidx = fontname.indexOf('.')) == -1)
diff --git a/src/libbluray/bdj/java/sun/font/FontDesignMetrics.java b/src/libbluray/bdj/java/sun/font/FontDesignMetrics.java
new file mode 100644
index 0000000..18b7a64
--- /dev/null
+++ b/src/libbluray/bdj/java/sun/font/FontDesignMetrics.java
@@ -0,0 +1,55 @@
+/*
+ * This file is part of libbluray
+ * Copyright (C) 2015 libbluray
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+package sun.font;
+
+import java.awt.FontMetrics;
+import java.awt.Font;
+
+/*
+ * This class is used to "fix" Java 7 java.awt.Component.getFontMetrics()
+ *
+ * one disc calls directly (new java.awt.Component() { ... } ).getFontMetrics(font)
+ *
+ */
+
+public class FontDesignMetrics extends FontMetrics {
+
+ protected interface GetFontMetricsAccess {
+ public abstract FontDesignMetrics getFontMetrics(Font font);
+ }
+
+ private static GetFontMetricsAccess access;
+
+ protected static void setGetFontMetricsAccess(GetFontMetricsAccess a) {
+ access = a;
+ }
+
+ /*
+ *
+ */
+
+ public static FontDesignMetrics getMetrics(Font font) {
+ return access.getFontMetrics(font);
+ }
+
+ protected FontDesignMetrics(Font font) {
+ super(font);
+ }
+}
More information about the libbluray-devel
mailing list