Gitweb links:

...log 
http://git.netsurf-browser.org/netsurf.git/shortlog/f90ed33501485663a091baefe41a87db93d2db91
...commit 
http://git.netsurf-browser.org/netsurf.git/commit/f90ed33501485663a091baefe41a87db93d2db91
...tree 
http://git.netsurf-browser.org/netsurf.git/tree/f90ed33501485663a091baefe41a87db93d2db91

The branch, master has been updated
       via  f90ed33501485663a091baefe41a87db93d2db91 (commit)
      from  d8b6de50d6da9a965df70ad758e9631c15be9728 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=f90ed33501485663a091baefe41a87db93d2db91
commit f90ed33501485663a091baefe41a87db93d2db91
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>

    update cocoa frontend to use font layout table

diff --git a/cocoa/NetsurfApp.m b/cocoa/NetsurfApp.m
index 3d5ff06..ec798be 100644
--- a/cocoa/NetsurfApp.m
+++ b/cocoa/NetsurfApp.m
@@ -25,6 +25,7 @@
 #import "cocoa/selection.h"
 #import "cocoa/fetch.h"
 #import "cocoa/bitmap.h"
+#import "cocoa/font.h"
 
 #import "utils/filename.h"
 #import "utils/log.h"
@@ -235,6 +236,7 @@ int main( int argc, char **argv )
                 .fetch = cocoa_fetch_table,
                 .search = cocoa_search_table,
                 .bitmap = cocoa_bitmap_table,
+                .layout = cocoa_layout_table,
         };
 
         error = netsurf_register(&cocoa_table);
diff --git a/cocoa/font.h b/cocoa/font.h
index 2a31e2c..cabd2b9 100644
--- a/cocoa/font.h
+++ b/cocoa/font.h
@@ -21,6 +21,8 @@
 
 #import "desktop/plot_style.h"
 
-void cocoa_draw_string( CGFloat x, CGFloat y, const char *bytes, size_t 
length, const plot_font_style_t *style );
+void cocoa_draw_string( CGFloat x, CGFloat y, const char *bytes, size_t 
length, const struct plot_font_style *style );
+
+struct gui_layout_table *cocoa_layout_table;
 
 #endif
diff --git a/cocoa/font.m b/cocoa/font.m
index 338339b..fb0562b 100644
--- a/cocoa/font.m
+++ b/cocoa/font.m
@@ -38,21 +38,24 @@ static NSDictionary *cocoa_font_attributes( const 
plot_font_style_t *style );
 static NSTextStorage *cocoa_text_storage = nil;
 static NSTextContainer *cocoa_text_container = nil;
 
-static bool nsfont_width(const plot_font_style_t *style,
-                                                const char *string, size_t 
length,
-                                                int *width)
+static nserror cocoa_font_width(const plot_font_style_t *style,
+                            const char *string, size_t length,
+                            int *width)
 {
-       NSLayoutManager *layout = cocoa_prepare_layout_manager( string, length, 
style );
+       NSLayoutManager *layout;
+        layout = cocoa_prepare_layout_manager( string, length, style );
        *width = cocoa_layout_width( layout );
-       return true;
+       return NSERROR_OK;
 }
 
-static bool nsfont_position_in_string(const plot_font_style_t *style,
-                                                                         const 
char *string, size_t length,
-                                                                         int 
x, size_t *char_offset, int *actual_x)
+static nserror cocoa_font_position(const plot_font_style_t *style,
+                                   const char *string, size_t length,
+                                   int x, size_t *char_offset, int *actual_x)
 {
        NSLayoutManager *layout = cocoa_prepare_layout_manager( string, length, 
style );
-       if (layout == nil) return false;
+       if (layout == nil) {
+                return NSERROR_BAD_PARAMETER;
+        }
        
        NSUInteger glyphIndex = cocoa_glyph_for_location( layout, x );
        NSUInteger chars = [layout characterIndexForGlyphAtIndex: glyphIndex];
@@ -61,17 +64,17 @@ static bool nsfont_position_in_string(const 
plot_font_style_t *style,
        else *char_offset = cocoa_bytes_for_characters( string, chars );
        
        *actual_x = cocoa_pt_to_px( NSMaxX( [layout boundingRectForGlyphRange: 
NSMakeRange( glyphIndex - 1, 1 ) 
-                                                                               
  inTextContainer: cocoa_text_container] ) );
+                                                              inTextContainer: 
cocoa_text_container] ) );
        
