Re: [AD] extract font range fix |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
Milan Mimica wrote:
Hi!
The attached patch fixes two bugs in extract_font_range.
New patch here. Fixes more issues. Ruthlessly tested.
--
Milan Mimica
http://sparklet.sf.net
--- src/font_old.c 2005-08-21 23:00:55.000000000 +0200
+++ src/font.c 2005-08-22 12:04:12.000000000 +0200
@@ -721,9 +721,16 @@ FONT *mono_extract_font_range(FONT *f, i
return NULL;
/* Special case: copy entire font */
if (begin==-1 && end==-1) {
- } else if (begin>end) {
+ }
+ else if (begin == -1 && end > mono_get_font_range_begin(f, -1)) {
+ }
+ else if (end == -1 && begin <= mono_get_font_range_end(f, -1)) {
+ }
+ else if (begin <= end && begin != -1 && end != -1) {
+ }
+ else {
return NULL;
}
/* Get output font */
@@ -734,15 +741,15 @@ FONT *mono_extract_font_range(FONT *f, i
fontout->data = NULL;
/* 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);
+ last = (end>-1) ? MIN(end, mono_get_font_range_end(f, -1) + 1) : mono_get_font_range_end(f, -1) + 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 && first < mfin->end) || (last <= mfin->end && last > mfin->begin)) {
int local_begin, local_end;
local_begin = MAX(mfin->begin, first);
local_end = MIN(mfin->end, last);
@@ -1187,9 +1194,16 @@ FONT *color_extract_font_range(FONT *f,
return NULL;
/* Special case: copy entire font */
if (begin==-1 && end==-1) {
- } else if (begin>end) {
+ }
+ else if (begin == -1 && end > color_get_font_range_begin(f, -1)) {
+ }
+ else if (end == -1 && begin <= color_get_font_range_end(f, -1)) {
+ }
+ else if (begin <= end && begin != -1 && end != -1) {
+ }
+ else {
return NULL;
}
/* Get output font */
@@ -1200,15 +1214,15 @@ FONT *color_extract_font_range(FONT *f,
fontout->data = NULL;
/* 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);
+ last = (end>-1) ? MIN(end, color_get_font_range_end(f, -1) + 1) : color_get_font_range_end(f, -1) + 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 && first < cfin->end) || (last <= cfin->end && last > cfin->begin)) {
int local_begin, local_end;
local_begin = MAX(cfin->begin, first);
local_end = MIN(cfin->end, last);