summaryrefslogtreecommitdiff
path: root/src/rufl_init.c
diff options
context:
space:
mode:
authorJohn-Mark Bell <jmb@netsurf-browser.org>2021-08-15 03:14:33 +0100
committerJohn-Mark Bell <jmb@netsurf-browser.org>2021-08-15 03:14:33 +0100
commit01da1538227f4d139c0665b730211c665c821625 (patch)
tree50959281d3964b7145fa0d44ce91eed6c1ec0f5c /src/rufl_init.c
parentb547911ad6cba76439eeb9cd03a6af3fe0dc6be3 (diff)
downloadlibrufl-01da1538227f4d139c0665b730211c665c821625.tar.gz
librufl-01da1538227f4d139c0665b730211c665c821625.tar.bz2
Clean up logging in the non-UCS Font Manager path
To obtain the full extent of a "language" font's glyph coverage we need to open and scan it in each of the available target encodings. All of the Latin1-6 + Welsh target encodings declare that they are based on the Base0 encoding and thus will cause the Font Manager to demand the existence of corresponding IntMetric0/Outlines0 font data files. A "language" font using a different base encoding (and corresponding target encodings based on it) would thus generate an error from the Font Manager. Additionally, without reinventing the Font Manager's own logic (and poking around the filesystem looking for IntMetrics and Encoding files), we don't know if a font is a "language" or a "symbol" font until we try to use it. Thus, we expect attempts to open "symbol" fonts with an explicit target encoding to generate an error from the Font Manager as well. As these are expected errors, there is no point logging them as it just produces a load of distracting noise.
Diffstat (limited to 'src/rufl_init.c')
-rw-r--r--src/rufl_init.c82
1 files changed, 39 insertions, 43 deletions
diff --git a/src/rufl_init.c b/src/rufl_init.c
index 3a77588..79433c3 100644
--- a/src/rufl_init.c
+++ b/src/rufl_init.c
@@ -870,7 +870,20 @@ rufl_code rufl_init_scan_font_old(unsigned int font_index)
code = rufl_init_scan_font_in_encoding(font_name, encoding,
charset, umap + (num_umaps - 1), &last_used);
- if (code != rufl_OK) {
+ /* Not finding the font isn't fatal */
+ if (code == rufl_FONT_MANAGER_ERROR &&
+ (rufl_fm_error->errnum ==
+ error_FONT_NOT_FOUND ||
+ rufl_fm_error->errnum ==
+ error_FILE_NOT_FOUND ||
+ rufl_fm_error->errnum ==
+ error_FONT_ENCODING_NOT_FOUND ||
+ /* Neither is a too modern font */
+ rufl_fm_error->errnum ==
+ error_FONT_TOO_MANY_CHUNKS)) {
+ /* Ensure we reuse the currently allocated umap */
+ num_umaps--;
+ } else if (code != rufl_OK) {
LOG("rufl_init_scan_font_in_encoding(\"%s\", \"%s\", "
"...): 0x%x (0x%x: %s)",
font_name, encoding, code,
@@ -879,26 +892,11 @@ rufl_code rufl_init_scan_font_old(unsigned int font_index)
code == rufl_FONT_MANAGER_ERROR ?
rufl_fm_error->errmess : "");
- /* Not finding the font isn't fatal */
- if (code != rufl_FONT_MANAGER_ERROR ||
- (rufl_fm_error->errnum !=
- error_FONT_NOT_FOUND &&
- rufl_fm_error->errnum !=
- error_FILE_NOT_FOUND &&
- rufl_fm_error->errnum !=
- error_FONT_ENCODING_NOT_FOUND &&
- /* Neither is a too modern font */
- rufl_fm_error->errnum !=
- error_FONT_TOO_MANY_CHUNKS)) {
- free(charset);
- for (i = 0; i < num_umaps; i++)
- free((umap + i)->encoding);
- free(umap);
- return code;
- }
-
- /* Ensure we reuse the currently allocated umap */
- num_umaps--;
+ free(charset);
+ for (i = 0; i < num_umaps; i++)
+ free((umap + i)->encoding);
+ free(umap);
+ return code;
} else {
/* If this mapping is identical to an existing one,
* then we can discard it */
@@ -937,7 +935,20 @@ rufl_code rufl_init_scan_font_old(unsigned int font_index)
code = rufl_init_scan_font_in_encoding(font_name, NULL,
charset, umap, &last_used);
- if (code != rufl_OK) {
+ /* Not finding the font isn't fatal */
+ if (code == rufl_FONT_MANAGER_ERROR &&
+ (rufl_fm_error->errnum ==
+ error_FONT_NOT_FOUND ||
+ rufl_fm_error->errnum ==
+ error_FILE_NOT_FOUND ||
+ rufl_fm_error->errnum ==
+ error_FONT_ENCODING_NOT_FOUND ||
+ /* Neither is a too modern font */
+ rufl_fm_error->errnum ==
+ error_FONT_TOO_MANY_CHUNKS)) {
+ /* Ensure we reuse the currently allocated umap */
+ num_umaps--;
+ } else if (code != rufl_OK) {
LOG("rufl_init_scan_font_in_encoding(\"%s\", NULL, "
"...): 0x%x (0x%x: %s)",
font_name, code,
@@ -946,25 +957,11 @@ rufl_code rufl_init_scan_font_old(unsigned int font_index)
code == rufl_FONT_MANAGER_ERROR ?
rufl_fm_error->errmess : "");
- /* Not finding the font isn't fatal */
- if (code != rufl_FONT_MANAGER_ERROR ||
- (rufl_fm_error->errnum !=
- error_FONT_NOT_FOUND &&
- rufl_fm_error->errnum !=
- error_FILE_NOT_FOUND &&
- rufl_fm_error->errnum !=
- error_FONT_ENCODING_NOT_FOUND &&
- /* Neither is a too modern font */
- rufl_fm_error->errnum !=
- error_FONT_TOO_MANY_CHUNKS)) {
- free(charset);
- for (i = 0; i < num_umaps; i++)
- free((umap + i)->encoding);
- free(umap);
- return code;
- }
-
- num_umaps--;
+ free(charset);
+ for (i = 0; i < num_umaps; i++)
+ free((umap + i)->encoding);
+ free(umap);
+ return code;
}
}
@@ -1023,8 +1020,7 @@ rufl_code rufl_init_scan_font_in_encoding(const char *font_name,
rufl_fm_error = xfont_find_font(buf, 160, 160, 0, 0, &font, 0, 0);
if (rufl_fm_error) {
- LOG("xfont_find_font(\"%s\"): 0x%x: %s", buf,
- rufl_fm_error->errnum, rufl_fm_error->errmess);
+ /* Leave it to our caller to log, if they wish */
return rufl_FONT_MANAGER_ERROR;
}