iOS/buildlibs/armv7/allegro-4.4.2/addons/allegrogl/src/fontconv.c
/* Crops a font over a particular range */
Crops a font over a particular range
Crops a font over a particular range
static int crop_font_range(FONT *f, void *src, int beg, int end,
                           AGL_GLYPH *glyphs,
                           int *net_area, int *gross_area,
                           int *max_w, int *max_h) {
	int i;
	int crop = 1;
	int max = end - beg;
	int ret = TRUE;
	union mixed_ptr dat;
	dat.ptr = src;
	if (is_color_font(f)) {
		FONT_COLOR_DATA *fcd = f->data;
		if (bitmap_color_depth(fcd->bitmaps[0]) != 8) {
			crop = 0;
		}
	}
	for (i = 0; i < max; i++) {
		glyphs[i].glyph_num = i;
		if (is_mono_font(f)) {
			glyphs[i].w = dat.mf->glyphs[i]->w + 1;
			glyphs[i].h = dat.mf->glyphs[i]->h + 1;
		} else {
			glyphs[i].w = dat.cf->bitmaps[i]->w + 1;
			glyphs[i].h = dat.cf->bitmaps[i]->h + 1;
		}
		glyphs[i].offset_w = -1;
		glyphs[i].offset_h = -1;
		glyphs[i].x = -1;
	}
	if (crop) {
		ret = do_crop_font_range(f, glyphs, beg, end);
	}
	(*gross_area) = 0;
	(*net_area) = 0;
	(*max_w) = 0;
	(*max_h) = 0;
	for (i = 0; i < max; i++) {
		if (glyphs[i].w > *max_w) (*max_w) = glyphs[i].w;
		if (glyphs[i].h > *max_h) (*max_h) = glyphs[i].h;
		(*net_area) += glyphs[i].w * glyphs[i].h;
		(*gross_area) += (glyphs[i].w + FONT_CHARACTER_SPACING)
		               * (glyphs[i].h + FONT_CHARACTER_SPACING);
	}
	return ret;
}
static int crop_font_range ( FONT * f , void * src , int beg , int end , AGL_GLYPH * glyphs , int * net_area , int * gross_area , int * max_w , int * max_h ) { int i ; int crop = 1 ; int max = end - beg ; int ret = TRUE ; union mixed_ptr dat ; dat . ptr = src ; if ( is_color_font ( f ) ) { FONT_COLOR_DATA * fcd = f -> data ; if ( bitmap_color_depth ( fcd -> bitmaps [ 0 ] ) != 8 ) { crop = 0 ; } } for ( i = 0 ; i < max ; i ++ ) { glyphs [ i ] . glyph_num = i ; if ( is_mono_font ( f ) ) { glyphs [ i ] . w = dat . mf -> glyphs [ i ] -> w + 1 ; glyphs [ i ] . h = dat . mf -> glyphs [ i ] -> h + 1 ; } else { glyphs [ i ] . w = dat . cf -> bitmaps [ i ] -> w + 1 ; glyphs [ i ] . h = dat . cf -> bitmaps [ i ] -> h + 1 ; } glyphs [ i ] . offset_w = -1 ; glyphs [ i ] . offset_h = -1 ; glyphs [ i ] . x = -1 ; } if ( crop ) { ret = do_crop_font_range ( f , glyphs , beg , end ) ; } ( * gross_area ) = 0 ; ( * net_area ) = 0 ; ( * max_w ) = 0 ; ( * max_h ) = 0 ; for ( i = 0 ; i < max ; i ++ ) { if ( glyphs [ i ] . w > * max_w ) ( * max_w ) = glyphs [ i ] . w ; if ( glyphs [ i ] . h > * max_h ) ( * max_h ) = glyphs [ i ] . h ; ( * net_area ) += glyphs [ i ] . w * glyphs [ i ] . h ; ( * gross_area ) += ( glyphs [ i ] . w + FONT_CHARACTER_SPACING ) * ( glyphs [ i ] . h + FONT_CHARACTER_SPACING ) ; } return ret ; }
Crops a font over a particular range
Crops a font over a particular range
/* Disable cropping for trucolor fonts. */ /* Load default sizes */ /* Not placed yet */ /* Find max w and h, total area covered by the bitmaps, and number of
	 * glyphs
	 */