-       return true;
+       return NSERROR_OK;
 }
 
-static bool nsfont_split(const plot_font_style_t *style,
-                                                const char *string, size_t 
length,
-                                                int x, size_t *char_offset, 
int *actual_x)
+static nserror cocoa_font_split(const plot_font_style_t *style,
+                                const char *string, size_t length,
+                                int x, size_t *char_offset, int *actual_x)
 {
        NSLayoutManager *layout = cocoa_prepare_layout_manager( string, length, 
style );
-       if (layout == nil) return false;
+       if (layout == nil) return NSERROR_BAD_PARAMETER;
 
        NSUInteger glyphIndex = cocoa_glyph_for_location( layout, x );
        NSUInteger chars = [layout characterIndexForGlyphAtIndex: glyphIndex];
@@ -79,7 +82,7 @@ static bool nsfont_split(const plot_font_style_t *style,
        if (chars >= [cocoa_text_storage length]) {
                *char_offset = length;
                *actual_x = cocoa_layout_width( layout );
-               return true;
+               return NSERROR_OK;
        }
        
 
@@ -87,21 +90,25 @@ static bool nsfont_split(const plot_font_style_t *style,
        if (chars == NSNotFound) {
                *char_offset = 0;
                *actual_x = 0;
-               return true;
+               return NSERROR_OK;
        }
        
        *char_offset = cocoa_bytes_for_characters( string, chars );
        *actual_x = cocoa_layout_width_chars( layout, chars );
        
-       return true;
+       return NSERROR_OK;
 }
 
-const struct font_functions nsfont = {
-       nsfont_width,
-       nsfont_position_in_string,
-       nsfont_split
+
+static struct gui_layout_table layout_table = {
+       .width = cocoa_font_width,
+       .position = fb_font_position,
+       .split = fb_font_split,
 };
 
+struct gui_layout_table *cocoa_layout_table = &layout_table;
+
+
 #pragma mark -
 
 void cocoa_draw_string( CGFloat x, CGFloat y, const char *bytes, size_t 
length, const plot_font_style_t *style )


-----------------------------------------------------------------------

Summary of changes:
 cocoa/NetsurfApp.m |    2 ++
 cocoa/font.h       |    4 +++-
 cocoa/font.m       |   51 +++++++++++++++++++++++++++++----------------------
 3 files changed, 34 insertions(+), 23 deletions(-)

diff --git a/cocoa/NetsurfApp.m b/cocoa/NetsurfApp.m
index 3d5ff06..ec798be 100644
--- a/cocoa/NetsurfApp.m
+++ b/cocoa/NetsurfApp.m
@@ -25,6 +25,7 @@
 #import "cocoa/selection.h"
 #import "cocoa/fetch.h"
 #import "cocoa/bitmap.h"
+#import "cocoa/font.h"
 
 #import "utils/filename.h"
 #import "utils/log.h"
@@ -235,6 +236,7 @@ int main( int argc, char **argv )
                 .fetch = cocoa_fetch_table,
                 .search = cocoa_search_table,
                 .bitmap = cocoa_bitmap_table,
+                .layout = cocoa_layout_table,
         };
 
         error = netsurf_register(&cocoa_table);
diff --git a/cocoa/font.h b/cocoa/font.h
index 2a31e2c..cabd2b9 100644
--- a/cocoa/font.h
+++ b/cocoa/font.h
@@ -21,6 +21,8 @@
 
 #import "desktop/plot_style.h"
 
-void cocoa_draw_string( CGFloat x, CGFloat y, const char *bytes, size_t 
length, const plot_font_style_t *style );
+void cocoa_draw_string( CGFloat x, CGFloat y, const char *bytes, size_t 
length, const struct plot_font_style *style );
+
+struct gui_layout_table *cocoa_layout_table;
 
 #endif
diff --git a/cocoa/font.m b/cocoa/font.m
index 338339b..fb0562b 100644
--- a/cocoa/font.m
+++ b/cocoa/font.m
@@ -38,21 +38,24 @@ static NSDictionary *cocoa_font_attributes( const 
plot_font_style_t *style );
 static NSTextStorage *cocoa_text_storage = nil;
 static NSTextContainer *cocoa_text_container = nil;
 
-static bool nsfont_width(const plot_font_style_t *style,
-                                                const char *string, size_t 
length,
-                                                int *width)
+static nserror cocoa_font_width(const plot_font_style_t *style,
+                            const char *string, size_t length,
+                            int *width)
 {
-       NSLayoutManager *layout = cocoa_prepare_layout_manager( string, length, 
style );
+       NSLayoutManager *layout;
+        layout = cocoa_prepare_layout_manager( string, length, style );
        *width = cocoa_layout_width( layout );
-       return true;
+       return NSERROR_OK;
 }
 
-static bool nsfont_position_in_string(const plot_font_style_t *style,
-                                                                         const 
char *string, size_t length,
-                                                                         int 
x, size_t *char_offset, int *actual_x)
+static nserror cocoa_font_position(const plot_font_style_t *style,
+                                   const char *string, size_t length,
+                                   int x, size_t *char_offset, int *actual_x)
 {
        NSLayoutManager *layout = cocoa_prepare_layout_manager( string, length, 
style );
-       if (layout == nil) return false;
+       if (layout == nil) {
+                return NSERROR_BAD_PARAMETER;
+        }
        
        NSUInteger glyphIndex = cocoa_glyph_for_location( layout, x );
        NSUInteger chars = [layout characterIndexForGlyphAtIndex: glyphIndex];
@@ -61,17 +64,17 @@ static bool nsfont_position_in_string(const 
plot_font_style_t *style,
        else *char_offset = cocoa_bytes_for_characters( string, chars );
        
        *actual_x = cocoa_pt_to_px( NSMaxX( [layout boundingRectForGlyphRange: 
NSMakeRange( glyphIndex - 1, 1 ) 
-                                                                               
  inTextContainer: cocoa_text_container] ) );
+                                                              inTextContainer: 
cocoa_text_container] ) );
        
-       return true;
+       return NSERROR_OK;
 }
 
