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
50 struct TextFont *bmfont = NULL;
51 struct TextAttr tattr;
55 if(rp == NULL)
return NULL;
81 tattr.ta_Style = FS_NORMAL;
84 tattr.ta_Style = FSF_ITALIC;
87 tattr.ta_Style = FSF_ITALIC;
90 tattr.ta_Style |= FSF_BOLD;
97 SetRPAttrs(rp, RPTAG_Font,
prev_font, TAG_DONE);
101 NSLOG(netsurf, INFO,
"Applying SoftStyle to current font");
102 SetSoftStyle(rp, tattr.ta_Style,
style_set);
107 tattr.ta_Name = font;
110 NSLOG(netsurf, INFO,
"font: %s/%d", tattr.ta_Name, tattr.ta_YSize);
117 if((bmfont = OpenDiskFont(&tattr))) {
118 SetRPAttrs(rp, RPTAG_Font, bmfont, TAG_DONE);
135 for(UWORD i = 0; i < offset; i++) {
136 chr =
utf8_next(utf8string, length, chr);
137 if(chr > length)
return length;
145 const char *
string,
size_t length,
148 char *localtext = NULL;
159 *
width = TextLength(&
temp_rp, localtext, (UWORD)strlen(localtext));
178 const char *
string,
size_t length,
179 int x,
size_t *char_offset,
int *actual_x)
181 struct TextExtent extent;
182 struct TextFont *bmfont;
183 char *localtext = NULL;
193 co = TextFit(&
temp_rp, localtext, (UWORD)strlen(localtext),
194 &extent, NULL, 1, x, 32767);
196 *actual_x = extent.te_Extent.MaxX;
228 const char *
string,
size_t length,
229 int x,
size_t *char_offset,
int *actual_x)
231 struct TextExtent extent;
243 offset = TextFit(&
temp_rp, localtext, (UWORD)strlen(localtext),
244 &extent, NULL, 1, (UWORD)x, 32767);
247 charp = localtext + co;
250 while((*charp !=
' ') && (co > 0)) {
257 charp = localtext + co;
258 while((*charp !=
' ') && (co < strlen(localtext))) {
264 if((co > 0) && (co < strlen(localtext))) {
265 *actual_x = TextLength(&
temp_rp, localtext, co);
269 *char_offset = length;
280 if(!
string ||
string[0]==
'\0')
return 0;
281 if(!length)
return 0;
282 if(rp == NULL)
return 0;
285 char *localtext = NULL;
286 if(bmfont == NULL)
return 0;
289 Text(rp, localtext, (UWORD)strlen(localtext));
nserror
Enumeration of error codes.
@ NSERROR_INVALID
Invalid data.
static struct RastPort * prev_rp
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
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.
#define nsoption_int(OPTION)
Get the value of an integer 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).