LCL-GTK2: Fix rect calculation and GetTextMetrics. Prevent painting cropped chars 'jy'. Issue #38268, patch from Anton Kavalenka.

git-svn-id: trunk@65056 -
This commit is contained in:
juha 2021-04-23 15:34:08 +00:00
parent 25a1c56fc2
commit ef7d930ca6
3 changed files with 6 additions and 3 deletions

View File

@ -875,7 +875,7 @@ function TGtkDeviceContext.CreateGC: PGdkGC;
begin
// create GC
if Drawable <> nil then
if (Drawable <> nil) and (Drawable^.parent_instance.ref_count>0) then
begin
if FWithChildWindows then
begin

View File

@ -5947,8 +5947,9 @@ begin
TextMetric.tmAveCharWidth := Max(1,
pango_font_metrics_get_approximate_char_width(APangoMetrics)
div PANGO_SCALE);
TextMetric.tmAscent := pango_font_metrics_get_ascent(APangoMetrics) div PANGO_SCALE;
TextMetric.tmDescent := pango_font_metrics_get_descent(APangoMetrics) div PANGO_SCALE;
TextMetric.tmAscent := PANGO_PIXELS(pango_font_metrics_get_ascent(APangoMetrics));
TextMetric.tmDescent := PANGO_PIXELS(pango_font_metrics_get_descent(APangoMetrics));
TextMetric.tmHeight := TextMetric.tmAscent+TextMetric.tmDescent;
pango_layout_set_text(UseFont, PChar(TestString[IsDoubleByteChar]),

View File

@ -2483,6 +2483,7 @@ var
else
begin
theRect.Right := theRect.Left + Min(MaxWidth, AP.cX);
theRect.Bottom := theRect.Top + AP.cY;
if (Flags and DT_VCENTER) > 0 then
begin
OffsetRect(theRect, 0, ((Rect.Bottom - Rect.Top) - (theRect.Bottom - theRect.Top)) div 2);
@ -2492,6 +2493,7 @@ var
begin
OffsetRect(theRect, 0, (Rect.Bottom - Rect.Top) - (theRect.Bottom - theRect.Top));
end;
end;
end
else