Skip to content

Commit

Permalink
check_single_font(): use quotation mark when msGetGlyphIndex() fails …
Browse files Browse the repository at this point in the history
…to retrieve the glyph
  • Loading branch information
rouault authored and github-actions[bot] committed May 25, 2021
1 parent 0bbf943 commit 53ee29e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions msautotest/renderers/font-fail.map
@@ -1,5 +1,6 @@
# RUN_PARMS: font-fail-key.txt [MAPSERV] QUERY_STRING="map=[MAPFILE]&mode=map&layer=l1" > [RESULT_DEVERSION]
# RUN_PARMS: font-fail-file.txt [MAPSERV] QUERY_STRING="map=[MAPFILE]&mode=map&layer=l2" > [RESULT_DEVERSION]
# RUN_PARMS: font-fail-missing-glyph.png [SHP2IMG] -m [MAPFILE] -l missing_glyph -i png -o [RESULT]

MAP

Expand Down Expand Up @@ -41,4 +42,21 @@ LAYER
FEATURE POINTS 50 50 END END
END

LAYER
NAME "missing_glyph"
STATUS ON
TYPE POLYGON
FEATURE
POINTS 0 0 400 0 400 300 0 300 0 0 END
END
CLASS
LABEL
TEXT 'this is a test: это проверка'
TYPE truetype
SIZE 8
FONT "default"
END
END
END

END
13 changes: 10 additions & 3 deletions textlayout.c
Expand Up @@ -214,7 +214,7 @@ static hb_position_t _ms_get_glyph_v_advance_func (hb_font_t *font, void *font_d
}
#endif

int WARN_UNUSED check_single_font(fontSetObj *fontset, char *fontkey, text_run *run, TextInfo *glyphs, int ignore_missing) {
static int check_single_font(fontSetObj *fontset, char *fontkey, text_run *run, TextInfo *glyphs, int ignore_missing) {
int i;
face_element *fcache = NULL;
if(fontset && fontkey) {
Expand All @@ -228,16 +228,23 @@ int WARN_UNUSED check_single_font(fontSetObj *fontset, char *fontkey, text_run *
run->face = fcache;
if(UNLIKELY(!fcache)) return MS_FAILURE;
for(i=0; i<run->length; i++) {
int codepoint = msGetGlyphIndex(fcache, glyphs->unicodes[run->offset+i]);
unsigned int codepoint = msGetGlyphIndex(fcache, glyphs->unicodes[run->offset+i]);
if(codepoint || ignore_missing)
{
if( codepoint == 0 )
{
msDebug("Unable to find glyph for codepoint %u. Using ? as fallback.\n", glyphs->unicodes[run->offset+i]);
codepoint = msGetGlyphIndex(fcache, '?');
}
glyphs->codepoints[run->offset+i] = codepoint;
}
else
return MS_FAILURE;
}
return MS_SUCCESS;
}

int WARN_UNUSED get_face_for_run(fontSetObj *fontset, char *fontlist, text_run *run, TextInfo *glyphs) {
static int get_face_for_run(fontSetObj *fontset, char *fontlist, text_run *run, TextInfo *glyphs) {
char *startfont, *endfont;
int ok;
#if defined(USE_HARFBUZZ) && defined(USE_FRIBIDI)
Expand Down

0 comments on commit 53ee29e

Please sign in to comment.