Font-FreeType
view release on metacpan or search on metacpan
FreeType.xs view on Meta::CPAN
MODULE = Font::FreeType PACKAGE = Font::FreeType PREFIX = qefft2_library_
PROTOTYPES: DISABLE
void
qefft2_import (const char *target_pkg)
PREINIT:
HV *stash;
size_t i;
PPCODE:
stash = gv_stashpv(target_pkg, 0);
if (!stash)
croak("the package I'm importing into doesn't seem to exist");
for (i = 0; i < sizeof(qefft2_uv_const) / sizeof(QefFT2_Uv_Const); ++i) {
const char* name = qefft2_uv_const[i].name;
if ( !hv_exists(stash, name, strlen(name)) )
newCONSTSUB(stash, name, newSVuv(qefft2_uv_const[i].value));
}
FreeType.xs view on Meta::CPAN
qefft2_library_DESTROY (Font_FreeType library)
CODE:
if (FT_Done_FreeType(library))
warn("error closing freetype library");
void
qefft2_library_version (Font_FreeType library)
PREINIT:
FT_Int major, minor, patch;
PPCODE:
major = minor = patch = -1;
FT_Library_Version(library, &major, &minor, &patch);
assert(major != -1);
assert(minor != -1);
assert(patch != -1);
if (GIMME_V != G_ARRAY)
PUSHs(sv_2mortal(newSVpvf("%d.%d.%d",
(int) major, (int) minor, (int) patch)));
else {
EXTEND(SP, 3);
FreeType.xs view on Meta::CPAN
RETVAL
void
qefft2_face_fixed_sizes (Font_FreeType_Face face)
PREINIT:
int i;
FT_Bitmap_Size *size;
HV *hash;
double pt = 0.0, ppem;
PPCODE:
if (GIMME_V != G_ARRAY) {
PUSHs(sv_2mortal(newSViv((int) face->num_fixed_sizes)));
}
else {
EXTEND(SP, face->num_fixed_sizes);
for (i = 0; i < face->num_fixed_sizes; ++i) {
size = &face->available_sizes[i];
hash = newHV();
if (size->height)
hv_store(hash, "height", 6, newSVuv(size->height), 0);
FreeType.xs view on Meta::CPAN
}
RETVAL = array;
}
OUTPUT:
RETVAL
void
qefft2_face_kerning (Font_FreeType_Face face, FT_UInt left_glyph_idx, FT_UInt right_glyph_idx, UV kern_mode = FT_KERNING_DEFAULT)
PREINIT:
FT_Vector kerning;
PPCODE:
errchk(FT_Get_Kerning(face, left_glyph_idx, right_glyph_idx, kern_mode,
&kerning),
"getting kerning from freetype face");
if (GIMME_V != G_ARRAY) {
PUSHs(sv_2mortal(newSVnv((double) kerning.x / 64.0)));
}
else {
EXTEND(SP, 2);
PUSHs(sv_2mortal(newSVnv((double) kerning.x / 64.0)));
PUSHs(sv_2mortal(newSVnv((double) kerning.y / 64.0)));
FreeType.xs view on Meta::CPAN
RETVAL
void
qefft2_glyph_outline_bbox (Font_FreeType_Glyph glyph)
PREINIT:
FT_Face face;
QefFT2_Face_Extra *extra;
FT_OutlineGlyph outline_glyph;
FT_BBox bbox;
PPCODE:
face = (FT_Face) SvIV(glyph->face_sv);
if (!ensure_outline_loaded(face, glyph))
croak("glyph %lu does not have an outline",
(unsigned long) glyph->char_code);
extra = face->generic.data;
outline_glyph = (FT_OutlineGlyph) extra->glyph_ft;
errchk(FT_Outline_Get_BBox(&outline_glyph->outline, &bbox),
"getting glyph outline bounding box");
EXTEND(SP, 4);
PUSHs(sv_2mortal(newSVnv((double) bbox.xMin / 64.0)));
FreeType.xs view on Meta::CPAN
qefft2_glyph_bitmap (Font_FreeType_Glyph glyph, UV render_mode = FT_RENDER_MODE_NORMAL)
PREINIT:
FT_Face face;
FT_GlyphSlot glyph_ft;
FT_Bitmap *bitmap;
unsigned char *buf;
int i, j;
int bits = 0;
AV *rows;
unsigned char *row_buf;
PPCODE:
face = (FT_Face) SvIV(glyph->face_sv);
/* XXX: For some reason I can't work out how to load the bitmap and
* then load the outline later, but it works the other way round.
* To ensure that a glyph object can be used for both, in either order,
* I load the outline first even if it's not needed. There's probably
* a better way of doing this. I'll ask on the mailing list. */
ensure_outline_loaded(face, glyph);
glyph_ft = face->glyph;
if (glyph_ft->format != FT_GLYPH_FORMAT_BITMAP) {
errchk(FT_Render_Glyph(glyph_ft, render_mode), "rendering glyph");
( run in 3.722 seconds using v1.01-cache-2.11-cpan-71847e10f99 )