-static bool nsfont_split(const plot_font_style_t *style,
-                                                const char *string, size_t 
length,
-                                                int x, size_t *char_offset, 
int *actual_x)
+static nserror cocoa_font_split(const plot_font_style_t *style,
+                                const char *string, size_t length,
+                                int x, size_t *char_offset, int *actual_x)
 {
        NSLayoutManager *layout = cocoa_prepare_layout_manager( string, length, 
style );
-       if (layout == nil) return false;
+       if (layout == nil) return NSERROR_BAD_PARAMETER;
 
        NSUInteger glyphIndex = cocoa_glyph_for_location( layout, x );
        NSUInteger chars = [layout characterIndexForGlyphAtIndex: glyphIndex];
@@ -79,7 +82,7 @@ static bool nsfont_split(const plot_font_style_t *style,
        if (chars >= [cocoa_text_storage length]) {
                *char_offset = length;
                *actual_x = cocoa_layout_width( layout );
-               return true;
+               return NSERROR_OK;
        }
        
 
@@ -87,21 +90,25 @@ static bool nsfont_split(const plot_font_style_t *style,
        if (chars == NSNotFound) {
                *char_offset = 0;
                *actual_x = 0;
-               return true;
+               return NSERROR_OK;
        }
        
        *char_offset = cocoa_bytes_for_characters( string, chars );
        *actual_x = cocoa_layout_width_chars( layout, chars );
        
-       return true;
+       return NSERROR_OK;
 }
 
-const struct font_functions nsfont = {
-       nsfont_width,
-       nsfont_position_in_string,
-       nsfont_split
+
+static struct gui_layout_table layout_table = {
+       .width = cocoa_font_width,
+       .position = fb_font_position,
+       .split = fb_font_split,
 };
 
+struct gui_layout_table *cocoa_layout_table = &layout_table;
+
+
 #pragma mark -
 
 void cocoa_draw_string( CGFloat x, CGFloat y, const char *bytes, size_t 
length, const plot_font_style_t *style )


-- 
NetSurf Browser

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

Reply via email to