1.1 --- a/test.cpp Wed May 21 09:03:40 2014 +0200
1.2 +++ b/test.cpp Wed May 21 10:19:22 2014 +0200
1.3 @@ -52,7 +52,8 @@
1.4
1.5 MainWindow::MainWindow(FXApp *app)
1.6 : FXMainWindow(app, "HIDAPI Test Application", NULL, NULL, DECOR_ALL, 200,100, 600,900),
1.7 - iCurrentFont(NULL)
1.8 + iCurrentFont(NULL),
1.9 + iFontImage(NULL)
1.10 {
1.11 iDimming=0x35;
1.12 devices = NULL;
1.13 @@ -178,6 +179,9 @@
1.14 delete iCurrentFont;
1.15 iCurrentFont = NULL;
1.16
1.17 + delete iFontImage;
1.18 + iFontImage = NULL;
1.19 +
1.20 if (connected_device)
1.21 hid_close(connected_device);
1.22 hid_exit();
1.23 @@ -750,6 +754,35 @@
1.24 delete iCurrentFont;
1.25 iCurrentFont = NULL;
1.26 iCurrentFont = new FXFont(getApp(),iCurrentFontDesc);
1.27 + iCurrentFont->create();
1.28 + //
1.29 + delete iFontImage;
1.30 + iFontImage = NULL;
1.31 + //
1.32 + FXString text="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-[]{}();%$£&~#|_";
1.33 + //Create an image the proper size for our text
1.34 + iFontImage = new FXTGAImage(getApp(),NULL,IMAGE_SHMI|IMAGE_SHMP,iCurrentFont->getTextWidth(text),iCurrentFont->getFontHeight());
1.35 + iFontImage->create();
1.36 + //Perform our drawing
1.37 + {
1.38 + FXDCWindow dc(iFontImage);
1.39 + //dc.begin(iFontImage);
1.40 + dc.setFont(iCurrentFont);
1.41 + dc.setForeground(0xFFFFFFFF);
1.42 + //dc.setBackground(0xFF000000);
1.43 + //dc.setFillStyle(FILL_SOLID);
1.44 + dc.fillRectangle(0,0,iFontImage->getWidth(),iFontImage->getHeight());
1.45 + dc.setForeground(0xFF000000);
1.46 + dc.drawText(0,iCurrentFont->getFontAscent(),text);
1.47 + //dc.end();
1.48 + }
1.49 + FXFileStream file;
1.50 + file.open("fonttest.tga",FXStreamSave);
1.51 + iFontImage->restore();
1.52 + iFontImage->savePixels(file);
1.53 + file.close();
1.54 +
1.55 + //
1.56
1.57 }
1.58