Skip to content

Commit

Permalink
Enlarge the font by adding 2 pixels above the cap height
Browse files Browse the repository at this point in the history
  • Loading branch information
mniip committed Apr 29, 2018
1 parent 67132c9 commit 16acc95
Show file tree
Hide file tree
Showing 6 changed files with 310 additions and 310 deletions.
578 changes: 289 additions & 289 deletions data/font.h

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion font/editor.c
Expand Up @@ -7,7 +7,7 @@
#include <SDL/SDL.h>

#define CELLW 12
#define CELLH 10
#define CELLH 12

#define XRES 800
#define YRES 600
Expand Down
2 changes: 1 addition & 1 deletion font/packer.c
Expand Up @@ -6,7 +6,7 @@
#include <math.h>

#define CELLW 12
#define CELLH 10
#define CELLH 12
//#define EXTENDED_FONT 1

char font[256][CELLH][CELLW];
Expand Down
2 changes: 1 addition & 1 deletion font/unpacker.c
Expand Up @@ -11,7 +11,7 @@
#include "font.h"

#define CELLW 12
#define CELLH 10
#define CELLH 12

char font[256][CELLH][CELLW];
char width[256];
Expand Down
30 changes: 15 additions & 15 deletions src/graphics/Graphics.cpp
Expand Up @@ -91,7 +91,7 @@ int VideoBuffer::SetCharacter(int x, int y, int c, int r, int g, int b, int a)
int i, j, w, bn = 0, ba = 0;
unsigned char *rp = font_data + font_ptrs[c];
w = *(rp++);
for (j=0; j<FONT_H; j++)
for (j=-2; j<FONT_H-2; j++)
for (i=0; i<w; i++)
{
if (!bn)
Expand All @@ -111,7 +111,7 @@ int VideoBuffer::BlendCharacter(int x, int y, int c, int r, int g, int b, int a)
int i, j, w, bn = 0, ba = 0;
unsigned char *rp = font_data + font_ptrs[c];
w = *(rp++);
for (j=0; j<FONT_H; j++)
for (j=-2; j<FONT_H-2; j++)
for (i=0; i<w; i++)
{
if (!bn)
Expand All @@ -131,7 +131,7 @@ int VideoBuffer::AddCharacter(int x, int y, int c, int r, int g, int b, int a)
int i, j, w, bn = 0, ba = 0;
unsigned char *rp = font_data + font_ptrs[c];
w = *(rp++);
for (j=0; j<FONT_H; j++)
for (j=-2; j<FONT_H-2; j++)
for (i=0; i<w; i++)
{
if (!bn)
Expand Down Expand Up @@ -626,7 +626,7 @@ void Graphics::textnpos(char *s, int n, int w, int *cx, int *cy)
if (charspace<wordlen && wordlen && w-x<w/3)
{
x = 0;
y += FONT_H+2;
y += FONT_H;
}
for (; *s && --wordlen>=-1; s++)
{
Expand All @@ -637,7 +637,7 @@ void Graphics::textnpos(char *s, int n, int w, int *cx, int *cy)
if (x>=w)
{
x = 0;
y += FONT_H+2;
y += FONT_H;
}
n--;
}
Expand Down Expand Up @@ -681,7 +681,7 @@ int Graphics::PositionAtCharIndex(char *s, int charIndex, int & positionX, int &
if(*s == '\n') {
lines++;
x = 0;
y += FONT_H+2;
y += FONT_H;
charIndex--;
continue;
} else if(*s =='\b') {
Expand All @@ -705,12 +705,12 @@ int Graphics::PositionAtCharIndex(char *s, int charIndex, int & positionX, int &

int Graphics::CharIndexAtPosition(char *s, int positionX, int positionY)
{
int x=0, y=0,charIndex=0,cw;
int x=0, y=-2,charIndex=0,cw;
for (; *s; s++)
{
if(*s == '\n') {
x = 0;
y += FONT_H+2;
y += FONT_H;
charIndex++;
continue;
} else if(*s == '\b') {
Expand All @@ -736,7 +736,7 @@ int Graphics::CharIndexAtPosition(char *s, int positionX, int positionY)

int Graphics::textwrapheight(char *s, int width)
{
int x=0, height=FONT_H+2, cw;
int x=0, height=FONT_H, cw;
int wordlen;
int charspace;
while (*s)
Expand All @@ -746,14 +746,14 @@ int Graphics::textwrapheight(char *s, int width)
if (charspace<wordlen && wordlen && width-x<width/3)
{
x = 0;
height += FONT_H+2;
height += FONT_H;
}
for (; *s && --wordlen>=-1; s++)
{
if (*s == '\n')
{
x = 0;
height += FONT_H+2;
height += FONT_H;
}
else if (*s == '\b')
{
Expand All @@ -771,7 +771,7 @@ int Graphics::textwrapheight(char *s, int width)
if (x+cw>=width)
{
x = 0;
height += FONT_H+2;
height += FONT_H;
}
x += cw;
}
Expand All @@ -785,17 +785,17 @@ void Graphics::textsize(const char * s, int & width, int & height)
if(!strlen(s))
{
width = 0;
height = FONT_H;
height = FONT_H-2;
return;
}

int cHeight = FONT_H, cWidth = 0, lWidth = 0;
int cHeight = FONT_H-2, cWidth = 0, lWidth = 0;
for (; *s; s++)
{
if (*s == '\n')
{
cWidth = 0;
cHeight += FONT_H+2;
cHeight += FONT_H;
}
else if (*s == '\x0F')
{
Expand Down
6 changes: 3 additions & 3 deletions src/graphics/RasterDrawMethods.inl
Expand Up @@ -26,7 +26,7 @@ int PIXELMETHODS_CLASS::drawtext(int x, int y, const char *s, int r, int g, int
if (*s == '\n')
{
characterX = startX;
characterY += FONT_H+2;
characterY += FONT_H;
}
else if (*s == '\x0F')
{
Expand Down Expand Up @@ -112,7 +112,7 @@ int PIXELMETHODS_CLASS::drawchar(int x, int y, int c, int r, int g, int b, int a
int i, j, w, bn = 0, ba = 0;
unsigned char *rp = font_data + font_ptrs[c];
w = *(rp++);
for (j=0; j<FONT_H; j++)
for (j=-2; j<FONT_H-2; j++)
for (i=0; i<w; i++)
{
if (!bn)
Expand All @@ -132,7 +132,7 @@ int PIXELMETHODS_CLASS::addchar(int x, int y, int c, int r, int g, int b, int a)
int i, j, w, bn = 0, ba = 0;
unsigned char *rp = font_data + font_ptrs[c];
w = *(rp++);
for (j=0; j<FONT_H; j++)
for (j=-2; j<FONT_H-2; j++)
for (i=0; i<w; i++)
{
if (!bn)
Expand Down

0 comments on commit 16acc95

Please sign in to comment.