Re: [AD] Old problems that still persist on Allegro 4.2 beta 3 |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On Tue, 2005-05-31 at 17:56 +0200, Elias Pschernig wrote:
> No, the grabber only supported loading from bitmaps:
>
> http://srnet.cz/~stepan/allegro/srcs/allegro-4.1.17/tools/plugins/datfont.c.html#line679
>
> Doesn't matter though.. I'll update the patch a bit later..
>
Ok, patch attached, tested in linux (old fonts that worked in 4.2.0 work
again now - didn't try new-style fonts).
--
Elias Pschernig <elias@xxxxxxxxxx>
Index: tools/plugins/datfont.c
===================================================================
RCS file: /cvsroot/alleg/allegro/tools/plugins/datfont.c,v
retrieving revision 1.27
diff -u -p -r1.27 datfont.c
--- tools/plugins/datfont.c 3 May 2005 20:56:46 -0000 1.27
+++ tools/plugins/datfont.c 4 Jun 2005 10:24:43 -0000
@@ -751,7 +751,7 @@ static char *range_getter(int index, int
return 0;
}
- sprintf(buf, "%04X-%04X, color", get_font_range_begin(f, index), get_font_range_end(f, index) - 1);
+ sprintf(buf, "%04X-%04X, color", get_font_range_begin(f, index), get_font_range_end(f, index));
return buf;
}
Index: src/font.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/font.c,v
retrieving revision 1.19
diff -u -p -r1.19 font.c
--- src/font.c 16 May 2005 12:40:48 -0000 1.19
+++ src/font.c 4 Jun 2005 10:24:44 -0000
@@ -640,7 +640,7 @@ static int mono_get_font_range_begin(FON
/* mono_get_font_range_end:
* (mono vtable entry)
- * Get last character for font range. Pass -1 to search the entire font
+ * Get last character for font range. Pass -1 to search the entire font.
*/
static int mono_get_font_range_end(FONT* f, int range)
{
@@ -656,9 +656,8 @@ static int mono_get_font_range_end(FONT*
while(mf && (n<=range || range==-1)) {
FONT_MONO_DATA* next = mf->next;
-
if (!next || range == n)
- return mf->end;
+ return mf->end - 1;
mf = next;
n++;
}
@@ -689,7 +688,7 @@ static FONT_MONO_DATA *mono_copy_glyph_r
newmf->begin = begin;
newmf->end = end;
newmf->next = NULL;
- num = end - begin+1;
+ num = end - begin;
gl = newmf->glyphs = _al_malloc(num * sizeof *gl);
for (c=0; c<num; c++) {
@@ -737,12 +736,12 @@ FONT *mono_extract_font_range(FONT *f, i
/* Get real character ranges */
first = MAX(begin, mono_get_font_range_begin(f, -1));
last = (end>-1) ? MIN(end, mono_get_font_range_end(f, -1)) : mono_get_font_range_end(f, -1);
-
+
mf = NULL;
mfin = f->data;
while (mfin) {
/* Check if we've found the proper range */
- if ((first >= mfin->begin) && (last<=mfin->end)) {
+ if ((first >= mfin->begin) && (last<mfin->end)) {
int local_begin, local_end;
local_begin = MAX(mfin->begin, first);
@@ -1054,7 +1053,7 @@ static int color_get_font_range_begin(FO
/* color_get_font_range_end:
* (color vtable entry)
- * Get last character for font.
+ * Get last character for font range.
*/
static int color_get_font_range_end(FONT* f, int range)
{
@@ -1070,9 +1069,8 @@ static int color_get_font_range_end(FONT
while(cf && (n<=range || range==-1)) {
FONT_COLOR_DATA* next = cf->next;
-
if (!next || range == n)
- return cf->end;
+ return cf->end - 1;
cf = next;
n++;
}
@@ -1088,7 +1086,7 @@ static int color_get_font_range_end(FONT
static FONT_COLOR_DATA* upgrade_to_color_data(FONT_MONO_DATA* mf)
{
FONT_COLOR_DATA* cf = _al_malloc(sizeof *cf);
- BITMAP** bits = _al_malloc((mf->end - mf->begin+1)*sizeof *bits);
+ BITMAP** bits = _al_malloc((mf->end - mf->begin)*sizeof *bits);
int i;
cf->begin = mf->begin;
@@ -1096,7 +1094,7 @@ static FONT_COLOR_DATA* upgrade_to_color
cf->bitmaps = bits;
cf->next = 0;
- for(i = mf->begin; i <= mf->end; i++) {
+ for(i = mf->begin; i < mf->end; i++) {
FONT_GLYPH* g = mf->glyphs[i - mf->begin];
BITMAP* b = create_bitmap_ex(8, g->w, g->h);
clear_to_color(b, 0);
@@ -1158,7 +1156,7 @@ static FONT_COLOR_DATA *color_copy_glyph
newcf->begin = begin;
newcf->end = end;
newcf->next = NULL;
- num = end - begin+1;
+ num = end - begin;
gl = newcf->bitmaps = _al_malloc(num * sizeof *gl);
for (c=0; c<num; c++) {
@@ -1166,7 +1164,7 @@ static FONT_COLOR_DATA *color_copy_glyph
gl[c] = create_bitmap_ex(8, g->w, g->h);
blit(g, gl[c], 0, 0, 0, 0, g->w, g->h);
}
-
+
return newcf;
}
@@ -1201,12 +1199,12 @@ FONT *color_extract_font_range(FONT *f,
/* Get real character ranges */
first = MAX(begin, color_get_font_range_begin(f, -1));
last = (end>-1) ? MIN(end, color_get_font_range_end(f, -1)) : color_get_font_range_end(f, -1);
-
+
cf = NULL;
cfin = f->data;
while (cfin) {
/* Check if we've found the proper range */
- if ((first >= cfin->begin) && (last<=cfin->end)) {
+ if ((first >= cfin->begin) && (last<cfin->end)) {
int local_begin, local_end;
local_begin = MAX(cfin->begin, first);
@@ -1222,7 +1220,7 @@ FONT *color_extract_font_range(FONT *f,
}
cfin = cfin->next;
}
-
+
return fontout;
}
@@ -1402,7 +1400,7 @@ int is_compatible_font(FONT *f1, FONT *f
/* extract_font_range:
* Extracts a character range from a font f, and returns a new font containing
* only the extracted characters.
- * Returns NULL if teh character range could not be extracted.
+ * Returns NULL if the character range could not be extracted.
*/
FONT *extract_font_range(FONT *f, int begin, int end)
{
@@ -1462,13 +1460,13 @@ int get_font_range_begin(FONT *f, int ra
/* get_font_range_end:
* Returns the last character for the font in question, or -1 if that
- * information is not available.
+ * information is not available.
*/
int get_font_range_end(FONT *f, int range)
{
if (f->vtable->get_font_range_end)
return f->vtable->get_font_range_end(f, range);
-
+
return -1;
}
Index: src/fonttxt.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/fonttxt.c,v
retrieving revision 1.2
diff -u -p -r1.2 fonttxt.c
--- src/fonttxt.c 19 Mar 2005 11:15:06 -0000 1.2
+++ src/fonttxt.c 4 Jun 2005 10:24:44 -0000
@@ -27,7 +27,7 @@
FONT *load_txt_font(AL_CONST char *filename, RGB *pal, void *param)
{
char buf[1024], *font_str, *start_str = 0, *end_str = 0;
- FONT *f, *f2, *f3, *f4;
+ FONT *f, *f2, *f3;
PACKFILE *pack;
int begin, end;
@@ -35,7 +35,7 @@ FONT *load_txt_font(AL_CONST char *filen
if (!pack)
return NULL;
- f = f2 = f3 = f4 = NULL;
+ f = f2 = f3 = NULL;
while(pack_fgets(buf, sizeof(buf)-1, pack)) {
font_str = strtok(buf, " \t");
@@ -52,9 +52,9 @@ FONT *load_txt_font(AL_CONST char *filen
if(font_str[0] == '-')
font_str[0] = '\0';
-
+
begin = strtol(start_str, 0, 0);
-
+
if (end_str)
end = strtol(end_str, 0, 0) + 1;
else
@@ -69,19 +69,21 @@ FONT *load_txt_font(AL_CONST char *filen
/* Load the font that needs to be merged with the current font */
if (font_str[0]) {
- if (f4)
- destroy_font(f4);
- f4 = load_font(font_str, pal, param);
+ if (f2)
+ destroy_font(f2);
+ f2 = load_font(font_str, pal, param);
}
- if(!f4) {
- destroy_font(f);
+ if(!f2) {
+ if (f)
+ destroy_font(f);
pack_fclose(pack);
-
return NULL;
}
-
- /* Extract font range */
- f2 = extract_font_range(f4, begin, end);
+
+ /* transpose the font to the range given in the .txt file */
+ transpose_font(f2, begin - get_font_range_begin(f2, -1));
+
+ /* FIXME: More efficient way than to repeatedely merge into a new font? */
if (f) {
f3 = f;
f = merge_fonts(f2, f3);
@@ -89,10 +91,9 @@ FONT *load_txt_font(AL_CONST char *filen
destroy_font(f2);
} else {
f = f2;
- f2 = NULL;
}
+ f2 = NULL;
}
- destroy_font(f4);
pack_fclose(pack);
return f;