From 2967b76f4a4f12bfd3a7ce80a466280cb6a269d9 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sat, 27 Dec 2008 23:25:42 +0000 Subject: Unicode text display. Painfully slow and needs some work wrt text alignment, colours. The nsfont_width etc functions also need adjustment. svn path=/trunk/netsurf/; revision=5938 --- amiga/font.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'amiga/font.c') diff --git a/amiga/font.c b/amiga/font.c index f495427a8..e9f09a1e1 100644 --- a/amiga/font.c +++ b/amiga/font.c @@ -32,6 +32,7 @@ #include #include #include +#include static bool nsfont_width(const struct css_style *style, const char *string, size_t length, @@ -309,7 +310,7 @@ void ami_close_font(struct TextFont *tfont) if(tfont) CloseFont(tfont); } -void ami_unicode_text(struct RastPort *rp,char *string,ULONG length,struct css_style *style,ULONG x, ULONG y, ULONG c) +void ami_unicode_text(struct RastPort *rp,char *string,ULONG length,struct css_style *style,ULONG dx, ULONG dy, ULONG c) { WORD *utf16 = NULL; struct OutlineFont *ofont; @@ -317,6 +318,10 @@ void ami_unicode_text(struct RastPort *rp,char *string,ULONG length,struct css_s ULONG i,gx,gy; UBYTE *glyphbm; UWORD posn; + struct BitMap *tbm; + struct RastPort trp; + uint32 width,height; + uint32 x=0,y=0; if(!string || string[0]=='\0') return; if(!length) return; @@ -325,6 +330,19 @@ void ami_unicode_text(struct RastPort *rp,char *string,ULONG length,struct css_s if(!(ofont = ami_open_outline_font(style))) return; + /* width and height need to be calculated properly... */ + width = length*10; + height = css_len2px(&style->font_size.value.length, style); + if(height < option_font_min_size) + height = option_font_min_size; + + tbm = p96AllocBitMap(width,height,32,BMF_DISPLAYABLE,currp->BitMap,RGBFB_R8G8B8A8); + InitRastPort(&trp); + trp.BitMap = tbm; + + +y=height; + for(i=0;iolf_EEngine, @@ -350,7 +368,7 @@ void ami_unicode_text(struct RastPort *rp,char *string,ULONG length,struct css_s which is needed along with BLITA_UseSrcAlpha, TRUE to respect the alpha channel. We may even need to draw this text into a new bitmap and blit that onto our off-screen rendering bitmap. */ - p96WritePixel(rp,x+gx,(y-glyph->glm_BlackHeight)+gy, + p96WritePixel(&trp,x+gx,(y-glyph->glm_BlackHeight)+gy, p96EncodeColor(RGBFB_A8B8G8R8,(glyphbm[posn+gx] << 24) | c)); } @@ -369,4 +387,17 @@ rendering bitmap. */ } ami_close_outline_font(ofont); + + BltBitMapTags(BLITA_Width,width, + BLITA_Height,height, + BLITA_Source,tbm, + BLITA_Dest,currp, + BLITA_DestX,dx, + BLITA_DestY,dy-height, + BLITA_SrcType,BLITT_BITMAP, + BLITA_DestType,BLITT_RASTPORT, + BLITA_UseSrcAlpha,TRUE, + TAG_DONE); + + p96FreeBitMap(tbm); } -- cgit v1.2.3