00001 /***************************** License ********************************** 00002 00003 Copyright (C) 2008 by Communicative Machines 00004 http://www.cmlabs.com All rights reserved. 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Lesser General Public 00008 License as published by the Free Software Foundation; either 00009 version 2.1 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Lesser General Public License for more details. 00015 00016 You should have received a copy of the GNU Lesser General Public 00017 License along with this library; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 00020 ************************************************************************/ 00021 00022 namespace cmlabs { 00023 00024 OutputText::~OutputText() { 00025 if (font != NULL) 00026 DeleteObject(font); 00027 } 00028 00029 bool OutputText::useFontOn(HDC hdc) { 00030 /* 00031 CHOOSEFONT cf; 00032 LOGFONT lf; 00033 HFONT hfont; 00034 00035 // Initialize members of the CHOOSEFONT structure. 00036 00037 cf.lStructSize = sizeof(CHOOSEFONT); 00038 cf.hwndOwner = (HWND)NULL; 00039 cf.hDC = (HDC)NULL; 00040 cf.lpLogFont = &lf; 00041 cf.iPointSize = 0; 00042 cf.Flags = CF_SCREENFONTS; 00043 cf.rgbColors = RGB(0,0,0); 00044 cf.lCustData = 0L; 00045 cf.lpfnHook = (LPCFHOOKPROC)NULL; 00046 cf.lpTemplateName = (LPTSTR)NULL; 00047 cf.hInstance = (HINSTANCE) NULL; 00048 cf.lpszStyle = (LPTSTR)NULL; 00049 cf.nFontType = SCREEN_FONTTYPE; 00050 cf.nSizeMin = 0; 00051 cf.nSizeMax = 0; 00052 00053 // Display the CHOOSEFONT common-dialog box. 00054 00055 ChooseFont(&cf); 00056 00057 */ 00058 #if !defined(CYGWIN) 00059 00060 if (font == NULL) { 00061 LOGFONT logfont; 00062 memset ((char *)&logfont, 0, sizeof (logfont)); 00063 logfont.lfQuality = ANTIALIASED_QUALITY; 00064 if (fontname.length() < 32) 00065 _tcscpy(logfont.lfFaceName, fontname); 00066 // else 00067 // _tcscpy(logfont.lfFaceName, TEXT("Arial")); 00068 logfont.lfHeight = fontsize; 00069 logfont.lfWeight = 700; 00070 font = (HFONT) CreateFontIndirect (&logfont); 00071 if (font == NULL) 00072 return false; 00073 } 00074 00075 SelectObject(hdc, font); 00076 #endif 00077 00078 return true; 00079 } 00080 00081 } // namespace cmlabs