本文整理汇总了C++中FT_Outline_Translate函数的典型用法代码示例。如果您正苦于以下问题:C++ FT_Outline_Translate函数的具体用法?C++ FT_Outline_Translate怎么用?C++ FT_Outline_Translate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FT_Outline_Translate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: R_RenderGlyph
FT_Bitmap* R_RenderGlyph(FT_GlyphSlot glyph, glyphInfo_t* glyphOut) {
FT_Bitmap* bit2;
int left, right, width, top, bottom, height, pitch, size;
R_GetGlyphInfo(glyph, &left, &right, &width, &top, &bottom, &height, &pitch);
if (glyph->format == ft_glyph_format_outline) {
size = pitch * height;
bit2 = (FT_Bitmap*) ri.Z_Malloc(sizeof(FT_Bitmap));
bit2->width = width;
bit2->rows = height;
bit2->pitch = pitch;
bit2->pixel_mode = ft_pixel_mode_grays;
bit2->buffer = (unsigned char*) ri.Z_Malloc(pitch * height);
bit2->num_grays = 256;
Com_Memset(bit2->buffer, 0, size);
FT_Outline_Translate(&glyph->outline, -left, -bottom);
FT_Outline_Get_Bitmap(ftLibrary, &glyph->outline, bit2);
glyphOut->height = height;
glyphOut->pitch = pitch;
glyphOut->top = (glyph->metrics.horiBearingY >> 6) + 1;
glyphOut->bottom = bottom;
return bit2;
} else {
示例2: ft_raster1_transform
/* transform a given glyph image */
static
FT_Error ft_raster1_transform(FT_Renderer render,
FT_GlyphSlot slot,
FT_Matrix *matrix,
FT_Vector *delta)
{
FT_Error error = FT_Err_Ok;
if(slot->format != render->glyph_format)
{
error = FT_Err_Invalid_Argument;
goto Exit;
}
if(matrix)
{
FT_Outline_Transform(&slot->outline, matrix);
}
if(delta)
{
FT_Outline_Translate(&slot->outline, delta->x, delta->y);
}
Exit:
return error;
}
示例3: ft_smooth_render_generic
/* convert a slot's glyph image into a bitmap */
static FT_Error
ft_smooth_render_generic( FT_Renderer render,
FT_GlyphSlot slot,
FT_Render_Mode mode,
const FT_Vector* origin,
FT_Render_Mode required_mode )
{
FT_Error error;
FT_Outline* outline = NULL;
FT_BBox cbox;
FT_UInt width, height, pitch;
#ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
FT_UInt height_org, width_org;
#endif
FT_Bitmap* bitmap;
FT_Memory memory;
FT_Int hmul = mode == FT_RENDER_MODE_LCD;
FT_Int vmul = mode == FT_RENDER_MODE_LCD_V;
FT_Pos x_shift, y_shift, x_left, y_top;
FT_Raster_Params params;
/* check glyph image format */
if ( slot->format != render->glyph_format )
{
error = Smooth_Err_Invalid_Argument;
goto Exit;
}
/* check mode */
if ( mode != required_mode )
return Smooth_Err_Cannot_Render_Glyph;
outline = &slot->outline;
/* translate the outline to the new origin if needed */
if ( origin )
FT_Outline_Translate( outline, origin->x, origin->y );
/* compute the control box, and grid fit it */
FT_Outline_Get_CBox( outline, &cbox );
cbox.xMin = FT_PIX_FLOOR( cbox.xMin );
cbox.yMin = FT_PIX_FLOOR( cbox.yMin );
cbox.xMax = FT_PIX_CEIL( cbox.xMax );
cbox.yMax = FT_PIX_CEIL( cbox.yMax );
if ( cbox.xMin < 0 && cbox.xMax > FT_INT_MAX + cbox.xMin )
{
FT_ERROR(( "ft_smooth_render_generic: glyph too large:"
" xMin = %d, xMax = %d\n",
cbox.xMin >> 6, cbox.xMax >> 6 ));
return Smooth_Err_Raster_Overflow;
}
示例4: ft_outline_glyph_transform
static
void ft_outline_glyph_transform( FT_OutlineGlyph glyph,
FT_Matrix* matrix,
FT_Vector* delta )
{
if ( matrix )
FT_Outline_Transform( &glyph->outline, matrix );
if ( delta )
FT_Outline_Translate( &glyph->outline, delta->x, delta->y );
}
示例5: ft_outline_glyph_transform
ft_outline_glyph_transform( FT_Glyph outline_glyph,
const FT_Matrix* matrix,
const FT_Vector* delta )
{
FT_OutlineGlyph glyph = (FT_OutlineGlyph)outline_glyph;
if ( matrix )
FT_Outline_Transform( &glyph->outline, matrix );
if ( delta )
FT_Outline_Translate( &glyph->outline, delta->x, delta->y );
}
示例6: FT_Outline_Get_CBox
Bitmap *outline_to_bitmap(ASS_Library *library, FT_Library ftlib,
FT_Outline *outline, int bord)
{
Bitmap *bm;
int w, h;
int error;
FT_BBox bbox;
FT_Bitmap bitmap;
FT_Outline_Get_CBox(outline, &bbox);
// move glyph to origin (0, 0)
bbox.xMin &= ~63;
bbox.yMin &= ~63;
FT_Outline_Translate(outline, -bbox.xMin, -bbox.yMin);
// bitmap size
bbox.xMax = (bbox.xMax + 63) & ~63;
bbox.yMax = (bbox.yMax + 63) & ~63;
w = (bbox.xMax - bbox.xMin) >> 6;
h = (bbox.yMax - bbox.yMin) >> 6;
// pen offset
bbox.xMin >>= 6;
bbox.yMax >>= 6;
if (w * h > 8000000) {
ass_msg(library, MSGL_WARN, "Glyph bounding box too large: %dx%dpx",
w, h);
return NULL;
}
// allocate and set up bitmap
bm = alloc_bitmap(w + 2 * bord, h + 2 * bord);
bm->left = bbox.xMin - bord;
bm->top = -bbox.yMax - bord;
bitmap.width = w;
bitmap.rows = h;
bitmap.pitch = bm->stride;
bitmap.buffer = bm->buffer + bord + bm->stride * bord;
bitmap.num_grays = 256;
bitmap.pixel_mode = FT_PIXEL_MODE_GRAY;
// render into target bitmap
if ((error = FT_Outline_Get_Bitmap(ftlib, outline, &bitmap))) {
ass_msg(library, MSGL_WARN, "Failed to rasterize glyph: %d\n", error);
ass_free_bitmap(bm);
return NULL;
}
return bm;
}
示例7: FT_Vector_Transform
void SkScalerContext_CairoFT::fixVerticalLayoutBearing(FT_GlyphSlot glyph)
{
FT_Vector vector;
vector.x = glyph->metrics.vertBearingX - glyph->metrics.horiBearingX;
vector.y = -glyph->metrics.vertBearingY - glyph->metrics.horiBearingY;
if (glyph->format == FT_GLYPH_FORMAT_OUTLINE) {
if (fHaveShape) {
FT_Vector_Transform(&vector, &fShapeMatrix);
}
FT_Outline_Translate(&glyph->outline, vector.x, vector.y);
} else if (glyph->format == FT_GLYPH_FORMAT_BITMAP) {
glyph->bitmap_left += SkFDot6Floor(vector.x);
glyph->bitmap_top += SkFDot6Floor(vector.y);
}
}
示例8: getFTOutline
static FT_Outline* getFTOutline(JNIEnv* env, jobject font2D,
FTScalerContext *context, FTScalerInfo* scalerInfo,
jint glyphCode, jfloat xpos, jfloat ypos) {
int renderFlags;
int glyph_index;
FT_Error error;
FT_GlyphSlot ftglyph;
if (glyphCode >= INVISIBLE_GLYPHS ||
isNullScalerContext(context) || scalerInfo == NULL) {
return NULL;
}
error = setupFTContext(env, font2D, scalerInfo, context);
if (error) {
return NULL;
}
renderFlags = FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP;
glyph_index = FT_Get_Char_Index(scalerInfo->face, glyphCode);
error = FT_Load_Glyph(scalerInfo->face, glyphCode, renderFlags);
if (error) {
return NULL;
}
ftglyph = scalerInfo->face->glyph;
/* apply styles */
if (context->doBold) { /* if bold style */
FT_GlyphSlot_Embolden(ftglyph);
}
if (context->doItalize) { /* if oblique */
FT_GlyphSlot_Oblique(ftglyph);
}
FT_Outline_Translate(&ftglyph->outline,
FloatToF26Dot6(xpos),
-FloatToF26Dot6(ypos));
return &ftglyph->outline;
}
示例9: LoadTrueTypeChar
static FT_Error
LoadTrueTypeChar(Font *fnt,
int idx,
Boolean hint,
Boolean quiet)
{
FT_Error error;
int flags;
flags = FT_LOAD_DEFAULT;
if (hint)
flags |= FT_LOAD_FORCE_AUTOHINT;
error = FT_Load_Glyph(face, idx, flags);
if (!error)
{
if (fnt->efactor != 1.0 || fnt->slant != 0.0 )
FT_Outline_Transform(&face->glyph->outline, &matrix1);
if (fnt->rotate)
{
FT_Outline_Transform(&face->glyph->outline, &matrix2);
error = FT_Outline_Get_BBox(&face->glyph->outline, &bbox); /* we need the non-
grid-fitted bbox */
if (!error)
FT_Outline_Translate(&face->glyph->outline,
face->glyph->metrics.vertBearingY - bbox.xMin,
-fnt->y_offset * ppem * 64);
}
}
if (!error)
error = FT_Outline_Get_BBox(&face->glyph->outline, &bbox);
if (!error)
{
FT_Outline_Get_CBox(&face->glyph->outline, &bbox); /* for the case of BBox != CBox */
SetRasterArea(quiet);
}
return error;
}
示例10: R_GetGlyphInfo
/**
* @brief R_RenderGlyph
* @param[in] glyph
* @param[out] glyphOut
* @return
*/
FT_Bitmap *R_RenderGlyph(FT_GlyphSlot glyph, glyphInfo_t *glyphOut)
{
FT_Bitmap *bit2;
int left, right, width, top, bottom, height, pitch, size;
R_GetGlyphInfo(glyph, &left, &right, &width, &top, &bottom, &height, &pitch);
if (glyph->format != FT_GLYPH_FORMAT_OUTLINE)
{
Ren_Print("Non-outline fonts are not supported\n");
return NULL;
}
size = pitch * height;
bit2 = (FT_Bitmap *)ri.Z_Malloc(sizeof(FT_Bitmap));
bit2->width = width;
bit2->rows = height;
bit2->pitch = pitch;
bit2->pixel_mode = FT_PIXEL_MODE_GRAY;
bit2->buffer = (unsigned char *)ri.Z_Malloc(size);
bit2->num_grays = 256;
Com_Memset(bit2->buffer, 0, size);
FT_Outline_Translate(&glyph->outline, -left, -bottom);
FT_Outline_Get_Bitmap(ftLibrary, &glyph->outline, bit2);
glyphOut->height = height;
glyphOut->pitch = pitch;
glyphOut->top = _TRUNC(glyph->metrics.horiBearingY) + 1;
glyphOut->bottom = bottom;
glyphOut->xSkip = _TRUNC(glyph->metrics.horiAdvance) + 1;
return bit2;
}
示例11: ft_smooth_transform
/* transform a given glyph image */
static FT_Error
ft_smooth_transform( FT_Renderer render,
FT_GlyphSlot slot,
const FT_Matrix* matrix,
const FT_Vector* delta )
{
FT_Error error = FT_Err_Ok;
if ( slot->format != render->glyph_format )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
}
if ( matrix )
FT_Outline_Transform( &slot->outline, matrix );
if ( delta )
FT_Outline_Translate( &slot->outline, delta->x, delta->y );
Exit:
return error;
}
示例12: ft_raster1_render
/* convert a slot's glyph image into a bitmap */
static FT_Error
ft_raster1_render( FT_Renderer render,
FT_GlyphSlot slot,
FT_Render_Mode mode,
const FT_Vector* origin )
{
FT_Error error;
FT_Outline* outline;
FT_BBox cbox, cbox0;
FT_UInt width, height, pitch;
FT_Bitmap* bitmap;
FT_Memory memory;
FT_Raster_Params params;
/* check glyph image format */
if ( slot->format != render->glyph_format )
{
error = Raster_Err_Invalid_Argument;
goto Exit;
}
/* check rendering mode */
#ifndef FT_CONFIG_OPTION_PIC
if ( mode != FT_RENDER_MODE_MONO )
{
/* raster1 is only capable of producing monochrome bitmaps */
if ( render->clazz == &ft_raster1_renderer_class )
return Raster_Err_Cannot_Render_Glyph;
}
else
{
/* raster5 is only capable of producing 5-gray-levels bitmaps */
if ( render->clazz == &ft_raster5_renderer_class )
return Raster_Err_Cannot_Render_Glyph;
}
#else /* FT_CONFIG_OPTION_PIC */
/* When PIC is enabled, we cannot get to the class object */
/* so instead we check the final character in the class name */
/* ("raster5" or "raster1"). Yes this is a hack. */
/* The "correct" thing to do is have different render function */
/* for each of the classes. */
if ( mode != FT_RENDER_MODE_MONO )
{
/* raster1 is only capable of producing monochrome bitmaps */
if ( render->clazz->root.module_name[6] == '1' )
return Raster_Err_Cannot_Render_Glyph;
}
else
{
/* raster5 is only capable of producing 5-gray-levels bitmaps */
if ( render->clazz->root.module_name[6] == '5' )
return Raster_Err_Cannot_Render_Glyph;
}
#endif /* FT_CONFIG_OPTION_PIC */
outline = &slot->outline;
/* translate the outline to the new origin if needed */
if ( origin )
FT_Outline_Translate( outline, origin->x, origin->y );
/* compute the control box, and grid fit it */
FT_Outline_Get_CBox( outline, &cbox0 );
/* undocumented but confirmed: bbox values get rounded */
#if 1
cbox.xMin = FT_PIX_ROUND( cbox0.xMin );
cbox.yMin = FT_PIX_ROUND( cbox0.yMin );
cbox.xMax = FT_PIX_ROUND( cbox0.xMax );
cbox.yMax = FT_PIX_ROUND( cbox0.yMax );
#else
cbox.xMin = FT_PIX_FLOOR( cbox.xMin );
cbox.yMin = FT_PIX_FLOOR( cbox.yMin );
cbox.xMax = FT_PIX_CEIL( cbox.xMax );
cbox.yMax = FT_PIX_CEIL( cbox.yMax );
#endif
/* in the event either width or height round to 0, */
/* try explicitly rounding up/down. In the case of */
/* glyphs containing only one very narrow feature, */
/* this give the drop-out compensation in the */
/* in the scan conversion code to do its stuff. */
width = (FT_UInt)( ( cbox.xMax - cbox.xMin ) >> 6 );
if ( width == 0 )
{
cbox.xMin = FT_PIX_FLOOR( cbox0.xMin );
cbox.xMax = FT_PIX_CEIL( cbox0.xMax );
width = (FT_UInt)( ( cbox.xMax - cbox.xMin ) >> 6 );
}
示例13: cff_slot_load
//.........这里部分代码省略.........
FT_Short vertBearingY = 0;
FT_UShort vertAdvance = 0;
( (SFNT_Service)face->sfnt )->get_metrics( face, 1,
glyph_index,
&vertBearingY,
&vertAdvance );
metrics->vertBearingY = vertBearingY;
metrics->vertAdvance = vertAdvance;
}
else
{
/* make up vertical ones */
if ( face->os2.version != 0xFFFFU )
metrics->vertAdvance = (FT_Pos)( face->os2.sTypoAscender -
face->os2.sTypoDescender );
else
metrics->vertAdvance = (FT_Pos)( face->horizontal.Ascender -
face->horizontal.Descender );
}
glyph->root.linearVertAdvance = metrics->vertAdvance;
glyph->root.format = FT_GLYPH_FORMAT_OUTLINE;
glyph->root.outline.flags = 0;
if ( size && size->root.metrics.y_ppem < 24 )
glyph->root.outline.flags |= FT_OUTLINE_HIGH_PRECISION;
glyph->root.outline.flags |= FT_OUTLINE_REVERSE_FILL;
/* apply the font matrix, if any */
if ( font_matrix.xx != 0x10000L || font_matrix.yy != 0x10000L ||
font_matrix.xy != 0 || font_matrix.yx != 0 )
{
FT_Outline_Transform( &glyph->root.outline, &font_matrix );
metrics->horiAdvance = FT_MulFix( metrics->horiAdvance,
font_matrix.xx );
metrics->vertAdvance = FT_MulFix( metrics->vertAdvance,
font_matrix.yy );
}
if ( font_offset.x || font_offset.y )
{
FT_Outline_Translate( &glyph->root.outline,
font_offset.x,
font_offset.y );
metrics->horiAdvance += font_offset.x;
metrics->vertAdvance += font_offset.y;
}
if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 || force_scaling )
{
/* scale the outline and the metrics */
FT_Int n;
FT_Outline* cur = &glyph->root.outline;
FT_Vector* vec = cur->points;
FT_Fixed x_scale = glyph->x_scale;
FT_Fixed y_scale = glyph->y_scale;
/* First of all, scale the points */
if ( !hinting || !decoder.builder.hints_funcs )
for ( n = cur->n_points; n > 0; n--, vec++ )
{
vec->x = FT_MulFix( vec->x, x_scale );
vec->y = FT_MulFix( vec->y, y_scale );
}
/* Then scale the metrics */
metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, x_scale );
metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, y_scale );
}
/* compute the other metrics */
FT_Outline_Get_CBox( &glyph->root.outline, &cbox );
metrics->width = cbox.xMax - cbox.xMin;
metrics->height = cbox.yMax - cbox.yMin;
metrics->horiBearingX = cbox.xMin;
metrics->horiBearingY = cbox.yMax;
if ( has_vertical_info )
metrics->vertBearingX = metrics->horiBearingX -
metrics->horiAdvance / 2;
else
{
if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
ft_synthesize_vertical_metrics( metrics,
metrics->vertAdvance );
}
}
}
return error;
}
示例14: af_loader_load_glyph
//.........这里部分代码省略.........
* must therefore be recomputed for each size and
* `standard_{vertical,horizontal}_width' change.
*
* Ignore errors and carry on without emboldening.
*
*/
/* stem darkening only works well in `light' mode */
if ( scaler.render_mode == FT_RENDER_MODE_LIGHT &&
( !face->internal->no_stem_darkening ||
( face->internal->no_stem_darkening < 0 &&
!module->no_stem_darkening ) ) )
af_loader_embolden_glyph_in_slot( loader, face, style_metrics );
loader->transformed = slot_internal->glyph_transformed;
if ( loader->transformed )
{
FT_Matrix inverse;
loader->trans_matrix = slot_internal->glyph_matrix;
loader->trans_delta = slot_internal->glyph_delta;
inverse = loader->trans_matrix;
if ( !FT_Matrix_Invert( &inverse ) )
FT_Vector_Transform( &loader->trans_delta, &inverse );
}
switch ( slot->format )
{
case FT_GLYPH_FORMAT_OUTLINE:
/* translate the loaded glyph when an internal transform is needed */
if ( loader->transformed )
FT_Outline_Translate( &slot->outline,
loader->trans_delta.x,
loader->trans_delta.y );
/* compute original horizontal phantom points */
/* (and ignore vertical ones) */
loader->pp1.x = hints->x_delta;
loader->pp1.y = hints->y_delta;
loader->pp2.x = FT_MulFix( slot->metrics.horiAdvance,
hints->x_scale ) + hints->x_delta;
loader->pp2.y = hints->y_delta;
/* be sure to check for spacing glyphs */
if ( slot->outline.n_points == 0 )
goto Hint_Metrics;
/* now load the slot image into the auto-outline */
/* and run the automatic hinting process */
if ( writing_system_class->style_hints_apply )
{
error = writing_system_class->style_hints_apply(
glyph_index,
hints,
&gloader->base.outline,
style_metrics );
if ( error )
goto Exit;
}
/* we now need to adjust the metrics according to the change in */
/* width/positioning that occurred during the hinting process */
if ( scaler.render_mode != FT_RENDER_MODE_LIGHT )
{
示例15: af_loader_load_g
static FT_Error
af_loader_load_g( AF_Loader loader,
AF_Scaler scaler,
FT_UInt glyph_index,
FT_Int32 load_flags )
{
FT_Error error;
FT_Face face = loader->face;
AF_StyleMetrics metrics = loader->metrics;
AF_GlyphHints hints = loader->hints;
FT_GlyphSlot slot = face->glyph;
FT_Slot_Internal internal = slot->internal;
FT_GlyphLoader gloader = internal->loader;
FT_Int32 flags;
flags = load_flags | FT_LOAD_LINEAR_DESIGN;
error = FT_Load_Glyph( face, glyph_index, flags );
if ( error )
goto Exit;
loader->transformed = internal->glyph_transformed;
if ( loader->transformed )
{
FT_Matrix inverse;
loader->trans_matrix = internal->glyph_matrix;
loader->trans_delta = internal->glyph_delta;
inverse = loader->trans_matrix;
if ( !FT_Matrix_Invert( &inverse ) )
FT_Vector_Transform( &loader->trans_delta, &inverse );
}
switch ( slot->format )
{
case FT_GLYPH_FORMAT_OUTLINE:
/* translate the loaded glyph when an internal transform is needed */
if ( loader->transformed )
FT_Outline_Translate( &slot->outline,
loader->trans_delta.x,
loader->trans_delta.y );
/* compute original horizontal phantom points (and ignore */
/* vertical ones) */
loader->pp1.x = hints->x_delta;
loader->pp1.y = hints->y_delta;
loader->pp2.x = FT_MulFix( slot->metrics.horiAdvance,
hints->x_scale ) + hints->x_delta;
loader->pp2.y = hints->y_delta;
/* be sure to check for spacing glyphs */
if ( slot->outline.n_points == 0 )
goto Hint_Metrics;
/* now load the slot image into the auto-outline and run the */
/* automatic hinting process */
{
#ifdef FT_CONFIG_OPTION_PIC
AF_FaceGlobals globals = loader->globals;
#endif
AF_StyleClass style_class = metrics->style_class;
AF_WritingSystemClass writing_system_class =
AF_WRITING_SYSTEM_CLASSES_GET[style_class->writing_system];
if ( writing_system_class->style_hints_apply )
writing_system_class->style_hints_apply( hints,
&gloader->base.outline,
metrics );
}
/* we now need to adjust the metrics according to the change in */
/* width/positioning that occurred during the hinting process */
if ( scaler->render_mode != FT_RENDER_MODE_LIGHT )
{
FT_Pos old_rsb, old_lsb, new_lsb;
FT_Pos pp1x_uh, pp2x_uh;
AF_AxisHints axis = &hints->axis[AF_DIMENSION_HORZ];
AF_Edge edge1 = axis->edges; /* leftmost edge */
AF_Edge edge2 = edge1 +
axis->num_edges - 1; /* rightmost edge */
if ( axis->num_edges > 1 && AF_HINTS_DO_ADVANCE( hints ) )
{
old_rsb = loader->pp2.x - edge2->opos;
old_lsb = edge1->opos;
new_lsb = edge1->pos;
/* remember unhinted values to later account */
/* for rounding errors */
pp1x_uh = new_lsb - old_lsb;
pp2x_uh = edge2->pos + old_rsb;
/* prefer too much space over too little space */
/* for very small sizes */
//.........这里部分代码省略.........