[twinBASIC] ColorFontLabel - Color emojis, angled text, and more (w/ OCX for VB6/VBA)
ColorFontLabel v1.3
ColorFontLabel is a UserControl/ActiveX Label Control that supports Color Fonts-- fonts that have characters with multiple colors, most commonly used for color emojis that are still copy/paste-able text and not images. Powered with Direct2D/DirectWrite.
Additional features
Font effects (bold, italic, underline, strikethru, condense/expand) can be applied only to a specific range.
Angled text
Color gradients (linear and radial)
Locale can be specified
Several options for word wrap mode
Set line spacing
Antialiasing options
Can act as a drop target for DragDrop from other apps and displays the fancy icons like Explorer.
Mouse events including MouseWheel
Background picture property with stretch or offset options
Normal Label properties like Alignment, RightToLeft, ForeColor/BackColor, etc.
The project is provided as both a UserControl you can use within twinBASIC projects, and as a OCX control tested to work in VB6 and VBA (both 32 and 64bit). ColorFontLabel.twinproj can be used to build the OCX, and ucColorFontLabel.tbcontrol/.twin are the files you'd import to use in a project, with ucColorFontTest.twinproj being a test project for this type.
Requirements
-Color fonts are only supported on Windows 8 and above. The control should work on Windows 7, but emojis etc would be in black and white.
-For building or IDE use of the tbcontrol version, my WinDevLib package, v9.1.566+, is required (References->Available packages). Projects use the new package linking option so it's no longer embedded by default, which means I can once again post it here!
-The latest twinBASIC Beta is recommended, and 828+ is required, to build the OCX or read the test project.
Changelog
v1.3 (07 Jul 2025)
- Bug fix: Font was smaller than regular label with same font/size.
- Bug fix: PictureStretch size wrong when DPI awareness enabled.
v1.2 (07 Jul 2025)
- Added support for Picture property to set a background image. PictureStretch property sets whether it's stretched to fill the label. If not, you can set an x/y offset with PictureOffsetX/Y.
v1.1 (05 Jul 2025)
- Now using quicker/more stable DC render target. Thanks to Wayne Phillips for this contribution. This works better in the IDE and faster at runtime.
(Bug fix) Size/position badly broken when DPI awareness enabled.