// ---- End Project Data ---- // ---- File Font Scaling.t ---- stretchApp := {title: "Font Stretching Example", viewBounds: {top: 0, left: 0, right: 240, bottom: 336}, viewSetupFormScript: func() begin local a := GetAppParams(); self.viewBounds := RelBounds(a.appAreaLeft, a.appAreaTop, a.appAreaWidth, a.appAreaHeight); end, _proto: protoApp, debug: "stretchApp" }; _view000 := /* child of stretchApp */ {viewFlags: 513, viewFormat: 0, viewBounds: {top: 18, left: 2, right: -2, bottom: -18}, StretchText: func( right, bottom) begin ScaleShape(myTextPicture, nil, SetBounds(0, 0, Max(1, right), Max(1, bottom))); self:Dirty(); RefreshViews(); //We only call this because we want to see immediate results end, viewDrawScript: func() begin :DrawShape(myTextPicture, nil); end, viewSetupDoneScript: func() begin :SetText(); end, viewClickScript: func(unit) begin local x, y; InkOff(unit); //Turn off the display of recognition ink while not StrokeDone(unit) do //While the pen is still down... begin x := GetPoint(finalX, unit) - viewbounds.left; //x value in current view coordinate system y := GetPoint(finalY, unit) - viewbounds.top; :StretchText(x,y); end; :SetText(); //Set up myTextPicture so that next time we see a new string end, SetText: func() begin local txt := GetRandomWord(3, 20); //get some word between 3 and 20 characters long local font := userconfiguration.userfont; //user the user's preferred font local idealBox := { left: 0, top: 0, right: StrFontWidth(txt, font), bottom: FontHeight(font) - FontLeading(font) - FontDescent(font)}; //Make a text shape with the word. //The dimensions of the shape are based on the font size from idealBox. local txtshape := MakeText(txt, idealBox.left, idealBox.top, idealBox.right + pad, idealBox.bottom); //Make a frame to go around the text local framingRect := MakeRect(idealBox.left, idealBox.top, idealBox.right, idealBox.bottom + FontDescent(font)); myTextPicture := MakePict([{penpattern: vfNone}, framingRect, txtshape], NIL); //Setting penPattern here isn't strictly necessary. //We just do it to make sure we get the right pattern. end, pad: 5 // set this less than 5 and you may lose letters!, viewJustify: 240, myTextPicture: // will hold the stretchable text object -- DON'T use a "picture"-type slot from NTK or it will invoke the bitmap resource browser nil, viewclass: 74 }; _view001 := /* child of stretchApp */ {text: "Tap and drag to display stretched words.", viewBounds: {top: -32, left: 0, right: 0, bottom: -16}, viewJustify: 8388786 , _proto: protoStaticText }; // ---- Beginning of section for non used Layout files ---- // End of output