fresult InitColorSchema() { fresult fres; fres = CreateTextFormat(DEFAULT_FONT, HEADER_BACKGROUND, HEADER_FOREGROUND,&gTextFormats[FormatHeader]); if (fres!=SUCCESS) return fres; fres = CreateTextFormat(DEFAULT_FONT, MENU_BACKGROUND, MENU_FOREGROUND,&gTextFormats[FormatMenu]); if (fres!=SUCCESS) return fres; fres = CreateTextFormat(DEFAULT_FONT, TEXT_BACKGROUND, TEXT_FOREGROUND,&gTextFormats[FormatText]); if (fres!=SUCCESS) return fres; fres = CreateTextFormat(DEFAULT_FONT, GREEN, RED,&gTextFormats[FormatParrot]); if (fres!=SUCCESS) return fres; gFormatsRepository.Init((TextFormat*)gTextFormats, FORMATS_COUNT); return SUCCESS; }
// 获取字体格式 IDWriteTextFormat* TextFormatCache::GetTextFormat(const TextFormat& font){ TextFormatCache::Map::iterator itr = s_mapTextCache.find(font); if (itr != s_mapTextCache.end()) return itr->second; return CreateTextFormat(font); }
/// <summary> /// Create text formats to draw FPS and image resolution lable /// </summary> void ImageRenderer::CreateTextFormats() { CreateTextFormat(L"Segoe UI", 25.0f, DWRITE_TEXT_ALIGNMENT_CENTER, DWRITE_PARAGRAPH_ALIGNMENT_CENTER, &m_formats[ImageRendererTextFormatFps]); // FPS text format CreateTextFormat(L"Segoe UI", 12.0f, DWRITE_TEXT_ALIGNMENT_LEADING, DWRITE_PARAGRAPH_ALIGNMENT_NEAR, &m_formats[ImageRendererTextFormatResolution]); // Resolution text format }