[prev in list] [next in list] [prev in thread] [next in thread]
List: openjdk-2d-dev
Subject: [OpenJDK 2D-Dev] Problem with user font discovery in Java on Windows 10 17704+.
From: Mikhail Filippov <mikhail.filippov () jetbrains ! com>
Date: 2019-02-12 11:23:20
Message-ID: 5c62aca8.1c69fb81.14ed9.fef3 () mx ! google ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Java can't find user installed fonts in Windows 10. Starting from Windows 10 Preview \
Build 17704 fonts are installed into the user's home folder by default, and are \
listed in user's registry section. This is Microsoft blog post about it: \
"https://blogs.windows.com/windowsexperience/2018/06/27/announcing-windows-10-insider-preview-build-17704/". \
I have the fix for this issue in the attached patch but I can't create bug into \
https://bugs.openjdk.java.net to link it because I don't have an account on this \
service.
--
Mikhail Filippov
Software Developer
JetBrains
http://jetbrains.com
"The Drive To Develop"
[Attachment #5 (unknown)]
<html xmlns:o="urn:schemas-microsoft-com:office:office" \
xmlns:w="urn:schemas-microsoft-com:office:word" \
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" \
xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type \
content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 \
(filtered medium)"><style><!-- /* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style></head><body lang=EN-US link="#0563C1" vlink="#954F72"><div \
class=WordSection1><p class=MsoNormal>Java can't find user installed fonts in Windows \
10. Starting from Windows 10 Preview Build 17704 fonts are installed into the user's \
home folder by default, and are listed in user's registry section. This is Microsoft \
blog post about it: "https://blogs.windows.com/windowsexperience/2018/06/27/announcing-windows-10-insider-preview-build-17704/". \
I have the fix for this issue in the attached patch but I can't create bug into \
https://bugs.openjdk.java.net to link it because I don't have an account on this \
service.</p><p class=MsoNormal>--<o:p></o:p></p><p class=MsoNormal>Mikhail \
Filippov<o:p></o:p></p><p class=MsoNormal>Software Developer<o:p></o:p></p><p \
class=MsoNormal>JetBrains<o:p></o:p></p><p \
class=MsoNormal>http://jetbrains.com<o:p></o:p></p><p class=MsoNormal>"The Drive To \
Develop"<o:p></o:p></p><p \
class=MsoNormal><o:p> </o:p></p></div></body></html>
["font-discovery-fix.patch" (application/octet-stream)]
From a03103bbe6ea67c80ab88913ad9b55a12ce17078 Mon Sep 17 00:00:00 2001
From: Mikhail Filippov <mikhail@filippov.me>
Date: Wed, 30 Jan 2019 10:34:27 +0300
Subject: [PATCH] JRE-1166 [jdk11] Handle the case when fonts are installed
into user registry key. This is the default behaviour since Windows 10 1809.
---
.../windows/native/libfontmanager/fontpath.c | 120 +++++++++---------
1 file changed, 63 insertions(+), 57 deletions(-)
diff --git a/src/java.desktop/windows/native/libfontmanager/fontpath.c \
b/src/java.desktop/windows/native/libfontmanager/fontpath.c index \
980070622ab..b72f5d71e12 100644
--- a/src/java.desktop/windows/native/libfontmanager/fontpath.c
+++ b/src/java.desktop/windows/native/libfontmanager/fontpath.c
@@ -511,14 +511,7 @@ static void registerFontW(GdiFontMapInfo *fmi, jobject \
fontToFileMap, DeleteLocalReference(env, fileStr);
}
-/* Obtain all the fontname -> filename mappings.
- * This is called once and the results returned to Java code which can
- * use it for lookups to reduce or avoid the need to search font files.
- */
-JNIEXPORT void JNICALL
-Java_sun_awt_Win32FontManager_populateFontFileNameMap0
-(JNIEnv *env, jclass obj, jobject fontToFileMap,
- jobject fontToFamilyMap, jobject familyToFontListMap, jobject locale)
+static void populateFontFileNameFromRegistryKey(HKEY regKey, GdiFontMapInfo *fmi, \
jobject fontToFileMap) {
#define MAX_BUFFER (FILENAME_MAX+1)
const wchar_t wname[MAX_BUFFER];
@@ -531,7 +524,63 @@ Java_sun_awt_Win32FontManager_populateFontFileNameMap0
DWORD dwDataValueSize;
DWORD nval;
DWORD dwNumValues, dwMaxValueNameLen, dwMaxValueDataLen;
- DWORD numValues = 0;
+
+ /* Use the windows registry to map font names to files */
+ ret = RegOpenKeyEx(regKey,
+ FONTKEY_NT, 0L, KEY_READ, &hkeyFonts);
+ if (ret != ERROR_SUCCESS) {
+ return;
+ }
+
+ ret = RegQueryInfoKeyW(hkeyFonts, NULL, NULL, NULL, NULL, NULL, NULL,
+ &dwNumValues, &dwMaxValueNameLen,
+ &dwMaxValueDataLen, NULL, NULL);
+
+ if (ret != ERROR_SUCCESS ||
+ dwMaxValueNameLen >= MAX_BUFFER ||
+ dwMaxValueDataLen >= MAX_BUFFER) {
+ RegCloseKey(hkeyFonts);
+ return;
+ }
+ for (nval = 0; nval < dwNumValues; nval++ ) {
+ dwNameSize = MAX_BUFFER;
+ dwDataValueSize = MAX_BUFFER;
+ ret = RegEnumValueW(hkeyFonts, nval, (LPWSTR)wname, &dwNameSize,
+ NULL, &type, (LPBYTE)data, &dwDataValueSize);
+
+ if (ret != ERROR_SUCCESS) {
+ break;
+ }
+ if (type != REG_SZ) { /* REG_SZ means a null-terminated string */
+ continue;
+ }
+
+ if (!RegistryToBaseTTNameW((LPWSTR)wname) ) {
+ /* If the filename ends with ".ttf" or ".otf" also accept it.
+ * Not expecting to need to do this for .ttc files.
+ * Also note this code is not mirrored in the "A" (win9x) path.
+ */
+ LPWSTR dot = wcsrchr((LPWSTR)data, L'.');
+ if (dot == NULL || ((wcsicmp(dot, L".ttf") != 0)
+ && (wcsicmp(dot, L".otf") != 0))) {
+ continue; /* not a TT font... */
+ }
+ }
+ registerFontW(fmi, fontToFileMap, (LPWSTR)wname, (LPWSTR)data);
+ }
+
+ RegCloseKey(hkeyFonts);
+}
+
+/* Obtain all the fontname -> filename mappings.
+ * This is called once and the results returned to Java code which can
+ * use it for lookups to reduce or avoid the need to search font files.
+ */
+JNIEXPORT void JNICALL
+Java_sun_awt_Win32FontManager_populateFontFileNameMap0
+(JNIEnv *env, jclass obj, jobject fontToFileMap,
+ jobject fontToFamilyMap, jobject familyToFontListMap, jobject locale)
+{
jclass classIDHashMap;
jclass classIDString;
jmethodID putMID;
@@ -607,55 +656,12 @@ Java_sun_awt_Win32FontManager_populateFontFileNameMap0
(FONTENUMPROCW)EnumFamilyNamesW,
(LPARAM)(&fmi), 0L);
- /* Use the windows registry to map font names to files */
- ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
- FONTKEY_NT, 0L, KEY_READ, &hkeyFonts);
- if (ret != ERROR_SUCCESS) {
- ReleaseDC(NULL, screenDC);
- screenDC = NULL;
- return;
- }
-
- ret = RegQueryInfoKeyW(hkeyFonts, NULL, NULL, NULL, NULL, NULL, NULL,
- &dwNumValues, &dwMaxValueNameLen,
- &dwMaxValueDataLen, NULL, NULL);
-
- if (ret != ERROR_SUCCESS ||
- dwMaxValueNameLen >= MAX_BUFFER ||
- dwMaxValueDataLen >= MAX_BUFFER) {
- RegCloseKey(hkeyFonts);
- ReleaseDC(NULL, screenDC);
- screenDC = NULL;
- return;
- }
- for (nval = 0; nval < dwNumValues; nval++ ) {
- dwNameSize = MAX_BUFFER;
- dwDataValueSize = MAX_BUFFER;
- ret = RegEnumValueW(hkeyFonts, nval, (LPWSTR)wname, &dwNameSize,
- NULL, &type, (LPBYTE)data, &dwDataValueSize);
-
- if (ret != ERROR_SUCCESS) {
- break;
- }
- if (type != REG_SZ) { /* REG_SZ means a null-terminated string */
- continue;
- }
-
- if (!RegistryToBaseTTNameW((LPWSTR)wname) ) {
- /* If the filename ends with ".ttf" or ".otf" also accept it.
- * Not expecting to need to do this for .ttc files.
- * Also note this code is not mirrored in the "A" (win9x) path.
- */
- LPWSTR dot = wcsrchr((LPWSTR)data, L'.');
- if (dot == NULL || ((wcsicmp(dot, L".ttf") != 0)
- && (wcsicmp(dot, L".otf") != 0))) {
- continue; /* not a TT font... */
- }
- }
- registerFontW(&fmi, fontToFileMap, (LPWSTR)wname, (LPWSTR)data);
- }
+ populateFontFileNameFromRegistryKey(HKEY_LOCAL_MACHINE, &fmi, fontToFileMap);
+ /* Starting from Windows 10 Preview Build 17704 fonts are installed into user's \
home folder by default, + * and are listed in user's registry section
+ */
+ populateFontFileNameFromRegistryKey(HKEY_CURRENT_USER, &fmi, fontToFileMap);
- RegCloseKey(hkeyFonts);
ReleaseDC(NULL, screenDC);
screenDC = NULL;
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic