{"id":90,"date":"2007-11-14T03:04:43","date_gmt":"2007-11-14T08:04:43","guid":{"rendered":"http:\/\/mariusbancila.ro\/blog\/?p=90"},"modified":"2007-11-14T03:07:27","modified_gmt":"2007-11-14T08:07:27","slug":"create-a-font-with-the-desire-size","status":"publish","type":"post","link":"https:\/\/mariusbancila.ro\/blog\/2007\/11\/14\/create-a-font-with-the-desire-size\/","title":{"rendered":"Create a font with the desired size"},"content":{"rendered":"<p>Let&#8217;s asume you want to change the font of a window\\control and for the sake of simplicity let&#8217;s consider an MFC dialog application. In that case, there are several steps you should follow:<\/p>\n<ul>\n<li>declare a CFont variable in the dialog class<\/li>\n<li>create the font in OnInitDialog (using CreateFont)<\/li>\n<li>set the font to the control (using SetFont)<\/li>\n<\/ul>\n<p>For example, say that you want to use Arial size 12 for a multiline edit control. In that case you could put the following code in OnInitDialog:<\/p>\n<pre class=\"prettyprint\">\r\nBOOL CFontSampleDlg::OnInitDialog() \r\n{ \r\n\tCDialog::OnInitDialog();   \r\n\r\n\t\/\/ Set the icon for this dialog.  The framework does this automatically \r\n\t\/\/  when the application's main window is not a dialog \r\n\tSetIcon(m_hIcon, TRUE);\t\t\t\/\/ Set big icon \r\n\tSetIcon(m_hIcon, FALSE);\t\t\/\/ Set small icon   \r\n\r\n\tVERIFY(editFont.CreateFont( \r\n\t\t12,                        \/\/ nHeight \r\n\t\t0,                         \/\/ nWidth \r\n\t\t0,                         \/\/ nEscapement \r\n\t\t0,                         \/\/ nOrientation \r\n\t\tFW_NORMAL,                 \/\/ nWeight \r\n\t\tFALSE,                     \/\/ bItalic \r\n\t\tFALSE,                     \/\/ bUnderline \r\n\t\t0,                         \/\/ cStrikeOut \r\n\t\tANSI_CHARSET,              \/\/ nCharSet \r\n\t\tOUT_DEFAULT_PRECIS,        \/\/ nOutPrecision \r\n\t\tCLIP_DEFAULT_PRECIS,       \/\/ nClipPrecision \r\n\t\tDEFAULT_QUALITY,           \/\/ nQuality \r\n\t\tDEFAULT_PITCH | FF_SWISS,  \/\/ nPitchAndFamily \r\n\t\t_T(\"Arial\")));             \/\/ lpszFacename   \r\n\r\n\tGetDlgItem(IDC_EDIT_SAMPLE)-&gt;SetFont(&amp;editFont);   \r\n\r\n\treturn TRUE;  \/\/ return TRUE  unless you set the focus to a control \r\n}<\/pre>\n<p>The result should be the following:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" border=\"0\" align=\"middle\" width=\"461\" src=\"\/blog\/wp-content\/uploads\/2007\/11\/font1.png\" alt=\"control with Arial of wrong size\" height=\"166\" \/><\/p>\n<p>Look carefully and you&#8217;ll see that&#8217;s not the right size 12? Why? Because the height and width (which doesn&#8217;t matter in this case) parameters for <a target=\"_blank\" href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/2ek64h34(VS.80).aspx\">CreateFont()<\/a> are given in logical units and not pixels. When you passed 12 we meant pixels, so to correctly create a font of size 12 pixels, you must convert from pixels to logical units. To do that, you need to determine the number of pixels per logical inch along the screen height. For that you have to use <a target=\"_blank\" href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/ms533266.aspx\">GetDeviceCaps()<\/a> with the appropriate device context. To compute the actual value, <a target=\"_blank\" href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/aa383718.aspx\">MulDiv()<\/a> is used. This function multiplies two 32-bit integers and devides the 64-bit result by a third 32-bit integer.<\/p>\n<p>In this case, OnInitDialog() becomes:<\/p>\n<pre class=\"prettyprint\">\r\nBOOL CFontSampleDlg::OnInitDialog() \r\n{ \r\n\tCDialog::OnInitDialog();   \r\n\r\n\t\/\/ Set the icon for this dialog.  The framework does this automatically \r\n\t\/\/  when the application's main window is not a dialog \r\n\tSetIcon(m_hIcon, TRUE);\t\t\t\/\/ Set big icon \r\n\tSetIcon(m_hIcon, FALSE);\t\t\/\/ Set small icon   \r\n\r\n\tCDC* pDC = GetDC(); \r\n\tint desiredHeight = 12; \r\n\tint height = -MulDiv(desiredHeight, pDC-&gt;GetDeviceCaps(LOGPIXELSY), 72); \r\n\tReleaseDC(pDC);   \r\n\r\n\tVERIFY(editFont.CreateFont( \r\n\t\theight,                    \/\/ nHeight \r\n\t\t0,                         \/\/ nWidth \r\n\t\t0,                         \/\/ nEscapement \r\n\t\t0,                         \/\/ nOrientation \r\n\t\tFW_NORMAL,                 \/\/ nWeight \r\n\t\tFALSE,                     \/\/ bItalic \r\n\t\tFALSE,                     \/\/ bUnderline \r\n\t\t0,                         \/\/ cStrikeOut \r\n\t\tANSI_CHARSET,              \/\/ nCharSet \r\n\t\tOUT_DEFAULT_PRECIS,        \/\/ nOutPrecision \r\n\t\tCLIP_DEFAULT_PRECIS,       \/\/ nClipPrecision \r\n\t\tDEFAULT_QUALITY,           \/\/ nQuality \r\n\t\tDEFAULT_PITCH | FF_SWISS,  \/\/ nPitchAndFamily \r\n\t\t_T(\"Arial\")));             \/\/ lpszFacename   \r\n\r\n\tGetDlgItem(IDC_EDIT_SAMPLE)-&gt;SetFont(&amp;editFont);   \r\n\r\n\treturn TRUE;  \/\/ return TRUE  unless you set the focus to a control \r\n}<\/pre>\n<p>and the result is:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" border=\"0\" align=\"middle\" width=\"461\" src=\"\/blog\/wp-content\/uploads\/2007\/11\/font2.png\" alt=\"Arial with correct size 12 pixels\" height=\"166\" \/><\/p>\n<p>and that is what we wanted in the first place.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Let&#8217;s asume you want to change the font of a window\\control and for the sake of simplicity let&#8217;s consider an MFC dialog application. In that case, there are several steps you should follow: declare a CFont variable in the dialog class create the font in OnInitDialog (using CreateFont) set the font to the control (using &#8230; <a title=\"Create a font with the desired size\" class=\"read-more\" href=\"https:\/\/mariusbancila.ro\/blog\/2007\/11\/14\/create-a-font-with-the-desire-size\/\" aria-label=\"Read more about Create a font with the desired size\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","advgb_blocks_editor_width":"","advgb_blocks_columns_visual_guide":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[7,12],"tags":[23,27,26,453,24,25],"class_list":["post-90","post","type-post","status-publish","format-standard","hentry","category-c","category-mfc","tag-createfont","tag-font","tag-getdevicecaps","tag-mfc","tag-muldiv","tag-setfont"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.1.1 - aioseo.com -->\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Marius Bancila\"\/>\n\t<meta name=\"keywords\" content=\"createfont,font,getdevicecaps,mfc,muldiv,setfont\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/mariusbancila.ro\/blog\/2007\/11\/14\/create-a-font-with-the-desire-size\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.1.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Marius Bancila&#039;s Blog | About code. Mostly on C++\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Create a font with the desired size\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/mariusbancila.ro\/blog\/2007\/11\/14\/create-a-font-with-the-desire-size\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2007-11-14T08:04:43+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2007-11-14T08:07:27+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Create a font with the desired size\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2007\\\/11\\\/14\\\/create-a-font-with-the-desire-size\\\/#article\",\"name\":\"Create a font with the desired size\",\"headline\":\"Create a font with the desired size\",\"author\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"\\\/blog\\\/wp-content\\\/uploads\\\/2007\\\/11\\\/font1.png\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2007\\\/11\\\/14\\\/create-a-font-with-the-desire-size\\\/#articleImage\"},\"datePublished\":\"2007-11-14T03:04:43+02:00\",\"dateModified\":\"2007-11-14T03:07:27+02:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2007\\\/11\\\/14\\\/create-a-font-with-the-desire-size\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2007\\\/11\\\/14\\\/create-a-font-with-the-desire-size\\\/#webpage\"},\"articleSection\":\"C++, MFC, CreateFont, font, GetDeviceCaps, MFC, MulDiv, SetFont\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2007\\\/11\\\/14\\\/create-a-font-with-the-desire-size\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/#listItem\",\"name\":\"IT\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/#listItem\",\"position\":2,\"name\":\"IT\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/#listItem\",\"name\":\"Software\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/#listItem\",\"position\":3,\"name\":\"Software\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/c\\\/#listItem\",\"name\":\"C++\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/#listItem\",\"name\":\"IT\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/c\\\/#listItem\",\"position\":4,\"name\":\"C++\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/c\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/c\\\/mfc\\\/#listItem\",\"name\":\"MFC\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/#listItem\",\"name\":\"Software\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/c\\\/mfc\\\/#listItem\",\"position\":5,\"name\":\"MFC\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/c\\\/mfc\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2007\\\/11\\\/14\\\/create-a-font-with-the-desire-size\\\/#listItem\",\"name\":\"Create a font with the desired size\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/c\\\/#listItem\",\"name\":\"C++\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2007\\\/11\\\/14\\\/create-a-font-with-the-desire-size\\\/#listItem\",\"position\":6,\"name\":\"Create a font with the desired size\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/c\\\/mfc\\\/#listItem\",\"name\":\"MFC\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#organization\",\"name\":\"Marius Bancila's Blog\",\"description\":\"About code. Mostly on C++\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/#author\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/\",\"name\":\"Marius Bancila\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2007\\\/11\\\/14\\\/create-a-font-with-the-desire-size\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a84dd2831d955c38355ddea55df4df260809b88f36408bc14fd4eab8f7f131c9?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Marius Bancila\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2007\\\/11\\\/14\\\/create-a-font-with-the-desire-size\\\/#webpage\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2007\\\/11\\\/14\\\/create-a-font-with-the-desire-size\\\/\",\"name\":\"Create a font with the desired size\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2007\\\/11\\\/14\\\/create-a-font-with-the-desire-size\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/#author\"},\"datePublished\":\"2007-11-14T03:04:43+02:00\",\"dateModified\":\"2007-11-14T03:07:27+02:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/\",\"name\":\"Marius Bancila's Blog\",\"description\":\"About code. Mostly on C++\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Create a font with the desired size","description":"","canonical_url":"https:\/\/mariusbancila.ro\/blog\/2007\/11\/14\/create-a-font-with-the-desire-size\/","robots":"max-image-preview:large","keywords":"createfont,font,getdevicecaps,mfc,muldiv,setfont","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/mariusbancila.ro\/blog\/2007\/11\/14\/create-a-font-with-the-desire-size\/#article","name":"Create a font with the desired size","headline":"Create a font with the desired size","author":{"@id":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/#author"},"publisher":{"@id":"https:\/\/mariusbancila.ro\/blog\/#organization"},"image":{"@type":"ImageObject","url":"\/blog\/wp-content\/uploads\/2007\/11\/font1.png","@id":"https:\/\/mariusbancila.ro\/blog\/2007\/11\/14\/create-a-font-with-the-desire-size\/#articleImage"},"datePublished":"2007-11-14T03:04:43+02:00","dateModified":"2007-11-14T03:07:27+02:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/mariusbancila.ro\/blog\/2007\/11\/14\/create-a-font-with-the-desire-size\/#webpage"},"isPartOf":{"@id":"https:\/\/mariusbancila.ro\/blog\/2007\/11\/14\/create-a-font-with-the-desire-size\/#webpage"},"articleSection":"C++, MFC, CreateFont, font, GetDeviceCaps, MFC, MulDiv, SetFont"},{"@type":"BreadcrumbList","@id":"https:\/\/mariusbancila.ro\/blog\/2007\/11\/14\/create-a-font-with-the-desire-size\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog#listItem","position":1,"name":"Home","item":"https:\/\/mariusbancila.ro\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/#listItem","name":"IT"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/#listItem","position":2,"name":"IT","item":"https:\/\/mariusbancila.ro\/blog\/category\/it\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/#listItem","name":"Software"},"previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/#listItem","position":3,"name":"Software","item":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/#listItem","name":"C++"},"previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/#listItem","name":"IT"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/#listItem","position":4,"name":"C++","item":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/mfc\/#listItem","name":"MFC"},"previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/#listItem","name":"Software"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/mfc\/#listItem","position":5,"name":"MFC","item":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/mfc\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/2007\/11\/14\/create-a-font-with-the-desire-size\/#listItem","name":"Create a font with the desired size"},"previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/#listItem","name":"C++"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/2007\/11\/14\/create-a-font-with-the-desire-size\/#listItem","position":6,"name":"Create a font with the desired size","previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/mfc\/#listItem","name":"MFC"}}]},{"@type":"Organization","@id":"https:\/\/mariusbancila.ro\/blog\/#organization","name":"Marius Bancila's Blog","description":"About code. Mostly on C++","url":"https:\/\/mariusbancila.ro\/blog\/"},{"@type":"Person","@id":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/#author","url":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/","name":"Marius Bancila","image":{"@type":"ImageObject","@id":"https:\/\/mariusbancila.ro\/blog\/2007\/11\/14\/create-a-font-with-the-desire-size\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/a84dd2831d955c38355ddea55df4df260809b88f36408bc14fd4eab8f7f131c9?s=96&d=mm&r=g","width":96,"height":96,"caption":"Marius Bancila"}},{"@type":"WebPage","@id":"https:\/\/mariusbancila.ro\/blog\/2007\/11\/14\/create-a-font-with-the-desire-size\/#webpage","url":"https:\/\/mariusbancila.ro\/blog\/2007\/11\/14\/create-a-font-with-the-desire-size\/","name":"Create a font with the desired size","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/mariusbancila.ro\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/mariusbancila.ro\/blog\/2007\/11\/14\/create-a-font-with-the-desire-size\/#breadcrumblist"},"author":{"@id":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/#author"},"creator":{"@id":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/#author"},"datePublished":"2007-11-14T03:04:43+02:00","dateModified":"2007-11-14T03:07:27+02:00"},{"@type":"WebSite","@id":"https:\/\/mariusbancila.ro\/blog\/#website","url":"https:\/\/mariusbancila.ro\/blog\/","name":"Marius Bancila's Blog","description":"About code. Mostly on C++","inLanguage":"en-US","publisher":{"@id":"https:\/\/mariusbancila.ro\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"Marius Bancila's Blog | About code. Mostly on C++","og:type":"article","og:title":"Create a font with the desired size","og:url":"https:\/\/mariusbancila.ro\/blog\/2007\/11\/14\/create-a-font-with-the-desire-size\/","article:published_time":"2007-11-14T08:04:43+00:00","article:modified_time":"2007-11-14T08:07:27+00:00","twitter:card":"summary","twitter:title":"Create a font with the desired size"},"aioseo_meta_data":{"post_id":"90","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"location":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2021-03-18 21:11:01","updated":"2025-12-12 07:15:12","seo_analyzer_scan_date":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"author_meta":{"display_name":"Marius Bancila","author_link":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/"},"featured_img":null,"jetpack_publicize_connections":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"Marius Bancila","author_link":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/"},"uagb_comment_info":0,"uagb_excerpt":"Let&#8217;s asume you want to change the font of a window\\control and for the sake of simplicity let&#8217;s consider an MFC dialog application. In that case, there are several steps you should follow: declare a CFont variable in the dialog class create the font in OnInitDialog (using CreateFont) set the font to the control (using&hellip;","coauthors":[],"tax_additional":{"categories":{"linked":["<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/\" class=\"advgb-post-tax-term\">C++<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/mfc\/\" class=\"advgb-post-tax-term\">MFC<\/a>"],"unlinked":["<span class=\"advgb-post-tax-term\">C++<\/span>","<span class=\"advgb-post-tax-term\">MFC<\/span>"]},"tags":{"linked":["<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/mfc\/\" class=\"advgb-post-tax-term\">CreateFont<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/mfc\/\" class=\"advgb-post-tax-term\">font<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/mfc\/\" class=\"advgb-post-tax-term\">GetDeviceCaps<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/mfc\/\" class=\"advgb-post-tax-term\">MFC<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/mfc\/\" class=\"advgb-post-tax-term\">MulDiv<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/mfc\/\" class=\"advgb-post-tax-term\">SetFont<\/a>"],"unlinked":["<span class=\"advgb-post-tax-term\">CreateFont<\/span>","<span class=\"advgb-post-tax-term\">font<\/span>","<span class=\"advgb-post-tax-term\">GetDeviceCaps<\/span>","<span class=\"advgb-post-tax-term\">MFC<\/span>","<span class=\"advgb-post-tax-term\">MulDiv<\/span>","<span class=\"advgb-post-tax-term\">SetFont<\/span>"]}},"comment_count":"0","relative_dates":{"created":"Posted 19 years ago","modified":"Updated 19 years ago"},"absolute_dates":{"created":"Posted on November 14, 2007","modified":"Updated on November 14, 2007"},"absolute_dates_time":{"created":"Posted on November 14, 2007 3:04 am","modified":"Updated on November 14, 2007 3:07 am"},"featured_img_caption":"","series_order":"","jetpack_shortlink":"https:\/\/wp.me\/pYNdv-1s","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/posts\/90","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/comments?post=90"}],"version-history":[{"count":0,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/posts\/90\/revisions"}],"wp:attachment":[{"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/media?parent=90"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/categories?post=90"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/tags?post=90"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}