Buscar

Calculo em pixel dos caracteres em fonte arial tamanho 8

Código

//Funcão retorna a quantidade  em pixels para fonte arial tamanho 8
//este calculo pode mudar de acordo com a fonte usada e o tamanho

function tampxl(str:string):integer;
const
  pxl2  = 'ijl| '+chr(39);
  pxl3  = 'Ifrt!¨&()-[´`]:;.,³²¹';
  pxl4  = '*{}ªº°';
  pxl5  = 'Jsyxz"/';
  pxl6  = 'abcdeghknopquFL1234567890$_+=§^?<>¬¢£';
  pxl7  = 'ABCEKPSTVYXZ~#';
  pxl8  = 'mwDGHNOQRU%';
  pxl9  = 'M';
  pxl11 = '@W';
var
tam,i : integer;
begin
  tam := 0;
  for i := 1 to length(str) do
    begin
      if Pos(str[i],pxl2) > 0 Then
        begin
          tam                  := tam + 2;
        end;
      if Pos(str[i],pxl3) > 0 Then
        begin
          tam                  := tam + 3;
        end;
      if Pos(str[i],pxl4) > 0 Then
        begin
          tam                  := tam + 4;
        end;
      if Pos(str[i],pxl5) > 0 Then
        begin
          tam                  := tam + 5;
        end;
      if Pos(str[i],pxl6) > 0 Then
        begin
          tam                  := tam + 6;
        end;
      if Pos(str[i],pxl7) > 0 Then
        begin
          tam                  := tam + 7;
        end;
      if Pos(str[i],pxl8) > 0 Then
        begin
          tam                  := tam + 8;
        end;
      if Pos(str[i],pxl9) > 0 Then
        begin
          tam                  := tam + 9;
        end;
      if Pos(str[i],pxl11) > 0 Then
        begin
          tam                  := tam + 11;
        end;
    end;
  result                          := tam;
end;

Publicidade

Vote na dica




Quantidade de votos: 0 votos
Aceitação: 0%


Detalhes da dica

Categoria: Object pascal
Adicionada dia: 16/05/07
Por: Wandy Luciano
Visualizada: 6294 vezes

Planeta Delphi - Tudo sobre programação Delphi Planeta Delphi - www.planetadelphi.com.br - Todos os direitos reservados | Copyright 2001-2009