网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

AGG第四十一课AGG和GDI渲染字体大小对比

如下是GDI渲染字体的代码:

创新互联专注于企业成都全网营销、网站重做改版、大兴安岭网站定制设计、自适应品牌网站建设、H5高端网站建设电子商务商城网站建设、集团公司官网建设、成都外贸网站制作、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为大兴安岭等各大城市提供网站开发制作服务。

  CClientDC dc(this);

  CPen pen(PS_SOLID,3,RGB(0,255,255)); 

  CPen* pOldPen; 

  pOldPen=dc.SelectObject (&pen); 

  dc.SelectObject (&pOldPen);

  CFont font;

  CFont* pOLdFont = NULL;

  font.CreatePointFont(10,_T("System"),&dc);

  pOLdFont = dc.SelectObject(&font);

  dc.SetBkMode(TRANSPARENT);

  dc.TextOut(1074 - 100, 800 - 293, _T("A"));

  dc.SelectObject(pOLdFont);

  font.DeleteObject();

  font.CreatePointFont(100,_T("System"),&dc);

  pOLdFont = dc.SelectObject(&font);

  dc.SetBkMode(TRANSPARENT);

  dc.TextOut(1074 - 90, 800 - 280, _T("A"));

  dc.SelectObject(pOLdFont);

  font.DeleteObject();

结论:发现字体的高度最小为100,设置其他的最小值,字体没有发生改变。

如下是AGG渲染字体大小的代码:

  void RenderTestByGsv()

  {

    agg::rendering_buffer &rbuf = rbuf_window();

    agg::pixfmt_bgr24 pixf(rbuf);

    typedef agg::renderer_base renderer_base_type;

    renderer_base_type renb(pixf);

    typedef agg::renderer_scanline_aa_solid renderder_scanline_type;

    renderder_scanline_type rensl(renb);

    agg::rasterizer_scanline_aa<> ras;

    agg::scanline_u8 sl;

    ras.reset();

    agg::gsv_text text;

    text.text("123ABC");

    text.size(10, 8);

    text.flip(true);

    text.start_point(150,150);

    agg::trans_affine mtx;

    mtx.reset();

    agg::gsv_text_outline text_p(text, mtx);

    text_p.width(1.0);

    rensl.color(agg::rgba(0.0, 0.0, 0.0));

    ras.add_path(text_p, 0);

    agg::render_scanlines_aa_solid(ras,sl,renb,agg::rgba8(255,0,0));

  }

邮件原文:

This is going to come off as a smart-ass reply, and I don't intend it to be.

If agg doesn't work well with small fonts, why not just use GDI in those

cases?  Its easy to have a single buffer that can be operated on by both agg

and gdi.

if (font_height < 10)

{

   renderWithGdi()

}

else

{

   renderWithAgg()

}

Since I am bothering everybody today, I am wondering about rendering small

true type fonts.

When the font height gets below 10 or so, Windows draws the font with

vectors.  This keeps the characters readable as the font gets smaller.

With AGG I'm using outlines, and that tends to "smoosh" the characters

together.

I've set the contour width to 0.01, and even 0.0, but when the fonts get

small, the characters Become unreadable.  More so, when displaying Kanji.

What I'd like to do is to figure out a way to force the glyphs to be drawn

as vector's (like GDI).

I want to keep using glyph_ren_outline, as I can rotate and scale the

results nicely.

Any Ideas?

Here is a simple version of code that I use (I removed extra stuff):

//

//  feng is create before as font_engine_win32_tt_int32 // typedef

agg::conv_contour >

contour_type; typedef agg::conv_curve

curve_type;

typedef agg::font_cache_manager

font_manager_type;

font_manager_type       fman(feng);

curve_type               curves(fman.path_adaptor());

contour_type                        contour(curves);

//

//Draw Text Routine

//

agg::rasterizer_scanline_aa<>       ras;

agg::scanline_u8                    sl;

agg::glyph_rendering                gren = agg::glyph_ren_outline;

agg::path_storage                   path;

agg::conv_stroke conv(path);

agg::trans_affine mtx;

mtx *= agg::trans_affine_translation(-x, -y); mtx *=

agg::trans_affine_rotation(-1.0 * rotation ); mtx *=

agg::trans_affine_translation(x, y);

feng.char_set( SHIFTJIS_CHARSET );

if(m_feng.create_font( "MS GOTHIC", gren ))

    {

    feng.weight( 100 ); // FW_LIGHT == 300

    contour.width( 0.01 );

    font_trans_type ftrans( contour, mtx );

    const char              *pp = pString;

    const agg::glyph_cache  *glyph;

    while(*pp)

        {

        if(isJIS(pp))   // Check for Multibtye Japanese String

            {

            WCHAR   ws[2];

         MultiByteToWideChar( 932, 0, pp, 2, ws, sizeof(ws));

            glyph = pT->m_fman.glyph(ws[0]);

            ++pp;// Multi byte

            }

        else

            {

            glyph = pT->m_fman.glyph(*pp);

            }

        pp++;

        if(glyph)

            {

            ras.reset();

            ras.add_path(ftrans);

            fman.add_kerning(&x, &y);

            agg::render_scanlines(ras, sl, ren_aa);

            x += glyph->advance_x;

            y += glyph->advance_y;

            }

        }

    }


分享题目:AGG第四十一课AGG和GDI渲染字体大小对比
本文链接:http://bjjierui.cn/article/jidsei.html

其他资讯