Skip to main content
added 483 characters in body
Source Link
Deltics
  • 23.1k
  • 3
  • 46
  • 76

Using the standard label control your only option is to use two such controls, one with Font.Style including fsBold, the other not.

Place your first, bold label then as long as you leave/set the AutoSize property true, the Width property will tell you the width:

// Where: // // - boldLabel is a created, initialised and positioned // label with bold text // // - normalLabel is a created and initialised label which // has not yet been positioned (horizontally) // // - spacingPixels is the distance you wish to maintain // between the two normalLabel.Position.X := boldLabel.Position.X + boldLabel.Width + spacingPixels; 

Alternatively, thereThere are a number of 3rd party label controls, many of them free + open source (for VCL [see below]), which support varying degrees of markup in a label, including one in. There may be similar implementations for FMX.

For VCL projects you might want to check out the JediVCL library which supportsincludes a label supporting not just bold but other, albeit limited HTML markup.

The If this is of interest, the control you are looking for in that library is TJvHTLabel.

NB. For future ref: You don't specify whether your project is FMX or VCL but it appears from the use of the Position property that it is likely to be FMX. For issues involving controls, the framework in use can be a significant factor and should be mentioned to avoid eliciting answers that may not be relevant.

Using the standard label control your only option is to use two such controls, one with Font.Style including fsBold, the other not.

Place your first, bold label then as long as you leave/set the AutoSize property true, the Width property will tell you the width:

// Where: // // - boldLabel is a created, initialised and positioned // label with bold text // // - normalLabel is a created and initialised label which // has not yet been positioned (horizontally) // // - spacingPixels is the distance you wish to maintain // between the two normalLabel.Position.X := boldLabel.Position.X + boldLabel.Width + spacingPixels; 

Alternatively, there are a number of 3rd party label controls which support varying degrees of markup in a label, including one in the JediVCL library which supports not just bold but other, albeit limited HTML markup.

The control you are looking for in that library is TJvHTLabel.

Using the standard label control your only option is to use two such controls, one with Font.Style including fsBold, the other not.

Place your first, bold label then as long as you leave/set the AutoSize property true, the Width property will tell you the width:

// Where: // // - boldLabel is a created, initialised and positioned // label with bold text // // - normalLabel is a created and initialised label which // has not yet been positioned (horizontally) // // - spacingPixels is the distance you wish to maintain // between the two normalLabel.Position.X := boldLabel.Position.X + boldLabel.Width + spacingPixels; 

There are a number of 3rd party label controls, many of them free + open source (for VCL [see below]), which support varying degrees of markup in a label. There may be similar implementations for FMX.

For VCL projects you might want to check out the JediVCL library which includes a label supporting not just bold but other, albeit limited HTML markup. If this is of interest, the control you are looking for in that library is TJvHTLabel.

NB. For future ref: You don't specify whether your project is FMX or VCL but it appears from the use of the Position property that it is likely to be FMX. For issues involving controls, the framework in use can be a significant factor and should be mentioned to avoid eliciting answers that may not be relevant.

Source Link
Deltics
  • 23.1k
  • 3
  • 46
  • 76

Using the standard label control your only option is to use two such controls, one with Font.Style including fsBold, the other not.

Place your first, bold label then as long as you leave/set the AutoSize property true, the Width property will tell you the width:

// Where: // // - boldLabel is a created, initialised and positioned // label with bold text // // - normalLabel is a created and initialised label which // has not yet been positioned (horizontally) // // - spacingPixels is the distance you wish to maintain // between the two normalLabel.Position.X := boldLabel.Position.X + boldLabel.Width + spacingPixels; 

Alternatively, there are a number of 3rd party label controls which support varying degrees of markup in a label, including one in the JediVCL library which supports not just bold but other, albeit limited HTML markup.

The control you are looking for in that library is TJvHTLabel.