Author: chris_y
Date: Fri Jan 16 14:05:21 2009
New Revision: 6095

URL: http://source.netsurf-browser.org?rev=6095&view=rev
Log:
nsfont_width implemented for Unicode text
cache outline fonts for big speedup

still need to implement other text size functions
and also bold and italic fonts

Modified:
    trunk/netsurf/amiga/context_menu.h
    trunk/netsurf/amiga/font.c
    trunk/netsurf/amiga/font.h
    trunk/netsurf/amiga/gui.c

Modified: trunk/netsurf/amiga/context_menu.h
URL: 
http://source.netsurf-browser.org/trunk/netsurf/amiga/context_menu.h?rev=6095&r1=6094&r2=6095&view=diff
==============================================================================
--- trunk/netsurf/amiga/context_menu.h (original)
+++ trunk/netsurf/amiga/context_menu.h Fri Jan 16 14:05:21 2009
@@ -1,5 +1,5 @@
 /*
- * Copyright 2008 Chris Young <[email protected]>
+ * Copyright 2008,2009 Chris Young <[email protected]>
  *
  * This file is part of NetSurf, http://www.netsurf-browser.org/
  *

Modified: trunk/netsurf/amiga/font.c
URL: 
http://source.netsurf-browser.org/trunk/netsurf/amiga/font.c?rev=6095&r1=6094&r2=6095&view=diff
==============================================================================
--- trunk/netsurf/amiga/font.c (original)
+++ trunk/netsurf/amiga/font.c Fri Jan 16 14:05:21 2009
@@ -1,6 +1,5 @@
 /*
- * Copyright 2005 James Bursa <[email protected]>
- *           2008 Chris Young <[email protected]>
+ * Copyright 2008,2009 Chris Young <[email protected]>
  *
  * This file is part of NetSurf, http://www.netsurf-browser.org/
  *
@@ -33,7 +32,9 @@
 #include <proto/Picasso96API.h>
 #include <proto/exec.h>
 #include <graphics/blitattr.h>
-#include <graphics/composite.h>
+#include "amiga/options.h"
+
+struct OutlineFont *of[CSS_FONT_FAMILY_NOT_SET];
 
 static bool nsfont_width(const struct css_style *style,
          const char *string, size_t length,
@@ -57,9 +58,19 @@
                const char *string, size_t length,
                int *width)
 {
-       struct TextFont *tfont = ami_open_font(style);
-       *width = TextLength(currp,string,length); //buffer,strlen(buffer));
-       ami_close_font(tfont);
+       struct TextFont *tfont;
+
+       if(option_quick_text)
+       {
+               tfont = ami_open_font(style);
+               *width = TextLength(currp,string,length); 
//buffer,strlen(buffer));
+               ami_close_font(tfont);
+       }
+       else
+       {
+               *width = ami_unicode_text(NULL,string,length,style,0,0,0);
+       }
+
        return true;
 }
 
@@ -245,34 +256,7 @@
        char *fontname;
        WORD ysize;
 
-       switch(style->font_family)
-       {
-               case CSS_FONT_FAMILY_SANS_SERIF:
-                       fontname = option_font_sans;
-               break;
-
-               case CSS_FONT_FAMILY_SERIF:
-                       fontname = option_font_serif;
-               break;
-
-               case CSS_FONT_FAMILY_MONOSPACE:
-                       fontname = option_font_mono;
-               break;
-
-               case CSS_FONT_FAMILY_CURSIVE:
-                       fontname = option_font_cursive;
-               break;
-
-               case CSS_FONT_FAMILY_FANTASY:
-                       fontname = option_font_fantasy;
-               break;
-
-               default:
-                       fontname = option_font_sans;
-               break;
-       }
-
-       if(!(ofont = OpenOutlineFont(fontname,NULL,OFF_OPEN))) return NULL;
+       ofont = of[style->font_family];
 
 /* see diskfont implementation for currently unimplemented bold/italic stuff */
 
@@ -282,24 +266,14 @@
                ysize = option_font_min_size;
 
        if(ESetInfo(&ofont->olf_EEngine,
-                               OT_DeviceDPI,(72<<16) | 72,
-                               OT_PointHeight,(ysize<<16),
-                               TAG_END) == OTERR_Success)
-       {
-
-       }
-       else
-       {
-               CloseOutlineFont(ofont,NULL);
-               return NULL;
-       }
-
-       return ofont;
-}
-
-void ami_close_outline_font(struct OutlineFont *ofont)
-{
-       if(ofont) CloseOutlineFont(ofont,NULL);
+                       OT_DeviceDPI,(72<<16) | 72,
+                       OT_PointHeight,(ysize<<16),
+                       TAG_END) == OTERR_Success)
+       {
+               return ofont;
+       }
+
+       return NULL;
 }
 
 void ami_close_font(struct TextFont *tfont)
@@ -311,7 +285,7 @@
        if(tfont) CloseFont(tfont);
 }
 
-void ami_unicode_text(struct RastPort *rp,char *string,ULONG length,struct 
css_style *style,ULONG dx, ULONG dy, ULONG c)
+ULONG 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;
@@ -329,7 +303,7 @@
 
        if(utf8_to_enc(string,"UTF-16",length,&utf16) != UTF8_CONVERT_OK) 
