summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2015-01-28 18:49:44 +0000
committerChris Young <chris@unsatisfactorysoftware.co.uk>2015-01-28 18:49:44 +0000
commitecdf37c6ac7b72761133b2a749d28ded12ed6c03 (patch)
tree287f8536a4424361e21f491e1c650163f895d74c
parentfd59fa248a08451d4ff20c4fb91834c13ae405da (diff)
downloadnetsurf-ecdf37c6ac7b72761133b2a749d28ded12ed6c03.tar.gz
netsurf-ecdf37c6ac7b72761133b2a749d28ded12ed6c03.tar.bz2
Fixup font.c a bit better for OS3
-rwxr-xr-xamiga/font.c43
-rw-r--r--amiga/os3support.c106
-rw-r--r--amiga/os3support.h17
3 files changed, 160 insertions, 6 deletions
diff --git a/amiga/font.c b/amiga/font.c
index a60f1bdfc..0db94890f 100755
--- a/amiga/font.c
+++ b/amiga/font.c
@@ -20,6 +20,9 @@
#include <assert.h>
+#ifndef __amigaos4__
+#include <proto/bullet.h>
+#endif
#include <proto/diskfont.h>
#include <proto/exec.h>
#include <proto/graphics.h>
@@ -175,7 +178,7 @@ const struct font_functions nsfont = {
nsfont_split
};
-#ifdef __amigaos4__
+
bool nsfont_width(const plot_font_style_t *fstyle,
const char *string, size_t length,
int *width)
@@ -367,6 +370,7 @@ static struct ami_font_node *ami_font_open(const char *font)
struct nsObject *node;
struct ami_font_node *nodedata;
+#ifdef __amigaos4__
node = (struct nsObject *)FindIName((struct List *)ami_font_list, font);
if(node)
{
@@ -374,6 +378,9 @@ static struct ami_font_node *ami_font_open(const char *font)
GetSysTime(&nodedata->lastused);
return nodedata;
}
+#else
+#warning FIXME: font cache won't work on OS3
+#endif
LOG(("Font cache miss: %s", font));
@@ -547,6 +554,9 @@ struct OutlineFont *ami_open_outline_font(const plot_font_style_t *fstyle,
ysize = fstyle->size * ((1 << 16) / FONT_SIZE_SCALE);
ofont = node->font;
+#ifndef __amigaos4__
+ struct BulletBase *BulletBase = ofont->BulletBase;
+#endif
if(ESetInfo(&ofont->olf_EEngine,
OT_DeviceDPI, ami_devicedpi,
@@ -568,8 +578,11 @@ int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPort *rp,
UBYTE *glyphbm;
int32 char_advance = 0;
FIXED kern = 0;
- ULONG glyphmaptag = OT_GlyphMap8Bit;
- ULONG template_type = BLITT_ALPHATEMPLATE;
+ ULONG glyphmaptag;
+ ULONG template_type;
+#ifndef __amigaos4__
+ struct BulletBase *BulletBase = ofont->BulletBase;
+#endif
if ((*char1 >= 0xD800) && (*char1 <= 0xDBFF)) {
/* We don't support UTF-16 surrogates yet, so just return. */
@@ -580,10 +593,17 @@ int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPort *rp,
/* Don't attempt to kern a UTF-16 surrogate */
*char2 = 0;
}
-
- if(aa == false) {
+
+ if(aa == true) {
+#ifdef __amigaos4__
+ glyphmaptag = OT_GlyphMap8Bit;
+ template_type = BLITT_ALPHATEMPLATE;
+#endif
+ } else {
glyphmaptag = OT_GlyphMap;
+#ifdef __amigaos4__
template_type = BLITT_TEMPLATE;
+#endif
}
if(ESetInfo(&ofont->olf_EEngine,
@@ -600,6 +620,7 @@ int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPort *rp,
if(rp)
{
+#ifdef __amigaos4__
BltBitMapTags(BLITA_SrcX, glyph->glm_BlackLeft,
BLITA_SrcY, glyph->glm_BlackTop,
BLITA_DestX, x - glyph->glm_X0 + glyph->glm_BlackLeft,
@@ -612,6 +633,12 @@ int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPort *rp,
BLITA_DestType, BLITT_RASTPORT,
BLITA_SrcBytesPerRow, glyph->glm_BMModulo,
TAG_DONE);
+#else
+#warning OS3 needs this as a BltBitMapTemplate
+ /* So we get some sort of text on screen */
+ Move(rp, x, y);
+ Text(rp, &char1, 1);
+#endif
}
kern = 0;
@@ -644,6 +671,9 @@ int32 ami_font_width_glyph(struct OutlineFont *ofont,
FIXED char1w = 0;
struct GlyphWidthEntry *gwnode;
bool skip_c2 = false;
+#ifndef __amigaos4__
+ struct BulletBase *BulletBase = ofont->BulletBase;
+#endif
if ((*char1 >= 0xD800) && (*char1 <= 0xDBFF)) {
/* We don't support UTF-16 surrogates yet, so just return. */
@@ -871,7 +901,8 @@ static void ami_font_cleanup(struct MinList *ami_font_list)
/* reschedule to run in five minutes */
ami_schedule(300000, (void *)ami_font_cleanup, ami_font_list);
}
-#else
+
+#if 0
#warning FIXME: font.c needs fixing properly for OS3, currently bodged to get it to build
bool nsfont_width(const plot_font_style_t *fstyle,
const char *string, size_t length,
diff --git a/amiga/os3support.c b/amiga/os3support.c
index 3b42685a5..987f18b2b 100644
--- a/amiga/os3support.c
+++ b/amiga/os3support.c
@@ -27,17 +27,123 @@
#include <stdarg.h>
#include <stdio.h>
+#include <proto/bullet.h>
#include <proto/exec.h>
#include <proto/intuition.h>
#include <proto/dos.h>
#include <proto/utility.h>
+#include <diskfont/diskfonttag.h>
#include <intuition/gadgetclass.h>
+#include "utils/log.h"
+
#define SUCCESS (TRUE)
#define FAILURE (FALSE)
#define NO !
+/* Diskfont */
+struct OutlineFont *OpenOutlineFont(STRPTR fileName, struct List *list, ULONG flags)
+{
+ BPTR fh = 0;
+ int64 size = 0;
+ struct TagItem *buffer, *ti;
+ STRPTR fname, otagpath;
+ struct BulletBase *BulletBase;
+ struct OutlineFont *of = NULL;
+ struct GlyphEngine *eengine;
+
+ otagpath = (STRPTR)ASPrintf("FONTS:%s.otag", fileName);
+ fh = Open(otagpath, MODE_OLDFILE);
+
+ 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 %s", otagpath));
+ FreeVec(otagpath);
+ return NULL;
+ }
+
+ size = GetFileSize(fh);
+ buffer = (struct TagItem *)AllocVec(size, MEMF_ANY);
+ if(buffer == NULL) {
+ LOG(("Unable to allocate memory"));
+ Close(fh);
+ FreeVec(otagpath);
+ return NULL;
+ }
+
+ Read(fh, buffer, size);
+ Close(fh);
+
+ /* The first tag is supposed to be OT_FileIdent and should equal 'size' */
+ struct TagItem *tag = buffer;
+ if((tag->ti_Tag != OT_FileIdent) || (tag->ti_Data != (ULONG)size)) {
+ LOG(("Invalid OTAG file"));
+ FreeVec(buffer);
+ FreeVec(otagpath);
+ return NULL;
+ }
+
+ /* Relocate all the OT_Indirect tags */
+ while (ti = NextTagItem(&buffer)) {
+ if(ti->ti_Tag & OT_Indirect) {
+ ti->ti_Data += buffer;
+ }
+ }
+
+ /* Find OT_Engine and open the font engine */
+ if(ti = FindTagItem(OT_Engine, buffer)) {
+ LOG(("Using font engine %s", ti->ti_Data));
+ fname = ASPrintf("%s.library", ti->ti_Data);
+ } else {
+ LOG(("Cannot find OT_Engine tag"));
+ FreeVec(buffer);
+ FreeVec(otagpath);
+ return NULL;
+ }
+
+ BulletBase = OpenLibrary(fname, 0L);
+
+ if(BulletBase == NULL) {
+ LOG(("Unable to open %s", fname));
+ FreeVec(buffer);
+ FreeVec(fname);
+ FreeVec(otagpath);
+ }
+
+ FreeVec(fname);
+
+ eengine = OpenEngine();
+
+ SetInfo(eengine,
+ OT_OTagPath, otagpath,
+ OT_OTagList, buffer,
+ TAG_DONE);
+
+ of = AllocVec(sizeof(struct OutlineFont), MEMF_CLEAR);
+ if(of == NULL) return NULL;
+
+ of->BulletBase = BulletBase;
+ of->olf_EEngine = eengine;
+ of->OTagPath = otagpath;
+ of->olf_OTagList = buffer;
+}
+
+void CloseOutlineFont(struct OutlineFont *of, struct List *list)
+{
+ struct BulletBase *BulletBase = of->BulletBase;
+
+ CloseEngine(of->olf_EEngine);
+ CloseLibrary(BulletBase);
+
+ FreeVec(of->OTagPath);
+ FreeVec(of->olf_OTagList);
+ FreeVec(of);
+}
+
+
/* DOS */
int64 GetFileSize(BPTR fh)
{
diff --git a/amiga/os3support.h b/amiga/os3support.h
index 1e17f861b..a9806eafb 100644
--- a/amiga/os3support.h
+++ b/amiga/os3support.h
@@ -107,6 +107,7 @@
#define WINDOW_BACKMOST 0
#define DN_FULLPATH 0
#define BGBACKFILL JAM1
+#define OFF_OPEN 0
/* Renamed structures */
#define AnchorPathOld AnchorPath
@@ -124,6 +125,10 @@
#define SaveDTObjectA(O,W,R,F,M,I,A) DoDTMethod(O,W,R,DTM_WRITE,F,M,NULL)
/* diskfont */
+#define EReleaseInfo ReleaseInfo
+#define EObtainInfo ObtainInfo
+#define ESetInfo SetInfo
+
/* Only used in one place we haven't ifdeffed, where it returns the charset name */
#define ObtainCharsetInfo(A,B,C) (const char *)"ISO-8859-1"
@@ -175,6 +180,14 @@ struct TimeRequest {
struct TimeVal Time;
};
+/* OutlineFont */
+struct OutlineFont {
+ struct BulletBase *BulletBase;
+ struct GlyphEngine *olf_EEngine;
+ STRPTR OTagPath;
+ struct TagItem *olf_OTagList;
+};
+
/* Compositing */
#define COMPFLAG_IgnoreDestAlpha 0
#define COMPFLAG_SrcAlphaOverride 0
@@ -215,6 +228,10 @@ enum {
};
/* Functions */
+/* Diskfont */
+void CloseOutlineFont(struct OutlineFont *of, struct List *list);
+struct OutlineFont *OpenOutlineFont(STRPTR fileName, struct List *list, ULONG flags);
+
/* DOS */
int64 GetFileSize(BPTR fh);
void FreeSysObject(ULONG type, APTR obj);