diff options
author | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2015-08-16 23:26:21 +0100 |
---|---|---|
committer | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2015-08-16 23:26:21 +0100 |
commit | 9b222fdeb66d149628aace66853ee29627dfabc1 (patch) | |
tree | 4208864ecdc1c9f632897e63a38fc85090c14c16 /amiga/os3support.c | |
parent | 69a133969bf0aaaa64a928403ade8f1dc88a7ae0 (diff) | |
download | netsurf-9b222fdeb66d149628aace66853ee29627dfabc1.tar.gz netsurf-9b222fdeb66d149628aace66853ee29627dfabc1.tar.bz2 |
Check .font file is indicating this is an outline font before attempting to open the .otag
Diffstat (limited to 'amiga/os3support.c')
-rw-r--r-- | amiga/os3support.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/amiga/os3support.c b/amiga/os3support.c index 9e50d1a57..f4d857a78 100644 --- a/amiga/os3support.c +++ b/amiga/os3support.c @@ -49,24 +49,46 @@ struct OutlineFont *OpenOutlineFont(STRPTR fileName, struct List *list, ULONG fl int64 size = 0; struct TagItem *ti; UBYTE *buffer; - STRPTR fname, otagpath; + STRPTR fname, otagpath, fontpath; struct BulletBase *BulletBase; struct OutlineFont *of = NULL; struct GlyphEngine *gengine; char *p = 0; + struct FontContentsHeader fch; if(p = strrchr(fileName, '.')) *p = '\0'; + fontpath = (STRPTR)ASPrintf("FONTS:%s.font", fileName); + fh = Open(fontpath, MODE_OLDFILE); + + if(fh == 0) { + LOG("Unable to open FONT %s", fontpath); + FreeVec(fontpath); + return NULL; + } + + if(Read(fh, &magic, sizeof(struct FontContentsHeader)) != sizeof(struct FontContentsHeader)) { + LOG("Unable to read FONT %s", fontpath); + FreeVec(fontpath); + Close(fh); + return NULL; + } + + Close(fh); + + if(fch.fch_FileID != OFCH_ID) { + LOG("%s is not an outline font!", fontpath); + FreeVec(fontpath); + return NULL; + } + otagpath = (STRPTR)ASPrintf("FONTS:%s.otag", fileName); fh = Open(otagpath, MODE_OLDFILE); if(p) *p = '.'; if(fh == 0) { - /*\todo we should be opening the .font file too and checking - * for the magic bytes to indicate this is an outline font. - */ LOG("Unable to open OTAG %s", otagpath); FreeVec(otagpath); return NULL; |