Add const qualifiers

This commit is contained in:
Norman Feske 2012-10-09 14:28:23 +02:00
parent 1389b63050
commit fb452ce6ba
2 changed files with 21 additions and 19 deletions

View File

@ -82,7 +82,7 @@ class Chunky_canvas : public Canvas
if (!str || !font) return;
unsigned char *src = font->img;
unsigned char const *src = font->img;
int d, h = font->img_h;
/* check top clipping */
@ -114,7 +114,7 @@ class Chunky_canvas : public Canvas
int start = max(0, _clip.x1() - x);
int end = min(w - 1, _clip.x2() - x);
PT *d = dst + x;
unsigned char *s = src + font->otab[*str];
unsigned char const *s = src + font->otab[*str];
for (int j = 0; j < h; j++, s += font->img_w, d += _size.w())
for (int i = start; i <= end; i++)

View File

@ -24,27 +24,29 @@ class Font
public:
unsigned char *img; /* font image */
int img_w, img_h; /* size of font image */
int32_t *wtab; /* width table */
int32_t *otab; /* offset table */
unsigned char const *img; /* font image */
int const img_w, img_h; /* size of font image */
int32_t const *otab; /* offset table */
int32_t const *wtab; /* width table */
/**
* Construct font from a TFF data block
*/
Font(const char *tff)
{
otab = (int32_t *)(tff);
wtab = (int32_t *)(tff + 1024);
img_w = *((int32_t *)(tff + 2048));
img_h = *((int32_t *)(tff + 2052));
img = (unsigned char *)(tff + 2056);
}
:
img((unsigned char *)(tff + 2056)),
img_w(*((int32_t *)(tff + 2048))),
img_h(*((int32_t *)(tff + 2052))),
otab((int32_t *)(tff)),
wtab((int32_t *)(tff + 1024))
{ }
/**
* Calculate width of string when printed with the font
*/
int str_w(const char *sstr)
int str_w(const char *sstr) const
{
const unsigned char *str = (const unsigned char *)sstr;
int res = 0;
@ -55,7 +57,7 @@ class Font
/**
* Calculate height of string when printed with the font
*/
int str_h(const char *str) { return img_h; }
int str_h(const char *str) const { return img_h; }
};
#endif /* _INCLUDE__NITPICKER_GFX__FONT_H_ */