这篇教程C++ FT_Outline_Translate函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中FT_Outline_Translate函数的典型用法代码示例。如果您正苦于以下问题:C++ FT_Outline_Translate函数的具体用法?C++ FT_Outline_Translate怎么用?C++ FT_Outline_Translate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了FT_Outline_Translate函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: R_RenderGlyphFT_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 {
开发者ID:Kangz,项目名称:Unvanquished,代码行数:31,
示例2: ft_raster1_transform/* transform a given glyph image */staticFT_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;}
开发者ID:Diskutant,项目名称:RTCW-SP,代码行数:29,
示例3: ft_smooth_render_generic/* convert a slot's glyph image into a bitmap */static FT_Errorft_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; }
开发者ID:prestocore,项目名称:browser,代码行数:56,
示例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 ); }
开发者ID:opieproject,项目名称:qte-opie,代码行数:11,
示例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 ); }
开发者ID:7heaven,项目名称:softart,代码行数:13,
示例6: FT_Outline_Get_CBoxBitmap *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;}
开发者ID:PengLei-Adam,项目名称:FFmepg-Android,代码行数:49,
示例7: FT_Vector_Transformvoid 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); }}
开发者ID:zbraniecki,项目名称:gecko-dev,代码行数:15,
示例8: getFTOutlinestatic 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;}
开发者ID:krichter722,项目名称:jdk9-jdk9-jdk,代码行数:43,
示例9: LoadTrueTypeCharstatic FT_ErrorLoadTrueTypeChar(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;}
开发者ID:MiKTeX,项目名称:miktex,代码行数:39,
示例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;}
开发者ID:ioid3-games,项目名称:ioid3-wet,代码行数:42,
示例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; }
开发者ID:litao1009,项目名称:SimpleRoom,代码行数:25,
示例12: ft_raster1_render/* convert a slot's glyph image into a bitmap */static FT_Errorft_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 ); }
开发者ID:hackqiang,项目名称:gs,代码行数:93,
示例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; }
开发者ID:93i,项目名称:godot,代码行数:101,
示例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 ) {
开发者ID:ImageMagick,项目名称:ttf,代码行数:67,
示例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 *///.........这里部分代码省略.........
开发者ID:Clever-Boy,项目名称:XLE,代码行数:101,
示例16: 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_UInt depth ) { FT_Error error; FT_Face face = loader->face; FT_GlyphLoader gloader = loader->gloader; AF_ScriptMetrics metrics = loader->metrics; AF_GlyphHints hints = &loader->hints; FT_GlyphSlot slot = face->glyph; FT_Slot_Internal internal = slot->internal; 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; 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 ); /* copy the outline points in the loader's current */ /* extra points which are used to keep original glyph coordinates */ error = FT_GLYPHLOADER_CHECK_POINTS( gloader, slot->outline.n_points + 4, slot->outline.n_contours ); if ( error ) goto Exit; FT_ARRAY_COPY( gloader->current.outline.points, slot->outline.points, slot->outline.n_points ); FT_ARRAY_COPY( gloader->current.outline.contours, slot->outline.contours, slot->outline.n_contours ); FT_ARRAY_COPY( gloader->current.outline.tags, slot->outline.tags, slot->outline.n_points ); gloader->current.outline.n_points = slot->outline.n_points; gloader->current.outline.n_contours = slot->outline.n_contours; /* 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 ( metrics->clazz->script_hints_apply ) metrics->clazz->script_hints_apply( hints, &gloader->current.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 ) )//.........这里部分代码省略.........
开发者ID:2or3,项目名称:PlaygroundOSS,代码行数:101,
示例17: 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, height_org, width_org, pitch; 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 ); width = (FT_UInt)( ( cbox.xMax - cbox.xMin ) >> 6 ); height = (FT_UInt)( ( cbox.yMax - cbox.yMin ) >> 6 ); bitmap = &slot->bitmap; memory = render->root.memory; width_org = width; height_org = height; /* release old bitmap buffer */ if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) { FT_FREE( bitmap->buffer ); slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP; } /* allocate new one */ pitch = width; if ( hmul ) { width = width * 3; pitch = FT_PAD_CEIL( width, 4 ); } if ( vmul ) height *= 3; x_shift = (FT_Int) cbox.xMin; y_shift = (FT_Int) cbox.yMin; x_left = (FT_Int)( cbox.xMin >> 6 ); y_top = (FT_Int)( cbox.yMax >> 6 );#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING if ( slot->library->lcd_filter_func ) { FT_Int extra = slot->library->lcd_extra; if ( hmul ) { x_shift -= 64 * ( extra >> 1 ); width += 3 * extra; pitch = FT_PAD_CEIL( width, 4 ); x_left -= extra >> 1; } if ( vmul ) { y_shift -= 64 * ( extra >> 1 ); height += 3 * extra; y_top += extra >> 1; } }
开发者ID:abaradulkin,项目名称:dava.framework,代码行数:99,
示例18: FT_Set_Pixel_Sizes// lookup glyph and extract all the shapes required to draw the outlinelong int Ttt::render_char(FT_Face face, wchar_t c, long int offset, int linescale) { int error; int glyph_index; FT_Outline outline; FT_Outline_Funcs func_interface; error = FT_Set_Pixel_Sizes(face, 4096, linescale ? linescale : 64); if(error) handle_ft_error("FT_Set_Pixel_Sizes", error, __LINE__); /* lookup glyph */ glyph_index = FT_Get_Char_Index(face, (FT_ULong)c); if(!glyph_index) handle_ft_error("FT_Get_Char_Index", 0, __LINE__); /* load glyph */ error = FT_Load_Glyph(face, glyph_index, FT_LOAD_NO_BITMAP | FT_LOAD_NO_HINTING); if(error) handle_ft_error("FT_Load_Glyph", error, __LINE__); error = FT_Render_Glyph(face->glyph, FT_RENDER_MODE_MONO); if(error) handle_ft_error("FT_Render_Glyph", error, __LINE__); if(linescale > 0) // this is for the "zigzag" fill of letters? my_draw_bitmap(&face->glyph->bitmap, face->glyph->bitmap_left + offset, face->glyph->bitmap_top, linescale); error = FT_Set_Pixel_Sizes(face, 0, 64); if(error) handle_ft_error("FT_Set_Pixel_Sizes", error, __LINE__); error = FT_Load_Glyph(face, glyph_index, FT_LOAD_NO_BITMAP | FT_LOAD_NO_HINTING); if(error) handle_ft_error("FT_Load_Glyph", error, __LINE__); /* shortcut to the outline for our desired character */ outline = face->glyph->outline; /* set up entries in the interface used by FT_Outline_Decompose() */ func_interface.shift = 0; func_interface.delta = 0; func_interface.move_to = move_to_wrapper; func_interface.line_to = line_to_wrapper; func_interface.conic_to = conic_to_wrapper; func_interface.cubic_to = cubic_to_wrapper; /* offset the outline to the correct position in x */ FT_Outline_Translate( &outline, offset, 0L ); /* plot the current character */ error = FT_Outline_Decompose( &outline, &func_interface, NULL); if(error) handle_ft_error("FT_Outline_Decompose", error, __LINE__); /* save advance in a global */ advance.x = face->glyph->advance.x; advance.y = face->glyph->advance.y; /* FT_Bool use_kerning = FT_HAS_KERNING( face ); std::cout << " not using kerning /n"; if ( use_kerning && previous ) { FT_Vector kerning; error = FT_Get_Kerning( face, // handle to face object previous_glyph_index, // left glyph index glyph_index, // right glyph index FT_KERNING_DEFAULT, // kerning mode FT_KERNING_DEFAULT , FT_KERNING_UNFITTED , FT_KERNING_UNSCALED &kerning ); // target vector std::cout << " kerning x-advance: " << kerning.x << "/n"; } */ /* FT_Vector kerning; error = FT_Get_Kerning( face, // handle to face object left, // left glyph index right, // right glyph index kerning_mode, // kerning mode FT_KERNING_DEFAULT , FT_KERNING_UNFITTED , FT_KERNING_UNSCALED &kerning ); // target vector */ // delete glyph with FT_Done_Glyph? previous = true; // we have a prev glyph, for kerning previous_glyph_index = glyph_index; /* offset will get bumped up by the x size of the char just plotted */ return face->glyph->advance.x;}
开发者ID:aewallin,项目名称:truetype-tracer,代码行数:75,
示例19: CID_Load_Glyph//.........这里部分代码省略......... /* advance width */ if ( load_flags & FT_LOAD_NO_RECURSE ) { FT_Slot_Internal internal = glyph->root.internal; glyph->root.metrics.horiBearingX = decoder.builder.left_bearing.x; glyph->root.metrics.horiAdvance = decoder.builder.advance.x; internal->glyph_matrix = font_matrix; internal->glyph_delta = font_offset; internal->glyph_transformed = 1; } else { FT_BBox cbox; FT_Glyph_Metrics* metrics = &glyph->root.metrics; /* copy the _unscaled_ advance width */ metrics->horiAdvance = decoder.builder.advance.x; glyph->root.linearHoriAdvance = decoder.builder.advance.x; glyph->root.internal->glyph_transformed = 0; /* make up vertical metrics */ metrics->vertBearingX = 0; metrics->vertBearingY = 0; metrics->vertAdvance = 0; glyph->root.linearVertAdvance = 0; glyph->root.format = ft_glyph_format_outline; if ( size && size->root.metrics.y_ppem < 24 ) glyph->root.outline.flags |= ft_outline_high_precision; /* apply the font matrix */ FT_Outline_Transform( &glyph->root.outline, &font_matrix ); FT_Outline_Translate( &glyph->root.outline, font_offset.x, font_offset.y ); if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 ) { /* scale the outline and the metrics */ FT_Int n; FT_Outline* cur = decoder.builder.base; 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 ) 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 ); } FT_Outline_Get_CBox( &glyph->root.outline, &cbox ); /* Then scale the metrics */ metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, x_scale ); metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, y_scale ); metrics->vertBearingX = FT_MulFix( metrics->vertBearingX, x_scale ); metrics->vertBearingY = FT_MulFix( metrics->vertBearingY, y_scale ); if ( hinting ) { metrics->horiAdvance = ( metrics->horiAdvance + 32 ) & -64; metrics->vertAdvance = ( metrics->vertAdvance + 32 ) & -64; metrics->vertBearingX = ( metrics->vertBearingX + 32 ) & -64; metrics->vertBearingY = ( metrics->vertBearingY + 32 ) & -64; } } /* compute the other metrics */ FT_Outline_Get_CBox( &glyph->root.outline, &cbox ); /* grid fit the bounding box if necessary */ if ( hinting ) { cbox.xMin &= -64; cbox.yMin &= -64; cbox.xMax = ( cbox.xMax + 63 ) & -64; cbox.yMax = ( cbox.yMax + 63 ) & -64; } metrics->width = cbox.xMax - cbox.xMin; metrics->height = cbox.yMax - cbox.yMin; metrics->horiBearingX = cbox.xMin; metrics->horiBearingY = cbox.yMax; } } return error; }
开发者ID:1007650105,项目名称:aseprite,代码行数:101,
示例20: ft_raster1_render/* convert a slot's glyph image into a bitmap */staticFT_Error ft_raster1_render(FT_Renderer render, FT_GlyphSlot slot, FT_UInt mode, FT_Vector *origin){ FT_Error error; FT_Outline *outline; FT_BBox cbox; 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 = FT_Err_Invalid_Argument; goto Exit; } /* check rendering mode */ if(mode != ft_render_mode_mono) { /* raster1 is only capable of producing monochrome bitmaps */ if(render->clazz == &ft_raster1_renderer_class) { return FT_Err_Cannot_Render_Glyph; } } else { /* raster5 is only capable of producing 5-gray-levels bitmaps */ if(render->clazz == &ft_raster5_renderer_class) { return FT_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 &= -64; cbox.yMin &= -64; cbox.xMax = (cbox.xMax + 63) & - 64; cbox.yMax = (cbox.yMax + 63) & - 64; width = (cbox.xMax - cbox.xMin) >> 6; height = (cbox.yMax - cbox.yMin) >> 6; bitmap = &slot->bitmap; memory = render->root.memory; /* release old bitmap buffer */ if(slot->flags & ft_glyph_own_bitmap) { FREE(bitmap->buffer); slot->flags &= ~ft_glyph_own_bitmap; } /* allocate new one, depends on pixel format */ if(!(mode & ft_render_mode_mono)) { /* we pad to 32 bits, only for backwards compatibility with FT 1.x */ pitch = (width + 3) & - 4; bitmap->pixel_mode = ft_pixel_mode_grays; bitmap->num_grays = 256; } else { pitch = (width + 7) >> 3; bitmap->pixel_mode = ft_pixel_mode_mono; } bitmap->width = width; bitmap->rows = height; bitmap->pitch = pitch; if(ALLOC(bitmap->buffer, (FT_ULong)pitch * height)) { goto Exit; } slot->flags |= ft_glyph_own_bitmap; /* translate outline to render it into the bitmap */ FT_Outline_Translate(outline, -cbox.xMin, -cbox.yMin); /* set up parameters */ params.target = bitmap;//.........这里部分代码省略.........
开发者ID:Diskutant,项目名称:RTCW-SP,代码行数:101,
示例21: ft_OutlineStrokeFT_Error ft_OutlineStroke( FT_Library library, FT_Outline *Outline, int Thickness ){ FT_Error err = 0; FT_Outline OutlineReversed; FT_Outline OutlineFattened; FT_Outline OutlineStroke; if ( Outline == NULL ) { goto failure; } err = FT_Outline_New( library, Outline->n_points, Outline->n_contours, &OutlineReversed ); if ( err != 0 ) { goto failure; } err = FT_Outline_New( library, Outline->n_points, Outline->n_contours, &OutlineFattened ); if ( err != 0 ) { goto failure; } err = FT_Outline_Copy( Outline, &OutlineReversed ); if ( err != 0 ) { goto failure; } err = FT_Outline_Copy( Outline, &OutlineFattened ); if ( err != 0 ) { goto failure; } err = FT_Outline_New( library, Outline->n_points * 2, Outline->n_contours * 2, &OutlineStroke ); if ( err != 0 ) { goto failure; } /* Perform fattening operation */ err = FT_Outline_Embolden( &OutlineFattened, Thickness << 1 ); if ( err != 0 ) { goto failure; } /* Perform reversal operation */ ft_OutlineReverse( Outline, &OutlineReversed ); FT_Outline_Translate( &OutlineReversed, Thickness, Thickness ); /* Merge outlines */ ft_OutlineMerge( &OutlineFattened, &OutlineReversed, &OutlineStroke ); /* delete temporary and input outline */ err = FT_Outline_Done( library, &OutlineReversed ); if ( err != 0 ) { goto failure; } err = FT_Outline_Done( library, &OutlineFattened ); if ( err != 0 ) { goto failure; } err = FT_Outline_Done( library, Outline ); if ( err != 0 ) { goto failure; } /* finally copy the outline - its not clear from ft docs if this does the right thing but i _think_ its correct */ memcpy( Outline, &OutlineStroke, sizeof( FT_Outline ) ); return 0;failure: return err;}
开发者ID:wayfinder,项目名称:Wayfinder-CppCore-v3,代码行数:90,
示例22: ft_smooth_render /* convert a slot's glyph image into a bitmap */ static FT_Error ft_smooth_render( FT_Renderer render, FT_GlyphSlot slot, FT_UInt mode, FT_Vector* origin ) { FT_Error error; FT_Outline* outline = NULL; FT_BBox cbox; 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 = Smooth_Err_Invalid_Argument; goto Exit; } /* check mode */ if ( mode != ft_render_mode_normal ) 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 &= -64; cbox.yMin &= -64; cbox.xMax = ( cbox.xMax + 63 ) & -64; cbox.yMax = ( cbox.yMax + 63 ) & -64; width = ( cbox.xMax - cbox.xMin ) >> 6; height = ( cbox.yMax - cbox.yMin ) >> 6; bitmap = &slot->bitmap; memory = render->root.memory; /* release old bitmap buffer */ if ( slot->flags & FT_GLYPH_OWN_BITMAP ) { FT_FREE( bitmap->buffer ); slot->flags &= ~FT_GLYPH_OWN_BITMAP; } /* allocate new one, depends on pixel format */ pitch = width; bitmap->pixel_mode = ft_pixel_mode_grays; bitmap->num_grays = 256; bitmap->width = width; bitmap->rows = height; bitmap->pitch = pitch; if ( FT_ALLOC( bitmap->buffer, (FT_ULong)pitch * height ) ) goto Exit; slot->flags |= FT_GLYPH_OWN_BITMAP; /* translate outline to render it into the bitmap */ FT_Outline_Translate( outline, -cbox.xMin, -cbox.yMin ); /* set up parameters */ params.target = bitmap; params.source = outline; params.flags = ft_raster_flag_aa; /* render outline into the bitmap */ error = render->raster_render( render->raster, ¶ms ); FT_Outline_Translate( outline, cbox.xMin, cbox.yMin ); if ( error ) goto Exit; slot->format = ft_glyph_format_bitmap; slot->bitmap_left = cbox.xMin >> 6; slot->bitmap_top = cbox.yMax >> 6; Exit: if ( outline && origin ) FT_Outline_Translate( outline, -origin->x, -origin->y ); return error; }
开发者ID:Claruarius,项目名称:stblinux-2.6.37,代码行数:93,
示例23: PalFont_RenderHarfBuzz//.........这里部分代码省略......... &delta ) == 0 ) { thePen_x += ( int )( ( ( double )ftContext->m_Matrix.xx * ( double )delta.x ) / ( 65536.0 ) ); } } /* load glyph image into the slot (erase previous one) */ if ( FT_Load_Glyph( ftContext->m_face, aGlyphIndex, FT_LOAD_DEFAULT ) != 0 ) { continue; /* ignore errors */ } // if we are synthesising italic then shear outline if ( ftContext->m_Synth & SynthItalic ) { FT_Matrix m; m.xx = 65536; m.yy = 65536; m.xy = 19660; m.yx = 0; FT_Outline_Transform( &slot->outline, &m ); } /* if we are doing first pass of two color then fatten */ if ( ( ftContext->m_Synth & SynthTwoColor ) && j == 0 ) { if ( FT_Outline_Embolden( &slot->outline, ftContext->m_StrokeWidth << 2 ) != 0 ) { continue; } } // if we are doing second pass of two color then translate if ( ( ftContext->m_Synth & SynthTwoColor ) && j == 1 ) { FT_Outline_Translate( &slot->outline, ftContext->m_StrokeWidth * 2, ftContext->m_StrokeWidth * 2 ); } /* if we are synthesising bold then perform fattening operation */ if ( ftContext->m_Synth & SynthBold ) { if ( FT_Outline_Embolden( &slot->outline, ftContext->m_Boldness << 1 ) != 0 ) { continue; } } /* if we are synthesising stroke font then stroke it */ if ( ftContext->m_Synth & SynthStroke ) { if ( ft_OutlineStroke( ftContext->m_library, &slot->outline, ftContext->m_StrokeWidth ) != 0 ) { continue; } } FT_Outline_Transform( &slot->outline, &ftContext->m_Matrix ); /* if bounding box is supplied then accumulate the glyphs bounding boxes */ if ( aBBox != NULL ) { FT_BBox theCBox; FT_Outline_Get_CBox( &slot->outline, &theCBox ); theCBox.xMin += thePen_x; theCBox.xMax += thePen_x; theCBox.yMin += thePen_y;
开发者ID:wayfinder,项目名称:Wayfinder-CppCore-v3,代码行数:67,
示例24: af_loader_load_g//.........这里部分代码省略......... globals->scale_down_factor = FT_DivFix( em_size - ( darken_by_font_units_y + af_intToFixed( 8 ) ), em_size ); } FT_Outline_EmboldenXY( &slot->outline, globals->darken_x, globals->darken_y ); scale_down_matrix.yy = globals->scale_down_factor; FT_Outline_Transform( &slot->outline, &scale_down_matrix ); } After_Emboldening: 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( glyph_index, hints, &gloader->base.outline, metrics ); }
开发者ID:hsmith,项目名称:freetype,代码行数:67,
示例25: 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_Int hmul, FT_Int vmul ) { FT_Error error; FT_Outline* outline = NULL; FT_BBox cbox; 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 = 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 ); width = (FT_UInt)( ( cbox.xMax - cbox.xMin ) >> 6 ); height = (FT_UInt)( ( cbox.yMax - cbox.yMin ) >> 6 ); bitmap = &slot->bitmap; memory = render->root.memory; /* release old bitmap buffer */ if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) { FT_FREE( bitmap->buffer ); slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP; } /* allocate new one, depends on pixel format */ pitch = width; if ( hmul ) { width = width * hmul; pitch = FT_PAD_CEIL( width, 4 ); } if ( vmul ) height *= vmul; bitmap->pixel_mode = FT_PIXEL_MODE_GRAY; bitmap->num_grays = 256; bitmap->width = width; bitmap->rows = height; bitmap->pitch = pitch; if ( FT_ALLOC( bitmap->buffer, (FT_ULong)pitch * height ) ) goto Exit; slot->internal->flags |= FT_GLYPH_OWN_BITMAP; /* translate outline to render it into the bitmap */ FT_Outline_Translate( outline, -cbox.xMin, -cbox.yMin ); /* set up parameters */ params.target = bitmap; params.source = outline; params.flags = FT_RASTER_FLAG_AA; /* implode outline if needed */ { FT_Int n; FT_Vector* vec; if ( hmul ) for ( vec = outline->points, n = 0; n < outline->n_points; n++, vec++ ) vec->x *= hmul; if ( vmul ) for ( vec = outline->points, n = 0; n < outline->n_points; n++, vec++ ) vec->y *= vmul;//.........这里部分代码省略.........
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:101,
示例26: T1_Load_Glyph//.........这里部分代码省略......... { FT_Slot_Internal internal = glyph->root.internal; glyph->root.metrics.horiBearingX = FIXED_TO_INT( decoder.builder.left_bearing.x ); glyph->root.metrics.horiAdvance = FIXED_TO_INT( decoder.builder.advance.x ); internal->glyph_matrix = font_matrix; internal->glyph_delta = font_offset; internal->glyph_transformed = 1; } else { FT_BBox cbox; FT_Glyph_Metrics* metrics = &glyph->root.metrics; FT_Vector advance; /* copy the _unscaled_ advance width */ metrics->horiAdvance = FIXED_TO_INT( decoder.builder.advance.x ); glyph->root.linearHoriAdvance = FIXED_TO_INT( decoder.builder.advance.x ); glyph->root.internal->glyph_transformed = 0; /* make up vertical ones */ metrics->vertAdvance = ( face->type1.font_bbox.yMax - face->type1.font_bbox.yMin ) >> 16; glyph->root.linearVertAdvance = metrics->vertAdvance; glyph->root.format = FT_GLYPH_FORMAT_OUTLINE; if ( size && size->root.metrics.y_ppem < 24 ) glyph->root.outline.flags |= FT_OUTLINE_HIGH_PRECISION;#if 1 /* apply the font matrix, if any */ if ( font_matrix.xx != 0x10000L || font_matrix.yy != font_matrix.xx || font_matrix.xy != 0 || font_matrix.yx != 0 ) FT_Outline_Transform( &glyph->root.outline, &font_matrix ); if ( font_offset.x || font_offset.y ) FT_Outline_Translate( &glyph->root.outline, font_offset.x, font_offset.y ); advance.x = metrics->horiAdvance; advance.y = 0; FT_Vector_Transform( &advance, &font_matrix ); metrics->horiAdvance = advance.x + font_offset.x; advance.x = 0; advance.y = metrics->vertAdvance; FT_Vector_Transform( &advance, &font_matrix ); metrics->vertAdvance = advance.y + font_offset.y;#endif if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 ) { /* scale the outline and the metrics */ FT_Int n; FT_Outline* cur = decoder.builder.base; 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 we are not hinting */ 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; /* make up vertical ones */ ft_synthesize_vertical_metrics( metrics, metrics->vertAdvance ); } /* Set control data to the glyph charstrings. Note that this is */ /* _not_ zero-terminated. */ glyph->root.control_data = (FT_Byte*)glyph_data.pointer; glyph->root.control_len = glyph_data.length; }
开发者ID:FlorianChevassu,项目名称:VTK,代码行数:101,
示例27: cid_slot_load_glyph//.........这里部分代码省略......... /* for composite glyphs, return only left side bearing and */ /* advance width */ if ( load_flags & FT_LOAD_NO_RECURSE ) { FT_Slot_Internal internal = cidglyph->internal; cidglyph->metrics.horiBearingX = FIXED_TO_INT( decoder.builder.left_bearing.x ); cidglyph->metrics.horiAdvance = FIXED_TO_INT( decoder.builder.advance.x ); internal->glyph_matrix = font_matrix; internal->glyph_delta = font_offset; internal->glyph_transformed = 1; } else { FT_BBox cbox; FT_Glyph_Metrics* metrics = &cidglyph->metrics; FT_Vector advance; /* copy the _unscaled_ advance width */ metrics->horiAdvance = FIXED_TO_INT( decoder.builder.advance.x ); cidglyph->linearHoriAdvance = FIXED_TO_INT( decoder.builder.advance.x ); cidglyph->internal->glyph_transformed = 0; /* make up vertical ones */ metrics->vertAdvance = ( face->cid.font_bbox.yMax - face->cid.font_bbox.yMin ) >> 16; cidglyph->linearVertAdvance = metrics->vertAdvance; cidglyph->format = FT_GLYPH_FORMAT_OUTLINE; if ( cidsize->metrics.y_ppem < 24 ) cidglyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION; /* apply the font matrix */ FT_Outline_Transform( &cidglyph->outline, &font_matrix ); FT_Outline_Translate( &cidglyph->outline, font_offset.x, font_offset.y ); advance.x = metrics->horiAdvance; advance.y = 0; FT_Vector_Transform( &advance, &font_matrix ); metrics->horiAdvance = advance.x + font_offset.x; advance.x = 0; advance.y = metrics->vertAdvance; FT_Vector_Transform( &advance, &font_matrix ); metrics->vertAdvance = advance.y + font_offset.y; if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 ) { /* scale the outline and the metrics */ FT_Int n; FT_Outline* cur = decoder.builder.base; 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( &cidglyph->outline, &cbox ); metrics->width = cbox.xMax - cbox.xMin; metrics->height = cbox.yMax - cbox.yMin; metrics->horiBearingX = cbox.xMin; metrics->horiBearingY = cbox.yMax; if ( load_flags & FT_LOAD_VERTICAL_LAYOUT ) { /* make up vertical ones */ ft_synthesize_vertical_metrics( metrics, metrics->vertAdvance ); } } Exit: return error; }
开发者ID:0302zq,项目名称:libgdx,代码行数:101,
示例28: SkToBoolvoid SkScalerContext_FreeType_Base::generateGlyphImage( FT_Face face, const SkGlyph& glyph, const SkMatrix& bitmapTransform){ const bool doBGR = SkToBool(fRec.fFlags & SkScalerContext::kLCD_BGROrder_Flag); const bool doVert = SkToBool(fRec.fFlags & SkScalerContext::kLCD_Vertical_Flag); switch ( face->glyph->format ) { case FT_GLYPH_FORMAT_OUTLINE: { FT_Outline* outline = &face->glyph->outline; int dx = 0, dy = 0; if (fRec.fFlags & SkScalerContext::kSubpixelPositioning_Flag) { dx = SkFixedToFDot6(glyph.getSubXFixed()); dy = SkFixedToFDot6(glyph.getSubYFixed()); // negate dy since freetype-y-goes-up and skia-y-goes-down dy = -dy; } memset(glyph.fImage, 0, glyph.rowBytes() * glyph.fHeight); if (SkMask::kLCD16_Format == glyph.fMaskFormat) { FT_Outline_Translate(outline, dx, dy); FT_Error err = FT_Render_Glyph(face->glyph, doVert ? FT_RENDER_MODE_LCD_V : FT_RENDER_MODE_LCD); if (err) { SK_TRACEFTR(err, "Could not render glyph."); return; } SkMask mask; glyph.toMask(&mask);#ifdef SK_SHOW_TEXT_BLIT_COVERAGE memset(mask.fImage, 0x80, mask.fBounds.height() * mask.fRowBytes);#endif FT_GlyphSlotRec& ftGlyph = *face->glyph; if (!SkIRect::Intersects(mask.fBounds, SkIRect::MakeXYWH( ftGlyph.bitmap_left, -ftGlyph.bitmap_top, ftGlyph.bitmap.width, ftGlyph.bitmap.rows))) { return; } // If the FT_Bitmap extent is larger, discard bits of the bitmap outside the mask. // If the SkMask extent is larger, shrink mask to fit bitmap (clearing discarded). unsigned char* origBuffer = ftGlyph.bitmap.buffer; // First align the top left (origin). if (-ftGlyph.bitmap_top < mask.fBounds.fTop) { int32_t topDiff = mask.fBounds.fTop - (-ftGlyph.bitmap_top); ftGlyph.bitmap.buffer += ftGlyph.bitmap.pitch * topDiff; ftGlyph.bitmap.rows -= topDiff; ftGlyph.bitmap_top = -mask.fBounds.fTop; } if (ftGlyph.bitmap_left < mask.fBounds.fLeft) { int32_t leftDiff = mask.fBounds.fLeft - ftGlyph.bitmap_left; ftGlyph.bitmap.buffer += leftDiff; ftGlyph.bitmap.width -= leftDiff; ftGlyph.bitmap_left = mask.fBounds.fLeft; } if (mask.fBounds.fTop < -ftGlyph.bitmap_top) { mask.fImage += mask.fRowBytes * (-ftGlyph.bitmap_top - mask.fBounds.fTop); mask.fBounds.fTop = -ftGlyph.bitmap_top; } if (mask.fBounds.fLeft < ftGlyph.bitmap_left) { mask.fImage += sizeof(uint16_t) * (ftGlyph.bitmap_left - mask.fBounds.fLeft); mask.fBounds.fLeft = ftGlyph.bitmap_left; } // Origins aligned, clean up the width and height. int ftVertScale = (doVert ? 3 : 1); int ftHoriScale = (doVert ? 1 : 3); if (mask.fBounds.height() * ftVertScale < SkToInt(ftGlyph.bitmap.rows)) { ftGlyph.bitmap.rows = mask.fBounds.height() * ftVertScale; } if (mask.fBounds.width() * ftHoriScale < SkToInt(ftGlyph.bitmap.width)) { ftGlyph.bitmap.width = mask.fBounds.width() * ftHoriScale; } if (SkToInt(ftGlyph.bitmap.rows) < mask.fBounds.height() * ftVertScale) { mask.fBounds.fBottom = mask.fBounds.fTop + ftGlyph.bitmap.rows / ftVertScale; } if (SkToInt(ftGlyph.bitmap.width) < mask.fBounds.width() * ftHoriScale) { mask.fBounds.fRight = mask.fBounds.fLeft + ftGlyph.bitmap.width / ftHoriScale; } if (fPreBlend.isApplicable()) { copyFT2LCD16<true>(ftGlyph.bitmap, mask, doBGR, fPreBlend.fR, fPreBlend.fG, fPreBlend.fB); } else { copyFT2LCD16<false>(ftGlyph.bitmap, mask, doBGR, fPreBlend.fR, fPreBlend.fG, fPreBlend.fB); } // Restore the buffer pointer so FreeType can properly free it. ftGlyph.bitmap.buffer = origBuffer; } else { FT_BBox bbox; FT_Bitmap target; FT_Outline_Get_CBox(outline, &bbox); /*//.........这里部分代码省略.........
开发者ID:MIPS,项目名称:external-skia,代码行数:101,
示例29: T1_Load_Glyph//.........这里部分代码省略......... internal->glyph_matrix = font_matrix; internal->glyph_delta = font_offset; internal->glyph_transformed = 1; } else { FT_BBox cbox; FT_Glyph_Metrics* metrics = &t1glyph->metrics; /* copy the _unscaled_ advance width */ metrics->horiAdvance = FIXED_TO_INT( decoder.builder.advance.x ); t1glyph->linearHoriAdvance = FIXED_TO_INT( decoder.builder.advance.x ); t1glyph->internal->glyph_transformed = 0; if ( load_flags & FT_LOAD_VERTICAL_LAYOUT ) { /* make up vertical ones */ metrics->vertAdvance = ( face->type1.font_bbox.yMax - face->type1.font_bbox.yMin ) >> 16; t1glyph->linearVertAdvance = metrics->vertAdvance; } else { metrics->vertAdvance = FIXED_TO_INT( decoder.builder.advance.y ); t1glyph->linearVertAdvance = FIXED_TO_INT( decoder.builder.advance.y ); } t1glyph->format = FT_GLYPH_FORMAT_OUTLINE; if ( t1size && t1size->metrics.y_ppem < 24 ) t1glyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION;#if 1 /* 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( &t1glyph->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( &t1glyph->outline, font_offset.x, font_offset.y ); metrics->horiAdvance += font_offset.x; metrics->vertAdvance += font_offset.y; }#endif if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 || force_scaling ) { /* scale the outline and the metrics */ FT_Int n; FT_Outline* cur = decoder.builder.base; 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 we are not hinting */ 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( &t1glyph->outline, &cbox ); metrics->width = cbox.xMax - cbox.xMin; metrics->height = cbox.yMax - cbox.yMin; metrics->horiBearingX = cbox.xMin; metrics->horiBearingY = cbox.yMax; if ( load_flags & FT_LOAD_VERTICAL_LAYOUT ) { /* make up vertical ones */ ft_synthesize_vertical_metrics( metrics, metrics->vertAdvance ); } }
开发者ID:Moteesh,项目名称:reactos,代码行数:101,
示例30: t1operator_seac//.........这里部分代码省略......... return PSaux_Err_Syntax_Error; } /* if we are trying to load a composite glyph, do not load the */ /* accent character and return the array of subglyphs. */ if ( decoder->builder.no_recurse ) { FT_GlyphSlot glyph = (FT_GlyphSlot)decoder->builder.glyph; FT_GlyphLoader loader = glyph->internal->loader; FT_SubGlyph subg; /* reallocate subglyph array if necessary */ error = FT_GlyphLoader_CheckSubGlyphs( loader, 2 ); if ( error ) goto Exit; subg = loader->current.subglyphs; /* subglyph 0 = base character */ subg->index = bchar_index; subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES | FT_SUBGLYPH_FLAG_USE_MY_METRICS; subg->arg1 = 0; subg->arg2 = 0; subg++; /* subglyph 1 = accent character */ subg->index = achar_index; subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES; subg->arg1 = adx - asb; subg->arg2 = ady; /* set up remaining glyph fields */ glyph->num_subglyphs = 2; glyph->subglyphs = loader->base.subglyphs; glyph->format = ft_glyph_format_composite; loader->current.num_subglyphs = 2; goto Exit; } /* First load `bchar' in builder */ /* now load the unscaled outline */ FT_GlyphLoader_Prepare( decoder->builder.loader ); /* prepare loader */ error = T1_Decoder_Parse_Glyph( decoder, bchar_index ); if ( error ) goto Exit;#if 0 n_base_points = base->n_points;#endif /* save the left bearing and width of the base character */ /* as they will be erased by the next load. */ left_bearing = decoder->builder.left_bearing; advance = decoder->builder.advance; decoder->builder.left_bearing.x = 0; decoder->builder.left_bearing.y = 0; decoder->builder.pos_x = adx - asb; decoder->builder.pos_y = ady; /* Now load `achar' on top of */ /* the base outline */ error = T1_Decoder_Parse_Glyph( decoder, achar_index ); if ( error ) goto Exit; /* restore the left side bearing and */ /* advance width of the base character */ decoder->builder.left_bearing = left_bearing; decoder->builder.advance = advance; /* XXX: old code doesn't work with PostScript hinter */#if 0 /* Finally, move the accent */ if ( decoder->builder.load_points ) { FT_Outline dummy; dummy.n_points = (short)( base->n_points - n_base_points ); dummy.points = base->points + n_base_points; FT_Outline_Translate( &dummy, adx - asb, ady ); }#else decoder->builder.pos_x = 0; decoder->builder.pos_y = 0;#endif Exit: return error; }
开发者ID:Claruarius,项目名称:stblinux-2.6.37,代码行数:101,
注:本文中的FT_Outline_Translate函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ FT_PRINTERR函数代码示例 C++ FT_Outline_Transform函数代码示例 |