static VALUE coverage_set(VALUE self, VALUE index_, VALUE level) { pango_coverage_set(_SELF(self), NUM2INT(index_), RVAL2GENUM(level, PANGO_TYPE_COVERAGE_LEVEL)); return self; }
static PangoCoverage * pango_coverage_from_cf_charset (CFCharacterSetRef charset) { CFIndex i, length; CFDataRef bitmap; const UInt8 *ptr; PangoCoverage *coverage; coverage = pango_coverage_new (); bitmap = CFCharacterSetCreateBitmapRepresentation (kCFAllocatorDefault, charset); /* We only handle the BMP plane */ length = MIN (CFDataGetLength (bitmap), 8192); ptr = CFDataGetBytePtr (bitmap); /* FIXME: can and should this be done more efficiently? */ for (i = 0; i < length; i++) { int j; for (j = 0; j < 8; j++) pango_coverage_set (coverage, i * 8 + j, ((ptr[i] & (1 << j)) == (1 << j)) ? PANGO_COVERAGE_EXACT : PANGO_COVERAGE_NONE); } CFRelease (bitmap); return coverage; }
static PangoCoverage * thai_engine_x_get_coverage (PangoFont *font, PangoLanguage *lang) { PangoCoverage *result = pango_coverage_new (); ThaiFontInfo *font_info = thai_x_get_font_info (font); if (font_info->font_set != THAI_FONT_NONE) { gunichar wc; for (wc = 0xe01; wc <= 0xe3a; wc++) pango_coverage_set (result, wc, PANGO_COVERAGE_EXACT); for (wc = 0xe3f; wc <= 0xe5b; wc++) pango_coverage_set (result, wc, PANGO_COVERAGE_EXACT); } return result; }
SCRIPT_ENGINE_DEFINITION static PangoCoverage * pango_indic_engine_get_coverage (PangoFont * font, PangoLanguage *lang) { gunichar i; PangoCoverage *result = pango_coverage_new (); PangoXSubfont subfont; int dev_font = pango_x_find_first_subfont (font, &default_charset, 1, &subfont); if (dev_font) { for (i = RANGE_START; i <= RANGE_END; i++) pango_coverage_set (result, i, PANGO_COVERAGE_EXACT); pango_coverage_set (result, PANGO_ZERO_WIDTH_JOINER, PANGO_COVERAGE_EXACT); } return result; }
static PangoCoverage * ct_font_descriptor_get_coverage (CTFontDescriptorRef desc) { CFCharacterSetRef charset; CFIndex i, length; CFDataRef bitmap; const UInt8 *ptr; PangoCoverage *coverage; coverage = pango_coverage_new (); charset = CTFontDescriptorCopyAttribute (desc, kCTFontCharacterSetAttribute); if (!charset) /* Return an empty coverage */ return coverage; bitmap = CFCharacterSetCreateBitmapRepresentation (kCFAllocatorDefault, charset); /* We only handle the BMP plane */ length = MIN (CFDataGetLength (bitmap), 8192); ptr = CFDataGetBytePtr (bitmap); /* FIXME: can and should this be done more efficiently? */ for (i = 0; i < length; i++) { int j; for (j = 0; j < 8; j++) pango_coverage_set (coverage, i * 8 + j, ((ptr[i] & (1 << j)) == (1 << j)) ? PANGO_COVERAGE_EXACT : PANGO_COVERAGE_NONE); } CFRelease (bitmap); CFRelease (charset); return coverage; }
static PangoCoverage * ct_font_descriptor_get_coverage (CTFontDescriptorRef desc) { CFCharacterSetRef charset; CFIndex i, length; CFDataRef bitmap; const UInt8 *ptr, *plane_ptr; const UInt32 plane_size = 8192; PangoCoverage *coverage; coverage = pango_coverage_new (); charset = CTFontDescriptorCopyAttribute (desc, kCTFontCharacterSetAttribute); if (!charset) /* Return an empty coverage */ return coverage; bitmap = CFCharacterSetCreateBitmapRepresentation (kCFAllocatorDefault, charset); ptr = CFDataGetBytePtr (bitmap); /* First handle the BMP plane. */ length = MIN (CFDataGetLength (bitmap), plane_size); /* FIXME: can and should this be done more efficiently? */ for (i = 0; i < length; i++) { int j; for (j = 0; j < 8; j++) if ((ptr[i] & (1 << j)) == (1 << j)) pango_coverage_set (coverage, i * 8 + j, PANGO_COVERAGE_EXACT); } /* Next, handle the other planes. The plane number is encoded first as * a single byte. In the following 8192 bytes that plane's coverage bitmap * is stored. */ plane_ptr = ptr + plane_size; while (plane_ptr - ptr < CFDataGetLength (bitmap)) { const UInt8 plane_number = *plane_ptr; plane_ptr++; for (i = 0; i < plane_size; i++) { int j; for (j = 0; j < 8; j++) if ((plane_ptr[i] & (1 << j)) == (1 << j)) pango_coverage_set (coverage, (plane_number * plane_size + i) * 8 + j, PANGO_COVERAGE_EXACT); } plane_ptr += plane_size; } CFRelease (bitmap); CFRelease (charset); return coverage; }