[cairo] Pango font thickness
- From: Edder <edder tkwsping nl>
- To: gtk-i18n-list gnome org
- Subject: [cairo] Pango font thickness
- Date: Sat, 6 Feb 2010 14:20:38 +0100
Hi all,
I am trying to make a simple plotting library using cairomm and
pangomm. Currently I have problems with the fonts though. Using
pangomm I always get very thick fonts, while I want thin fonts. I
tried playing around with font weight etc, but this only has minimal
effect. I also played around with different fonts, but they all have
the same problem. Anyone any tips?
Cheers, Edwin
Example code:
#include <string>
#include <cairomm/context.h>
#include <cairomm/surface.h>
#include <pangomm/init.h>
#include <pangomm/context.h>
#include <pangomm/layout.h>
int main()
{
Cairo::RefPtr<Cairo::ImageSurface> surface =
Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, 600, 400);
Cairo::RefPtr<Cairo::Context> cr = Cairo::Context::create(surface);
cr->set_source_rgb(0.86, 0.85, 0.47);
cr->paint(); // fill image with the color
Pango::init();
Glib::RefPtr<Pango::Layout> pangoLayout = Pango::Layout::create (cr);
Pango::FontDescription pango_font = Pango::FontDescription("verdana 10");
pango_font.set_weight( Pango::WEIGHT_ULTRALIGHT );
pangoLayout->set_font_description( pango_font );
cr->move_to(300,200);
cr->set_source_rgb(0, 0, 0);
pangoLayout->set_text("text");
//pangoLayout->update_from_cairo_context(cr); //gets cairo cursor position
pangoLayout->add_to_cairo_context(cr); //adds text to cairos
stack of stuff to be drawn
cr->stroke();
std::string filename = "image.png";
surface->write_to_png(filename);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]