summaryrefslogtreecommitdiff
path: root/amiga
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2008-08-23 16:17:23 +0000
committerChris Young <chris@unsatisfactorysoftware.co.uk>2008-08-23 16:17:23 +0000
commit889648aa4d59940cd5e8a766fee0575582c72255 (patch)
tree698dec7f44d70d37748670b754c019186f914a8e /amiga
parentac427e05e59d24a88cdc4919208ecf040f35fd44 (diff)
downloadnetsurf-889648aa4d59940cd5e8a766fee0575582c72255.tar.gz
netsurf-889648aa4d59940cd5e8a766fee0575582c72255.tar.bz2
Convert UTF-8 text to local charset before printing to screen
svn path=/trunk/netsurf/; revision=5184
Diffstat (limited to 'amiga')
-rwxr-xr-xamiga/plotters.c47
-rwxr-xr-xamiga/utf8.c52
2 files changed, 94 insertions, 5 deletions
diff --git a/amiga/plotters.c b/amiga/plotters.c
index de416ab06..57f37e0aa 100755
--- a/amiga/plotters.c
+++ b/amiga/plotters.c
@@ -25,6 +25,7 @@
#include <intuition/intuition.h>
#include <graphics/rpattr.h>
#include <graphics/gfxmacros.h>
+#include "amiga/utf8.h"
#include <proto/exec.h> // for debugprintf only
@@ -168,6 +169,7 @@ bool ami_clip(int x0, int y0, int x1, int y1)
bool ami_text(int x, int y, const struct css_style *style,
const char *text, size_t length, colour bg, colour c)
{
+ char *buffer = NULL;
struct TextFont *tfont = ami_open_font(style);
SetRPAttrs(currp,RPTAG_APenColor,p96EncodeColor(RGBFB_A8B8G8R8,c),
@@ -175,10 +177,18 @@ bool ami_text(int x, int y, const struct css_style *style,
// RPTAG_OPenColor,p96EncodeColor(RGBFB_A8B8G8R8,bg),
// RPTAG_Font,tfont,
TAG_DONE);
+
+ utf8_to_local_encoding(text,length,&buffer);
+// ami_utf8_to_any(text,length,&buffer);
+
+ if(!buffer) return true;
+
Move(currp,x,y);
- Text(currp,text,length);
+ Text(currp,buffer,strlen(buffer));
+// Text(currp,text,length);
ami_close_font(tfont);
+ ami_utf8_free(buffer);
return true;
}
@@ -245,11 +255,9 @@ bool ami_bitmap_tile(int x, int y, int width, int height,
bool repeat_x, bool repeat_y, struct content *content)
{
struct RenderInfo ri;
+ ULONG xf,yf,wf,hf;
DebugPrintF("bitmap tile plotter\n");
-/* not implemented properly - needs to tile! */
-
- if(x<0 || y<0) DebugPrintF("NEGATIVE X,Y COORDINATES\n");
SetRPAttrs(currp,RPTAG_BPenColor,p96EncodeColor(RGBFB_A8B8G8R8,bg),
TAG_DONE);
@@ -258,7 +266,36 @@ DebugPrintF("bitmap tile plotter\n");
ri.BytesPerRow = bitmap->width * 4;
ri.RGBFormat = RGBFB_R8G8B8A8;
- p96WritePixelArray((struct RenderInfo *)&ri,0,0,currp,x,y,width,height);
+/*
+if(repeat_x) printf("repeatx\n");
+if(repeat_y) printf("repeaty\n");
+*/
+ for(xf=0;xf<width;xf+=bitmap->width)
+ {
+ for(yf=0;yf<height;yf+=bitmap->height)
+ {
+ if(width > xf+bitmap->width)
+ {
+ wf = width-(xf+bitmap->width);
+ }
+ else
+ {
+ wf=bitmap->width;
+ }
+
+ if(height > yf+bitmap->height)
+ {
+ hf = height-(yf+bitmap->height);
+ }
+ else
+ {
+ hf=bitmap->height;
+ }
+
+//printf("%ld %ld %ld\n",xf,width,bitmap->width);
+ p96WritePixelArray((struct RenderInfo *)&ri,0,0,currp,x+xf,y+yf,wf,hf);
+ }
+ }
return true;
}
diff --git a/amiga/utf8.c b/amiga/utf8.c
index 22812ba0c..87c95d58a 100755
--- a/amiga/utf8.c
+++ b/amiga/utf8.c
@@ -18,8 +18,60 @@
#include <sys/types.h>
#include "utils/utf8.h"
+#include <proto/codesets.h>
+#include <proto/exec.h>
+#include <parserutils/charset/mibenum.h>
utf8_convert_ret utf8_to_local_encoding(const char *string, size_t len,
char **result)
{
+/*
+ struct codeset *cs = CodesetsFind("ISO-8859-1",
+ CSA_FallbackToDefault,FALSE,
+ TAG_DONE);
+*/
+
+// if(!len) return UTF8_CONVERT_OK;
+
+ *result = CodesetsUTF8ToStr(CSA_Source,string,
+ CSA_SourceLen,len,
+// CSA_MapForeignChars,TRUE,
+// CSA_DestCodeset,cs,
+ TAG_DONE);
+
+ return UTF8_CONVERT_OK;
+}
+
+ULONG ami_utf8_to_any(const char *string, size_t len, char **result)
+{
+ uint16 mibenum = 0;
+
+ struct codeset *cs = CodesetsFindBest(CSA_Source,string,
+ CSA_SourceLen,len,
+ CSA_FallbackToDefault,TRUE,
+ TAG_DONE);
+
+ *result = CodesetsUTF8ToStr(CSA_Source,string,
+ CSA_SourceLen,len,
+// CSA_MapForeignChars,TRUE,
+ CSA_DestCodeset,cs,
+ TAG_DONE);
+
+ mibenum = parserutils_charset_mibenum_from_name(cs->name,strlen(cs->name));
+
+ printf("%ld\n",mibenum);
+
+ return mibenum; // mibenum
+}
+
+/*
+char *ami_utf8_alloc(char *string)
+{
+ return (AllocVec(CodesetsUTF8Len(string)+1,MEMF_CLEAR));
+}
+*/
+
+void ami_utf8_free(char *ptr)
+{
+ if(ptr) CodesetsFreeA(ptr,NULL);
}