当前位置: 首页>>代码示例>>C++>>正文


C++ glyph_positions类代码示例

本文整理汇总了C++中glyph_positions的典型用法代码示例。如果您正苦于以下问题:C++ glyph_positions类的具体用法?C++ glyph_positions怎么用?C++ glyph_positions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了glyph_positions类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: scoped_glyph_positions_offset

    scoped_glyph_positions_offset(glyph_positions & glyphs, pixel_position const& offset)
        : glyphs_(glyphs)
        , base_point_(glyphs.get_base_point())
        , marker_pos_(glyphs.marker_pos())
    {
        // move the glyphs to the correct offset
        glyphs_.set_base_point(base_point_ + offset);

        // update the position of any marker
        if (auto const& marker_info = glyphs_.get_marker())
        {
            glyphs_.set_marker(marker_info, marker_pos_ + offset);
        }
    }
开发者ID:DavidLiuGitHub,项目名称:mapnik,代码行数:14,代码来源:glyph_positions.hpp

示例2: prepare_glyphs

void text_renderer::prepare_glyphs(glyph_positions const& positions)
{
    FT_Matrix matrix;
    FT_Vector pen;
    FT_Error  error;

    glyphs_.reserve(positions.size());
    for (auto const& glyph_pos : positions)
    {
        glyph_info const& glyph = glyph_pos.glyph;
        glyph.face->set_character_sizes(glyph.format->text_size * scale_factor_); //TODO: Optimize this?

        matrix.xx = static_cast<FT_Fixed>( glyph_pos.rot.cos * 0x10000L);
        matrix.xy = static_cast<FT_Fixed>(-glyph_pos.rot.sin * 0x10000L);
        matrix.yx = static_cast<FT_Fixed>( glyph_pos.rot.sin * 0x10000L);
        matrix.yy = static_cast<FT_Fixed>( glyph_pos.rot.cos * 0x10000L);

        pixel_position pos = glyph_pos.pos + glyph.offset.rotate(glyph_pos.rot);
        pen.x = static_cast<FT_Pos>(pos.x * 64);
        pen.y = static_cast<FT_Pos>(pos.y * 64);

        FT_Face face = glyph.face->get_face();
        FT_Set_Transform(face, &matrix, &pen);

        error = FT_Load_Glyph(face, glyph.glyph_index, FT_LOAD_NO_HINTING);
        if (error) continue;

        FT_Glyph image;
        error = FT_Get_Glyph(face->glyph, &image);
        if (error) continue;

        glyphs_.emplace_back(image, *glyph.format);
    }
}
开发者ID:Airphrame,项目名称:mapnik,代码行数:34,代码来源:renderer.cpp

示例3:

void grid_text_renderer<T>::render(glyph_positions const& pos, value_integer feature_id)
{
    glyphs_.clear();
    prepare_glyphs(pos);
    FT_Error  error;
    FT_Vector start;
    unsigned height = pixmap_.height();
    pixel_position const& base_point = pos.get_base_point();
    start.x =  static_cast<FT_Pos>(base_point.x * (1 << 6));
    start.y =  static_cast<FT_Pos>((height - base_point.y) * (1 << 6));

    // now render transformed glyphs
    double halo_radius = 0.0;
    for (auto & glyph : glyphs_)
    {
        if (glyph.properties)
        {
            halo_radius = glyph.properties->halo_radius * scale_factor_;
        }
        FT_Glyph_Transform(glyph.image, 0, &start);
        error = FT_Glyph_To_Bitmap(&glyph.image, FT_RENDER_MODE_NORMAL, 0, 1);
        if (!error)
        {

            FT_BitmapGlyph bit = reinterpret_cast<FT_BitmapGlyph>(glyph.image);
            render_halo_id(&bit->bitmap,
                           feature_id,
                           bit->left,
                           height - bit->top,
                           static_cast<int>(halo_radius));
        }
    }
}
开发者ID:anselmbradford,项目名称:mapnik,代码行数:33,代码来源:renderer.cpp

示例4: prepare_glyphs

