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;
109 NSLOG(netsurf, INFO,
"font: %s/%d", tattr.ta_Name, tattr.ta_YSize);
116 if((bmfont = OpenDiskFont(&tattr))) {
117 SetRPAttrs(rp, RPTAG_Font, bmfont, TAG_DONE);
134 for(UWORD i = 0; i < offset; i++) {
135 chr =
utf8_next(utf8string, length, chr);
136 if(chr > length)
return length;
144 const char *
string,
size_t length,
147 char *localtext = NULL;
158 *
width = TextLength(&
temp_rp, localtext, (UWORD)strlen(localtext));
177 const char *
string,
size_t length,
178 int x,
size_t *char_offset,
int *actual_x)
180 struct TextExtent extent;
181 struct TextFont *bmfont;
182 char *localtext = NULL;
192 co = TextFit(&
temp_rp, localtext, (UWORD)strlen(localtext),
193 &extent, NULL, 1, x, 32767);
195 *actual_x = extent.te_Extent.MaxX;
227 const char *
string,
size_t length,
228 int x,
size_t *char_offset,
int *actual_x)
230 struct TextExtent extent;
242 offset = TextFit(&
temp_rp, localtext, (UWORD)strlen(localtext),
243 &extent, NULL, 1, (UWORD)x, 32767);
246 charp = localtext + co;
249 while((*charp !=
' ') && (co > 0)) {
256 charp = localtext + co;
257 while((*charp !=
' ') && (co < strlen(localtext))) {
263 if((co > 0) && (co < strlen(localtext))) {
264 *actual_x = TextLength(&
temp_rp, localtext, co);
268 *char_offset = length;
279 if(!
string ||
string[0]==
'\0')
return 0;
280 if(!length)
return 0;
281 if(rp == NULL)
return 0;
284 char *localtext = NULL;
285 if(bmfont == NULL)
return 0;
288 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.
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).