|
GtkWidget* normal_drawing_area = gtk_drawing_area_new();
g_signal_connect(G_OBJECT(normal_drawing_area), "expose-event", G_CALLBACK(BigPaint), BR);
void BigPaint(GtkWidget *w, GdkEventExpose *evt,_BookReader *BR)
{
cairo_t *cr;
cr = gdk_cairo_create(w->window);
cairo_set_source_rgb(cr, 1, 1, 1);
cairo_paint(cr);
if(RF==1)//旋转90度
{
cairo_rotate(cr, M_PI/2.0);
}
else// 不旋转
{
}
cairo_select_font_face(cr, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_source_rgb(cr, 0, 0, 0);
cairo_set_font_size(cr,BR->font_size);
int iline=1;
for(iline=1;iline<=Filux_GetCurPageLineCount();++iline)
{
if(1==RF) //旋转90度
{
cairo_move_to(cr, 0, -(evt->area.width)+BR->font_size*iline);
cairo_show_text(cr, PageCon[iline-1]);
}
else // 不旋转
{
cairo_move_to(cr, 0, BR->font_size*iline);
cairo_show_text(cr, PageCon[iline-1]);
cairo_text_extents(cr,PageCon[iline-1],StringRect);
printf("\n\n PageCon[iline-1] %s \n",PageCon[iline-1]);
printf("StringRect->x_bearing , %d StringRect->y_bearing StringRect->width %d ,StringRect->height %d ,StringRect->x_advance %d ,StringRect->y_advance %d",StringRect->x_bearing , StringRect->y_bearing,StringRect->width,StringRect->height,StringRect->x_advance,StringRect->y_advance);
}
}
在屏幕上能正常显示,但是需要知道每个字在屏幕上的位置,
而cairo_text_extents获得的字体宽/高均为之 0. |
|