procedure TGtkDeviceContext.DrawTextWithColors(AText: PChar; ALength: LongInt;
X, Y: Integer; FGColor, BGColor: PGdkColor);
var
WidgetCont: PPangoContext;
NewMatrix: TPangoMatrix;
OldMatrix: PPangoMatrix;
renderer: PGdkPangoRenderer;
Direction : TPangoDirection;
AFont: PGdiObject;
procedure SetColors(AFGColor, ABGColor: PGdkColor); inline;
begin
gdk_pango_renderer_set_override_color(renderer, PANGO_RENDER_PART_FOREGROUND, AFGColor);
gdk_pango_renderer_set_override_color(renderer, PANGO_RENDER_PART_UNDERLINE, AFGColor);
gdk_pango_renderer_set_override_color(renderer, PANGO_RENDER_PART_STRIKETHROUGH, AFGColor);
gdk_pango_renderer_set_override_color(renderer, PANGO_RENDER_PART_BACKGROUND, ABGColor);
end;
begin
AFont := GetFont;
SetLayoutText(AFont^.GDIFontObject, AText, ALength);
WidgetCont := pango_layout_get_context(AFont^.GDIFontObject);
Direction := pango_find_base_dir(AText, ALength);
pango_context_set_base_dir(WidgetCont, Direction);
if AFont^.LogFont.lfEscapement <> 0 then
begin
if Widget <> nil then
renderer := gdk_pango_renderer_get_default(gtk_widget_get_screen(Widget))
else
renderer := gdk_pango_renderer_get_default(gdk_screen_get_default);
RemovePixbuf;
gdk_pango_renderer_set_drawable(renderer, drawable);
gdk_pango_renderer_set_gc(renderer, GC);
SetColors(FGColor, BGColor);
OldMatrix := pango_context_get_matrix(WidgetCont);
NewMatrix.xx := 1.0;
NewMatrix.xy := 0.0;
NewMatrix.yx := 0.0;
NewMatrix.yy := 1.0;
NewMatrix.x0 := 0.0;
NewMatrix.y0 := 0.0;
pango_matrix_translate(@NewMatrix, X, Y);
pango_matrix_rotate(@NewMatrix, AFont^.LogFont.lfEscapement / 10);
pango_context_set_matrix(WidgetCont, @NewMatrix);
pango_layout_context_changed(AFont^.GDIFontObject);
pango_renderer_draw_layout(PPangoRenderer(renderer), AFont^.GDIFontObject, X, Y);
//now reset
pango_context_set_matrix(WidgetCont, OldMatrix);
pango_layout_context_changed(AFont^.GDIFontObject);
SetColors(nil, nil);
gdk_pango_renderer_set_drawable(renderer, nil);
gdk_pango_renderer_set_gc(renderer, nil);
end
else
gdk_draw_layout_with_colors(drawable, GC, X, Y, AFont^.GDIFontObject, FGColor, BGColor);
end;