MCPcopy Create free account
hub / github.com/MapServer/MapServer / agg2RenderGlyphs

Function agg2RenderGlyphs

mapagg.cpp:278–349  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

276}
277
278int agg2RenderGlyphs(imageObj *img, double x, double y, labelStyleObj *style, char *text) {
279 AGG2Renderer *r = AGG_RENDERER(img);
280 aggRendererCache *cache = (aggRendererCache*)MS_RENDERER_CACHE(MS_IMAGE_RENDERER(img));
281 if (!cache->m_feng.load_font(style->font, 0, mapserver::glyph_ren_outline)) {
282 msSetError(MS_TTFERR, "AGG error loading font (%s)", "agg2RenderGlyphs()", style->font);
283 return MS_FAILURE;
284 }
285 r->m_rasterizer_aa.filling_rule(mapserver::fill_non_zero);
286
287 const mapserver::glyph_cache* glyph;
288 int unicode;
289 //cache->m_feng.hinting(true);
290 cache->m_feng.height(style->size);
291 cache->m_feng.resolution(96);
292 cache->m_feng.flip_y(true);
293 font_curve_type m_curves(cache->m_fman.path_adaptor());
294 mapserver::trans_affine mtx;
295 mtx *= mapserver::trans_affine_translation(-x, -y);
296 /*agg angles are antitrigonometric*/
297 mtx *= mapserver::trans_affine_rotation(-style->rotation);
298 mtx *= mapserver::trans_affine_translation(x, y);
299
300 double fx = x, fy = y;
301 const char *utfptr = text;
302 mapserver::path_storage glyphs;
303
304 //first render all the glyphs to a path
305 while (*utfptr) {
306 if (*utfptr == '\r') {
307 fx = x;
308 utfptr++;
309 continue;
310 }
311 if (*utfptr == '\n') {
312 fx = x;
313 fy += ceil(style->size * AGG_LINESPACE);
314 utfptr++;
315 continue;
316 }
317 utfptr += msUTF8ToUniChar(utfptr, &unicode);
318 glyph = cache->m_fman.glyph(unicode);
319 ;
320 if (glyph) {
321 //cache->m_fman.add_kerning(&fx, &fy);
322 cache->m_fman.init_embedded_adaptors(glyph, fx, fy);
323 mapserver::conv_transform<font_curve_type, mapserver::trans_affine> trans_c(m_curves, mtx);
324 glyphs.concat_path(trans_c);
325 fx += glyph->advance_x;
326 fy += glyph->advance_y;
327 }
328 }
329
330 if (style->outlinewidth) {
331 r->m_rasterizer_aa.reset();
332 r->m_rasterizer_aa.filling_rule(mapserver::fill_non_zero);
333 mapserver::conv_contour<mapserver::path_storage> cc(glyphs);
334 cc.width(style->outlinewidth + 1);
335 r->m_rasterizer_aa.add_path(cc);

Callers

nothing calls this directly

Calls 15

msSetErrorFunction · 0.85
msUTF8ToUniCharFunction · 0.85
render_scanlinesFunction · 0.85
glyphMethod · 0.80
concat_pathMethod · 0.80
load_fontMethod · 0.45
filling_ruleMethod · 0.45
heightMethod · 0.45
resolutionMethod · 0.45

Tested by

no test coverage detected