如下是GDI渲染字體的代碼:
創(chuàng)新互聯(lián)長期為超過千家客戶提供的網(wǎng)站建設(shè)服務(wù),團(tuán)隊(duì)從業(yè)經(jīng)驗(yàn)10年,關(guān)注不同地域、不同群體,并針對不同對象提供差異化的產(chǎn)品和服務(wù);打造開放共贏平臺,與合作伙伴共同營造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為肇州企業(yè)提供專業(yè)的做網(wǎng)站、網(wǎng)站制作,肇州網(wǎng)站改版等技術(shù)服務(wù)。擁有十年豐富建站經(jīng)驗(yàn)和眾多成功案例,為您定制開發(fā)。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();
結(jié)論:發(fā)現(xiàn)字體的高度最小為100,設(shè)置其他的最小值,字體沒有發(fā)生改變。
如下是AGG渲染字體大小的代碼:
void RenderTestByGsv()
{
agg::rendering_buffer &rbuf = rbuf_window();
agg::pixfmt_bgr24 pixf(rbuf);
typedef agg::renderer_base
renderer_base_type renb(pixf);
typedef agg::renderer_scanline_aa_solid
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.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
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;
}
}
}
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。