提交 e740c469 编写于 作者: P prr

6867603: sun.font.FontManager.getDefaultPlatformFont throws NPE in OpenJDK on Solaris 10 10/08

Reviewed-by: igor, jgodinez
上级 006d992d
......@@ -194,18 +194,36 @@ public class FontConfigManager {
fontArr[i].style = i % 4; // depends on array order.
}
getFontConfig(getFCLocaleStr(), fcInfo, fontArr, includeFallbacks);
FontConfigFont anyFont = null;
/* If don't find anything (eg no libfontconfig), then just return */
for (int i = 0; i< fontArr.length; i++) {
FcCompFont fci = fontArr[i];
if (fci.firstFont == null) {
if (FontUtilities.isLogging()) {
Logger logger = FontUtilities.getLogger();
logger.info("Fontconfig returned no fonts.");
logger.info("Fontconfig returned no font for " +
fontArr[i].fcName);
}
fontConfigFailed = true;
} else if (anyFont == null) {
anyFont = fci.firstFont;
}
}
if (anyFont == null) {
if (FontUtilities.isLogging()) {
Logger logger = FontUtilities.getLogger();
logger.info("Fontconfig returned no fonts at all.");
return;
}
} else if (fontConfigFailed) {
for (int i = 0; i< fontArr.length; i++) {
if (fontArr[i].firstFont == null) {
fontArr[i].firstFont = anyFont;
}
}
}
fontConfigFonts = fontArr;
if (FontUtilities.isLogging()) {
......
......@@ -1203,11 +1203,7 @@ Java_sun_font_FontConfigManager_getFontConfig
* Inspect the returned fonts and the ones we like (adds enough glyphs)
* are added to the arrays and we increment 'fontCount'.
*/
if (includeFallbacks) {
nfonts = fontset->nfont;
} else {
nfonts = 1;
}
nfonts = fontset->nfont;
family = (FcChar8**)calloc(nfonts, sizeof(FcChar8*));
styleStr = (FcChar8**)calloc(nfonts, sizeof(FcChar8*));
fullname = (FcChar8**)calloc(nfonts, sizeof(FcChar8*));
......@@ -1249,7 +1245,7 @@ Java_sun_font_FontConfigManager_getFontConfig
* adversely affects load time for minimal value-add.
* This is still likely far more than we've had in the past.
*/
if (nfonts==10) {
if (j==10) {
minGlyphs = 50;
}
if (unionCharset == NULL) {
......@@ -1268,6 +1264,9 @@ Java_sun_font_FontConfigManager_getFontConfig
(*FcPatternGetString)(fontPattern, FC_FAMILY, 0, &family[j]);
(*FcPatternGetString)(fontPattern, FC_STYLE, 0, &styleStr[j]);
(*FcPatternGetString)(fontPattern, FC_FULLNAME, 0, &fullname[j]);
if (!includeFallbacks) {
break;
}
}
/* Once we get here 'fontCount' is the number of returned fonts
......@@ -1309,6 +1308,8 @@ Java_sun_font_FontConfigManager_getFontConfig
}
if (includeFallbacks) {
(*env)->SetObjectArrayElement(env, fcFontArr, fn++,fcFont);
} else {
break;
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册