Exemplo n.º 1
0
static void setFontSize(SFFontRef sfFont, SFFloat size) {
	sfFont->_size = size;
	sfFont->_sizeByEm = size / CGFontGetUnitsPerEm(sfFont->_cgFont);
	sfFont->_ascender = sfFont->_sizeByEm * CGFontGetAscent(sfFont->_cgFont);
	sfFont->_descender = sfFont->_sizeByEm * CGFontGetDescent(sfFont->_cgFont);
	sfFont->_leading = sfFont->_ascender - sfFont->_descender;
}
Exemplo n.º 2
0
void
load(XFont *f)
{
	int i, j;
	CGFontRef font;
	CFStringRef s;
	UniChar u[256];
	CGGlyph g[256];
	CGRect bbox;

	if(f->loaded)
		return;
	f->loaded = 1;
	s = c2mac(f->name);
	font = CGFontCreateWithFontName(s);
	CFRelease(s);
	if(font == nil)
		return;
	
	// assume bbox gives latin1 is height/ascent for all
	bbox = subfontbbox(font, 0x00, 0xff);
	f->unit = CGFontGetUnitsPerEm(font);
	f->height = bbox.size.height;
	f->originy = bbox.origin.y;

	// figure out where the letters are
	for(i=0; i<0xffff; i+=0x100) {
		for(j=0; j<0x100; j++) {
			u[j] = mapUnicode(i+j);
			g[j] = 0;
		}
		CGFontGetGlyphsForUnichars(font, u, g, 256);
		for(j=0; j<0x100; j++) {
			if(g[j] != 0) {
				f->range[i>>8] = 1;
				f->nrange++;
				break;
			}
		}
	}