source: abuse/trunk/src/imlib/fonts.cpp @ 124

Last change on this file since 124 was 124, checked in by Sam Hocevar, 15 years ago
  • Get rid of ugly tabs and trailing spaces everywhere.
File size: 1.7 KB
RevLine 
[56]1/*
2 *  Abuse - dark 2D side-scrolling platform game
3 *  Copyright (c) 1995 Crack dot Com
4 *
5 *  This software was released into the Public Domain. As with most public
6 *  domain software, no warranty is made or implied by Crack dot Com or
7 *  Jonathan Clark.
8 */
9
10#include "config.h"
11
[2]12#include <ctype.h>
13
[56]14#include "fonts.hpp"
15
[2]16texture_font::texture_font(image *letters, image *font_pattern)
17{ fntpat=font_pattern;
18  let=letters;
19  tl=(let->width()+1)/32;
20  th=(let->height()+1)/8;
21}
22
23void texture_font::put_char(image *screen,  int x, int y, char ch)
24{ if (fntpat)
25    fntpat->put_part_masked(screen,let, x,y,
26       ((int)ch%32)*tl,((int)ch/32)*th,0,0,tl-1,th-1);
27  else let->put_part(screen,x,y,((int)ch%32)*tl,((int)ch/32)*th,
28     ((int)ch%32)*tl+tl-1,((int)ch/32)*th+th-1,1);
29}
30
[39]31void texture_font::put_string(image *screen, int x, int y, char const *st)
[2]32{ while (*st)
33  { put_char(screen,x,y,*st);
34    st++;
35    x+=tl;
36  }
37}
38
39
[39]40void JCFont::put_string(image *screen, int x, int y, char const *st, int color)
[2]41{ while (*st)
42  { put_char(screen,x,y,*st,color);
43    st++;
44    x+=tl;
45  }
46}
47
48
49void JCFont::put_char(image *screen,  int x, int y, char ch, int color)
50{
[4]51  if (let[(int)ch])
[2]52  {
53    if (color>=0)
[4]54      let[(int)ch]->put_color(screen,x,y,color);
55    else let[(int)ch]->put_image(screen,x,y);
[2]56  }
57}
58
59JCFont::JCFont(image *letters)
60{
61  tl=(letters->width()+1)/32;
[124]62  th=(letters->height()+1)/8;
[2]63
64  image tmp(tl,th);
[124]65
[2]66  int ch;
[124]67
[2]68  for (ch=0;ch<256;ch++)
[124]69  {
70    tmp.clear();
[2]71    letters->put_part(&tmp,0,0,((int)ch%32)*tl,((int)ch/32)*th,
[124]72              ((int)ch%32)*tl+tl-1,((int)ch/32)*th+th-1,1);
[2]73    let[ch]=new trans_image(&tmp,"JCfont");
[124]74  }
[2]75}
76
77JCFont::~JCFont()
78{
79  int ch;
[124]80  for (ch=0;ch<256;ch++)
81    delete let[ch];
[2]82}
83
Note: See TracBrowser for help on using the repository browser.