Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/MacCF/ATS/ATS FontGlyph
Function:
Required plugins for this example: MBS MacCF Plugin, MBS MacCG Plugin, MBS Util Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCF/ATS/ATS FontGlyph
This example is the version from Sun, 17th Mar 2012.
Project "ATS FontGlyph.rbp"
Class Window1 Inherits Window
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
EventHandler Function MouseDown(X As Integer, Y As Integer) As Boolean Refresh Return true End EventHandler
EventHandler Sub Paint(g As Graphics) dim t as ATSUTextLayoutMBS dim s as ATSUStyleMBS dim u as string dim gl as ATSFontGlyphListMBS dim gf as ATSFontGlyphMBS dim i,c,x,y as integer dim o as string dim cg as CGContextMBS cg=me.CGContextMBS const kATSUFromTextBeginning=-1 const kATSUToTextEnd=-1 o="ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890 ÄÖܧ" u=UnicodeStringMBS(o) s=new ATSUStyleMBS s.Create s.Size=36 t=new ATSUTextLayoutMBS t.Create t.SetTextPointerLocation u,kATSUFromTextBeginning,kATSUToTextEnd,len(u) t.SetRunStyle s,kATSUFromTextBeginning, kATSUToTextEnd t.SetCGContext cg.Handle gl=t.GlyphInfo(0,-1,s,false,true) c=gl.Count-1 for i=0 to c gf=gl.Item(i) if i=16 or i=15 then system.debuglog "CaretX: "+str(gf.CaretX) system.debuglog "DeltaY: "+str(gf.DeltaY) system.debuglog "IdealAdvanceX: "+str(gf.IdealAdvanceX) system.debuglog "IdealAdvanceY: "+str(gf.IdealAdvanceY) system.debuglog "IdealOtherSideBearingX: "+str(gf.IdealOtherSideBearingX) system.debuglog "IdealOtherSideBearingY: "+str(gf.IdealOtherSideBearingY) system.debuglog "IdealSideBearingX: "+str(gf.IdealSideBearingX) system.debuglog "IdealSideBearingY: "+str(gf.IdealSideBearingY) system.debuglog "IdealValues: "+bool(gf.IdealValues) system.debuglog "IdealX: "+str(gf.IdealX) system.debuglog "ScreenDeviceAdvanceX: "+str(gf.ScreenDeviceAdvanceX) system.debuglog "ScreenDeviceAdvanceY: "+str(gf.ScreenDeviceAdvanceY) system.debuglog "ScreenHeight: "+str(gf.ScreenHeight) system.debuglog "ScreenOtherSideBearingX: "+str(gf.ScreenOtherSideBearingX) system.debuglog "ScreenOtherSideBearingY: "+str(gf.ScreenOtherSideBearingY) system.debuglog "ScreenSideBearingX: "+str(gf.ScreenSideBearingX) system.debuglog "ScreenSideBearingY: "+str(gf.ScreenSideBearingY) system.debuglog "ScreenTopLeftX: "+str(gf.ScreenTopLeftX) system.debuglog "ScreenTopLeftY: "+str(gf.ScreenTopLeftY) system.debuglog "ScreenValues: "+bool(gf.ScreenValues) system.debuglog "ScreenWidth: "+str(gf.ScreenWidth) system.debuglog "ScreenX: "+str(gf.ScreenX) end if cg.SetRGBFillColor rnd*0.5+0.5,rnd*0.5+0.5,rnd*0.5+0.5,1 cg.SetGrayStrokeColor 0,0 x=gf.ScreenX y=gf.ScreenTopLeftY-gf.ScreenHeight cg.FillRect CGMakeRectMBS(x,y+100,gf.ScreenDeviceAdvanceX,gf.ScreenHeight) next cg.SetGrayFillColor 0,1 cg.SetGrayStrokeColor 0,1 t.DrawText kATSUFromTextBeginning, kATSUToTextEnd,0,100 Exception End EventHandler
Protected Function bool(b as boolean) As string if b then Return "true" else Return "false" end if End Function
End Class
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
End Class
End Project

See also:

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS MacCF Plugin.




Links
MBS Xojo blog