Ejemplo n.º 1
0
void
font_create(int font_size, struct font_context *ctx) {
    FT_Face face;
    int err = FT_New_Face(library, TTFONT, 0, &face);
    if (err) {
        if (err == 1)
            _fault(err, "set your own vector font");
        else
            _fault(err, "new face failed");
    }

    err = FT_Set_Pixel_Sizes(face,0,font_size);

    if (err)
        _fault(err, "set char size failed");
    
    ctx->font = face;
}
Ejemplo n.º 2
0
void
font_create(int font_size, struct font_context *ctx) {
    FT_Face face;
    int err = FT_New_Face(library, TTFONT, 0, &face);
    if (err) {
        if (err == 1)
            _fault(err, "set your own vector font resource path");
        else
            _fault(err, "new face failed");
    }

    err = FT_Set_Pixel_Sizes(face,0,font_size);

    if (err)
        _fault(err, "set char size failed");
    
    ctx->font = face;
    ctx->ascent = face->size->metrics.ascender >>6;
    ctx->h = face->size->metrics.height >> 6;
}
Ejemplo n.º 3
0
void 
font_size(const char *str, int unicode, struct font_context *ctx) {
    FT_Face face = ctx->font;
    FT_UInt glyph_index = FT_Get_Char_Index(face, unicode);
	if (!glyph_index) {
		printf("cannot find glyph %d\n", unicode);
		exit(1);
	}
    FT_Load_Glyph(face, glyph_index, FT_LOAD_NO_BITMAP);
    
    int err = FT_Render_Glyph(face->glyph, FT_RENDER_MODE_NORMAL);
	if (err)
        _fault(err, "render failed");

    FT_GlyphSlot slot = face->glyph;

    ctx->w = slot->advance.x >> 6;
}
Ejemplo n.º 4
0
void 
font_size(const char *str, int unicode, struct font_context *ctx) {
    FT_Face face = ctx->font;
    FT_UInt glyph_index = FT_Get_Char_Index(face, unicode);
	if (!glyph_index) {
		printf("cannot find glyph %d\n", unicode);
		exit(1);
	}
    FT_Load_Glyph(face, glyph_index, FT_LOAD_NO_BITMAP);
    
    int err = FT_Render_Glyph(face->glyph, FT_RENDER_MODE_NORMAL);
	if (err)
        _fault(err, "render failed");

	FT_Bitmap *bitmap = &(face->glyph->bitmap);

    ctx->w = bitmap->width;
    ctx->h = bitmap->rows;
}