Ver Mensaje Individual
  #2  
Antiguo 17-02-2022
Esteban74 Esteban74 is offline
Miembro
 
Registrado: jun 2020
Posts: 12
Reputación: 0
Esteban74 Va por buen camino
Bueno con la idea de que un TLayout al tener una propiedad parent podría llegar a heredar los atributos de fuente (que es donde fallaba el código al intentar asignarles un valor) podría funcionar, y funcionó anda en Windows y Android, no estoy seguro bien por que pero cito la solucion al problema, por si a alguien le pasó.

Código Delphi [-]
function Tfrm_Hoy.calcularAnchoString(AText: string): Single;
var
  unLayout: TLayout;
  ancho: Single;

begin
  unLayout := TLayout.Create(frmPrincipal);
  unLayout.Parent := frmPrincipal;
  Memo1.Lines.Add('paso: bmp := TBitmap.Create; ');
  try
    unLayout.Canvas.Font.Style := [];
    unLayout.Canvas.Font.Family := frmPrincipal.configuracion.Family;
    unLayout.Canvas.Font.Size := frmPrincipal.configuracion.tam_fuente;
    ancho := unLayout.Canvas.TextWidth(AText);
    Result := ancho;
  finally
    unLayout.Free;
  end;
end;
Responder Con Cita