mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-16 09:12:44 +03:00
Fixup font.c a bit better for OS3
This commit is contained in:
parent
fd59fa248a
commit
ecdf37c6ac
41
amiga/font.c
41
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. */
|
||||
@ -581,9 +594,16 @@ int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPort *rp,
|
||||
*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,
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user