void MapPainterAgg::SetOutlineFont(const Projection& projection, const MapParameter& parameter, double size) { if (!fontEngine->load_font(parameter.GetFontName().c_str(), 0, agg::glyph_ren_outline)) { std::cout << "Cannot load font '" << parameter.GetFontName() << "'" << std::endl; return; } //fontEngine->resolution(72); fontEngine->width(size*projection.ConvertWidthToPixel(parameter.GetFontSize())); fontEngine->height(size*projection.ConvertWidthToPixel(parameter.GetFontSize())); fontEngine->hinting(true); fontEngine->flip_y(true); }
void MapPainterSVG::DrawLabel(const Projection& projection, const MapParameter& parameter, const LabelData& label) { if (dynamic_cast<const TextStyle*>(label.style.get())!=NULL) { const TextStyle* style=dynamic_cast<const TextStyle*>(label.style.get()); #if defined(OSMSCOUT_MAP_SVG_HAVE_LIB_PANGO) PangoFontDescription* font=GetFont(projection, parameter, label.fontSize); #endif // TODO: This is not the exact placement, we cannot just move vertical by fontSize, but we must move the actual // text height. For this we need the text bounding box in LabelData. stream << " <text"; stream << " x=\"" << label.x << "\""; stream << " y=\"" << label.y+projection.ConvertWidthToPixel(label.fontSize*parameter.GetFontSize()) << "\""; stream << " font-family=\"" << parameter.GetFontName() << "\""; stream << " font-size=\"" << projection.ConvertWidthToPixel(label.fontSize*parameter.GetFontSize()) << "\""; stream << " fill=\"" << GetColorValue(style->GetTextColor()) << "\""; if (label.alpha!=1.0) { stream << " fill-opacity=\"" << label.alpha << "\""; } stream << ">"; stream << label.text; stream << "</text>" << std::endl; /* stream << "<rect x=\"" << label.bx1 << "\"" << " y=\"" << label.by1 << "\"" <<" width=\"" << label.bx2-label.bx1 << "\"" << " height=\"" << label.by2-label.by1 << "\"" << " fill=\"none\" stroke=\"blue\"/>" << std::endl;*/ } else if (dynamic_cast<const ShieldStyle*>(label.style.get())!=NULL) { const ShieldStyle* style=dynamic_cast<const ShieldStyle*>(label.style.get()); #if defined(OSMSCOUT_MAP_SVG_HAVE_LIB_PANGO) PangoFontDescription* font=GetFont(projection, parameter, label.fontSize); #endif // Shield background stream << " <rect"; stream << " x=\"" << label.bx1 << "\""; stream << " y=\"" << label.by1 << "\""; stream << " width=\"" << label.bx2-label.bx1+1 << "\""; stream << " height=\"" << label.by2-label.by1+1 << "\""; stream << " fill=\"" << GetColorValue(style->GetBgColor()) << "\""; stream << " stroke=\"none\""; stream << "/>" << std::endl; // Shield inner border stream << " <rect"; stream << " x=\"" << label.bx1+2 << "\""; stream << " y=\"" << label.by1+2 << "\""; stream << " width=\"" << label.bx2-label.bx1+1-4 << "\""; stream << " height=\"" << label.by2-label.by1+1-4 << "\""; stream << " fill=\"none\""; stream << " stroke=\"" << GetColorValue(style->GetBorderColor()) << "\""; stream << " stroke-width=\"1\""; stream << "/>" << std::endl; // TODO: This is not the exact placement, we cannot just move vertical by fontSize, but we must move the actual // text height. For this we need the text bounding box in LabelData. stream << " <text"; stream << " x=\"" << label.x << "\""; stream << " y=\"" << label.y+projection.ConvertWidthToPixel(label.fontSize*parameter.GetFontSize()) << "\""; stream << " font-family=\"" << parameter.GetFontName() << "\""; stream << " font-size=\"" << projection.ConvertWidthToPixel(label.fontSize*parameter.GetFontSize()) << "\""; stream << " fill=\"" << GetColorValue(style->GetTextColor()) << "\""; if (label.alpha!=1.0) { stream << " fill-opacity=\"" << label.alpha << "\""; } stream << ">"; stream << label.text; stream << "</text>" << std::endl; } }