Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

AGG lesson 41 comparison of font sizes between AGG and GDI rendering

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

The following is the code for GDI to render the font:

CClientDC dc (this)

CPen pen (PS_SOLID,3,RGB (0255255))

CPen* pOldPen

POldPen=dc.SelectObject & pen)

Dc.SelectObject & pOldPen)

CFont font

CFont* pOLdFont = NULL

Font.CreatePointFont (10 "System"), & dc)

POLdFont = dc.SelectObject (& font)

Dc.SetBkMode (TRANSPARENT)

Dc.TextOut (1074-100800-293, _ T ("A"))

Dc.SelectObject (pOLdFont)

Font.DeleteObject ()

Font.CreatePointFont (100 font.CreatePointFont ("System") & dc)

POLdFont = dc.SelectObject (& font)

Dc.SetBkMode (TRANSPARENT)

Dc.TextOut (1074-90,800-280, _ T ("A"))

Dc.SelectObject (pOLdFont)

Font.DeleteObject ()

Conclusion: it is found that the minimum height of the font is 100, set the other minimum value, the font has not changed.

Here is the code for AGG to render the font size:

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 (150150)

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 (255j0pl 0))

}

Original email text:

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

}

}

}

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report