void text_renderer::prepare_glyphs(glyph_positions const& positions)
{
    FT_Matrix matrix;
    FT_Vector pen;
    FT_Error  error;

    glyphs_.clear();
    glyphs_.reserve(positions.size());

    for (auto const& glyph_pos : positions)
    {
        glyph_info const& glyph = glyph_pos.glyph;
        FT_Int32 load_flags = FT_LOAD_DEFAULT | FT_LOAD_NO_HINTING;

        FT_Face face = glyph.face->get_face();
        if (glyph.face->is_color())
        {
            load_flags |= FT_LOAD_COLOR ;
            if (face->num_fixed_sizes > 0)
            {
                int scaled_size = static_cast<int>(glyph.format->text_size * scale_factor_);
                int best_match = 0;
                int diff = std::abs(scaled_size - face->available_sizes[0].width);
                for (int i = 1; i < face->num_fixed_sizes; ++i)
                {
                    int ndiff = std::abs(scaled_size - face->available_sizes[i].height);
                    if (ndiff < diff)
                    {
                        best_match = i;
                        diff = ndiff;
                    }
                }
                error = FT_Select_Size(face, best_match);
            }
        }
        else
        {
            glyph.face->set_character_sizes(glyph.format->text_size * scale_factor_);
        }

        double size = glyph.format->text_size * scale_factor_;
        matrix.xx = static_cast<FT_Fixed>( glyph_pos.rot.cos * 0x10000L);
        matrix.xy = static_cast<FT_Fixed>(-glyph_pos.rot.sin * 0x10000L);
        matrix.yx = static_cast<FT_Fixed>( glyph_pos.rot.sin * 0x10000L);
        matrix.yy = static_cast<FT_Fixed>( glyph_pos.rot.cos * 0x10000L);

        pixel_position pos = glyph_pos.pos + glyph.offset.rotate(glyph_pos.rot);
        pen.x = static_cast<FT_Pos>(pos.x * 64);
        pen.y = static_cast<FT_Pos>(pos.y * 64);

        FT_Set_Transform(face, &matrix, &pen);
        error = FT_Load_Glyph(face, glyph.glyph_index, load_flags);
        if (error) continue;
        FT_Glyph image;
        error = FT_Get_Glyph(face->glyph, &image);
        if (error) continue;
        box2d<double> bbox(0, glyph_pos.glyph.ymin(), glyph_pos.glyph.advance(), glyph_pos.glyph.ymax());
        glyphs_.emplace_back(image, *glyph.format, pos, glyph_pos.rot, size, bbox);
    }
}
开发者ID:CartoDB,项目名称:mapnik,代码行数:60,代码来源:renderer.cpp

示例5: render_pos

void grid_text_renderer<T>::render(glyph_positions const& pos, value_integer feature_id)
{
    prepare_glyphs(pos);
    FT_Error  error;
    FT_Vector start;
    unsigned height = pixmap_.height();
    pixel_position const& base_point = pos.get_base_point();
    start.x =  static_cast<FT_Pos>(base_point.x * (1 << 6));
    start.y =  static_cast<FT_Pos>((height - base_point.y) * (1 << 6));
    start.x += transform_.tx * 64;
    start.y += transform_.ty * 64;

    // now render transformed glyphs
    double halo_radius = 0.0;
    FT_Matrix halo_matrix;
    halo_matrix.xx = halo_transform_.sx  * 0x10000L;
    halo_matrix.xy = halo_transform_.shx * 0x10000L;
    halo_matrix.yy = halo_transform_.sy  * 0x10000L;
    halo_matrix.yx = halo_transform_.shy * 0x10000L;
    for (auto & glyph : glyphs_)
    {
        halo_radius = glyph.properties.halo_radius * scale_factor_;
        FT_Glyph_Transform(glyph.image, &halo_matrix, &start);
        error = FT_Glyph_To_Bitmap(&glyph.image, FT_RENDER_MODE_NORMAL, 0, 1);
        if (!error)
        {
            FT_BitmapGlyph bit = reinterpret_cast<FT_BitmapGlyph>(glyph.image);
            if (bit->bitmap.pixel_mode == FT_PIXEL_MODE_BGRA)
            {
                pixel_position render_pos(base_point);
                image_rgba8 glyph_image(render_glyph_image(glyph,
                                                           bit->bitmap,
                                                           transform_,
                                                           render_pos));
                const constexpr std::size_t pixel_size = sizeof(image_rgba8::pixel_type);
                render_halo_id<pixel_size>(glyph_image.bytes(),
                                           glyph_image.width(),
                                           glyph_image.height(),
                                           feature_id,
                                           render_pos.x, render_pos.y,
                                           static_cast<int>(halo_radius));
            }
            else
            {
                render_halo_id<1>(bit->bitmap.buffer,
                                  bit->bitmap.width,
                                  bit->bitmap.rows,
                                  feature_id,
                                  bit->left,
                                  height - bit->top,
                                  static_cast<int>(halo_radius));
            }
        }
        FT_Done_Glyph(glyph.image);
    }
}
开发者ID:CartoDB,项目名称:mapnik,代码行数:56,代码来源:renderer.cpp

