summaryrefslogtreecommitdiff
path: root/amiga/font_scan.c
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2013-04-14 16:03:46 +0100
committerChris Young <chris@unsatisfactorysoftware.co.uk>2013-04-14 16:03:46 +0100
commitd9b8809908be8d25b4a301529725e1df65bb610b (patch)
tree4414b598f7eaabaf1987efe4ff9fed0e1cc7ae13 /amiga/font_scan.c
parent52e811a84298519ef328f50f68d5fc9c216f8c83 (diff)
downloadnetsurf-d9b8809908be8d25b4a301529725e1df65bb610b.tar.gz
netsurf-d9b8809908be8d25b4a301529725e1df65bb610b.tar.bz2
Fix memory leak and make a point of ignoring UTF-16 surrogates
Diffstat (limited to 'amiga/font_scan.c')
-rw-r--r--amiga/font_scan.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/amiga/font_scan.c b/amiga/font_scan.c
index 83025b643..768fceef9 100644
--- a/amiga/font_scan.c
+++ b/amiga/font_scan.c
@@ -71,10 +71,15 @@ struct ami_font_scan_window {
* \param glypharray an array of 0xffff lwc_string pointers
* \return font name or NULL
*/
-const char *ami_font_scan_lookup(uint16 code, lwc_string **glypharray)
+const char *ami_font_scan_lookup(uint16 *code, lwc_string **glypharray)
{
- if(glypharray[code] == NULL) return NULL;
- else return lwc_string_data(glypharray[code]);
+ if(*code >= 0xd800 && *code <= 0xdbff) {
+ /* This is a multi-byte character, we don't support falback for these yet. */
+ return NULL;
+ }
+
+ if(glypharray[*code] == NULL) return NULL;
+ else return lwc_string_data(glypharray[*code]);
}
/**
@@ -207,6 +212,7 @@ ULONG ami_font_scan_font(const char *fontname, lwc_string **glypharray)
ULONG foundglyphs = 0;
ULONG serif = 0;
lwc_error lerror;
+ ULONG unicoderanges = 0;
ofont = OpenOutlineFont(fontname, NULL, OFF_OPEN);
@@ -219,7 +225,8 @@ ULONG ami_font_scan_font(const char *fontname, lwc_string **glypharray)
TAG_END) == OTERR_Success)
{
if(EObtainInfo(&ofont->olf_EEngine,
- OT_WidthList, &widthlist, TAG_END) == 0)
+ OT_WidthList, &widthlist,
+ TAG_END) == 0)
{
gwnode = (struct GlyphWidthEntry *)GetHead((struct List *)widthlist);
do {
@@ -229,9 +236,19 @@ ULONG ami_font_scan_font(const char *fontname, lwc_string **glypharray)
foundglyphs++;
}
} while(gwnode = (struct GlyphWidthEntry *)GetSucc((struct Node *)gwnode));
+ EReleaseInfo(&ofont->olf_EEngine,
+ OT_WidthList, widthlist,
+ TAG_END);
}
}
+ if(EObtainInfo(&ofont->olf_EEngine, OT_UnicodeRanges, &unicoderanges, TAG_END) == 0) {
+ if(unicoderanges & UCR_SURROGATES) LOG(("%s supports UTF-16 surrogates", fontname));
+ EReleaseInfo(&ofont->olf_EEngine,
+ OT_UnicodeRanges, unicoderanges,
+ TAG_END);
+ }
+
CloseOutlineFont(ofont, NULL);
return foundglyphs;