equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
896 return -1; |
896 return -1; |
897 } |
897 } |
898 locale = (*env)->GetStringUTFChars(env, localeStr, 0); |
898 locale = (*env)->GetStringUTFChars(env, localeStr, 0); |
899 |
899 |
900 if ((libfontconfig = openFontConfig()) == NULL) { |
900 if ((libfontconfig = openFontConfig()) == NULL) { |
901 (*env)->ReleaseStringUTFChars (env, fcNameStr, (const char*)fcName); |
901 (*env)->ReleaseStringUTFChars(env, fcNameStr, (const char*)fcName); |
902 if (locale) { |
902 if (locale) { |
903 (*env)->ReleaseStringUTFChars (env, localeStr,(const char*)locale); |
903 (*env)->ReleaseStringUTFChars(env, localeStr,(const char*)locale); |
904 } |
904 } |
905 return -1; |
905 return -1; |
906 } |
906 } |
907 |
907 |
908 FcNameParse = (FcNameParseFuncType)dlsym(libfontconfig, "FcNameParse"); |
908 FcNameParse = (FcNameParseFuncType)dlsym(libfontconfig, "FcNameParse"); |
927 FcFontMatch == NULL || |
927 FcFontMatch == NULL || |
928 FcPatternGetBool == NULL || |
928 FcPatternGetBool == NULL || |
929 FcPatternGetInteger == NULL || |
929 FcPatternGetInteger == NULL || |
930 FcPatternDestroy == NULL) { /* problem with the library: return. */ |
930 FcPatternDestroy == NULL) { /* problem with the library: return. */ |
931 |
931 |
932 (*env)->ReleaseStringUTFChars (env, fcNameStr, (const char*)fcName); |
932 (*env)->ReleaseStringUTFChars(env, fcNameStr, (const char*)fcName); |
933 if (locale) { |
933 if (locale) { |
934 (*env)->ReleaseStringUTFChars (env, localeStr,(const char*)locale); |
934 (*env)->ReleaseStringUTFChars(env, localeStr,(const char*)locale); |
935 } |
935 } |
936 closeFontConfig(libfontconfig, JNI_FALSE); |
936 closeFontConfig(libfontconfig, JNI_FALSE); |
937 return -1; |
937 return -1; |
938 } |
938 } |
939 |
939 |
954 (*FcPatternGetInteger)(matchPattern, FC_RGBA, 0, &rgba); |
954 (*FcPatternGetInteger)(matchPattern, FC_RGBA, 0, &rgba); |
955 (*FcPatternDestroy)(matchPattern); |
955 (*FcPatternDestroy)(matchPattern); |
956 } |
956 } |
957 (*FcPatternDestroy)(pattern); |
957 (*FcPatternDestroy)(pattern); |
958 |
958 |
959 (*env)->ReleaseStringUTFChars (env, fcNameStr, (const char*)fcName); |
959 (*env)->ReleaseStringUTFChars(env, fcNameStr, (const char*)fcName); |
960 if (locale) { |
960 if (locale) { |
961 (*env)->ReleaseStringUTFChars (env, localeStr, (const char*)locale); |
961 (*env)->ReleaseStringUTFChars(env, localeStr, (const char*)locale); |
962 } |
962 } |
963 closeFontConfig(libfontconfig, JNI_TRUE); |
963 closeFontConfig(libfontconfig, JNI_TRUE); |
964 |
964 |
965 if (antialias == FcFalse) { |
965 if (antialias == FcFalse) { |
966 return TEXT_AA_OFF; |
966 return TEXT_AA_OFF; |
1188 pattern = (*FcNameParse)((FcChar8 *)fcName); |
1188 pattern = (*FcNameParse)((FcChar8 *)fcName); |
1189 (*env)->ReleaseStringUTFChars(env, fcNameStr, (const char*)fcName); |
1189 (*env)->ReleaseStringUTFChars(env, fcNameStr, (const char*)fcName); |
1190 (*env)->DeleteLocalRef(env, fcNameStr); |
1190 (*env)->DeleteLocalRef(env, fcNameStr); |
1191 if (pattern == NULL) { |
1191 if (pattern == NULL) { |
1192 closeFontConfig(libfontconfig, JNI_FALSE); |
1192 closeFontConfig(libfontconfig, JNI_FALSE); |
|
1193 if (locale) { |
|
1194 (*env)->ReleaseStringUTFChars(env, localeStr, (const char*)locale); |
|
1195 } |
1193 return; |
1196 return; |
1194 } |
1197 } |
1195 |
1198 |
1196 /* locale may not usually be necessary as fontconfig appears to apply |
1199 /* locale may not usually be necessary as fontconfig appears to apply |
1197 * this anyway based on the user's environment. However we want |
1200 * this anyway based on the user's environment. However we want |
1205 (*FcDefaultSubstitute)(pattern); |
1208 (*FcDefaultSubstitute)(pattern); |
1206 fontset = (*FcFontSort)(NULL, pattern, FcTrue, NULL, &result); |
1209 fontset = (*FcFontSort)(NULL, pattern, FcTrue, NULL, &result); |
1207 if (fontset == NULL) { |
1210 if (fontset == NULL) { |
1208 (*FcPatternDestroy)(pattern); |
1211 (*FcPatternDestroy)(pattern); |
1209 closeFontConfig(libfontconfig, JNI_FALSE); |
1212 closeFontConfig(libfontconfig, JNI_FALSE); |
|
1213 if (locale) { |
|
1214 (*env)->ReleaseStringUTFChars(env, localeStr, (const char*)locale); |
|
1215 } |
1210 return; |
1216 return; |
1211 } |
1217 } |
1212 |
1218 |
1213 /* fontconfig returned us "nfonts". If we are just getting the |
1219 /* fontconfig returned us "nfonts". If we are just getting the |
1214 * first font, we set nfont to zero. Otherwise we use "nfonts". |
1220 * first font, we set nfont to zero. Otherwise we use "nfonts". |
1236 free(file); |
1242 free(file); |
1237 } |
1243 } |
1238 (*FcPatternDestroy)(pattern); |
1244 (*FcPatternDestroy)(pattern); |
1239 (*FcFontSetDestroy)(fontset); |
1245 (*FcFontSetDestroy)(fontset); |
1240 closeFontConfig(libfontconfig, JNI_FALSE); |
1246 closeFontConfig(libfontconfig, JNI_FALSE); |
|
1247 if (locale) { |
|
1248 (*env)->ReleaseStringUTFChars(env, localeStr, (const char*)locale); |
|
1249 } |
1241 return; |
1250 return; |
1242 } |
1251 } |
1243 fontCount = 0; |
1252 fontCount = 0; |
1244 minGlyphs = 20; |
1253 minGlyphs = 20; |
1245 if (debugMinGlyphsStr != NULL) { |
1254 if (debugMinGlyphsStr != NULL) { |
1278 free(styleStr); |
1287 free(styleStr); |
1279 free(file); |
1288 free(file); |
1280 (*FcPatternDestroy)(pattern); |
1289 (*FcPatternDestroy)(pattern); |
1281 (*FcFontSetDestroy)(fontset); |
1290 (*FcFontSetDestroy)(fontset); |
1282 closeFontConfig(libfontconfig, JNI_FALSE); |
1291 closeFontConfig(libfontconfig, JNI_FALSE); |
|
1292 if (locale) { |
|
1293 (*env)->ReleaseStringUTFChars(env, localeStr, (const char*)locale); |
|
1294 } |
1283 return; |
1295 return; |
1284 } |
1296 } |
1285 |
1297 |
1286 /* We don't want 20 or 30 fonts, so once we hit 10 fonts, |
1298 /* We don't want 20 or 30 fonts, so once we hit 10 fonts, |
1287 * then require that they really be adding value. Too many |
1299 * then require that they really be adding value. Too many |
1332 free(styleStr); |
1344 free(styleStr); |
1333 free(file); |
1345 free(file); |
1334 (*FcPatternDestroy)(pattern); |
1346 (*FcPatternDestroy)(pattern); |
1335 (*FcFontSetDestroy)(fontset); |
1347 (*FcFontSetDestroy)(fontset); |
1336 closeFontConfig(libfontconfig, JNI_FALSE); |
1348 closeFontConfig(libfontconfig, JNI_FALSE); |
|
1349 if (locale) { |
|
1350 (*env)->ReleaseStringUTFChars(env, localeStr, (const char*)locale); |
|
1351 } |
1337 return; |
1352 return; |
1338 } |
1353 } |
1339 (*env)->SetObjectField(env,fcCompFontObj, fcAllFontsID, fcFontArr); |
1354 (*env)->SetObjectField(env,fcCompFontObj, fcAllFontsID, fcFontArr); |
1340 } |
1355 } |
1341 fn=0; |
1356 fn=0; |
1393 } |
1408 } |
1394 |
1409 |
1395 /* release resources and close the ".so" */ |
1410 /* release resources and close the ".so" */ |
1396 |
1411 |
1397 if (locale) { |
1412 if (locale) { |
1398 (*env)->ReleaseStringUTFChars (env, localeStr, (const char*)locale); |
1413 (*env)->ReleaseStringUTFChars(env, localeStr, (const char*)locale); |
1399 } |
1414 } |
1400 closeFontConfig(libfontconfig, JNI_TRUE); |
1415 closeFontConfig(libfontconfig, JNI_TRUE); |
1401 } |
1416 } |