Page 1 of 1
Combining characters from different fonts
Posted: Sat Apr 05, 2008 8:17 pm
by Capella
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?
Posted: Sat Apr 05, 2008 8:26 pm
by Kaeru Gaman
I would say, chose a graphical solution.
I bet the preview of Word is no Textsurface.
a Webgadget or Imagegadget should work,
but I doubt a Textgadget or Stringgadget is capable of with without a fat workaround.
Posted: Sat Apr 05, 2008 8:37 pm
by Derek
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.
Posted: Sun Apr 06, 2008 12:19 am
by akj
Here's a way to do it, but whether it shows as I intended will depend on the fonts available on your PC.
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
End
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.
ANSI encoding
Posted: Sun Apr 06, 2008 8:34 am
by Capella
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).
Posted: Sun Apr 06, 2008 2:03 pm
by akj
Read the documentation for the EditorGadget and you will see how to make it read only.