23#include <proto/diskfont.h>
24#include <proto/exec.h>
25#include <proto/graphics.h>
26#include <proto/utility.h>
28#include <graphics/rpattr.h>
40#define MAX_FONT_NAME_SIZE 33
48 struct TextFont *bmfont = NULL;
49 struct TextAttr tattr;
61 if(rp == NULL)
return NULL;
87 tattr.ta_Style = FS_NORMAL;
90 tattr.ta_Style = FSF_ITALIC;
93 tattr.ta_Style = FSF_ITALIC;
96 tattr.ta_Style |= FSF_BOLD;
101 NSLOG(netsurf, INFO,
"font: %s/%d", tattr.ta_Name, tattr.ta_YSize);
108 if((bmfont = OpenDiskFont(&tattr))) {
109 SetRPAttrs(rp, RPTAG_Font, bmfont, TAG_DONE);
124 for(UWORD i = 0; i < offset; i++) {
125 chr =
utf8_next(utf8string, length, chr);
126 if(chr > length)
return length;
134 const char *
string,
size_t length,
137 char *localtext = NULL;
148 *
width = TextLength(&
temp_rp, localtext, (UWORD)strlen(localtext));
167 const char *
string,
size_t length,
168 int x,
size_t *char_offset,
int *actual_x)
170 struct TextExtent extent;
171 struct TextFont *bmfont;
172 char *localtext = NULL;
182 co = TextFit(&
temp_rp, localtext, (UWORD)strlen(localtext),
183 &extent, NULL, 1, x, 32767);
185 *actual_x = extent.te_Extent.MaxX;
217 const char *
string,
size_t length,
218 int x,
size_t *char_offset,
int *actual_x)
220 struct TextExtent extent;
232 offset = TextFit(&
temp_rp, localtext, (UWORD)strlen(localtext),
233 &extent, NULL, 1, (UWORD)x, 32767);
236 charp = localtext + co;
239 while((*charp !=
' ') && (co > 0)) {
246 charp = localtext + co;
247 while((*charp !=
' ') && (co < strlen(localtext))) {
253 if((co > 0) && (co < strlen(localtext))) {
254 *actual_x = TextLength(&
temp_rp, localtext, co);
258 *char_offset = length;
269 if(!
string ||
string[0]==
'\0')
return 0;
270 if(!length)
return 0;
271 if(rp == NULL)
return 0;
274 char *localtext = NULL;
275 if(bmfont == NULL)
return 0;
278 Text(rp, localtext, (UWORD)strlen(localtext));
nserror
Enumeration of error codes.
@ NSERROR_INVALID
Invalid data.
static nserror amiga_bm_nsfont_width(const plot_font_style_t *fstyle, const char *string, size_t length, int *width)
void ami_font_diskfont_init(void)
static struct RastPort temp_rp
static size_t ami_font_bm_convert_local_to_utf8_offset(const char *utf8string, size_t length, UWORD offset)
static struct TextFont * prev_font
void ami_font_diskfont_fini(void)
static nserror amiga_bm_nsfont_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.
#define MAX_FONT_NAME_SIZE
static ULONG amiga_bm_nsfont_text(struct RastPort *rp, const char *string, ULONG length, const plot_font_style_t *fstyle, ULONG dx, ULONG dy, bool aa)
static struct TextFont * ami_font_bm_open(struct RastPort *rp, const plot_font_style_t *fstyle)
const struct ami_font_functions ami_font_diskfont_table
static nserror amiga_bm_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)
Find the position in a string where an x coordinate falls.
static plot_font_style_t * prev_fstyle
const struct ami_font_functions * ami_nsfont
nserror utf8_to_local_encoding(const char *string, size_t len, char **result)
#define NSLOG(catname, level, logmsg, args...)
Minimal compatibility header for AmigaOS 3.
@ PLOT_FONT_FAMILY_CURSIVE
@ PLOT_FONT_FAMILY_SANS_SERIF
@ PLOT_FONT_FAMILY_FANTASY
@ PLOT_FONT_FAMILY_MONOSPACE
#define PLOT_STYLE_SCALE
Scaling factor for plot styles.
Interface to utility string handling.
plot_font_generic_family_t family
Generic family to plot with.
plot_font_flags_t flags
Font flags.
plot_style_fixed size
Font size, in pt.
int weight
Font weight: value in range [100,900] as per CSS.
Option reading and saving interface.
#define nsoption_charp(OPTION)
Get the value of a string option.
size_t utf8_next(const char *s, size_t l, size_t o)
Find next legal UTF-8 char in string.
UTF-8 manipulation functions (interface).