# HG changeset patch # User sl # Date 1400660362 -7200 # Node ID 631f53604811127521cff0a9958c3866b91d5473 # Parent e8c05ae7f41843a310a4b09ca89f82055ed907a5 Font selection now generates and saves a TGA sample. diff -r e8c05ae7f418 -r 631f53604811 MainWindow.h --- a/MainWindow.h Wed May 21 09:03:40 2014 +0200 +++ b/MainWindow.h Wed May 21 10:19:22 2014 +0200 @@ -118,6 +118,7 @@ unsigned char iDimming; //Current VFD dimming FXFontDesc iCurrentFontDesc; FXFont* iCurrentFont; + FXTGAImage* iFontImage; struct hid_device_info *devices; hid_device *connected_device; diff -r e8c05ae7f418 -r 631f53604811 test.cpp --- a/test.cpp Wed May 21 09:03:40 2014 +0200 +++ b/test.cpp Wed May 21 10:19:22 2014 +0200 @@ -52,7 +52,8 @@ MainWindow::MainWindow(FXApp *app) : FXMainWindow(app, "HIDAPI Test Application", NULL, NULL, DECOR_ALL, 200,100, 600,900), - iCurrentFont(NULL) + iCurrentFont(NULL), + iFontImage(NULL) { iDimming=0x35; devices = NULL; @@ -178,6 +179,9 @@ delete iCurrentFont; iCurrentFont = NULL; + delete iFontImage; + iFontImage = NULL; + if (connected_device) hid_close(connected_device); hid_exit(); @@ -750,6 +754,35 @@ delete iCurrentFont; iCurrentFont = NULL; iCurrentFont = new FXFont(getApp(),iCurrentFontDesc); + iCurrentFont->create(); + // + delete iFontImage; + iFontImage = NULL; + // + FXString text="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-[]{}();%$£&~#|_"; + //Create an image the proper size for our text + iFontImage = new FXTGAImage(getApp(),NULL,IMAGE_SHMI|IMAGE_SHMP,iCurrentFont->getTextWidth(text),iCurrentFont->getFontHeight()); + iFontImage->create(); + //Perform our drawing + { + FXDCWindow dc(iFontImage); + //dc.begin(iFontImage); + dc.setFont(iCurrentFont); + dc.setForeground(0xFFFFFFFF); + //dc.setBackground(0xFF000000); + //dc.setFillStyle(FILL_SOLID); + dc.fillRectangle(0,0,iFontImage->getWidth(),iFontImage->getHeight()); + dc.setForeground(0xFF000000); + dc.drawText(0,iCurrentFont->getFontAscent(),text); + //dc.end(); + } + FXFileStream file; + file.open("fonttest.tga",FXStreamSave); + iFontImage->restore(); + iFontImage->savePixels(file); + file.close(); + + // }