From 74f6474fd00efa8bc81be84f0e3c2ee6fdd6a058 Mon Sep 17 00:00:00 2001 From: linyuxuan Date: Fri, 5 Jan 2024 10:30:27 +0800 Subject: [PATCH 2/4] Adds a new fallback form: FONTCONFIGURATION_FALLBACK This from uses the FontConfiguration to get the fallback font. The default logical font is used in systems where this form is not implemented. --- src/java.desktop/share/classes/sun/font/FontManager.java | 3 ++- .../share/classes/sun/font/SunFontManager.java | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/java.desktop/share/classes/sun/font/FontManager.java b/src/java.desktop/share/classes/sun/font/FontManager.java index 6eb151177d8..678dbb9c811 100644 --- a/src/java.desktop/share/classes/sun/font/FontManager.java +++ b/src/java.desktop/share/classes/sun/font/FontManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,6 +39,7 @@ public interface FontManager { public static final int NO_FALLBACK = 0; public static final int PHYSICAL_FALLBACK = 1; public static final int LOGICAL_FALLBACK = 2; + public static final int FONTCONFIGURATION_FALLBACK = 3; /** * Register a new font. Please, note that {@code null} is not a valid diff --git a/src/java.desktop/share/classes/sun/font/SunFontManager.java b/src/java.desktop/share/classes/sun/font/SunFontManager.java index 3aec139b56d..42044f7874c 100644 --- a/src/java.desktop/share/classes/sun/font/SunFontManager.java +++ b/src/java.desktop/share/classes/sun/font/SunFontManager.java @@ -1041,6 +1041,13 @@ public Font2D getDefaultLogicalFont(int style) { return findFont2D("dialog", style, NO_FALLBACK); } + public Font2D getFontFromFontConfiguration(String name, int style) { + // The current implementation of this function is not available + // for Windows, MacOSX, and Linux without Fontconfig. + // Use the default logical font instead. + return getDefaultLogicalFont(style); + } + /* * return String representation of style prepended with "." * This is useful for performance to avoid unnecessary string operations. @@ -2162,6 +2169,7 @@ public Font2D findFont2D(String name, int style, int fallback) { switch (fallback) { case PHYSICAL_FALLBACK: return getDefaultPhysicalFont(); case LOGICAL_FALLBACK: return getDefaultLogicalFont(style); + case FONTCONFIGURATION_FALLBACK: return getFontFromFontConfiguration(name, style); default: return null; } } -- 2.39.2