Draw Chinese Font problom

View: New views
1 Messages — Rating Filter:   Alert me  

Draw Chinese Font problom

by kane_zzt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,all I think use Agg draw truetype chinese font,But Agg output chinese is bedlam character. Who can tell me why not draw? and tell me how to.Thx! my code is following: if(m_feng.create_font("黑体", agg::glyph_ren_agg_mono)) { m_fman.precache(' ', 127); double x = 10.0; double y0 = 10.0; double y = y0; const char_type* p = "中文字符"; while(*p) { const agg::glyph_cache* glyph = m_fman.glyph(*p); if(glyph) { if(m_kerning.status()) { m_fman.add_kerning(&x, &y); } if(x >= width() - m_height.value()) { x = 10.0; y0 -= m_height.value(); if(y0 <= 120) break; y = y0; } m_fman.init_embedded_adaptors(glyph, x, y); switch(glyph->data_type) { case agg::glyph_data_mono: ren_bin.color(agg::rgba8(0, 0, 0)); agg::render_scanlines(m_fman.mono_adaptor(), m_fman.mono_scanline(), ren_bin); break; case agg::glyph_data_gray8: ren_solid.color(agg::rgba8(0, 0, 0)); agg::render_scanlines(m_fman.gray8_adaptor(), m_fman.gray8_scanline(), ren_solid); break; case agg::glyph_data_outline: ras.reset(); if(fabs(m_weight.value()) <= 0.01) { // For the sake of efficiency skip the // contour converter if the weight is about zero. //----------------------- ras.add_path(m_curves); } else { ras.add_path(m_contour); } ren_solid.color(agg::rgba8(0, 0, 0)); agg::render_scanlines(ras, sl, ren_solid); break; } // increment pen position x += glyph->advance_x; y += glyph->advance_y; ++num_glyphs; } ++p; } } The program resulte picture: