void Font::CreateFont() { ReleaseFont(); // get a handle to the new font _hFont = CreateFontIndirect(&_log_font); }
void GUI_Element::ReleaseResources(){ for (auto &itr : m_style){ ReleaseTexture(itr.second.m_backgroundImage); ReleaseTexture(itr.second.m_glyph); ReleaseFont(itr.second.m_textFont); } }
void EmoticonsSelectionLayout::DrawEmoticonText(HDC hdc, char *txt, RECT rc) { HFONT hFont = GetFont(hdc); HFONT oldFont = (HFONT) SelectObject(hdc, hFont); DrawTextA(hdc, txt, strlen(txt), &rc, DT_NOPREFIX); SelectObject(hdc, oldFont); ReleaseFont(hFont); }
void Font::SetAll(const wchar_t* name, const int height, const bool is_bold, const bool is_italic) { ReleaseFont(); wcsncpy_s(_log_font.lfFaceName, name, sizeof(_log_font.lfFaceName) / sizeof(*_log_font.lfFaceName)); _log_font.lfHeight = height; _log_font.lfWeight = is_bold ? FW_BOLD : FW_NORMAL; _log_font.lfItalic = is_italic ? TRUE : FALSE; CreateFont(); }
RECT EmoticonsSelectionLayout::CalcRect(char *txt) { HDC hdc = GetDC(hwnd); HFONT hFont = GetFont(hdc); HFONT oldFont = (HFONT) SelectObject(hdc, hFont); RECT rc = { 0, 0, 0xFFFF, 0xFFFF }; DrawTextA(hdc, txt, strlen(txt), &rc, DT_CALCRECT | DT_NOPREFIX); SelectObject(hdc, oldFont); ReleaseFont(hFont); ReleaseDC(hwnd, hdc); return rc; }
void Font::Clear() { ReleaseFont(); _log_font.lfHeight = 0; _log_font.lfWidth = 0; _log_font.lfEscapement = 0; _log_font.lfOrientation = 0; _log_font.lfWeight = FW_NORMAL; _log_font.lfItalic = FALSE; _log_font.lfUnderline = FALSE; _log_font.lfStrikeOut = FALSE; _log_font.lfCharSet = ANSI_CHARSET; _log_font.lfOutPrecision = OUT_DEFAULT_PRECIS; _log_font.lfClipPrecision = CLIP_DEFAULT_PRECIS; _log_font.lfQuality = DEFAULT_QUALITY; _log_font.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; _log_font.lfFaceName[0] = '\0'; }
EXPORT_C THuiFont& THuiFont::operator=( const THuiFont& aFont ) { if ( this == &aFont ) { return *this; } ReleaseFont(); iId = aFont.iId; iFontSpec = aFont.iFontSpec; iFont = aFont.iFont; if ( iFont ) { iFont->iRefCount++; } iTextPaneHeight = aFont.iTextPaneHeight; iCategory = aFont.iCategory; return *this; }
void GUI_Element::UpdateStyle(const GUI_ElementState& l_state, const GUI_Style& l_style) { // Resource management. if (l_style.m_backgroundImage != m_style[l_state].m_backgroundImage){ ReleaseTexture(m_style[l_state].m_backgroundImage); RequireTexture(l_style.m_backgroundImage); } if (l_style.m_glyph != m_style[l_state].m_glyph){ ReleaseTexture(m_style[l_state].m_glyph); RequireTexture(l_style.m_glyph); } if (l_style.m_textFont != m_style[l_state].m_textFont){ ReleaseFont(m_style[l_state].m_textFont); RequireFont(l_style.m_textFont); } // Style application. m_style[l_state] = l_style; if (l_state == m_state){ SetRedraw(true); ApplyStyle(); } }
void ParseImage( const char* nameFile ) { int width, height; const char syms[][2] = { { 'a', 'z' }, { 'A', 'Z' }, { 'а', 'я' }, { 'А', 'Я' }, { '0', '9' }, { '+', '+' }, { '-', '-' }, { 0, 0 } }; Font* font = InitFont( "Arial", 15, syms ); uchar* img = LoadImage( nameFile, width, height ); //DbgMsg( "%d %d", width, height ); //for( int i = 0; i < 256; i++ ) // DbgMsg( "%d - %d", i, colors[i] ); int colors[2]; int c_color = GetColorText( img, width, height, colors ); //оставляем только нужные цвета int sz = width * height; for( int i = 0; i < sz; i++ ) { int c = 0; for( int j = 0; j < c_color; j++ ) if( img[i] == colors[j] ) { c = 255; break; } img[i] = c; } const int maxRects = 1000; RECT* rects = (RECT*)u_alloc( sizeof(RECT) * maxRects ); int c_rects = GetRectSymbols( img, width, height, rects, maxRects ); /* for( int i = 0; i < c_rects; i++ ) { //DbgMsg( "%d %d %d %d", rects[i].left, rects[i].top, rects[i].right, rects[i].bottom ); int p1 = rects[i].top * width + rects[i].left; int p2 = rects[i].bottom * width + rects[i].left; for( int x = rects[i].left; x <= rects[i].right; x++, p1++, p2++ ) { img[p1] = 128; img[p2] = 128; } p1 = rects[i].top * width + rects[i].left; p2 = rects[i].top * width + rects[i].right; for( int y = rects[i].top; y <= rects[i].bottom; y++, p1 += width, p2 += width ) { img[p1] = 128; img[p2] = 128; } } SaveToBmp( "1_1.bmp", img, width, height ); */ char* chars = u_alloc(c_rects); for( int i = 0; i < c_rects; i++ ) { uint bits[MaxHeightSymbol]; RectToBits( img, width, height, rects[i], bits ); chars[i] = OCRChar( font, bits ); //DbgMsg( "[%c] %d,%d %d,%d", s, rects[i].left, rects[i].top, rects[i].right, rects[i].bottom ); } //объединяем символы в слова Word* words = (Word*)u_alloc( sizeof(Word) * c_rects ); int c_words = UnionChars( rects, chars, c_rects, words ); for( int i = 0; i < c_words; i++ ) DbgMsg( "[%s] %d,%d %d,%d", words[i].w, words[i].r.left, words[i].r.top, words[i].r.right, words[i].r.bottom ); u_free(words); u_free(chars); u_free(rects); u_free(img); ReleaseFont(font); }
EXPORT_C THuiFont::~THuiFont() { ReleaseFont(); iFont = NULL; }
EXPORT_C void THuiFont::SetFontSpec(const TFontSpec& aFontSpec) { iFontSpec = aFontSpec; ReleaseFont(); }
EXPORT_C void THuiFont::SetTextPaneHeight(TInt aTextPaneHeight) { iTextPaneHeight = aTextPaneHeight; ReleaseFont(); }
EXPORT_C void THuiFont::SetCategory(const TAknFontCategory aCategory) { iCategory = aCategory; ReleaseFont(); }