aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/gfx/font.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sci/gfx/font.cpp')
-rw-r--r--engines/sci/gfx/font.cpp69
1 files changed, 31 insertions, 38 deletions
diff --git a/engines/sci/gfx/font.cpp b/engines/sci/gfx/font.cpp
index b8d5d5a800..0b0abac733 100644
--- a/engines/sci/gfx/font.cpp
+++ b/engines/sci/gfx/font.cpp
@@ -33,8 +33,7 @@
int font_counter = 0;
void
-gfxr_free_font(gfx_bitmap_font_t *font)
-{
+gfxr_free_font(gfx_bitmap_font_t *font) {
if (font->widths)
free(font->widths);
@@ -49,8 +48,7 @@ gfxr_free_font(gfx_bitmap_font_t *font)
void
-scale_char(byte *dest, byte *src, int width, int height, int newwidth, int xfact, int yfact)
-{
+scale_char(byte *dest, byte *src, int width, int height, int newwidth, int xfact, int yfact) {
int x, y;
for (y = 0; y < height; y++) {
@@ -90,8 +88,7 @@ scale_char(byte *dest, byte *src, int width, int height, int newwidth, int xfact
}
gfx_bitmap_font_t *
-gfxr_scale_font_unfiltered(gfx_bitmap_font_t *orig_font, gfx_mode_t *mode)
-{
+gfxr_scale_font_unfiltered(gfx_bitmap_font_t *orig_font, gfx_mode_t *mode) {
gfx_bitmap_font_t *font = (gfx_bitmap_font_t*)sci_malloc(sizeof(gfx_bitmap_font_t));
int height = orig_font->height * mode->yfact;
int width = 0;
@@ -121,18 +118,17 @@ gfxr_scale_font_unfiltered(gfx_bitmap_font_t *orig_font, gfx_mode_t *mode)
for (i = 0; i < font->chars_nr; i++) {
font->widths[i] = orig_font->widths[i] * mode->xfact;
scale_char(font->data + font->char_size * i,
- orig_font->data + orig_font->char_size * i,
- orig_font->row_size, orig_font->height,
- font->row_size,
- mode->xfact, mode->yfact);
+ orig_font->data + orig_font->char_size * i,
+ orig_font->row_size, orig_font->height,
+ font->row_size,
+ mode->xfact, mode->yfact);
}
return font;
}
gfx_bitmap_font_t *
-gfxr_scale_font(gfx_bitmap_font_t *orig_font, gfx_mode_t *mode, gfxr_font_scale_filter_t filter)
-{
+gfxr_scale_font(gfx_bitmap_font_t *orig_font, gfx_mode_t *mode, gfxr_font_scale_filter_t filter) {
GFXWARN("This function hasn't been tested yet!\n");
switch (filter) {
@@ -151,10 +147,9 @@ gfxr_scale_font(gfx_bitmap_font_t *orig_font, gfx_mode_t *mode, gfxr_font_scale_
text_fragment_t *
gfxr_font_calculate_size(gfx_bitmap_font_t *font, int max_width, const char *text,
- int *width, int *height,
- int *lines, int *line_height_p, int *last_offset_p,
- int flags)
-{
+ int *width, int *height,
+ int *lines, int *line_height_p, int *last_offset_p,
+ int flags) {
int est_char_width = font->widths[(font->chars_nr > 'M')? 'M' : font->chars_nr - 1];
/* 'M' is typically among the widest chars */
int fragments_nr;
@@ -172,7 +167,8 @@ gfxr_font_calculate_size(gfx_bitmap_font_t *font, int max_width, const char *tex
if (line_height_p)
*line_height_p = lineheight;
- if (max_width>1) fragments_nr = 3 + (strlen(text) * est_char_width)*3 / (max_width << 1); else fragments_nr = 1;
+ if (max_width > 1) fragments_nr = 3 + (strlen(text) * est_char_width) * 3 / (max_width << 1);
+ else fragments_nr = 1;
fragments = (text_fragment_t*)sci_calloc(sizeof(text_fragment_t), fragments_nr);
@@ -183,7 +179,7 @@ gfxr_font_calculate_size(gfx_bitmap_font_t *font, int max_width, const char *tex
if (foo >= font->chars_nr) {
GFXWARN("Invalid char 0x%02x (max. 0x%02x) encountered in text string '%s', font %04x\n",
- foo, font->chars_nr, text, font->ID);
+ foo, font->chars_nr, text, font->ID);
if (font->chars_nr > ' ')
foo = ' ';
else {
@@ -193,7 +189,7 @@ gfxr_font_calculate_size(gfx_bitmap_font_t *font, int max_width, const char *tex
}
if (((foo == '\n') || (foo == 0x0d))
- && !(flags & GFXR_FONT_FLAG_NO_NEWLINES)) {
+ && !(flags & GFXR_FONT_FLAG_NO_NEWLINES)) {
fragments[current_fragment-1].length = text - 1 - fragments[current_fragment-1].offset;
@@ -233,7 +229,7 @@ gfxr_font_calculate_size(gfx_bitmap_font_t *font, int max_width, const char *tex
if (last_breakpoint == 0) {
GFXWARN("Warning: maxsize %d too small for '%s'\n",
- max_allowed_width, text);
+ max_allowed_width, text);
}
if (last_breakpoint > maxwidth)
@@ -251,10 +247,10 @@ gfxr_font_calculate_size(gfx_bitmap_font_t *font, int max_width, const char *tex
last_breakpoint = localmaxwidth = 0;
} else if (*text == ' ') {
- last_breakpoint = localmaxwidth;
- last_break_width = font->widths[foo];
- breakpoint_ptr = text;
- }
+ last_breakpoint = localmaxwidth;
+ last_break_width = font->widths[foo];
+ breakpoint_ptr = text;
+ }
}
}
@@ -279,8 +275,7 @@ gfxr_font_calculate_size(gfx_bitmap_font_t *font, int max_width, const char *tex
static inline void
-render_char(byte *dest, byte *src, int width, int line_width, int lines, int bytes_per_src_line, int fg0, int fg1, int bg)
-{
+render_char(byte *dest, byte *src, int width, int line_width, int lines, int bytes_per_src_line, int fg0, int fg1, int bg) {
int x, y;
for (y = 0; y < lines; y++) {
@@ -297,7 +292,7 @@ render_char(byte *dest, byte *src, int width, int line_width, int lines, int byt
xc--;
if (dat & 0x80)
- *vdest++ = ((xc ^ y) & 1)? fg0 : fg1; /* dither */
+ *vdest++ = ((xc ^ y) & 1) ? fg0 : fg1; /* dither */
else
*vdest++ = bg;
@@ -310,8 +305,7 @@ render_char(byte *dest, byte *src, int width, int line_width, int lines, int byt
gfx_pixmap_t *
gfxr_draw_font(gfx_bitmap_font_t *font, const char *stext, int characters,
- gfx_pixmap_color_t *fg0, gfx_pixmap_color_t *fg1, gfx_pixmap_color_t *bg)
-{
+ gfx_pixmap_color_t *fg0, gfx_pixmap_color_t *fg1, gfx_pixmap_color_t *bg) {
unsigned char *text = (unsigned char *) stext;
int height = font->height;
int width = 0;
@@ -336,13 +330,12 @@ gfxr_draw_font(gfx_bitmap_font_t *font, const char *stext, int characters,
pxm = gfx_pixmap_alloc_index_data(gfx_new_pixmap(width, height, GFX_RESID_NONE, 0, 0));
pxm->colors_nr = !!fg0 + !!fg1 + !!bg;
- if (pxm->colors_nr == 0)
- {
- GFXWARN("Pixmap would have zero colors, resetting!\n");
- pxm->colors_nr = 3;
- hack = 1;
- fg0 = fg1 = bg = &dummy;
- }
+ if (pxm->colors_nr == 0) {
+ GFXWARN("Pixmap would have zero colors, resetting!\n");
+ pxm->colors_nr = 3;
+ hack = 1;
+ fg0 = fg1 = bg = &dummy;
+ }
pxm->colors = (gfx_pixmap_color_t*)sci_malloc(sizeof(gfx_pixmap_color_t) * pxm->colors_nr);
#ifdef SATISFY_PURIFY
memset(pxm->colors, 0, sizeof(gfx_pixmap_color_t) * pxm->colors_nr);
@@ -374,8 +367,8 @@ gfxr_draw_font(gfx_bitmap_font_t *font, const char *stext, int characters,
width = font->widths[ch];
render_char(offset, font->data + (ch * font->char_size), width,
- pxm->index_xl, pxm->index_yl, font->row_size,
- fore_0, fore_1, back);
+ pxm->index_xl, pxm->index_yl, font->row_size,
+ fore_0, fore_1, back);
offset += width;
}