NetSurf
Macros | Functions | Variables
font.cpp File Reference

Font handling (BeOS implementation). More...

#include <stdbool.h>
#include <assert.h>
#include <stdio.h>
#include <Font.h>
#include <String.h>
#include <View.h>
#include "utils/utils.h"
#include "utils/log.h"
#include "utils/nsoption.h"
#include "utils/nsurl.h"
#include "netsurf/layout.h"
#include "beos/gui.h"
#include "beos/font.h"
#include "beos/plotters.h"
Include dependency graph for font.cpp:

Go to the source code of this file.

Macros

#define __STDBOOL_H__   1
 

Functions

void nsbeos_style_to_font (BFont &font, const struct plot_font_style *fstyle)
 Convert a font style to a PangoFontDescription. More...
 
static nserror beos_font_width (const plot_font_style_t *fstyle, const char *string, size_t length, int *width)
 Measure the width of a string. More...
 
static int utf8_char_len (const char *c)
 
static nserror beos_font_position (const plot_font_style_t *fstyle, const char *string, size_t length, int x, size_t *char_offset, int *actual_x)
 Find the position in a string where an x coordinate falls. More...
 
static nserror beos_font_split (const plot_font_style_t *fstyle, const char *string, size_t length, int x, size_t *char_offset, int *actual_x)
 Find where to split a string to make it fit a width. More...
 
bool nsfont_paint (const plot_font_style_t *fstyle, const char *string, size_t length, int x, int y)
 Render a string. More...
 

Variables

static struct gui_layout_table layout_table
 
struct gui_layout_tablebeos_layout_table = &layout_table
 

Detailed Description

Font handling (BeOS implementation).

TODO: check for correctness, the code is taken from the GTK one. maybe use the current view instead of constructing a new BFont each time ?

Definition in file font.cpp.

Macro Definition Documentation

◆ __STDBOOL_H__

#define __STDBOOL_H__   1

Definition at line 26 of file font.cpp.

Function Documentation

◆ beos_font_position()

static nserror beos_font_position ( const plot_font_style_t fstyle,
const char *  string,
size_t  length,
int  x,
size_t *  char_offset,
int *  actual_x 
)
static

Find the position in a string where an x coordinate falls.

Parameters
fstylestyle for this text
stringUTF-8 string to measure
lengthlength of string
xx coordinate to search for
char_offsetupdated to offset in string of actual_x, [0..length]
actual_xupdated to x coordinate of character closest to x
Returns
true on success, false on error and error reported

Definition at line 203 of file font.cpp.

References nsbeos_style_to_font(), NSERROR_OK, NSLOG, and utf8_char_len().

Here is the call graph for this function:

◆ beos_font_split()

static nserror beos_font_split ( const plot_font_style_t fstyle,
const char *  string,
size_t  length,
int  x,
size_t *  char_offset,
int *  actual_x 
)
static

Find where to split a string to make it fit a width.

Parameters
fstylestyle for this text
stringUTF-8 string to measure
lengthlength of string, in bytes
xwidth available
char_offsetupdated to offset in string of actual_x, [1..length]
actual_xupdated to x coordinate of character closest to x
Returns
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

Definition at line 260 of file font.cpp.

References MIN, nsbeos_style_to_font(), NSERROR_OK, NSLOG, and utf8_char_len().

Here is the call graph for this function:

◆ beos_font_width()

static nserror beos_font_width ( const plot_font_style_t fstyle,
const char *  string,
size_t  length,
int *  width 
)
static

Measure the width of a string.

Parameters
fstylestyle for this text
stringUTF-8 string to measure
lengthlength of string
widthupdated to width of string[0..length)
Returns
true on success, false on error and error reported

Definition at line 150 of file font.cpp.

References nsbeos_style_to_font(), NSERROR_OK, and width.

Here is the call graph for this function:

◆ nsbeos_style_to_font()

void nsbeos_style_to_font ( BFont &  font,
const struct plot_font_style fstyle 
)

Convert a font style to a PangoFontDescription.

Parameters
fontBeos font object.
fstylestyle for this text

Definition at line 53 of file font.cpp.

References plot_font_style::family, plot_font_style::flags, FONTF_ITALIC, FONTF_OBLIQUE, nsoption_charp, PLOT_FONT_FAMILY_CURSIVE, PLOT_FONT_FAMILY_FANTASY, PLOT_FONT_FAMILY_MONOSPACE, PLOT_FONT_FAMILY_SANS_SERIF, PLOT_FONT_FAMILY_SERIF, PLOT_STYLE_SCALE, plot_font_style::size, and plot_font_style::weight.

Referenced by beos_font_position(), beos_font_split(), beos_font_width(), gui_set_clipboard(), and nsfont_paint().

Here is the caller graph for this function:

◆ nsfont_paint()

bool nsfont_paint ( const plot_font_style_t fstyle,
const char *  string,
size_t  length,
int  x,
int  y 
)

Render a string.

Parameters
fstylestyle for this text
stringUTF-8 string to measure
lengthlength of string
xx coordinate
yy coordinate
Returns
true on success, false on error and error reported

Definition at line 312 of file font.cpp.

References plot_font_style::background, beos_warn_user(), plot_font_style::foreground, line(), nsbeos_current_gc(), nsbeos_rgb_colour(), nsbeos_style_to_font(), and view.

Referenced by nsbeos_plot_text(), nsgtk_plot_text(), and ro_plot_text().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ utf8_char_len()

static int utf8_char_len ( const char *  c)
static

Definition at line 169 of file font.cpp.

Referenced by beos_font_position(), and beos_font_split().

Here is the caller graph for this function:

Variable Documentation

◆ beos_layout_table

struct gui_layout_table* beos_layout_table = &layout_table

Definition at line 373 of file font.cpp.

Referenced by gui_init_replicant(), and main().

◆ layout_table

struct gui_layout_table layout_table
static
Initial value:
= {
}
static nserror beos_font_position(const plot_font_style_t *fstyle, const char *string, size_t length, int x, size_t *char_offset, int *actual_x)
Find the position in a string where an x coordinate falls.
Definition: font.cpp:203
static nserror beos_font_split(const plot_font_style_t *fstyle, const char *string, size_t length, int x, size_t *char_offset, int *actual_x)
Find where to split a string to make it fit a width.
Definition: font.cpp:260
static nserror beos_font_width(const plot_font_style_t *fstyle, const char *string, size_t length, int *width)
Measure the width of a string.
Definition: font.cpp:150

Definition at line 367 of file font.cpp.