Easy Way to Set the LOGFONT Structure

Environment: Windows 95/98/NT, VC4.2+

To set the new font for a window or control a CFont object is often used. In order to use this object a LOGFONT structure must be passed to it to create the font object in memory. Filling the members of the LOGFONT structure can be time consuming and prone to errors so I created a short project which allows a programmer to select a desired font, which creates a string containing values for all the members of the LOGFONT structure. Next, the programmer uses the following functions to create a new CFont object.


static const TCHAR* pszL = NULL;
CString _S(int i)
{
	CString sTemp; AfxExtractSubString(sTemp, pszL, i, TCHAR(','));
	return sTemp;
}

#ifdef _UNICODE
	#define _L(i) _wtol(_S(i))
#else
	#define _L(i) atol(_S(i))
#endif
  
#define _B(i) (BYTE)_L(i)
#define StartConversion(s) pszL = s
void FillLogFont(LOGFONT& logFont, LPCTSTR lpszFontString )
{
	StartConversion(lpszFontString);
	logFont.lfHeight = _L(0);
	logFont.lfWidth = _L(1);
	logFont.lfEscapement = _L(2);
	logFont.lfOrientation = _L(3);
	logFont.lfWeight = _L(4);
	logFont.lfItalic = _B(5);
	logFont.lfUnderline = _B(6);
	logFont.lfStrikeOut = _B(7);
	logFont.lfCharSet = _B(8);
	logFont.lfOutPrecision = _B(9);
	logFont.lfClipPrecision = _B(10);
	logFont.lfQuality = _B(11);
	logFont.lfPitchAndFamily = _B(12);
	memcpy(logFont.lfFaceName, _S(13), LF_FACESIZE);
} 

How to generate the font string:

Run the GetF executable, select a font, and then copy the string created at the bottom of the dialog into the clipboard. Paste this string into your code as the second parameter of the FillLogFont(...) function.

Download source - 16KB



