source: abuse/branches/lol/src/imlib/fonts.cpp @ 737

Last change on this file since 737 was 737, checked in by Sam Hocevar, 8 years ago

build: sync with newer Lol Engine changes.

File size: 1.4 KB
RevLine 
[56]1/*
2 *  Abuse - dark 2D side-scrolling platform game
3 *  Copyright (c) 1995 Crack dot Com
[715]4 *  Copyright (c) 2005-2013 Sam Hocevar <sam@hocevar.net>
[56]5 *
6 *  This software was released into the Public Domain. As with most public
[555]7 *  domain software, no warranty is made or implied by Crack dot Com, by
8 *  Jonathan Clark, or by Sam Hocevar.
[56]9 */
10
[732]11#if HAVE_CONFIG_H
[555]12#   include "config.h"
13#endif
[56]14
[2]15#include <ctype.h>
16
[512]17#include "common.h"
18
[724]19#include "imlib/fonts.h"
[56]20
[715]21void JCFont::PutString(AImage *screen, ivec2 pos, String const &st, int color)
[668]22{
[737]23    for (int i = 0; i < st.count(); ++i, pos.x += m_size.x)
[715]24        PutChar(screen, pos, st[i], color);
[2]25}
26
[709]27void JCFont::PutChar(AImage *screen, ivec2 pos, char ch, int color)
[2]28{
[668]29    if (!m_data[(int)ch])
30        return;
31
32    if (color >= 0)
33        m_data[(int)ch]->PutColor(screen, pos, color);
34    else
35        m_data[(int)ch]->PutImage(screen, pos);
[2]36}
37
[709]38JCFont::JCFont(AImage *letters)
[2]39{
[682]40    m_size = (letters->Size() + ivec2(1)) / ivec2(32, 8);
[2]41
[709]42    AImage tmp(m_size);
[124]43
[668]44    for (int ch = 0; ch < 256; ch++)
45    {
46        tmp.clear();
[719]47        tmp.PutPart(letters, ivec2::zero,
[682]48                    ivec2(ch % 32, ch / 32) * m_size,
49                    ivec2(ch % 32 + 1, ch / 32 + 1) * m_size, 1);
[668]50        m_data[ch] = new TransImage(&tmp, "JCfont");
51    }
[2]52}
53
54JCFont::~JCFont()
55{
[668]56    for (int ch = 0; ch < 256; ch++)
57        delete m_data[ch];
[2]58}
59
Note: See TracBrowser for help on using the repository browser.