提交 2afb44e2 编写于 作者: P prr

7145771: [macosx] CreateFont/Register.java test fails because of cached results of getAllFonts()

Reviewed-by: igor, flar
上级 e906c83a
...@@ -200,29 +200,25 @@ public class CGraphicsEnvironment extends SunGraphicsEnvironment { ...@@ -200,29 +200,25 @@ public class CGraphicsEnvironment extends SunGraphicsEnvironment {
return true; return true;
} }
private Font[] allFontsWithLogical;
static String[] sLogicalFonts = { "Serif", "SansSerif", "Monospaced", "Dialog", "DialogInput" }; static String[] sLogicalFonts = { "Serif", "SansSerif", "Monospaced", "Dialog", "DialogInput" };
@Override @Override
public Font[] getAllFonts() { public Font[] getAllFonts() {
if (allFontsWithLogical == null)
{
Font[] newFonts;
Font[] superFonts = super.getAllFonts();
int numLogical = sLogicalFonts.length; Font[] newFonts;
int numOtherFonts = superFonts.length; Font[] superFonts = super.getAllFonts();
newFonts = new Font[numOtherFonts + numLogical]; int numLogical = sLogicalFonts.length;
System.arraycopy(superFonts,0,newFonts,numLogical,numOtherFonts); int numOtherFonts = superFonts.length;
for (int i = 0; i < numLogical; i++) newFonts = new Font[numOtherFonts + numLogical];
{ System.arraycopy(superFonts,0,newFonts,numLogical,numOtherFonts);
newFonts[i] = new Font(sLogicalFonts[i], Font.PLAIN, 1);
} for (int i = 0; i < numLogical; i++)
allFontsWithLogical = newFonts; {
newFonts[i] = new Font(sLogicalFonts[i], Font.PLAIN, 1);
} }
return java.util.Arrays.copyOf(allFontsWithLogical, allFontsWithLogical.length); return newFonts;
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册