Skip to content

Commit 35f6f1d

Browse files
committedSep 17, 2021
8273808: Cleanup AddFontsToX11FontPath
Reviewed-by: pbansal, lucy
1 parent 1890d85 commit 35f6f1d

File tree

1 file changed

+1
-135
lines changed

1 file changed

+1
-135
lines changed
 

‎src/java.desktop/unix/native/common/awt/fontpath.c

+1-135
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -135,140 +135,6 @@ jboolean isDisplayLocal(JNIEnv *env) {
135135
return isLocal;
136136
}
137137

138-
static void AddFontsToX11FontPath ( fDirRecord *fDirP )
139-
{
140-
char *onePath;
141-
int index, nPaths;
142-
int origNumPaths, length;
143-
int origIndex;
144-
int totalDirCount;
145-
char **origFontPath;
146-
char **tempFontPath;
147-
int doNotAppend;
148-
int *appendDirList;
149-
char **newFontPath;
150-
int err, compareLength;
151-
char fontDirPath[512];
152-
int dirFile;
153-
154-
doNotAppend = 0;
155-
156-
if ( fDirP->num == 0 ) return;
157-
158-
appendDirList = SAFE_SIZE_ARRAY_ALLOC(malloc, fDirP->num, sizeof ( int ));
159-
if ( appendDirList == NULL ) {
160-
return; /* if it fails we cannot do much */
161-
}
162-
163-
origFontPath = XGetFontPath ( awt_display, &nPaths );
164-
165-
totalDirCount = nPaths;
166-
origNumPaths = nPaths;
167-
tempFontPath = origFontPath;
168-
169-
170-
for (index = 0; index < fDirP->num; index++ ) {
171-
172-
doNotAppend = 0;
173-
174-
tempFontPath = origFontPath;
175-
for ( origIndex = 0; origIndex < nPaths; origIndex++ ) {
176-
177-
onePath = *tempFontPath;
178-
179-
compareLength = strlen ( onePath );
180-
if ( onePath[compareLength -1] == '/' )
181-
compareLength--;
182-
183-
/* there is a slash at the end of every solaris X11 font path name */
184-
if ( strncmp ( onePath, fDirP->name[index], compareLength ) == 0 ) {
185-
doNotAppend = 1;
186-
break;
187-
}
188-
tempFontPath++;
189-
}
190-
191-
appendDirList[index] = 0;
192-
if ( doNotAppend == 0 ) {
193-
snprintf(fontDirPath, sizeof(fontDirPath), "%s/fonts.dir", fDirP->name[index]);
194-
fontDirPath[sizeof(fontDirPath) - 1] = '\0';
195-
dirFile = open ( fontDirPath, O_RDONLY, 0 );
196-
if ( dirFile == -1 ) {
197-
doNotAppend = 1;
198-
} else {
199-
close ( dirFile );
200-
totalDirCount++;
201-
appendDirList[index] = 1;
202-
}
203-
}
204-
205-
}
206-
207-
/* if no changes are required do not bother to do a setfontpath */
208-
if ( totalDirCount == nPaths ) {
209-
free ( ( void *) appendDirList );
210-
XFreeFontPath ( origFontPath );
211-
return;
212-
}
213-
214-
215-
newFontPath = SAFE_SIZE_ARRAY_ALLOC(malloc, totalDirCount, sizeof(char *));
216-
/* if it fails free things and get out */
217-
if ( newFontPath == NULL ) {
218-
free ( ( void *) appendDirList );
219-
XFreeFontPath ( origFontPath );
220-
return;
221-
}
222-
223-
for ( origIndex = 0; origIndex < nPaths; origIndex++ ) {
224-
onePath = origFontPath[origIndex];
225-
newFontPath[origIndex] = onePath;
226-
}
227-
228-
/* now add the other font paths */
229-
230-
for (index = 0; index < fDirP->num; index++ ) {
231-
232-
if ( appendDirList[index] == 1 ) {
233-
234-
/* printf ( "Appending %s\n", fDirP->name[index] ); */
235-
236-
onePath = SAFE_SIZE_ARRAY_ALLOC(malloc, strlen (fDirP->name[index]) + 2, sizeof( char ) );
237-
if (onePath == NULL) {
238-
free ( ( void *) appendDirList );
239-
240-
for ( index = origIndex; index < nPaths; index++ ) {
241-
free( newFontPath[index] );
242-
}
243-
244-
free( ( void *) newFontPath);
245-
XFreeFontPath ( origFontPath );
246-
return;
247-
}
248-
strcpy ( onePath, fDirP->name[index] );
249-
strcat ( onePath, "/" );
250-
newFontPath[nPaths++] = onePath;
251-
/* printf ( "The path to be appended is %s\n", onePath ); */
252-
}
253-
}
254-
255-
/* printf ( "The dir count = %d\n", totalDirCount ); */
256-
free ( ( void *) appendDirList );
257-
258-
XSetFontPath ( awt_display, newFontPath, totalDirCount );
259-
260-
for ( index = origNumPaths; index < totalDirCount; index++ ) {
261-
free( newFontPath[index] );
262-
}
263-
264-
free ( (void *) newFontPath );
265-
XFreeFontPath ( origFontPath );
266-
return;
267-
}
268-
#endif /* !HEADLESS */
269-
270-
271-
#ifndef HEADLESS
272138
static char **getX11FontPath ()
273139
{
274140
char **x11Path, **fontdirs;

3 commit comments

Comments
 (3)

openjdk-notifier[bot] commented on Sep 17, 2021

@openjdk-notifier[bot]

MBaesken commented on Oct 20, 2021

@MBaesken
MemberAuthor

/backport jdk17u

openjdk[bot] commented on Oct 20, 2021

@openjdk[bot]

@MBaesken @MBaesken the backport was successfully created on the branch MBaesken-backport-35f6f1d6 in my personal fork of openjdk/jdk17u. To create a pull request with this backport targeting openjdk/jdk17u:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

this pull request contains a backport of commit 35f6f1d6 from the openjdk/jdk repository.

The commit being backported was authored by Matthias Baesken on 17 Sep 2021 and was reviewed by Pankaj Bansal and Lutz Schmidt.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u:

$ git fetch https://github.com/openjdk-bots/jdk17u MBaesken-backport-35f6f1d6:MBaesken-backport-35f6f1d6
$ git checkout MBaesken-backport-35f6f1d6
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u MBaesken-backport-35f6f1d6
Please sign in to comment.