Determine the font size / determinar el tamaño de la fuente - Forum

Forum Navigation
You need to log in to create posts and topics.

Determine the font size / determinar el tamaño de la fuente

Hello everyone,

I am trying to solve the following problem:

Knowing the size of the text object (Label) and a text to display, how can I automatically determine which is the most appropriate font size to fill the width of the object?

I read all the ideas....
infinite thanks,
David de Argentina

 

 

 

 

 

Hola a todos,

Estoy tratando de resolver el siguiente problema:

Sabiendo el tamaño del objeto texto (Label) y un texto a desplegar, cómo puedo determinar automaticamente, cual es tamaño de la fuente (font) mas apropiado para completar el ancho del objeto?

Leo todas las ideas....
Infinitas gracias,
David de Argentina

The truth is that it is a good question... I subscribe.

-----------------------------------------------------------------

La verdad es que es una buena pregunta... me suscribo.

Place objects on the form:
CheckBox1
Text1
PushButton

In CheckBox1 the title [Text]
In Text1 the header [Text]

In PushButton the code

InputBox "Enter text" "" "[Text]"
GetObjectInfo "CheckBox1" "Width" "[WidthCheckBox]"
GetObjectInfo "Text1" "Width" "[WidthLabel]"
GetObjectInfo "CheckBox1" "FontSize" "[FontSize]"
If "[WidthCheckBox]-16" ">" "[WidthLabel]"
While "[WidthCheckBox]-16" ">" "[WidthLabel]"
  SetVar "[FontSize]" "[FontSize]-1"
  SetObjectFont "CheckBox1" "Black" "Arial Narrow" "[FontSize]" "Normal" "ANSI_CHARSET"
  GetObjectInfo "CheckBox1" "Width" "[WidthCheckBox]"
EndWhile
SetObjectFont "Text1" "Black" "Arial Narrow" "[FontSize]" "Normal" "ANSI_CHARSET"
EndIf

I think you get the point. The code will need to be edited, that if the text is shorter then to increase the font. If that's what it takes.

CN_Iceman has reacted to this post.
CN_Iceman