NetSurf
|
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"
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_table * | beos_layout_table = &layout_table |
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.
|
static |
Find the position in a string where an x coordinate falls.
fstyle | style for this text |
string | UTF-8 string to measure |
length | length of string |
x | x coordinate to search for |
char_offset | updated to offset in string of actual_x, [0..length] |
actual_x | updated to x coordinate of character closest to x |
Definition at line 203 of file font.cpp.
References nsbeos_style_to_font(), NSERROR_OK, NSLOG, and utf8_char_len().
|
static |
Find where to split a string to make it fit a width.
fstyle | style for this text |
string | UTF-8 string to measure |
length | length of string, in bytes |
x | width available |
char_offset | updated to offset in string of actual_x, [1..length] |
actual_x | updated to x coordinate of character closest to x |
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().
|
static |
Measure the width of a string.
fstyle | style for this text |
string | UTF-8 string to measure |
length | length of string |
width | updated to width of string[0..length) |
Definition at line 150 of file font.cpp.
References nsbeos_style_to_font(), NSERROR_OK, and width.
void nsbeos_style_to_font | ( | BFont & | font, |
const struct plot_font_style * | fstyle | ||
) |
Convert a font style to a PangoFontDescription.
font | Beos font object. |
fstyle | style 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().
bool nsfont_paint | ( | const plot_font_style_t * | fstyle, |
const char * | string, | ||
size_t | length, | ||
int | x, | ||
int | y | ||
) |
Render a string.
fstyle | style for this text |
string | UTF-8 string to measure |
length | length of string |
x | x coordinate |
y | y coordinate |
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().
|
static |
Definition at line 169 of file font.cpp.
Referenced by beos_font_position(), and beos_font_split().
struct gui_layout_table* beos_layout_table = &layout_table |
Definition at line 373 of file font.cpp.
Referenced by gui_init_replicant(), and main().
|
static |