Gitweb links:

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

The branch, master has been updated
       via  0b7edfd252423edf097d82b8354ef34946a1a290 (commit)
       via  ae01f3661938b14b44a907113b6b65c0e3d1721d (commit)
      from  922faa743b16fcfe661d18be9efcaf329186fbe9 (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=0b7edfd252423edf097d82b8354ef34946a1a290
commit 0b7edfd252423edf097d82b8354ef34946a1a290
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>

    update framebuffer frontend to use layout table

diff --git a/framebuffer/fbtk/text.c b/framebuffer/fbtk/text.c
index f15586a..3d35583 100644
--- a/framebuffer/fbtk/text.c
+++ b/framebuffer/fbtk/text.c
@@ -29,7 +29,6 @@
 
 #include "utils/log.h"
 #include "desktop/browser.h"
-#include "desktop/font.h"
 
 #include "framebuffer/gui.h"
 #include "framebuffer/fbtk.h"
@@ -342,7 +341,7 @@ text_input(fbtk_widget_t *widget, fbtk_callback_info *cbi)
                widget->u.text.len--;
                widget->u.text.text[widget->u.text.len] = 0;
 
-               nsfont.font_width(&font_style, widget->u.text.text,
+               fb_font_width(&font_style, widget->u.text.text,
                                widget->u.text.len, &widget->u.text.width);
 
                caret_moved = true;
@@ -428,14 +427,14 @@ text_input(fbtk_widget_t *widget, fbtk_callback_info *cbi)
                widget->u.text.len++;
                widget->u.text.text[widget->u.text.len] = '\0';
 
-               nsfont.font_width(&font_style, widget->u.text.text,
+               fb_font_width(&font_style, widget->u.text.text,
                                widget->u.text.len, &widget->u.text.width);
                caret_moved = true;
                break;
        }
 
        if (caret_moved) {
-               nsfont.font_width(&font_style, widget->u.text.text,
+               fb_font_width(&font_style, widget->u.text.text,
                                widget->u.text.idx, &widget->u.text.idx_offset);
                fbtk_set_caret(widget, true,
                                widget->u.text.idx_offset + border,
@@ -467,7 +466,7 @@ text_input_click(fbtk_widget_t *widget, fbtk_callback_info 
*cbi)
 
        widget->u.text.idx = widget->u.text.len;
 
-       nsfont.font_position_in_string(&font_style, widget->u.text.text,
+       fb_font_position(&font_style, widget->u.text.text,
                        widget->u.text.len, cbi->x - border,
                        &idx,
                        &widget->u.text.idx_offset);
@@ -529,9 +528,9 @@ fbtk_set_text(fbtk_widget_t *widget, const char *text)
 
 
        fb_text_font_style(widget, &fh, &border, &font_style);
-       nsfont.font_width(&font_style, widget->u.text.text,
+       fb_font_width(&font_style, widget->u.text.text,
                        widget->u.text.len, &widget->u.text.width);
-       nsfont.font_width(&font_style, widget->u.text.text,
+       fb_font_width(&font_style, widget->u.text.text,
                        widget->u.text.idx, &widget->u.text.idx_offset);
 
        if (fbtk_get_caret(widget, &c_x, &c_y, &c_h)) {
diff --git a/framebuffer/font.h b/framebuffer/font.h
index 6350421..722a604 100644
--- a/framebuffer/font.h
+++ b/framebuffer/font.h
@@ -19,13 +19,45 @@
 #ifndef NETSURF_FB_FONT_H
 #define NETSURF_FB_FONT_H
 
-#include "utils/utf8.h"
-
+extern struct gui_layout_table *framebuffer_layout_table;
 extern struct gui_utf8_table *framebuffer_utf8_table;
 
+/**
+ * Initialise framebuffer font handling.
+ */
 bool fb_font_init(void);
+
+/**
+ * Finalise framebuffer font handling.
+ */
 bool fb_font_finalise(void);
 
+/**
+ * Find the position in a string where an x coordinate falls.
+ *
+ * \param[in] fstyle style for this text
+ * \param[in] string UTF-8 string to measure
+ * \param[in] length length of string, in bytes
+ * \param[in] x coordinate to search for
+ * \param[out] char_offset updated to offset in string of actual_x, [0..length]
+ * \param[out] actual_x updated to x coordinate of character closest to x
+ * \return NSERROR_OK and char_offset and actual_x updated or
+ *          appropriate error code on faliure
+ */
+nserror fb_font_position(const struct plot_font_style *fstyle, const char 
*string, size_t length, int x, size_t *char_offset, int *actual_x);
+
+/**
+ * Measure the width of a string.
+ *
+ * \param[in] fstyle plot style for this text
+ * \param[in] string UTF-8 string to measure
+ * \param[in] length length of string, in bytes
+ * \param[out] width updated to width of string[0..length)
+ * \return NSERROR_OK and width updated or appropriate error code on faliure
+ */
+nserror fb_font_width(const struct plot_font_style *fstyle, const char 
*string, size_t length, int *width);
+
+
 #ifdef FB_USE_FREETYPE
 #include "framebuffer/font_freetype.h"
 #else
diff --git a/framebuffer/font_freetype.c b/framebuffer/font_freetype.c
index ec3ceab..7756ae7 100644
--- a/framebuffer/font_freetype.c
+++ b/framebuffer/font_freetype.c
@@ -28,7 +28,7 @@
 #include "utils/log.h"
 #include "utils/nsoption.h"
 #include "desktop/gui_utf8.h"
-#include "desktop/font.h"
+#include "desktop/gui_layout.h"
 #include "desktop/browser.h"
 
 #include "framebuffer/gui.h"
@@ -74,8 +74,14 @@ enum fb_face_e {
 
 static fb_faceid_t *fb_faces[FB_FACE_COUNT];
 
-/* map cache manager handle to face id */
-static FT_Error ft_face_requester(FTC_FaceID face_id, FT_Library  library, 
FT_Pointer request_data, FT_Face *face )
+/**
+ * map cache manager handle to face id
+ */
+static FT_Error
+ft_face_requester(FTC_FaceID face_id,
+                 FT_Library  library,
+                 FT_Pointer request_data,
+                 FT_Face *face )
 {
         FT_Error error;
         fb_faceid_t *fb_face = (fb_faceid_t *)face_id;
@@ -103,7 +109,9 @@ static FT_Error ft_face_requester(FTC_FaceID face_id, 
FT_Library  library, FT_Po
         return error;
 }
 
-/* create new framebuffer face and cause it to be loaded to check its ok */
+/**
+ * create new framebuffer face and cause it to be loaded to check its ok
+ */
 static fb_faceid_t *
 fb_new_face(const char *option, const char *resname, const char *fontname)
 {
@@ -132,7 +140,7 @@ fb_new_face(const char *option, const char *resname, const 
char *fontname)
         return newf;
 }
 
-/* initialise font handling */
+/* exported interface documented in framebuffer/font.h */
 bool fb_font_init(void)
 {
         FT_Error error;
@@ -298,6 +306,7 @@ bool fb_font_init(void)
         return true;
 }
 
+/* exported interface documented in framebuffer/font.h */
 bool fb_font_finalise(void)
 {
        int i, j;
@@ -324,6 +333,9 @@ bool fb_font_finalise(void)
         return true;
 }
 
+/**
+ * fill freetype scalar
+ */
 static void fb_fill_scalar(const plot_font_style_t *fstyle, FTC_Scaler srec)
 {
         int selected_face = FB_FACE_DEFAULT;
@@ -380,6 +392,7 @@ static void fb_fill_scalar(const plot_font_style_t *fstyle, 
FTC_Scaler srec)
        srec->x_res = srec->y_res = browser_get_dpi();
 }
 
+/* exported interface documented in framebuffer/freetype_font.h */
 FT_Glyph fb_getglyph(const plot_font_style_t *fstyle, uint32_t ucs4)
 {
         FT_UInt glyph_index;
@@ -410,16 +423,9 @@ FT_Glyph fb_getglyph(const plot_font_style_t *fstyle, 
uint32_t ucs4)
 }
 
 
-/**
- * Measure the width of a string.
- *
- * \param  fstyle  style for this text
- * \param  string  UTF-8 string to measure
- * \param  length  length of string
- * \param  width   updated to width of string[0..length)
- * \return  true on success, false on error and error reported
- */
-static bool nsfont_width(const plot_font_style_t *fstyle,
+/* exported interface documented in framebuffer/freetype_font.h */
+nserror
+fb_font_width(const plot_font_style_t *fstyle,
                          const char *string, size_t length,
                          int *width)
 {
@@ -442,19 +448,10 @@ static bool nsfont_width(const plot_font_style_t *fstyle,
        return true;
 }
 
-/**
- * Find the position in a string where an x coordinate falls.
- *
- * \param  fstyle       style for this text
- * \param  string       UTF-8 string to measure
- * \param  length       length of string
- * \param  x            x coordinate to search for
- * \param  char_offset  updated to offset in string of actual_x, [0..length]
- * \param  actual_x     updated to x coordinate of character closest to x
- * \return  true on success, false on error and error reported
- */
 
-static bool nsfont_position_in_string(const plot_font_style_t *fstyle,
+/* exported interface documented in framebuffer/freetype_font.h */
+nserror
+fb_font_position(const plot_font_style_t *fstyle,
                const char *string, size_t length,
                int x, size_t *char_offset, int *actual_x)
 {
@@ -510,8 +507,8 @@ static bool nsfont_position_in_string(const 
plot_font_style_t *fstyle,
  *
  * Returning char_offset == length means no split possible
  */
-
-static bool nsfont_split(const plot_font_style_t *fstyle,
+static nserror
+fb_font_split(const plot_font_style_t *fstyle,
                const char *string, size_t length,
                int x, size_t *char_offset, int *actual_x)
 {
@@ -551,12 +548,15 @@ static bool nsfont_split(const plot_font_style_t *fstyle,
        return true;
 }
 
-const struct font_functions nsfont = {
-       nsfont_width,
-       nsfont_position_in_string,
-       nsfont_split
+static struct gui_layout_table layout_table = {
+       .width = fb_font_width,
+       .position = fb_font_position,
+       .split = fb_font_split,
 };
 
+struct gui_layout_table *framebuffer_layout_table = &layout_table;
+
+
 struct gui_utf8_table *framebuffer_utf8_table = NULL;
 
 /*
diff --git a/framebuffer/font_internal.c b/framebuffer/font_internal.c
index fba298f..7578e64 100644
--- a/framebuffer/font_internal.c
+++ b/framebuffer/font_internal.c
@@ -25,7 +25,7 @@
 #include "utils/nsoption.h"
 #include "utils/utf8.h"
 #include "desktop/gui_utf8.h"
-#include "desktop/font.h"
+#include "desktop/gui_layout.h"
 
 #include "framebuffer/gui.h"
 #include "framebuffer/font.h"
@@ -343,9 +343,12 @@ static nserror utf8_from_local(const char *string,
 }
 
 
-static bool nsfont_width(const plot_font_style_t *fstyle,
-                         const char *string, size_t length,
-                         int *width)
+/* exported interface documented in framebuffer/freetype_font.h */
+nserror
+fb_font_width(const plot_font_style_t *fstyle,
+             const char *string,
+             size_t length,
+             int *width)
 {
         size_t nxtchr = 0;
 
@@ -364,21 +367,15 @@ static bool nsfont_width(const plot_font_style_t *fstyle,
        return true;
 }
 
-/**
- * Find the position in a string where an x coordinate falls.
- *
- * \param  fstyle       style for this text
- * \param  string       UTF-8 string to measure
- * \param  length       length of string
- * \param  x            x coordinate to search for
- * \param  char_offset  updated to offset in string of actual_x, [0..length]
- * \param  actual_x     updated to x coordinate of character closest to x
- * \return  true on success, false on error and error reported
- */
 
-static bool nsfont_position_in_string(const plot_font_style_t *fstyle,
-               const char *string, size_t length,
-               int x, size_t *char_offset, int *actual_x)
+/* exported interface documented in framebuffer/freetype_font.h */
+nserror
+fb_font_position(const plot_font_style_t *fstyle,
+                const char *string,
+                size_t length,
+                int x,
+                size_t *char_offset,
+                int *actual_x)
 {
         const int width = fb_get_font_size(fstyle) * FB_FONT_WIDTH;
         size_t nxtchr = 0;
@@ -404,7 +401,6 @@ static bool nsfont_position_in_string(const 
plot_font_style_t *fstyle,
 }
 
 
-
 /**
  * Find where to split a string to make it fit a width.
  *
@@ -427,10 +423,13 @@ static bool nsfont_position_in_string(const 
plot_font_style_t *fstyle,
  *
  * Returning char_offset == length means no split possible
  */
-
-static bool nsfont_split(const plot_font_style_t *fstyle,
-               const char *string, size_t length,
-               int x, size_t *char_offset, int *actual_x)
+static nserror
+fb_font_split(const plot_font_style_t *fstyle,
+             const char *string,
+             size_t length,
+             int x,
+             size_t *char_offset,
+             int *actual_x)
 {
         const int width = fb_get_font_size(fstyle) * FB_FONT_WIDTH;
         size_t nxtchr = 0;
@@ -467,12 +466,16 @@ static bool nsfont_split(const plot_font_style_t *fstyle,
        return true;
 }
 
-const struct font_functions nsfont = {
-       nsfont_width,
-       nsfont_position_in_string,
-       nsfont_split
+
+static struct gui_layout_table layout_table = {
+       .width = fb_font_width,
+       .position = fb_font_position,
+       .split = fb_font_split,
 };
 
+struct gui_layout_table *framebuffer_layout_table = &layout_table;
+
+
 static struct gui_utf8_table utf8_table = {
        .utf8_to_local = utf8_to_local,
        .local_to_utf8 = utf8_from_local,
diff --git a/framebuffer/font_internal.h b/framebuffer/font_internal.h
index d066f6b..f25df8d 100644
--- a/framebuffer/font_internal.h
+++ b/framebuffer/font_internal.h
@@ -40,10 +40,10 @@ enum fb_font_style {
 enum fb_font_style fb_get_font_style(const plot_font_style_t *fstyle);
 int fb_get_font_size(const plot_font_style_t *fstyle);
 
-const uint8_t *fb_get_glyph(uint32_t ucs4, enum fb_font_style style, int 
scale);
-
 #define codepoint_displayable(u) \
        (!(u >= 0x200b && u <= 0x200f))
 
+const uint8_t *fb_get_glyph(uint32_t ucs4, enum fb_font_style style, int 
scale);
+
 #endif /* NETSURF_FB_FONT_INTERNAL_H */
 
diff --git a/framebuffer/framebuffer.c b/framebuffer/framebuffer.c
index 97760cf..7d811aa 100644
--- a/framebuffer/framebuffer.c
+++ b/framebuffer/framebuffer.c
@@ -30,6 +30,7 @@
 
 #include "utils/utils.h"
 #include "utils/log.h"
+#include "utils/utf8.h"
 #include "desktop/browser.h"
 #include "image/bitmap.h"
 
diff --git a/framebuffer/gui.c b/framebuffer/gui.c
index 8a29681..11511fe 100644
--- a/framebuffer/gui.c
+++ b/framebuffer/gui.c
@@ -2082,6 +2082,7 @@ main(int argc, char** argv)
                .fetch = framebuffer_fetch_table,
                .utf8 = framebuffer_utf8_table,
                .bitmap = framebuffer_bitmap_table,
+               .layout = framebuffer_layout_table,
        };
 
         ret = netsurf_register(&framebuffer_table);


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

    update monkey frontend to use layout table

diff --git a/monkey/Makefile.target b/monkey/Makefile.target
index 3c7b093..f03290d 100644
--- a/monkey/Makefile.target
+++ b/monkey/Makefile.target
@@ -57,7 +57,7 @@ endif
 
 # S_MONKEY are sources purely for the MONKEY build
 S_MONKEY := main.c utils.c filetype.c schedule.c bitmap.c plot.c browser.c \
-       download.c 401login.c cert.c font.c dispatch.c fetch.c
+       download.c 401login.c cert.c layout.c dispatch.c fetch.c
 
 S_MONKEY := $(addprefix monkey/,$(S_MONKEY))
 
diff --git a/monkey/font.c b/monkey/font.c
deleted file mode 100644
index 3b6ca4f..0000000
--- a/monkey/font.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright 2011 Daniel Silverstone <[email protected]>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "utils/nsoption.h"
-#include "utils/utf8.h"
-#include "desktop/font.h"
-
-static bool nsfont_width(const plot_font_style_t *fstyle,
-                         const char *string, size_t length,
-                         int *width)
-{
-  *width = (fstyle->size * utf8_bounded_length(string, length)) / 
FONT_SIZE_SCALE;
-  return true;
-}
-
-/**
- * Find the position in a string where an x coordinate falls.
- *
- * \param  fstyle       style for this text
- * \param  string       UTF-8 string to measure
- * \param  length       length of string
- * \param  x            x coordinate to search for
- * \param  char_offset  updated to offset in string of actual_x, [0..length]
- * \param  actual_x     updated to x coordinate of character closest to x
- * \return  true on success, false on error and error reported
- */
-
-static bool nsfont_position_in_string(const plot_font_style_t *fstyle,
-               const char *string, size_t length,
-               int x, size_t *char_offset, int *actual_x)
-{
-  *char_offset = x / (fstyle->size / FONT_SIZE_SCALE);
-  if (*char_offset > length)
-    *char_offset = length;
-  *actual_x = *char_offset * (fstyle->size / FONT_SIZE_SCALE);
-  return true;
-}
-
-
-/**
- * Find where to split a string to make it fit a width.
- *
- * \param  fstyle       style for this text
- * \param  string       UTF-8 string to measure
- * \param  length       length of string, in bytes
- * \param  x            width available
- * \param  char_offset  updated to offset in string of actual_x, [1..length]
- * \param  actual_x     updated to x coordinate of character closest to x
- * \return  true on success, false on error and error reported
- *
- * On exit, char_offset indicates first character after split point.
- *
- * Note: char_offset of 0 should never be returned.
- *
- *   Returns:
- *     char_offset giving split point closest to x, where actual_x <= x
- *   else
- *     char_offset giving split point closest to x, where actual_x > x
- *
- * Returning char_offset == length means no split possible
- */
-
-static bool nsfont_split(const plot_font_style_t *fstyle,
-               const char *string, size_t length,
-               int x, size_t *char_offset, int *actual_x)
-{
-  int c_off = *char_offset = x / (fstyle->size / FONT_SIZE_SCALE);
-  if (*char_offset > length) {
-    *char_offset = length;
-  } else {
-    while (*char_offset > 0) {
-      if (string[*char_offset] == ' ')
-        break;
-      (*char_offset)--;
-    }
-    if (*char_offset == 0) {
-      *char_offset = c_off;
-      while (*char_offset < length && string[*char_offset] != ' ') {
-        (*char_offset)++;
-      }
-    }
-  }
-  *actual_x = *char_offset * (fstyle->size / FONT_SIZE_SCALE);
-  return true;
-}
-
-const struct font_functions nsfont = {
-       nsfont_width,
-       nsfont_position_in_string,
-       nsfont_split
-};
diff --git a/monkey/layout.c b/monkey/layout.c
new file mode 100644
index 0000000..401ca15
--- /dev/null
+++ b/monkey/layout.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2011 Daniel Silverstone <[email protected]>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * \file
+ * monkey implementation of font layout.
+ */
+
+#include <stddef.h>
+
+#include "utils/utf8.h"
+#include "desktop/plot_style.h"
+#include "desktop/gui_layout.h"
+
+#include "monkey/layout.h"
+
+static nserror nsfont_width(const plot_font_style_t *fstyle,
+                         const char *string, size_t length,
+                         int *width)
+{
+  *width = (fstyle->size * utf8_bounded_length(string, length)) / 
FONT_SIZE_SCALE;
+  return NSERROR_OK;
+}
+
+/**
+ * Find the position in a string where an x coordinate falls.
+ *
+ * \param  fstyle       style for this text
+ * \param  string       UTF-8 string to measure
+ * \param  length       length of string
+ * \param  x            x coordinate to search for
+ * \param  char_offset  updated to offset in string of actual_x, [0..length]
+ * \param  actual_x     updated to x coordinate of character closest to x
+ * \return  true on success, false on error and error reported
+ */
+
+static nserror nsfont_position_in_string(const plot_font_style_t *fstyle,
+               const char *string, size_t length,
+               int x, size_t *char_offset, int *actual_x)
+{
+  *char_offset = x / (fstyle->size / FONT_SIZE_SCALE);
+  if (*char_offset > length)
+    *char_offset = length;
+  *actual_x = *char_offset * (fstyle->size / FONT_SIZE_SCALE);
+  return NSERROR_OK;
+}
+
+
+/**
+ * Find where to split a string to make it fit a width.
+ *
+ * \param  fstyle       style for this text
+ * \param  string       UTF-8 string to measure
+ * \param  length       length of string, in bytes
+ * \param  x            width available
+ * \param  char_offset  updated to offset in string of actual_x, [1..length]
+ * \param  actual_x     updated to x coordinate of character closest to x
+ * \return  true on success, false on error and error reported
+ *
+ * On exit, char_offset indicates first character after split point.
+ *
+ * Note: char_offset of 0 should never be returned.
+ *
+ *   Returns:
+ *     char_offset giving split point closest to x, where actual_x <= x
+ *   else
+ *     char_offset giving split point closest to x, where actual_x > x
+ *
+ * Returning char_offset == length means no split possible
+ */
+
+static nserror nsfont_split(const plot_font_style_t *fstyle,
+               const char *string, size_t length,
+               int x, size_t *char_offset, int *actual_x)
+{
+  int c_off = *char_offset = x / (fstyle->size / FONT_SIZE_SCALE);
+  if (*char_offset > length) {
+    *char_offset = length;
+  } else {
+    while (*char_offset > 0) {
+      if (string[*char_offset] == ' ')
+        break;
+      (*char_offset)--;
+    }
+    if (*char_offset == 0) {
+      *char_offset = c_off;
+      while (*char_offset < length && string[*char_offset] != ' ') {
+        (*char_offset)++;
+      }
+    }
+  }
+  *actual_x = *char_offset * (fstyle->size / FONT_SIZE_SCALE);
+  return NSERROR_OK;
+}
+
+static struct gui_layout_table layout_table = {
+       .width = nsfont_width,
+       .position = nsfont_position_in_string,
+       .split = nsfont_split,
+};
+
+struct gui_layout_table *monkey_layout_table = &layout_table;
diff --git a/monkey/layout.h b/monkey/layout.h
new file mode 100644
index 0000000..1e713c2
--- /dev/null
+++ b/monkey/layout.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2016 Vincent Sanders <[email protected]>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef NS_MONKEY_LAYOUT_H
+#define NS_MONKEY_LAYOUT_H
+
+extern struct gui_layout_table *monkey_layout_table;
+
+#endif /* NS_MONKEY_LAYOUT_H */
diff --git a/monkey/main.c b/monkey/main.c
index 526488e..f7d6609 100644
--- a/monkey/main.c
+++ b/monkey/main.c
@@ -44,6 +44,7 @@
 #include "monkey/fetch.h"
 #include "monkey/schedule.h"
 #include "monkey/bitmap.h"
+#include "monkey/layout.h"
 
 /** maximum number of languages in language vector */
 #define LANGV_SIZE 32
@@ -319,6 +320,7 @@ main(int argc, char **argv)
     .download = monkey_download_table,
     .fetch = monkey_fetch_table,
     .bitmap = monkey_bitmap_table,
+    .layout = monkey_layout_table,
   };
 
   ret = netsurf_register(&monkey_table);


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

Summary of changes:
 framebuffer/fbtk/text.c          |   13 ++++----
 framebuffer/font.h               |   36 +++++++++++++++++++--
 framebuffer/font_freetype.c      |   66 +++++++++++++++++++-------------------
 framebuffer/font_internal.c      |   57 ++++++++++++++++----------------
 framebuffer/font_internal.h      |    4 +--
 framebuffer/framebuffer.c        |    1 +
 framebuffer/gui.c                |    1 +
 monkey/Makefile.target           |    2 +-
 monkey/{font.c => layout.c}      |   35 +++++++++++++-------
 atari/about.h => monkey/layout.h |   10 +++---
 monkey/main.c                    |    2 ++
 11 files changed, 138 insertions(+), 89 deletions(-)
 rename monkey/{font.c => layout.c} (82%)
 copy atari/about.h => monkey/layout.h (76%)

diff --git a/framebuffer/fbtk/text.c b/framebuffer/fbtk/text.c
index f15586a..3d35583 100644
--- a/framebuffer/fbtk/text.c
+++ b/framebuffer/fbtk/text.c
@@ -29,7 +29,6 @@
 
 #include "utils/log.h"
 #include "desktop/browser.h"
-#include "desktop/font.h"
 
 #include "framebuffer/gui.h"
 #include "framebuffer/fbtk.h"
@@ -342,7 +341,7 @@ text_input(fbtk_widget_t *widget, fbtk_callback_info *cbi)
                widget->u.text.len--;
                widget->u.text.text[widget->u.text.len] = 0;
 
-               nsfont.font_width(&font_style, widget->u.text.text,
+               fb_font_width(&font_style, widget->u.text.text,
                                widget->u.text.len, &widget->u.text.width);
 
                caret_moved = true;
@@ -428,14 +427,14 @@ text_input(fbtk_widget_t *widget, fbtk_callback_info *cbi)
                widget->u.text.len++;
                widget->u.text.text[widget->u.text.len] = '\0';
 
-               nsfont.font_width(&font_style, widget->u.text.text,
+               fb_font_width(&font_style, widget->u.text.text,
                                widget->u.text.len, &widget->u.text.width);
                caret_moved = true;
                break;
        }
 
        if (caret_moved) {
-               nsfont.font_width(&font_style, widget->u.text.text,
+               fb_font_width(&font_style, widget->u.text.text,
                                widget->u.text.idx, &widget->u.text.idx_offset);
                fbtk_set_caret(widget, true,
                                widget->u.text.idx_offset + border,
@@ -467,7 +466,7 @@ text_input_click(fbtk_widget_t *widget, fbtk_callback_info 
*cbi)
 
        widget->u.text.idx = widget->u.text.len;
 
-       nsfont.font_position_in_string(&font_style, widget->u.text.text,
+       fb_font_position(&font_style, widget->u.text.text,
                        widget->u.text.len, cbi->x - border,
                        &idx,
                        &widget->u.text.idx_offset);
@@ -529,9 +528,9 @@ fbtk_set_text(fbtk_widget_t *widget, const char *text)
 
 
        fb_text_font_style(widget, &fh, &border, &font_style);
-       nsfont.font_width(&font_style, widget->u.text.text,
+       fb_font_width(&font_style, widget->u.text.text,
                        widget->u.text.len, &widget->u.text.width);
-       nsfont.font_width(&font_style, widget->u.text.text,
+       fb_font_width(&font_style, widget->u.text.text,
                        widget->u.text.idx, &widget->u.text.idx_offset);
 
        if (fbtk_get_caret(widget, &c_x, &c_y, &c_h)) {
diff --git a/framebuffer/font.h b/framebuffer/font.h
index 6350421..722a604 100644
--- a/framebuffer/font.h
+++ b/framebuffer/font.h
@@ -19,13 +19,45 @@
 #ifndef NETSURF_FB_FONT_H
 #define NETSURF_FB_FONT_H
 
-#include "utils/utf8.h"
-
+extern struct gui_layout_table *framebuffer_layout_table;
 extern struct gui_utf8_table *framebuffer_utf8_table;
 
+/**
+ * Initialise framebuffer font handling.
+ */
 bool fb_font_init(void);
+
+/**
+ * Finalise framebuffer font handling.
+ */
 bool fb_font_finalise(void);
 
+/**
+ * Find the position in a string where an x coordinate falls.
+ *
+ * \param[in] fstyle style for this text
+ * \param[in] string UTF-8 string to measure
+ * \param[in] length length of string, in bytes
+ * \param[in] x coordinate to search for
+ * \param[out] char_offset updated to offset in string of actual_x, [0..length]
+ * \param[out] actual_x updated to x coordinate of character closest to x
+ * \return NSERROR_OK and char_offset and actual_x updated or
+ *          appropriate error code on faliure
+ */
+nserror fb_font_position(const struct plot_font_style *fstyle, const char 
*string, size_t length, int x, size_t *char_offset, int *actual_x);
+
+/**
+ * Measure the width of a string.
+ *
+ * \param[in] fstyle plot style for this text
+ * \param[in] string UTF-8 string to measure
+ * \param[in] length length of string, in bytes
+ * \param[out] width updated to width of string[0..length)
+ * \return NSERROR_OK and width updated or appropriate error code on faliure
+ */
+nserror fb_font_width(const struct plot_font_style *fstyle, const char 
*string, size_t length, int *width);
+
+
 #ifdef FB_USE_FREETYPE
 #include "framebuffer/font_freetype.h"
 #else
diff --git a/framebuffer/font_freetype.c b/framebuffer/font_freetype.c
index ec3ceab..7756ae7 100644
--- a/framebuffer/font_freetype.c
+++ b/framebuffer/font_freetype.c
@@ -28,7 +28,7 @@
 #include "utils/log.h"
 #include "utils/nsoption.h"
 #include "desktop/gui_utf8.h"
-#include "desktop/font.h"
+#include "desktop/gui_layout.h"
 #include "desktop/browser.h"
 
 #include "framebuffer/gui.h"
@@ -74,8 +74,14 @@ enum fb_face_e {
 
 static fb_faceid_t *fb_faces[FB_FACE_COUNT];
 
-/* map cache manager handle to face id */
-static FT_Error ft_face_requester(FTC_FaceID face_id, FT_Library  library, 
FT_Pointer request_data, FT_Face *face )
+/**
+ * map cache manager handle to face id
+ */
+static FT_Error
+ft_face_requester(FTC_FaceID face_id,
+                 FT_Library  library,
+                 FT_Pointer request_data,
+                 FT_Face *face )
 {
         FT_Error error;
         fb_faceid_t *fb_face = (fb_faceid_t *)face_id;
@@ -103,7 +109,9 @@ static FT_Error ft_face_requester(FTC_FaceID face_id, 
FT_Library  library, FT_Po
         return error;
 }
 
-/* create new framebuffer face and cause it to be loaded to check its ok */
+/**
+ * create new framebuffer face and cause it to be loaded to check its ok
+ */
 static fb_faceid_t *
 fb_new_face(const char *option, const char *resname, const char *fontname)
 {
@@ -132,7 +140,7 @@ fb_new_face(const char *option, const char *resname, const 
char *fontname)
         return newf;
 }
 
-/* initialise font handling */
+/* exported interface documented in framebuffer/font.h */
 bool fb_font_init(void)
 {
         FT_Error error;
@@ -298,6 +306,7 @@ bool fb_font_init(void)
         return true;
 }
 
+/* exported interface documented in framebuffer/font.h */
 bool fb_font_finalise(void)
 {
        int i, j;
@@ -324,6 +333,9 @@ bool fb_font_finalise(void)
         return true;
 }
 
+/**
+ * fill freetype scalar
+ */
 static void fb_fill_scalar(const plot_font_style_t *fstyle, FTC_Scaler srec)
 {
         int selected_face = FB_FACE_DEFAULT;
@@ -380,6 +392,7 @@ static void fb_fill_scalar(const plot_font_style_t *fstyle, 
FTC_Scaler srec)
        srec->x_res = srec->y_res = browser_get_dpi();
 }
 
+/* exported interface documented in framebuffer/freetype_font.h */
 FT_Glyph fb_getglyph(const plot_font_style_t *fstyle, uint32_t ucs4)
 {
         FT_UInt glyph_index;
@@ -410,16 +423,9 @@ FT_Glyph fb_getglyph(const plot_font_style_t *fstyle, 
uint32_t ucs4)
 }
 
 
-/**
- * Measure the width of a string.
- *
- * \param  fstyle  style for this text
- * \param  string  UTF-8 string to measure
- * \param  length  length of string
- * \param  width   updated to width of string[0..length)
- * \return  true on success, false on error and error reported
- */
-static bool nsfont_width(const plot_font_style_t *fstyle,
+/* exported interface documented in framebuffer/freetype_font.h */
+nserror
+fb_font_width(const plot_font_style_t *fstyle,
                          const char *string, size_t length,
                          int *width)
 {
@@ -442,19 +448,10 @@ static bool nsfont_width(const plot_font_style_t *fstyle,
        return true;
 }
 
-/**
- * Find the position in a string where an x coordinate falls.
- *
- * \param  fstyle       style for this text
- * \param  string       UTF-8 string to measure
- * \param  length       length of string
- * \param  x            x coordinate to search for
- * \param  char_offset  updated to offset in string of actual_x, [0..length]
- * \param  actual_x     updated to x coordinate of character closest to x
- * \return  true on success, false on error and error reported
- */
 
-static bool nsfont_position_in_string(const plot_font_style_t *fstyle,
+/* exported interface documented in framebuffer/freetype_font.h */
+nserror
+fb_font_position(const plot_font_style_t *fstyle,
                const char *string, size_t length,
                int x, size_t *char_offset, int *actual_x)
 {
@@ -510,8 +507,8 @@ static bool nsfont_position_in_string(const 
plot_font_style_t *fstyle,
  *
  * Returning char_offset == length means no split possible
  */
-
-static bool nsfont_split(const plot_font_style_t *fstyle,
+static nserror
+fb_font_split(const plot_font_style_t *fstyle,
                const char *string, size_t length,
                int x, size_t *char_offset, int *actual_x)
 {
@@ -551,12 +548,15 @@ static bool nsfont_split(const plot_font_style_t *fstyle,
        return true;
 }
 
-const struct font_functions nsfont = {
-       nsfont_width,
-       nsfont_position_in_string,
-       nsfont_split
+static struct gui_layout_table layout_table = {
+       .width = fb_font_width,
+       .position = fb_font_position,
+       .split = fb_font_split,
 };
 
+struct gui_layout_table *framebuffer_layout_table = &layout_table;
+
+
 struct gui_utf8_table *framebuffer_utf8_table = NULL;
 
 /*
diff --git a/framebuffer/font_internal.c b/framebuffer/font_internal.c
index fba298f..7578e64 100644
--- a/framebuffer/font_internal.c
+++ b/framebuffer/font_internal.c
@@ -25,7 +25,7 @@
 #include "utils/nsoption.h"
 #include "utils/utf8.h"
 #include "desktop/gui_utf8.h"
-#include "desktop/font.h"
+#include "desktop/gui_layout.h"
 
 #include "framebuffer/gui.h"
 #include "framebuffer/font.h"
@@ -343,9 +343,12 @@ static nserror utf8_from_local(const char *string,
 }
 
 
-static bool nsfont_width(const plot_font_style_t *fstyle,
-                         const char *string, size_t length,
-                         int *width)
+/* exported interface documented in framebuffer/freetype_font.h */
+nserror
+fb_font_width(const plot_font_style_t *fstyle,
+             const char *string,
+             size_t length,
+             int *width)
 {
         size_t nxtchr = 0;
 
@@ -364,21 +367,15 @@ static bool nsfont_width(const plot_font_style_t *fstyle,
        return true;
 }
 
-/**
- * Find the position in a string where an x coordinate falls.
- *
- * \param  fstyle       style for this text
- * \param  string       UTF-8 string to measure
- * \param  length       length of string
- * \param  x            x coordinate to search for
- * \param  char_offset  updated to offset in string of actual_x, [0..length]
- * \param  actual_x     updated to x coordinate of character closest to x
- * \return  true on success, false on error and error reported
- */
 
-static bool nsfont_position_in_string(const plot_font_style_t *fstyle,
-               const char *string, size_t length,
-               int x, size_t *char_offset, int *actual_x)
+/* exported interface documented in framebuffer/freetype_font.h */
+nserror
+fb_font_position(const plot_font_style_t *fstyle,
+                const char *string,
+                size_t length,
+                int x,
+                size_t *char_offset,
+                int *actual_x)
 {
         const int width = fb_get_font_size(fstyle) * FB_FONT_WIDTH;
         size_t nxtchr = 0;
@@ -404,7 +401,6 @@ static bool nsfont_position_in_string(const 
plot_font_style_t *fstyle,
 }
 
 
-
 /**
  * Find where to split a string to make it fit a width.
  *
@@ -427,10 +423,13 @@ static bool nsfont_position_in_string(const 
plot_font_style_t *fstyle,
  *
  * Returning char_offset == length means no split possible
  */
-
-static bool nsfont_split(const plot_font_style_t *fstyle,
-               const char *string, size_t length,
-               int x, size_t *char_offset, int *actual_x)
+static nserror
+fb_font_split(const plot_font_style_t *fstyle,
+             const char *string,
+             size_t length,
+             int x,
+             size_t *char_offset,
+             int *actual_x)
 {
         const int width = fb_get_font_size(fstyle) * FB_FONT_WIDTH;
         size_t nxtchr = 0;
@@ -467,12 +466,16 @@ static bool nsfont_split(const plot_font_style_t *fstyle,
        return true;
 }
 
-const struct font_functions nsfont = {
-       nsfont_width,
-       nsfont_position_in_string,
-       nsfont_split
+
+static struct gui_layout_table layout_table = {
+       .width = fb_font_width,
+       .position = fb_font_position,
+       .split = fb_font_split,
 };
 
+struct gui_layout_table *framebuffer_layout_table = &layout_table;
+
+
 static struct gui_utf8_table utf8_table = {
        .utf8_to_local = utf8_to_local,
        .local_to_utf8 = utf8_from_local,
diff --git a/framebuffer/font_internal.h b/framebuffer/font_internal.h
index d066f6b..f25df8d 100644
--- a/framebuffer/font_internal.h
+++ b/framebuffer/font_internal.h
@@ -40,10 +40,10 @@ enum fb_font_style {
 enum fb_font_style fb_get_font_style(const plot_font_style_t *fstyle);
 int fb_get_font_size(const plot_font_style_t *fstyle);
 
-const uint8_t *fb_get_glyph(uint32_t ucs4, enum fb_font_style style, int 
scale);
-
 #define codepoint_displayable(u) \
        (!(u >= 0x200b && u <= 0x200f))
 
+const uint8_t *fb_get_glyph(uint32_t ucs4, enum fb_font_style style, int 
scale);
+
 #endif /* NETSURF_FB_FONT_INTERNAL_H */
 
diff --git a/framebuffer/framebuffer.c b/framebuffer/framebuffer.c
index 97760cf..7d811aa 100644
--- a/framebuffer/framebuffer.c
+++ b/framebuffer/framebuffer.c
@@ -30,6 +30,7 @@
 
 #include "utils/utils.h"
 #include "utils/log.h"
+#include "utils/utf8.h"
 #include "desktop/browser.h"
 #include "image/bitmap.h"
 
diff --git a/framebuffer/gui.c b/framebuffer/gui.c
index 8a29681..11511fe 100644
--- a/framebuffer/gui.c
+++ b/framebuffer/gui.c
@@ -2082,6 +2082,7 @@ main(int argc, char** argv)
                .fetch = framebuffer_fetch_table,
                .utf8 = framebuffer_utf8_table,
                .bitmap = framebuffer_bitmap_table,
+               .layout = framebuffer_layout_table,
        };
 
         ret = netsurf_register(&framebuffer_table);
diff --git a/monkey/Makefile.target b/monkey/Makefile.target
index 3c7b093..f03290d 100644
--- a/monkey/Makefile.target
+++ b/monkey/Makefile.target
@@ -57,7 +57,7 @@ endif
 
 # S_MONKEY are sources purely for the MONKEY build
 S_MONKEY := main.c utils.c filetype.c schedule.c bitmap.c plot.c browser.c \
-       download.c 401login.c cert.c font.c dispatch.c fetch.c
+       download.c 401login.c cert.c layout.c dispatch.c fetch.c
 
 S_MONKEY := $(addprefix monkey/,$(S_MONKEY))
 
diff --git a/monkey/font.c b/monkey/layout.c
similarity index 82%
rename from monkey/font.c
rename to monkey/layout.c
index 3b6ca4f..401ca15 100644
--- a/monkey/font.c
+++ b/monkey/layout.c
@@ -16,16 +16,25 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "utils/nsoption.h"
+/**
+ * \file
+ * monkey implementation of font layout.
+ */
+
+#include <stddef.h>
+
 #include "utils/utf8.h"
-#include "desktop/font.h"
+#include "desktop/plot_style.h"
+#include "desktop/gui_layout.h"
+
+#include "monkey/layout.h"
 
-static bool nsfont_width(const plot_font_style_t *fstyle,
+static nserror nsfont_width(const plot_font_style_t *fstyle,
                          const char *string, size_t length,
                          int *width)
 {
   *width = (fstyle->size * utf8_bounded_length(string, length)) / 
FONT_SIZE_SCALE;
-  return true;
+  return NSERROR_OK;
 }
 
 /**
@@ -40,7 +49,7 @@ static bool nsfont_width(const plot_font_style_t *fstyle,
  * \return  true on success, false on error and error reported
  */
 
-static bool nsfont_position_in_string(const plot_font_style_t *fstyle,
+static nserror nsfont_position_in_string(const plot_font_style_t *fstyle,
                const char *string, size_t length,
                int x, size_t *char_offset, int *actual_x)
 {
@@ -48,7 +57,7 @@ static bool nsfont_position_in_string(const plot_font_style_t 
*fstyle,
   if (*char_offset > length)
     *char_offset = length;
   *actual_x = *char_offset * (fstyle->size / FONT_SIZE_SCALE);
-  return true;
+  return NSERROR_OK;
 }
 
 
@@ -75,7 +84,7 @@ static bool nsfont_position_in_string(const plot_font_style_t 
*fstyle,
  * Returning char_offset == length means no split possible
  */
 
-static bool nsfont_split(const plot_font_style_t *fstyle,
+static nserror nsfont_split(const plot_font_style_t *fstyle,
                const char *string, size_t length,
                int x, size_t *char_offset, int *actual_x)
 {
@@ -96,11 +105,13 @@ static bool nsfont_split(const plot_font_style_t *fstyle,
     }
   }
   *actual_x = *char_offset * (fstyle->size / FONT_SIZE_SCALE);
-  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 = nsfont_width,
+       .position = nsfont_position_in_string,
+       .split = nsfont_split,
 };
+
+struct gui_layout_table *monkey_layout_table = &layout_table;
diff --git a/atari/about.h b/monkey/layout.h
similarity index 76%
copy from atari/about.h
copy to monkey/layout.h
index dff6eae..1e713c2 100644
--- a/atari/about.h
+++ b/monkey/layout.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 2013 Ole Loots <[email protected]>
+ * Copyright 2016 Vincent Sanders <[email protected]>
  *
  * This file is part of NetSurf, http://www.netsurf-browser.org/
  *
@@ -16,9 +16,9 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef NS_ATARI_ABOUT_H_INCLUDED
-#define NS_ATARI_ABOUT_H_INCLUDED
+#ifndef NS_MONKEY_LAYOUT_H
+#define NS_MONKEY_LAYOUT_H
 
-void atari_about_show(void);
+extern struct gui_layout_table *monkey_layout_table;
 
-#endif // NS_ATARI_ABOUT_H_INCLUDED
+#endif /* NS_MONKEY_LAYOUT_H */
diff --git a/monkey/main.c b/monkey/main.c
index 526488e..f7d6609 100644
--- a/monkey/main.c
+++ b/monkey/main.c
@@ -44,6 +44,7 @@
 #include "monkey/fetch.h"
 #include "monkey/schedule.h"
 #include "monkey/bitmap.h"
+#include "monkey/layout.h"
 
 /** maximum number of languages in language vector */
 #define LANGV_SIZE 32
@@ -319,6 +320,7 @@ main(int argc, char **argv)
     .download = monkey_download_table,
     .fetch = monkey_fetch_table,
     .bitmap = monkey_bitmap_table,
+    .layout = monkey_layout_table,
   };
 
   ret = netsurf_register(&monkey_table);


-- 
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