示例6:

void grid_text_renderer<T>::render(glyph_positions const& pos, value_integer feature_id)
{
    prepare_glyphs(pos);
    FT_Error  error;
    FT_Vector start;
    unsigned height = pixmap_.height();
    pixel_position const& base_point = pos.get_base_point();
    start.x =  static_cast<FT_Pos>(base_point.x * (1 << 6));
    start.y =  static_cast<FT_Pos>((height - base_point.y) * (1 << 6));
    start.x += transform_.tx * 64;
    start.y += transform_.ty * 64;

    // now render transformed glyphs
    double halo_radius = 0.0;
    FT_Matrix halo_matrix;
    halo_matrix.xx = halo_transform_.sx  * 0x10000L;
    halo_matrix.xy = halo_transform_.shx * 0x10000L;
    halo_matrix.yy = halo_transform_.sy  * 0x10000L;
    halo_matrix.yx = halo_transform_.shy * 0x10000L;
    for (auto & glyph : glyphs_)
    {
        halo_radius = glyph.properties.halo_radius * scale_factor_;
        FT_Glyph_Transform(glyph.image, &halo_matrix, &start);
        error = FT_Glyph_To_Bitmap(&glyph.image, FT_RENDER_MODE_NORMAL, 0, 1);
        if (!error)
        {

            FT_BitmapGlyph bit = reinterpret_cast<FT_BitmapGlyph>(glyph.image);
            render_halo_id(&bit->bitmap,
                           feature_id,
                           bit->left,
                           height - bit->top,
                           static_cast<int>(halo_radius));
        }
        FT_Done_Glyph(glyph.image);
    }
}
开发者ID:cquest,项目名称:mapnik,代码行数:37,代码来源:renderer.cpp

示例7: black

