I want to create a string of characters from different fonts to be printed into a suitable gadget (preferable a TextGadget, but if that's not possible any other gadget for presenting text in a window is acceptable). For instance, one character from the font Courier followed by a character from the Symbol font, followed by a character from the Courier again.
How should that be done?
Combining characters from different fonts
- Kaeru Gaman
- Addict

- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
I would guess that no font information is stored for individual characters in a string or text gadget, just what font to use with the gadget as a whole so it wouldn't be possible to have different fonts in one.
That's my guess anyway, so as Kaeru said, perhaps use a webgadget or a graphical approach.
That's my guess anyway, so as Kaeru said, perhaps use a webgadget or a graphical approach.
Here's a way to do it, but whether it shows as I intended will depend on the fonts available on your PC.
Create the embellished text in WordPad (not Word as it is too verbose), Save As an RTF file, reopen it in Notepad and copy-and-paste the RTF codes.
Code: Select all
Enumeration
#winMain
#edtTest
EndEnumeration
gap = 20: winw = 400: winh = 150
edtw = winw-gap*2: edth = winh-gap*2
flags = #PB_Window_SystemMenu|#PB_Window_ScreenCentered
OpenWindow(#winMain, 0, 0, winw, winh, "Test", flags)
CreateGadgetList(WindowID(#winMain))
EditorGadget(#edtTest, gap, gap, edtw, edth)
text$ = "{\rtf1\ansi\ansicpg1252\deff0\deflang2057{\fonttbl{\f0\fnil\fcharset0 Times New Roman;}{\f1\fdecor\fprq2\fcharset0 AlphabetSoup Tilt BT;}{\f2\fscript\fprq2\fcharset0 Annie BTN;}{\f3\froman\fprq2\fcharset0 Book Antiqua;}{\f4\fswiss\fprq2\fcharset0 System;}}"
text$ + "{\colortbl ;\red255\green0\blue0;\red0\green255\blue0;}"
text$ + "\viewkind4\uc1\pard\f0\fs28\par "
text$ + " The \f1 cat \fs44 sat \f2\fs36 on \cf1\ul\f3 the\cf0\ulnone \cf2\f4 mat\f0\fs20\par}"
SetGadgetText(#edtTest, text$)
Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow
EndAnthony Jordan
ANSI encoding
Thanks for the example
Is ANSI-encoding only available in the EditorGadget, or?
If so, then is it possible to "lock" the text so that it's NOT editable? (as I only want to present text).
Is ANSI-encoding only available in the EditorGadget, or?
If so, then is it possible to "lock" the text so that it's NOT editable? (as I only want to present text).

