EditorGadget text char problem

Just starting out? Need help? Post your questions and find answers here.
User avatar
Shardik
Addict
Addict
Posts: 1989
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: EditorGadget text char problem

Post by Shardik »

skywalk wrote:I don't know how to specify Consolas font in the \rtf sequence.
Simply put the font name behind "fcharset254". And if you also want to increase the font size, put for example "\fs32" (font size 32 half points) in front of your text:

Code: Select all

a$ = "{\rtf1\ansi\ansicpg1252\deff0\deflang3082{\fonttbl" +
  "{\f0\fmodern\fcharset254 Consolas}}\fs32" + o$ + "}"
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: EditorGadget text char problem

Post by RASHAD »

Very good catch Shardik
Now it works with PB 5.61 as well
Thanks

Code: Select all

OpenWindow(0,200,200,500,170,
  "EditorGadget with DOS Graphics characters in Unicode mode")
EditorGadget(0,10,10,480,150,#PB_Editor_WordWrap)

dir$=Chr(34)+"C:\Program Files\Internet Explorer"+Chr(34)
flags=#PB_Program_Hide|#PB_Program_Open|#PB_Program_Read

p=RunProgram(GetEnvironmentVariable("comspec"),"/c tree "+dir$,"",flags)

While ProgramRunning(p)
  If AvailableProgramOutput(p)
    o$+ReadProgramString(p, #PB_Ascii)+"\par"
  EndIf
Wend

a$ = "{\rtf1\ansi\ansicpg1252\deff0\deflang3082{\fonttbl" +
  "{\f0\fmodern\fcharset254 Terminal}}\fs32" + o$ + "}"
b$ = Space(StringByteLength(a$, #PB_Ascii) + 1)
PokeS(@b$, a$, -1, #PB_Ascii)
SendMessage_(GadgetID(0), #WM_SETTEXT, 0, @b$)

Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
Egypt my love
User avatar
skywalk
Addict
Addict
Posts: 3972
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: EditorGadget text char problem

Post by skywalk »

Shardik wrote:
skywalk wrote:I don't know how to specify Consolas font in the \rtf sequence.
Simply put the font name behind "fcharset254". And if you also want to increase the font size, put for example "\fs32" (font size 32 half points) in front of your text:

Code: Select all

a$ = "{\rtf1\ansi\ansicpg1252\deff0\deflang3082{\fonttbl" +
  "{\f0\fmodern\fcharset254 Consolas}}\fs32" + o$ + "}"
Thanks Shardik, I was putting Consolas in place of fmodern. Now it works.
But, my conclusion is to stay with ReplaceString() and native PB commands for string concatenation and font selection. Thanks for the post. I never knew used the 'tree' command.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: EditorGadget text char problem

Post by Dude »

Rashad's post above works great for me. I am using Win 7. Thanks everyone! I knew you'd crack it. :)
Post Reply