void agg_text_renderer<T>::render(glyph_positions const& pos)
{
    glyphs_.clear();
    prepare_glyphs(pos);
    FT_Error  error;
    FT_Vector start;
    FT_Vector start_halo;
    int height = pixmap_.height();
    pixel_position const& base_point = pos.get_base_point();

    start.x =  static_cast<FT_Pos>(base_point.x * (1 << 6));
    start.y =  static_cast<FT_Pos>((height - base_point.y) * (1 << 6));
    start_halo = start;
    start.x += transform_.tx * 64;
    start.y += transform_.ty * 64;
    start_halo.x += halo_transform_.tx * 64;
    start_halo.y += halo_transform_.ty * 64;

    FT_Matrix halo_matrix;
    halo_matrix.xx = halo_transform_.sx  * 0x10000L;
    halo_matrix.xy = halo_transform_.shx * 0x10000L;
    halo_matrix.yy = halo_transform_.sy  * 0x10000L;
    halo_matrix.yx = halo_transform_.shy * 0x10000L;

    FT_Matrix matrix;
    matrix.xx = transform_.sx  * 0x10000L;
    matrix.xy = transform_.shx * 0x10000L;
    matrix.yy = transform_.sy  * 0x10000L;
    matrix.yx = transform_.shy * 0x10000L;

    // default formatting
    double halo_radius = 0;
    color black(0,0,0);
    unsigned fill = black.rgba();
    unsigned halo_fill = black.rgba();
    double text_opacity = 1.0;
    double halo_opacity = 1.0;

    for (auto const& glyph : glyphs_)
    {
        halo_fill = glyph.properties.halo_fill.rgba();
        halo_opacity = glyph.properties.halo_opacity;
        halo_radius = glyph.properties.halo_radius * scale_factor_;
        // make sure we've got reasonable values.
        if (halo_radius <= 0.0 || halo_radius > 1024.0) continue;
        FT_Glyph g;
        error = FT_Glyph_Copy(glyph.image, &g);
        if (!error)
        {
            FT_Glyph_Transform(g, &halo_matrix, &start_halo);
            if (rasterizer_ == HALO_RASTERIZER_FULL)
            {
                stroker_->init(halo_radius);
                FT_Glyph_Stroke(&g, stroker_->get(), 1);
                error = FT_Glyph_To_Bitmap(&g, FT_RENDER_MODE_NORMAL, 0, 1);
                if (!error)
                {
                    FT_BitmapGlyph bit = reinterpret_cast<FT_BitmapGlyph>(g);
                    composite_bitmap(pixmap_,
                                     &bit->bitmap,
                                     halo_fill,
                                     bit->left,
                                     height - bit->top,
                                     halo_opacity,
                                     halo_comp_op_);
                }
            }
            else
            {
                error = FT_Glyph_To_Bitmap(&g, FT_RENDER_MODE_NORMAL, 0, 1);
                if (!error)
                {
                    FT_BitmapGlyph bit = reinterpret_cast<FT_BitmapGlyph>(g);
                    render_halo(&bit->bitmap,
                                halo_fill,
                                bit->left,
                                height - bit->top,
                                halo_radius,
                                halo_opacity,
                                halo_comp_op_);
                }
            }
        }
        FT_Done_Glyph(g);
    }

    // render actual text
    for (auto & glyph : glyphs_)
    {
        fill = glyph.properties.fill.rgba();
        text_opacity = glyph.properties.text_opacity;
        FT_Glyph_Transform(glyph.image, &matrix, &start);
        error = FT_Glyph_To_Bitmap(&glyph.image ,FT_RENDER_MODE_NORMAL, 0, 1);
        if (!error)
        {
            FT_BitmapGlyph bit = reinterpret_cast<FT_BitmapGlyph>(glyph.image);
            composite_bitmap(pixmap_,
                             &bit->bitmap,
                             fill,
                             bit->left,
//.........这里部分代码省略.........
开发者ID:Airphrame,项目名称:mapnik,代码行数:101,代码来源:renderer.cpp

示例8: add_text

void cairo_context::add_text(glyph_positions const& pos,
                             cairo_face_manager & manager,
                             composite_mode_e comp_op,
                             composite_mode_e halo_comp_op,
                             double scale_factor)
{
    pixel_position const& base_point = pos.get_base_point();
    const double sx = base_point.x;
    const double sy = base_point.y;

    for (auto const& glyph_pos : pos)
    {
        glyph_info const& glyph = glyph_pos.glyph;
        glyph.face->set_character_sizes(glyph.format->text_size * scale_factor);
    }

    //render halo
    double halo_radius = 0;
    set_operator(halo_comp_op);
    for (auto const& glyph_pos : pos)
    {
        glyph_info const& glyph = glyph_pos.glyph;
        halo_radius = glyph.format->halo_radius * scale_factor;
        // make sure we've got reasonable values.
        if (halo_radius <= 0.0 || halo_radius > 1024.0) continue;
        double text_size = glyph.format->text_size * scale_factor;
        cairo_matrix_t matrix;
        matrix.xx = text_size * glyph_pos.rot.cos;
        matrix.xy = text_size * glyph_pos.rot.sin;
        matrix.yx = text_size * -glyph_pos.rot.sin;
        matrix.yy = text_size * glyph_pos.rot.cos;
        matrix.x0 = 0;
        matrix.y0 = 0;
        set_font_matrix(matrix);
        set_font_face(manager, glyph.face);
        pixel_position new_pos = glyph_pos.pos + glyph.offset.rotate(glyph_pos.rot);
        glyph_path(glyph.glyph_index, pixel_position(sx + new_pos.x, sy - new_pos.y));
        set_line_width(2.0 * halo_radius);
        set_line_join(ROUND_JOIN);
        set_color(glyph.format->halo_fill, glyph.format->halo_opacity);
        stroke();
    }
    set_operator(comp_op);
    for (auto const& glyph_pos : pos)
    {
        glyph_info const& glyph = glyph_pos.glyph;
        double text_size = glyph.format->text_size * scale_factor;
        cairo_matrix_t matrix;
        matrix.xx = text_size * glyph_pos.rot.cos;
        matrix.xy = text_size * glyph_pos.rot.sin;
        matrix.yx = text_size * -glyph_pos.rot.sin;
        matrix.yy = text_size * glyph_pos.rot.cos;
        matrix.x0 = 0;
        matrix.y0 = 0;
        set_font_matrix(matrix);
        set_font_face(manager, glyph.face);
        pixel_position new_pos = glyph_pos.pos + glyph.offset.rotate(glyph_pos.rot);
        set_color(glyph.format->fill, glyph.format->text_opacity);
        show_glyph(glyph.glyph_index, pixel_position(sx + new_pos.x, sy - new_pos.y));
    }

}
开发者ID:lightmare,项目名称:mapnik,代码行数:62,代码来源:cairo_context.cpp

示例9:

void agg_text_renderer<T>::render(glyph_positions const& pos)
{
    glyphs_.clear();
    prepare_glyphs(pos);
    FT_Error  error;
    FT_Vector start;
    int height = pixmap_.height();
    pixel_position const& base_point = pos.get_base_point();

    start.x =  static_cast<FT_Pos>(base_point.x * (1 << 6));
    start.y =  static_cast<FT_Pos>((height - base_point.y) * (1 << 6));

    //render halo
    double halo_radius = 0;
    char_properties_ptr format;
    for (auto const& glyph : glyphs_)
    {
        if (glyph.properties)
        {
            format = glyph.properties;
            // Settings have changed.
            halo_radius = glyph.properties->halo_radius * scale_factor_;
        }
        // make sure we've got reasonable values.
        if (halo_radius <= 0.0 || halo_radius > 1024.0) continue;
        FT_Glyph g;
        error = FT_Glyph_Copy(glyph.image, &g);
        if (!error)
        {
            FT_Glyph_Transform(g,0,&start);
            if (rasterizer_ == HALO_RASTERIZER_FULL)
            {
                stroker_->init(halo_radius);
                FT_Glyph_Stroke(&g, stroker_->get(), 1);
                error = FT_Glyph_To_Bitmap(&g, FT_RENDER_MODE_NORMAL, 0, 1);
                if (!error)
                {
                    FT_BitmapGlyph bit = reinterpret_cast<FT_BitmapGlyph>(g);
                    composite_bitmap(pixmap_,
                                     &bit->bitmap,
                                     format->halo_fill.rgba(),
                                     bit->left,
                                     height - bit->top,
                                     format->text_opacity,
                                     comp_op_);
                }
            }
            else
            {
                error = FT_Glyph_To_Bitmap(&g, FT_RENDER_MODE_NORMAL, 0, 1);
                if (!error)
                {
                    FT_BitmapGlyph bit = reinterpret_cast<FT_BitmapGlyph>(g);
                    render_halo(&bit->bitmap,
                                format->halo_fill.rgba(),
                                bit->left,
                                height - bit->top,
                                halo_radius,
                                format->text_opacity,
                                comp_op_);
                }
            }
        }
        FT_Done_Glyph(g);
    }

    // render actual text
    for (auto & glyph : glyphs_)
    {
        if (glyph.properties)
        {
            format = glyph.properties;
        }
        FT_Glyph_Transform(glyph.image, 0, &start);
        error = FT_Glyph_To_Bitmap(&glyph.image ,FT_RENDER_MODE_NORMAL,0,1);
        if (!error)
        {
            FT_BitmapGlyph bit = reinterpret_cast<FT_BitmapGlyph>(glyph.image);
            composite_bitmap(pixmap_,
                             &bit->bitmap,
                             format->fill.rgba(),
                             bit->left,
                             height - bit->top,
                             format->text_opacity,
                             comp_op_);
        }
    }
}
开发者ID:FlavioFalcao,项目名称:mapnik,代码行数:88,代码来源:renderer.cpp

示例10: black

void agg_text_renderer<T>::render(glyph_positions const& pos)
{
    prepare_glyphs(pos);
    FT_Error  error;
    FT_Vector start;
    FT_Vector start_halo;
    int height = pixmap_.height();
    pixel_position const& base_point = pos.get_base_point();

    start.x =  static_cast<FT_Pos>(base_point.x * (1 << 6));
    start.y =  static_cast<FT_Pos>((height - base_point.y) * (1 << 6));
    start_halo = start;
    start.x += transform_.tx * 64;
    start.y += transform_.ty * 64;
    start_halo.x += halo_transform_.tx * 64;
    start_halo.y += halo_transform_.ty * 64;

    FT_Matrix halo_matrix;
    halo_matrix.xx = halo_transform_.sx  * 0x10000L;
    halo_matrix.xy = halo_transform_.shx * 0x10000L;
    halo_matrix.yy = halo_transform_.sy  * 0x10000L;
    halo_matrix.yx = halo_transform_.shy * 0x10000L;

    FT_Matrix matrix;
    matrix.xx = transform_.sx  * 0x10000L;
    matrix.xy = transform_.shx * 0x10000L;
    matrix.yy = transform_.sy  * 0x10000L;
    matrix.yx = transform_.shy * 0x10000L;

    // default formatting
    double halo_radius = 0;
    color black(0,0,0);
    unsigned fill = black.rgba();
    unsigned halo_fill = black.rgba();
    double text_opacity = 1.0;
    double halo_opacity = 1.0;

    for (auto const& glyph : glyphs_)
    {
        halo_fill = glyph.properties.halo_fill.rgba();
        halo_opacity = glyph.properties.halo_opacity;
        halo_radius = glyph.properties.halo_radius * scale_factor_;
        // make sure we've got reasonable values.
        if (halo_radius <= 0.0 || halo_radius > 1024.0) continue;
        FT_Glyph g;
        error = FT_Glyph_Copy(glyph.image, &g);
        if (!error)
        {
            FT_Glyph_Transform(g, &halo_matrix, &start_halo);
            if (rasterizer_ == HALO_RASTERIZER_FULL)
            {
                stroker_->init(halo_radius);
                FT_Glyph_Stroke(&g, stroker_->get(), 1);
                error = FT_Glyph_To_Bitmap(&g, FT_RENDER_MODE_NORMAL, 0, 1);
                if (!error)
                {
                    FT_BitmapGlyph bit = reinterpret_cast<FT_BitmapGlyph>(g);
                    if (bit->bitmap.pixel_mode != FT_PIXEL_MODE_BGRA)
                    {
                        composite_bitmap(pixmap_,
                                         &bit->bitmap,
                                         halo_fill,
                                         bit->left,
                                         height - bit->top,
                                         halo_opacity,
                                         halo_comp_op_);
                    }
                }
            }
            else
            {
                error = FT_Glyph_To_Bitmap(&g, FT_RENDER_MODE_NORMAL, 0, 1);
                if (error)
                {
                    continue;
                }
                FT_BitmapGlyph bit = reinterpret_cast<FT_BitmapGlyph>(g);
                if (bit->bitmap.pixel_mode == FT_PIXEL_MODE_BGRA)
                {
                    pixel_position render_pos(base_point);
                    image_rgba8 glyph_image(render_glyph_image(glyph,
                                                               bit->bitmap,
                                                               transform_,
                                                               render_pos));
                    const constexpr std::size_t pixel_size = sizeof(image_rgba8::pixel_type);
                    render_halo<pixel_size>(glyph_image.bytes(),
                                            glyph_image.width(),
                                            glyph_image.height(),
                                            halo_fill,
                                            render_pos.x, render_pos.y,
                                            halo_radius,
                                            halo_opacity,
                                            halo_comp_op_);
                }
                else
                {
                    render_halo<1>(bit->bitmap.buffer,
                                   bit->bitmap.width,
                                   bit->bitmap.rows,
                                   halo_fill,
//.........这里部分代码省略.........
开发者ID:CartoDB,项目名称:mapnik,代码行数:101,代码来源:renderer.cpp


注:本文中的glyph_positions类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。