1 #include <Application.h> 2 #include <String.h> 3 #include <View.h> 4 #include <Window.h> 5 6 class View : public BView { 7 public: 8 View(BRect bounds) 9 : BView(bounds, "test", B_FOLLOW_ALL, B_WILL_DRAW) 10 { 11 } 12 13 virtual void Draw(BRect updateRect) 14 { 15 BFont font; 16 GetFont(&font); 17 18 const BRect bounds = Bounds(); 19 const BString text = "The quick brown fox jumps over the lazy dog!"; 20 21 float size = 2.0f; 22 float y = 30.0f; 23 24 while (size < 48 && y - size < bounds.bottom) { 25 font.SetSize(size); 26 SetFont(&font); 27 28 BString textAndSize = text; 29 textAndSize << " (" << size << ")"; 30 31 DrawString(textAndSize, BPoint(30.0f, y)); 32 33 y = (int)(y + size * 1.2f); 34 size *= 1.08; 35 } 36 } 37 }; 38 39 class Window : public BWindow { 40 public: 41 Window() 42 : BWindow(BRect(30, 30, 600, 500), "Text rendering test", 43 B_DOCUMENT_WINDOW, 44 B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE) 45 { 46 AddChild(new View(Bounds())); 47 } 48 49 }; 50 51 class Application : public BApplication { 52 public: 53 Application() 54 :BApplication("application/x-vnd.haiku.text-rendering-test") 55 { 56 } 57 58 virtual void ReadyToRun() 59 { 60 (new Window())->Show(); 61 } 62 }; 63 64 65 int 66 main() 67 { 68 Application app; 69 app.Run(); 70 return 0; 71 } 72