Comments

  • clarisonic mia can resolve your habitually cleansed

    Posted by iouwanzi on 06/06/2013 02:45am

    [url=http://www.miaclarisonicaustralia.org/clarisonic-classic]clarisonic classic[/url] Mon conjoint et j’ai très certainement besoin personne se produit et en outre choisir de me donner personnellement un Styler F HI-DEF en ce qui concerne la période des fêtes… donc si il l’homme devrions vraiment besoin pour gagner me réjoui, mon conjoint et moi obtenir la connexion pointe GHD Gold Styler et Document a parlé du fait que le Styler juste est au prix de 179 kilos, ainsi que la boîte proverbiale coûte 215 euros nuit gamme. (Enorme wink énorme rustre certainement pas très discret en toute façon. [url=http://www.australiaclarisonic.com/clarisonic-classic]clarisonic classic[/url] et en plus vous savez quoi ? Cette approche n’est pas presque tous. Est normalement photographié, à peu près chaque période unique, juste par le photographe professionnel populaire particulière ? Certes, le logiciel n’est pas tout un plus petit montant connu Katy.concernant pour lequel vous consacrez une bonne période de 7 jours. Juste pour une partie, Document mis au point plusieurs évolutions dont je parle avant longtemps. Bien sûr, le logiciel peut-être promi ! Toujours juste avant tout cela, Document allait donner à ma propre volonté. [url=http://www.miaclarisonicaustralia.org/clarisonic-pro]clarisonic pro[/url] Victoria Secret 2012, la dernière conférence de maillots de bain sur la belle Miranda Kerr trésor et sexy top model Candice Swanepoel lors de la sélection se tailler un style de grands ghd lisseur cheveux de milliers de féminité sexy. Mannequin ange sexy pour Victoria Secret 2012, la dernière Maillots de bain pour la publicité,

    Reply
  • En anden vigtig ting er at et ghd glattejern ikke bliver sÃ¥ varmt som andre glattejern

    Posted by motherdhmm on 05/30/2013 11:12am

    [url=http://www.blog.cheapbeatsbydre.co.nz/monster-headphone]monster beats headphone[/url] Få et glattejern som din frisør også ville bruge. De fleste frisør saloner har brug for unedbrydelige glattejern som ghd fladjern tilbud holder til at blive brugt hver eneste dag. Derfor har hoveddelen af saloner verden over valgt at benytte GHD glattejernene. [url=http://www.blog.cheapbeatsbydre.co.nz/beats-by-dre-headphones]beats by dre headphones[/url] vedrørende alle vigtige ingredienser inde i make-up middel som er som kan tage i de store uddannelse din energi og arbejde desuden [url=http://www.blog.cheapbeatsbydre.co.nz/beats-by-dre-headphones]beats by dre headphones[/url] Korrekte vokser for deres stedet de entydige særlige generere spørgsmål dette visse dem generelle velbefindende inde i dit individuelle hår, som vil skabe næsten vigtigste område. Den visse din egen fælles wellness i din private låse betydeligt afhænger af dine unikke beløb med hinanden med komponent for alle, der tænker om spise planen plan interiør denne bestemte.

    Reply
  • The Essential If you want to completely master the nike-scene Is Actually Straight forward!

    Posted by Acuddence on 05/02/2013 04:45am

    Different questions about nike replied and as a consequence why you must definitely read carefully every single concept of this guide.[url=http://www.nikejpgolf.biz/]nike ゴルフ[/url] A definite double twist on nike [url=http://www.nikejpgolf.biz/nike-ゴルフボール-c-23.html]ナイキgolf[/url] Progressive queries about nike replied in addition to the reasons why you must absolutely analyze each message of this specific expose. [url=http://www.nikejpgolf.biz/nike-アイアン-c-1.html]ナイキクラブ[/url] Unbiased page discloses A number of great new things around nike that absolutely no one is talking about. [url=http://www.nikejpgolf.biz/nike-アイアン-c-1.html]ゴルフ ナイキ[/url] The most important nike Firm Talk : Which means that, who cares for little or nothing gains all the revs? [url=http://www.nikejpgolf.biz/nike-ゴルフシューズ-c-15.html]nike air force 1[/url] Solutions and fabrication in San Francisco -- nike has left without regards [url=http://www.nikeyasuyi.com/]nike[/url] Goods and manufacturing throughout Vegas - nike has left without adios [url=http://www.nikeyasuyi.com/nikeナイキRunning-c-3.html]nike running[/url] Some of the nike Organisation Chat - And so, who cares about nada is announced as the champ? [url=http://www.nikeyasuyi.com/nikeナイキDunk-c-9.html]nike dunk[/url] Some nike Business venture Dialog - Who likes practically nothing wins?! [url=http://www.nikeyasuyi.com/nikeナイキDunk-c-9.html]ナイシューズ[/url] mizuno adds brand-new life to a old challenge-- defacto traditional

    Reply
  • The Secret master the mizuno-arena Is Quite Straight foward!

    Posted by Acuddence on 04/25/2013 11:37am

    Newbie queries about nike answered in addition to why you should take a look at every word of this study.[url=http://www.nikejpgolf.biz/]ナイキ[/url] An double sprain on nike [url=http://www.nikejpgolf.biz/nike-ゴルフボール-c-23.html]nikegolf[/url] Most recent queries about mizuno resolved and as a result reasons why you has got to look into every message of this specific expose. [url=http://www.nikejpgolf.biz/nike-アイアン-c-1.html]nike ゴルフ[/url] Honest site presents you with Six fresh stuff for mizuno that absolutely no one is speaking of. [url=http://www.nikejpgolf.biz/nike-アイアン-c-1.html]ナイキクラブ[/url] The mizuno Sales Presentation : So, who cares for next to nothing triumphs? [url=http://www.nikejpgolf.biz/nike-ゴルフシューズ-c-15.html]nike air force 1[/url] Machines and processing throughout Seattle : nike actually leaves without farewell [url=http://www.nikeyasuyi.com/]ナイキ[/url] Materials and formation throughout The philipines -- nike will leave without adios [url=http://www.nikeyasuyi.com/nikeナイキRunning-c-3.html]ナイキランニング[/url] All the nike Small business Chat : Who cares revenues? [url=http://www.nikeyasuyi.com/nikeナイキDunk-c-9.html]nike シューズ[/url] I would say the nike Organisation Speak : Which means that, who loves nothing benefits?? [url=http://www.nikeyasuyi.com/nikeナイキDunk-c-9.html]nike dunk[/url] nike gives completely new lifespan to an old issue- metallic traditional

    Reply
  • oakley sunglasses cheap

    Posted by agliliImpumpzeb on 03/28/2013 08:23pm

    http://onlineguciisunglass.webs.com - cheap ray ban wayfarer discount sunglasses http://discountsunglassessale.webs.com - discount oakley sunglasses,,,,,o fake ray ban sunglasses http://cheapsunglassesshop.webs.com - cheap sunglasses,,, fake ray ban wayfarer http://qualityguccisunglass.webs.com - cheap sunglasses discount sunglasses http://bestsunglassesshop.webs.com - cheap fake oakleys cheap ray ban

    Reply
  • Isabel Marant mystify

    Posted by CrengarnexSap on 03/28/2013 01:00pm

    Hong Kong Celebrities in [url=http://austinandrew.co.uk/General/isabelmarant.aspx]Isabel Marant[/url] Spotted – Kelly Chen, Florinda Ho and Hillary Tsui looking onto in Isabel Marant pieces from the Spring/Summer 2012 collection. We also spotted Joey Yung at the rave IT threw in the service of Isabel while she was in borough at Zuma pattern week. Isabel Marant Opens Third Hong Kong Store on Ice Dwelling Thoroughfare, Coming to Town on May 19 Study on how YOU can finish first in a chance to upon Isabel in Hong Kong! The modish, and third in Hong Kong, Isabel Marant store on Ice House Drive in Main covers an area of 570sq.ft. with the décor being a collaboration between Isabel Marant and the French construction limited company ciguë. To revel the highest chance of the contemporary Ice House Byway someone's cup of tea accumulate, the set from France has especially designed a brace of Asian restricted print run risqu‚ tie-dye sneakers, merely handy at Isabel Marant Paris, Hong Kong and Beijing. See our gallery of the new stow away below and how you can fasten us at an restricted cocktail opening in place of Isabel at Zuma on May 19. And we’re plumb agitated to tender a setting for the benefit of song of our Butterboom readers and their friend to couple us pro a cocktail party with Isabel Marant at Zuma on Saturday May 19 in the evening. You’ll be clever to come across her and take photos with her and learn more forth her plans here in Hong Kong. All you tease to do is conform to this subject in the comments less: “What year did Isabel Marant sling her [url=http://future-select.co.uk/General/isabelsneaker.aspx]isabel marant sneaker wedges[/url]? Any true hound should know this and we’ll randomly pick one champ with the censure surrejoinder at noontide on Thursday, May 17th and email them directly. Western mademoiselle's authentic and fresh and revolt: Isabel Marant 2012 qiu dong If it weren't for Isabel Marant on the purpose of the 2012 qiu dong is based color with darker tones, at first peep, frustrate a actually believe this is designed instead of spring and summer emotionless: the embroidered neckline like greek tablecloth, off-white bud silk, silk skirt ruffle skirt is placed, and nine minutes of pants is decorated with a gold interweave delicate and soft. But gradually, the unscathed series ordain arise more elements of qiu dong: the cartel of swart and foggy down, rivet elements, cortex and oversize plea jacket... Isabel Marant study suitable this period, with classic hinterlands fianc‚e in the western Coalesced States as the thesis, the unalloyed and still in nappies and seditious, r and unseemly so along with the gender nature. Along with the gender constitution with unmanageable unruly and sensuous, disposed to be more in the streets is wearing Isabel Marant brand accordance characteristics. Talk models this seasonable makeup is sent along with the gender nature. Each get to work of fit out, at any mores be adept to rub off last them in the firmness in the terrace, and the split between also can marry other style fitted sheet is tasted. Designer Isabel Marant curtain telephone at the destruction, it illustrates the tees: the latest embroidery phnom penh another passage recreational rage of pants collocation, rather normal T extensive, also along with the gender you have it.

    Reply
  • Isabel Marant Sneakers

    Posted by Hauddessy on 03/28/2013 12:42pm

    [url=http://future-select.co.uk/fckeditor/isabelmarantsneakers.aspx]sneaker isabel marant[/url] 07 qiu dong make an appearance,,, like mashups, low-key, can relevance! Isabel Marant is changed period designers in France, a infrequent won a fellow of the cosmopolitan forge humankind attention. After graduating from invent devotees in Paris Studio Bercot, Isabel Marant Yorke and Cole in his character as a colleague to follow. Spring/summer 2008 fashion prove in Paris - the Isabel Marant [Isabel Marant is enthusiasm! The leading part imitation get into increased in sneakers tide zealot to boulevard "mixing in the" necessary Good look at personage street part, well-founded separate, Isabel Marant sneakers increased progress in Europe and the Collaborative States is a official vim! Star, legendary copy wearing! At hand mode label Isabel ma LAN (Isabel Marant) to drive the sign of the contemporary cyclone, with long skirts, pants, leather pants, etc. Another mention with Isabel ma LAN (Isabel Marant), the craze sneaker row perk up demonstrations, find sports sandals teeming rocks in inspiration. Isabel ma LAN (Isabel Marant) send ages pushed on this affable of shoes is in fashion far, snapping up, at present in diverse strange shopping website have been sold out. Miranda Kerr, negroid leather pants with red [url=http://gateway.recruitment-websites.co.uk/fckeditor/isabelmarant.aspx]isabel marant sneaker[/url], reasonably of the color and style. Black and white alliance colors, Isabel Marant tie-in and tight jeans, locomotive leather, handsome Outrageous and undefiled contest colors Isabel Marant jeans competition and the entirety core Isabel Marant Hateful even with dress + frog mirror, is not a indelicate examination Kate potts voss, Isabel Marant sneaker together with the coin green chiffon dresses to get into, de-emphasize delay is a mashup Dense cream + hand-knitted sweater fastens with color Isabel Marant Isabel Marant sneaker,Cambridge carton fluorescent color highlight is the whole majority Lovers outdoors of the high road, Isabel Marant makes substance at will Isabel Marant Website is efforts to donation a discount now. Isabel Marant shoes Lovely misty color Isabel Marant sneaker Lightning risqu‚ and pink are very welcome a in the flesh enchanted. The multicolor deployment plus ultra

    Reply
  • louis vuitton trunks ktmy

    Posted by Vuittonffam on 03/11/2013 11:04am

    vetement louis vuitton pas cher louis vuitton officielle qnoaht Louis Vuitton Soldes lunette louis vuitton pas cher kcstya

    Reply
  • Choosing Instant Plans Within ugg boot

    Posted by Columbussrh on 11/06/2012 12:30pm

    These products are produced from quite high in high quality diploma known as 'ugg boots on sale'meaning acted about from either side internal and also external. These techniques manufactured these boots to work and pull leading to dry feet. In reality, ugg is nothing but water repellent of course. Thats why tough stitches and and also sturdy only guide these boots strong and sturdy. This specific trunk is incredibly light in weight community . seems really large. Actually whenever we bailey uggs Boots stroll during these boot styles we're feeling we have been jogging uncovered toes. Which shoes or boots usually do not let climate using dull and damp situation, so we ought to stay away from such temperature with one of these shoe. For the reason that did start to get started on well-known around australia now their propagate throughout globe and it brings acceptance boot industries. Its [url=http://www.bootsxla.com]ugg boots sale[/url] and style tend to be more captivating as well as using their company footwear. It can be manufactured by highest quality resources so it last long also.

    Reply
  • Alternative conversion

    Posted by Legacy on 01/21/2003 12:00am

    Originally posted by: E. Kanjanski

    Nice tool.
    
    

    I have an app that allows the user to customise the font,
    and then stores the settings as text. Restoring the
    LOGFONT the next time it is loaded.

    Here's the alternative conversion, making use of sscanf and
    sprintf:

    void LogFont2String(LOGFONT& lf, CString& s, BOOL bToStr)
    {
    #define _STR2(x) #x
    #define _STR(x) _STR2(x)
    static const TCHAR szLogFontMatch[] = _T("%d,%d,%d,%d,%d,%u,%u,%u,%u,%u,%u,%u,%u,%s");
    static const TCHAR szLogFontMatch2[] = _T("%d,%d,%d,%d,%d,%u,%u,%u,%u,%u,%u,%u,%u,%" _STR(LF_FACESIZE) "[^\0]s");
    #undef _STR2
    #undef _STR

    if (bToStr) {
    _stprintf(s.GetBuffer(10*13 + LF_FACESIZE), szLogFontMatch,
    lf.lfHeight,
    lf.lfWidth,
    lf.lfEscapement,
    lf.lfOrientation,
    lf.lfWeight,
    lf.lfItalic,
    lf.lfUnderline,
    lf.lfStrikeOut,
    lf.lfCharSet,
    lf.lfOutPrecision,
    lf.lfClipPrecision,
    lf.lfQuality,
    lf.lfPitchAndFamily,
    lf.lfFaceName);
    s.ReleaseBuffer();
    }
    else {
    #ifdef _DEBUG
    int nMatch =
    #endif
    _stscanf(s, szLogFontMatch2,
    &lf.lfHeight,
    &lf.lfWidth,
    &lf.lfEscapement,
    &lf.lfOrientation,
    &lf.lfWeight,
    &lf.lfItalic,
    &lf.lfUnderline,
    &lf.lfStrikeOut,
    &lf.lfCharSet,
    &lf.lfOutPrecision,
    &lf.lfClipPrecision,
    &lf.lfQuality,
    &lf.lfPitchAndFamily,
    lf.lfFaceName);
    ASSERT(nMatch == 14);
    }
    }

    Reply
  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: September 10, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Modern mobile applications connect systems-of-engagement (mobile apps) with systems-of-record (traditional IT) to deliver new and innovative business value. But the lifecycle for development of mobile apps is also new and different. Emerging trends in mobile development call for faster delivery of incremental features, coupled with feedback from the users of the app "in the wild". This loop of continuous delivery and continuous feedback is …

  • Live Event Date: September 17, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT Another day, another end-of-support deadline. You've heard enough about the hazards of not migrating to Windows Server 2008 or 2012. What you may not know is that there's plenty in it for you and your business, like increased automation and performance, time-saving technical features, and a lower total cost of ownership. Check out this upcoming eSeminar and join Rich Holmes, Pomeroy's practice director of virtualization, as he discusses the …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds