我寫使用開羅,我需要從屏幕上改變座標使用下面的代碼爲笛卡爾程序繪製文本時:黑底白字開羅
cairo_translate(cr, x, height);
cairo_scale(cr, 1.0, -1.0); // FLIP the Y axis
但是,當我嘗試呈現文本(cairo_show_text) ,文本也被翻轉,因此不可讀。
cairo_font_options_t *font_options;
cairo_matrix_t ctm, font_matrix;
cairo_scaled_font_t *scaled_font;
font_options = cairo_font_options_create();
cairo_get_matrix(cr, &ctm);
cairo_get_font_matrix(cr, &font_matrix);
font_matrix.xx = font_matrix.yy = 20.0; // font size
// font_face initialized elsewhere and is valid
scaled_font = cairo_scaled_font_create(font_face, &font_matrix, &ctm, font_options);
cairo_set_scaled_font(cr, scaled_font);
cairo_move_to(cr, 1, 50);
cairo_show_text(cr, "some text");
...
我覺得矩陣需要一些調整,但我不知道如何:使用縮放字體(cairo_scaled_font_t)時
同樣的情況。任何幫助表示讚賞。提前致謝。
編輯:
的文字是上下顛倒。例如,'L'看起來像一個Gamma,'W'看起來像一個'M'。
通過倒置,你的意思是沿着X軸還是Y軸? – 2013-03-27 16:10:19
或者你的意思是顏色倒置? – 2013-03-27 16:17:27
我認爲他的意思是顛倒,因爲有一個-1的Y比例。 – unwind 2013-03-27 16:17:55