Combining characters from different fonts

Just starting out? Need help? Post your questions and find answers here.
Capella
User
User
Posts: 16
Joined: Wed Mar 19, 2008 5:32 pm

Combining characters from different fonts

Post 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?
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post 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.
oh... and have a nice day.
Derek
Addict
Addict
Posts: 2354
Joined: Wed Apr 07, 2004 12:51 am
Location: England

Post 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.
akj
Enthusiast
Enthusiast
Posts: 668
Joined: Mon Jun 09, 2003 10:08 pm
Location: Nottingham

Post 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.
Anthony Jordan
Capella
User
User
Posts: 16
Joined: Wed Mar 19, 2008 5:32 pm

ANSI encoding

Post 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).
akj
Enthusiast
Enthusiast
Posts: 668
Joined: Mon Jun 09, 2003 10:08 pm
Location: Nottingham

Post by akj »

Read the documentation for the EditorGadget and you will see how to make it read only.
Anthony Jordan
Post Reply