anchor.diff:  end;
   
   function TfpgFontResourceImpl.GetTextWidth(const txt: string): integer;
  -var
  -  extents: TXGlyphInfo;
   begin
     if length(txt) < 1 then
     begin
       Result := 0;
       Exit;
     end;
  -  XftTextExtentsUTF8(xapplication.display, FFontData, PChar(txt), Length(txt), extents);
  -  Result := extents.xOff;
  +  // Xft uses smallint to return text extent information, so we have to
  +  // check if the text width is small enough to fit into smallint range
  +  if DoGetTextWidthClassic('W') * Length(txt) < High(smallint) then
  +    Result := DoGetTextWidthClassic(txt)
  +  else
  +    Result := DoGetTextWidthWorkaround(txt);
   end;
   
   { TfpgCanvasImpl }
  
positive.code:   gui_form,
    cursorfont,
    gfx_popupwindow,
    xatom,      // used for XA_WM_NAME
    gfx_utf8utils;
  
  var
    xapplication: TfpgApplication;
  
negative.code:   TfpgWindowImpl = class;
    
  
    { TfpgFontResourceImpl }
  
    TfpgFontResourceImpl = class(TfpgFontResourceBase)
    private
      FFontData: PXftFont;
      function    DoGetTextWidthClassic(const txt: string): integer;
      function    DoGetTextWidthWorkaround(const txt: string): integer;
    protected
      property    Handle: PXftFont read FFontData;
    public
  