return;
 
-       if(!(ofont = ami_open_outline_font(style))) return;
+       if(!(ofont = ami_open_outline_font(style))) return 0;
 
        
SetRPAttrs(currp,RPTAG_APenColor,p96EncodeColor(RGBFB_A8B8G8R8,c),TAG_DONE);
 
@@ -346,7 +320,9 @@
                                glyphbm = glyph->glm_BitMap;
                                if(!glyphbm) continue;
 
-                               BltBitMapTags(BLITA_SrcX,glyph->glm_BlackLeft,
+                               if(rp)
+                               {
+                                       
BltBitMapTags(BLITA_SrcX,glyph->glm_BlackLeft,
                                                BLITA_SrcY,glyph->glm_BlackTop,
                                                BLITA_DestX,dx+x,
                                                BLITA_DestY,dy-glyph->glm_Y1,
@@ -354,10 +330,11 @@
                                                
BLITA_Height,glyph->glm_BlackHeight,
                                                BLITA_Source,glyphbm,
                                                
BLITA_SrcType,BLITT_ALPHATEMPLATE,
-                                               BLITA_Dest,currp,
+                                               BLITA_Dest,rp,
                                                BLITA_DestType,BLITT_RASTPORT,
                                                
BLITA_SrcBytesPerRow,glyph->glm_BMModulo,
                                                TAG_DONE);
+                               }
 
                                x+= glyph->glm_X1;
 
@@ -370,5 +347,32 @@
 
        }
 
-       ami_close_outline_font(ofont);
-}
+       return x;
+}
+
+void ami_init_fonts(void)
+{
+       if(!option_quick_text)
+       {
+               of[CSS_FONT_FAMILY_SANS_SERIF] = 
OpenOutlineFont(option_font_sans,NULL,OFF_OPEN);
+               of[CSS_FONT_FAMILY_SERIF] = 
OpenOutlineFont(option_font_serif,NULL,OFF_OPEN);
+               of[CSS_FONT_FAMILY_MONOSPACE] = 
OpenOutlineFont(option_font_mono,NULL,OFF_OPEN);
+               of[CSS_FONT_FAMILY_CURSIVE] = 
OpenOutlineFont(option_font_cursive,NULL,OFF_OPEN);
+               of[CSS_FONT_FAMILY_FANTASY] = 
OpenOutlineFont(option_font_fantasy,NULL,OFF_OPEN);
+               of[CSS_FONT_FAMILY_UNKNOWN] = 
OpenOutlineFont(option_font_sans,NULL,OFF_OPEN);
+               of[CSS_FONT_FAMILY_NOT_SET] = 
OpenOutlineFont(option_font_sans,NULL,OFF_OPEN);
+       }
+}
+
+void ami_close_fonts(void)
+{
+       int i=0;
+
+       if(!option_quick_text)
+       {
+               for(i=0;i<=CSS_FONT_FAMILY_NOT_SET;i++)
+               {
+                       if(of[i]) CloseOutlineFont(of[i],NULL);
+               }
+       }
+}

Modified: trunk/netsurf/amiga/font.h
URL: 
http://source.netsurf-browser.org/trunk/netsurf/amiga/font.h?rev=6095&r1=6094&r2=6095&view=diff
==============================================================================
--- trunk/netsurf/amiga/font.h (original)
+++ trunk/netsurf/amiga/font.h Fri Jan 16 14:05:21 2009
@@ -1,5 +1,5 @@
 /*
- * Copyright 2008 Chris Young <[email protected]>
+ * Copyright 2008,2009 Chris Young <[email protected]>
  *
  * This file is part of NetSurf, http://www.netsurf-browser.org/
  *
@@ -24,5 +24,8 @@
 
 struct TextFont *ami_open_font(struct css_style *);
 void ami_close_font(struct TextFont *tfont);
-void ami_unicode_text(struct RastPort *rp,char *string,ULONG length,struct 
css_style *style,ULONG x,ULONG y,ULONG c);
+ULONG ami_unicode_text(struct RastPort *rp,char *string,ULONG length,struct 
css_style *style,ULONG x,ULONG y,ULONG c);
+
+void ami_init_fonts(void);
+void ami_close_fonts(void);
 #endif

Modified: trunk/netsurf/amiga/gui.c
URL: 
http://source.netsurf-browser.org/trunk/netsurf/amiga/gui.c?rev=6095&r1=6094&r2=6095&view=diff
==============================================================================
--- trunk/netsurf/amiga/gui.c (original)
+++ trunk/netsurf/amiga/gui.c Fri Jan 16 14:05:21 2009
@@ -330,6 +330,8 @@
        if(!option_window_width) option_window_width = 800;
        if(!option_window_height) option_window_height = 600;
 
+       ami_init_fonts();
+
        plot=amiplot;
 
        /* AmiUpdate */
@@ -1309,6 +1311,8 @@
        FreeVec(glob.rp.AreaInfo);
        FreeVec(glob.tmprasbuf);
        FreeVec(glob.areabuf);
+
+       ami_close_fonts();
 
        if(!locked_screen) /* set if we are using somebody else's screen */
        {


_______________________________________________
netsurf-commits mailing list
[email protected]
http://vlists.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org

Reply via email to