Hi there everyone! First time OSX coder looking for some help.
I've noticed from the PureBasic reference that LOADFONT doesn't support the underlined and strikeout styles for OSX. How would one go about displaying such text then? Have I missed something?
Any feedback will be appreciated.
Thank you.
DrawText underlined & strikeout
DrawText underlined & strikeout
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 

Re: DrawText underlined & strikeout
For "Strikeout" I currently don't have a solution but "Underlined" is no problem.
Take a look into my code example which demonstrates how to toggle between
different styles in the ListIconGadget and TextGadget:
Take a look into my code example which demonstrates how to toggle between
different styles in the ListIconGadget and TextGadget:
Code: Select all
ImportC ""
SetControlFontStyle(ControlRef.L, *ControlFontStyleRec)
SetControlVisibility(ControlRef.L, IsVisible.L, DoDraw.L)
EndImport
#kControlUseFaceMask = $0002
; ----- Font style constants
#Bold = 1
#Italic = 2
#Bold_Italic = 3
#Underline = 4
#Bold_Underline = 5
#Italic_Underline = 6
#Bold_Italic_Underline = 7
Structure RGBColor
Red.U
Green.U
Blue.U
EndStructure
Structure ControlFontStyleRec
Flags.W
Font.W
Size.W
Style.W
Mode.W
Just.W
ForeColor.RGBColor
BackColor.RGBColor
EndStructure
Procedure ChangeFontStyle(Style.W)
Protected FontStyle.ControlFontStyleRec
FontStyle\Flags = #kControlUseFaceMask
FontStyle\Style = Style
SetControlFontStyle(GadgetID(1), @FontStyle)
SetControlFontStyle(GadgetID(2), @FontStyle)
SetControlVisibility(GadgetID(2), #True, #True)
EndProcedure
OpenWindow(0, 200, 100, 480, 435, "Change font styles")
TextGadget(0, 195, 15, 100, 18, "ListIconGadget")
ListIconGadget(1, 5, 32, 470, 100, "Name", 135)
AddGadgetColumn(1, 1, "Address", 314)
AddGadgetItem(1, -1, "Harry Rannit" + #LF$ + "12 Parliament Way, Battle Street, By the Bay")
AddGadgetItem(1, -1, "Ginger Brokeit"+ #LF$ + "130 PureBasic Road, BigTown, CodeCity")
AddGadgetItem(1, -1, "Didi Foundit"+ #LF$ + "321 Logo Drive, Mouse House, Downtown")
TextGadget(2, 195, 152, 80, 18, "TextGadget", #PB_Text_Border)
Frame3DGadget(3, 130, 190, 210, 225, "Font styles:")
ButtonGadget(4, 140, 210, 190, 18, "Standard")
ButtonGadget(5, 140, 235, 190, 18, "Bold")
ButtonGadget(6, 140, 260, 190, 18, "Italic")
ButtonGadget(7, 140, 285, 190, 18, "Bold + Italic")
ButtonGadget(8, 140, 310, 190, 18, "Underlined")
ButtonGadget(9, 140, 335, 190, 18, "Bold + Underlined")
ButtonGadget(10, 140, 360, 190, 18, "Italic + Underlined")
ButtonGadget(11, 140, 385, 190, 18, "Bold + Italic + Underlined")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
If EventType() = #PB_EventType_LeftClick
GadgetNumber = EventGadget()
If GadgetNumber >= 4 And GadgetNumber <= 11
ChangeFontStyle(GadgetNumber - 4)
EndIf
EndIf
EndSelect
ForEver
Re: DrawText underlined & strikeout
Hi Shardik! Thank you very much; you seem to be very well versed with the OSX development platform.
If you don't mind, please allow me two questions:
1. The example that you have so kindly given seems to apply only to gadgets/controls. Is there any way that these font styles can be loaded for drawing purposes? i.e., LOADFONT -> DRAWINGFONT -> DRAWTEXT
2. An off-topic question, but one that I've been waiting to ask an OSX pro. I'm a little confused about all this Intel/PPC compile options; in your opinion, do the latest versions of PureBasic still support both options reliably, and if so, where and how do the XCode versions factor into the compile process? Must we actually use different versions of XCode for Intel and PPC compilations?
Your invaluable response is always appreciated.
Thank you.
If you don't mind, please allow me two questions:
1. The example that you have so kindly given seems to apply only to gadgets/controls. Is there any way that these font styles can be loaded for drawing purposes? i.e., LOADFONT -> DRAWINGFONT -> DRAWTEXT
2. An off-topic question, but one that I've been waiting to ask an OSX pro. I'm a little confused about all this Intel/PPC compile options; in your opinion, do the latest versions of PureBasic still support both options reliably, and if so, where and how do the XCode versions factor into the compile process? Must we actually use different versions of XCode for Intel and PPC compilations?
Your invaluable response is always appreciated.
Thank you.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 

Re: DrawText underlined & strikeout
Hello TI-994A,
thank you very much for your kind words. But unfortunately I am no MacOS X
expert. I am still a beginner on Macs having bought my first Mac in August 2010.
And I can't say anything about differences and techniques compiling for the Intel
and PPC-platforms because I only own an Intel Mac and just have written my first
"HelloWorld" program in Objective C...
I am sorry for posting an example which didn't help you. After having posted it I
read the title of your posting again and realized that you need an example for
drawing text into a graphics output. I am no graphics expert but what about
drawing the text in a first step and drawing a line for underlining or strikeout in
a second step? You can even automate it by calculating the width with TextWidth()
and the height with TextHeight() and then subtracting a different offset depending
on Underline oder Strikeout mode and on the height of your chosen font:
thank you very much for your kind words. But unfortunately I am no MacOS X
expert. I am still a beginner on Macs having bought my first Mac in August 2010.
And I can't say anything about differences and techniques compiling for the Intel
and PPC-platforms because I only own an Intel Mac and just have written my first
"HelloWorld" program in Objective C...

I am sorry for posting an example which didn't help you. After having posted it I
read the title of your posting again and realized that you need an example for
drawing text into a graphics output. I am no graphics expert but what about
drawing the text in a first step and drawing a line for underlining or strikeout in
a second step? You can even automate it by calculating the width with TextWidth()
and the height with TextHeight() and then subtracting a different offset depending
on Underline oder Strikeout mode and on the height of your chosen font:
Code: Select all
OpenWindow(0, 200, 100, 300, 170, "2D Drawing Example")
LoadFont(0, "Comic Sans MS", 48)
If CreateImage(0, 300, 170) And StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_Transparent)
DrawingFont(FontID(0))
Box(0, 0, 300, 170, RGB(255, 255, 255))
DrawText(10, 10, "Underlined", RGB(63, 148, 180))
Box(12, TextHeight("U") + 10 - 7, TextWidth("Underlined"), 3, RGB(63, 148, 180))
DrawText(10, 85, "Strikeout", RGB(218, 49, 107))
Box(12, TextHeight("S") + 85 - 31, TextWidth("Strikeout"), 4, RGB(0, 0, 0))
StopDrawing()
ImageGadget(0, 0, 0, 200, 200, ImageID(0))
EndIf
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Re: DrawText underlined & strikeout
Hi again Shardik!
I thought about that workaround as well. Thanks for the working example; it's going to save me a lot of time. And your earlier example for gadget/control font styles will definitely come in handy, I'm sure.
As for the platform requirements, I'll just post my questions on a new thread.
Nevertheless, your comprehensive and thoughtful replies are truly appreciated.
Thank you.
I thought about that workaround as well. Thanks for the working example; it's going to save me a lot of time. And your earlier example for gadget/control font styles will definitely come in handy, I'm sure.
As for the platform requirements, I'll just post my questions on a new thread.
Nevertheless, your comprehensive and thoughtful replies are truly appreciated.
Thank you.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 
