Problem in Drawing Text with different Fonts & Charset

Dear all,

I'm working in a program which will draw some string with both chinese and
English character in the Window.

I try to use CreateFont() to create a HFONT with Fonts "Arial" and CharSet
"CHINESEBIG5_CHARSET" and then select the HFONT to the current DC. However
the text drawing out isn't in Font "Arial" (It seems to be "Times New Roman"
instead).

After that, I try to use other available fonts on my platform, but the same
outpur again. No matter what font I'm using, it give the same output!!!

Does anyone know Why and how to fix it?

Here I attached part of my code.

..
..
..
CDC CurDC = GetDC();
CFont newFont;
newFont.CreateFont(20, 0, 0, 0, FW_NORMAL, FALSE, FALSE,
        0, CHINESEBIG5_CHARSET, OUT_DEFAULT_PRECIS,
        CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
        DEFAULT_PITCH, _T("Arial"));                    // <- No matter what
font I use, the program will "Times New Roman" to print text!
CFont oldFont = CurDC.SelectObject(newFont);

// Draw the Text in Screen

CurDC.SelectObject(oldFont );
ReleaseDC(CurDC);


0
marco (7)
8/27/2004 3:47:21 AM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
345 Views

Similar Articles

[PageSpeed] 27

(a) did you verify that CreateFont actually succeeded?
	VERIFY(newFont.CreateFont(...));
would be a good start. Also, although you say you are selecting the HFONT, you actually
are selecting the CFont *. The code shown should not compile; the correct code should be
	CFont * oldFont = CurDC.SelectObject(&newFont);

(b) Why are you calling GetDC? This should only be done in the OnPaint handler, which
already declares a DC for your use, CPaintDC dc(this); But if you need a DC, the correct
format is to do CClientDC dc(this);, not your own GetDC/ReleaseDC.

I've never used any iconographic font, so I'm not sure how to create one. Someone else
will have to jump in with advice on that. I know that the basic Arial font does not have
any glyphs, but the font "Arial Unicode MS" has a huge number of glyphs. But since you do
not verify the font creation worked, there is no way to tell what any of this code means.
But the presence of the GetDC is deeply suspicious, and I suspect you have additional
problems you need to address.

Also, read my essay on using SaveDC/RestoreDC, on my MVP Tips site, to avoid using more
and more variables to hold saved state.
				joe



On Fri, 27 Aug 2004 11:47:21 +0800, "Marco Hung" <marco@xmlhk.com> wrote:

>Dear all,
>
>I'm working in a program which will draw some string with both chinese and
>English character in the Window.
>
>I try to use CreateFont() to create a HFONT with Fonts "Arial" and CharSet
>"CHINESEBIG5_CHARSET" and then select the HFONT to the current DC. However
>the text drawing out isn't in Font "Arial" (It seems to be "Times New Roman"
>instead).
>
>After that, I try to use other available fonts on my platform, but the same
>outpur again. No matter what font I'm using, it give the same output!!!
>
>Does anyone know Why and how to fix it?
>
>Here I attached part of my code.
>
>.
>.
>.
>CDC CurDC = GetDC();
>CFont newFont;
>newFont.CreateFont(20, 0, 0, 0, FW_NORMAL, FALSE, FALSE,
>        0, CHINESEBIG5_CHARSET, OUT_DEFAULT_PRECIS,
>        CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
>        DEFAULT_PITCH, _T("Arial"));                    // <- No matter what
>font I use, the program will "Times New Roman" to print text!
>CFont oldFont = CurDC.SelectObject(newFont);
>
>// Draw the Text in Screen
>
>CurDC.SelectObject(oldFont );
>ReleaseDC(CurDC);
>

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
8/27/2004 7:21:11 AM
Arial Font does't support MBCS or chinese Charset. So Try to use MS
Arial Unicode or Tahoma or Specific Chinese fonts.

Regards
Jakir


Joseph M. Newcomer <newcomer@flounder.com> wrote in message news:<opnti0h653a4j5j326u0n6ijdq5j38eirb@4ax.com>...
> (a) did you verify that CreateFont actually succeeded?
> 	VERIFY(newFont.CreateFont(...));
> would be a good start. Also, although you say you are selecting the HFONT, you actually
> are selecting the CFont *. The code shown should not compile; the correct code should be
> 	CFont * oldFont = CurDC.SelectObject(&newFont);
> 
> (b) Why are you calling GetDC? This should only be done in the OnPaint handler, which
> already declares a DC for your use, CPaintDC dc(this); But if you need a DC, the correct
> format is to do CClientDC dc(this);, not your own GetDC/ReleaseDC.
> 
> I've never used any iconographic font, so I'm not sure how to create one. Someone else
> will have to jump in with advice on that. I know that the basic Arial font does not have
> any glyphs, but the font "Arial Unicode MS" has a huge number of glyphs. But since you do
> not verify the font creation worked, there is no way to tell what any of this code means.
> But the presence of the GetDC is deeply suspicious, and I suspect you have additional
> problems you need to address.
> 
> Also, read my essay on using SaveDC/RestoreDC, on my MVP Tips site, to avoid using more
> and more variables to hold saved state.
> 				joe
> 
> 
> 
> On Fri, 27 Aug 2004 11:47:21 +0800, "Marco Hung" <marco@xmlhk.com> wrote:
> 
> >Dear all,
> >
> >I'm working in a program which will draw some string with both chinese and
> >English character in the Window.
> >
> >I try to use CreateFont() to create a HFONT with Fonts "Arial" and CharSet
> >"CHINESEBIG5_CHARSET" and then select the HFONT to the current DC. However
> >the text drawing out isn't in Font "Arial" (It seems to be "Times New Roman"
> >instead).
> >
> >After that, I try to use other available fonts on my platform, but the same
> >outpur again. No matter what font I'm using, it give the same output!!!
> >
> >Does anyone know Why and how to fix it?
> >
> >Here I attached part of my code.
> >
> >.
> >.
> >.
> >CDC CurDC = GetDC();
> >CFont newFont;
> >newFont.CreateFont(20, 0, 0, 0, FW_NORMAL, FALSE, FALSE,
> >        0, CHINESEBIG5_CHARSET, OUT_DEFAULT_PRECIS,
> >        CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
> >        DEFAULT_PITCH, _T("Arial"));                    // <- No matter what
> >font I use, the program will "Times New Roman" to print text!
> >CFont oldFont = CurDC.SelectObject(newFont);
> >
> >// Draw the Text in Screen
> >
> >CurDC.SelectObject(oldFont );
> >ReleaseDC(CurDC);
> >
> 
> Joseph M. Newcomer [MVP]
> email: newcomer@flounder.com
> Web: http://www.flounder.com
> MVP Tips: http://www.flounder.com/mvp_tips.htm
0
jakir (35)
8/28/2004 12:28:36 AM
Reply:

Similar Artilces:

conversion from biz to deluxe caused odd problem
I had money 2003 biz version and was only using the personal section (no business entries). i bought a new computer, which had money 2003 deluxe. i exported from the biz edition, and imported into deluxe. seemed to import all of the data. when i look at an account in 'all transaction' mode, the balances are correct. but when i look at an account in 'unreconciled transactions' the balances are in the trillions! same when i try to balance an account or look at the account list. it's nice to think that i have a lot more money than bill, but it looks like a ser...

Problem with Microsoft Point of Sale
I already installed MS POS. At first time I start Point of Sale Manager, I get a blank page with only "MS Point of Sale" title. That's all. I can't see another thing in that page. I think this is an error. Please help me. Tks This is a multi-part message in MIME format. ------=_NextPart_000_00CF_01C6FC2E.B6BE2E50 Content-Type: text/plain; charset="Utf-8" Content-Transfer-Encoding: quoted-printable CC, MSPOS takes a very long time to open the first time after install. Be = patient! --=20 Jeff=20 Check Point Software =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=...

CAsyncSocket problems
Hey, Im currently developing a Server/Client program, I've developed client programs with MFC before, and some server-apps for linux, but never a server-app with MFC. Now I have 2 questions: the first question: which is better: using the CAsyncSocket class, which conveniently has OnReceive and OnAccept functions to respond to various events, or is it better to use treads and to post my own messages (or any other way of communication between the threads)? Second Question: Lazy as I am, I made a server app using the CAsyncSocket class, the problem is this, when I connect to this server th...

insert table into connecting text box w/link
How do I insert a rather large table (single column, many rows) into text boxes which overflow from page to page? You don't... -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "display name" <display name@discussions.microsoft.com> wrote in message news:B397C80A-B72D-4D1B-B106-E14E3222A331@microsoft.com... > How do I insert a rather large table (single column, many rows) into text > boxes which overflow from page to page? ...

AnimateWindow function problem
hi I want to hide my application on certain conditions when the application is minimized. Till now i was using ShowWindow to achieve this and it worked fine. Now when I am using the AnimateWindow API the window gets hidden but the window's entry in the taskbar remains. I am posting the code that i have written. void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam) { if ((nID & 0xFFF0) == SC_MINIMIZE) { if(bMinimizeToTray) { this->AnimateWindow(200,AW_HIDE |AW_SLIDE | AW_VER_POSITIVE); // this->ShowWindow(SW_HIDE); return; } } CFrameWnd::O...

Sending large attachments is a problem
In 2002 when I send large attachments they never disappear from my Outbox. Because of that they keep getting send over and over again. Any ideas as to what is going on? Define large. Are you allowed to snd messages that big by your ISP? -- Robert Sparnaaij [MVP-Outlook] www.howto-outlook.com Tips of the month: -What do the Outlook Icons Mean? -Create an Office 2003 CD slipstreamed with Service Pack 1 ----- "brian" <brian@discussions.microsoft.com> wrote in message news:5DA69CAD-9790-4E31-8996-2E5859A81EDD@microsoft.com... > In 2002 when I send large attachments they ...

Text size #2
Hello friends, is there a way to change the default text size and the font for the incoming emails in OutlookXP, the email format is set to HTML with Word as the email editor. Appreciate your help. Thanks. ...

inserting a text into xml file
Hi friends, I am new to csharp and XML : fp=File.OpenText(server.mappath(".\\upload\\")+"test.txt"); string info=fp.readtoend(); string[] arinfo =new string[4]; char splitter = {'|','^'}; arinfo =info.split(splitter); for(int x=0;x<arinfo.length;x++) { response.write(arinfo[x]+"<br>"); a=arinfo[x]; xmltextwriter xwriter=new xmltextwriter("C:/XML/Data.xml",system.text.encoding.UTF8); xwriter.writestartdocument(true); xwriter.writestartelement("login"); xwriter.writeelementstring("usernam...

Outlook connector Sync Problem with hotmail
I have windows 7 pro, outlook 2007... I keep getting this error sporadically when I open outlook: xxxxxxx@hotmail.com We were unable to sign in to your account. Please try again. Outlook Connector has encountered an error. Please restart Outlook. If the issue continues, open the Control Panel, click Add/Remove Programs and repair Outlook Connector. If this does nto fix the issue, contact Support. The error generally comes about 10 seconds after starting Outlook. I have 3 email accounts set up in outlook. One POP, one MSN.com and one Hotmail.com. The only one that I have iss...

text boxes
I have a unbound text box on a form that's not in a query how do i bind that to a report? Can't be done. Tell use what you want to do and perhaps we can tell you how. -- Dave Hargis, Microsoft Access MVP "DJACKSON" wrote: > I have a unbound text box on a form that's not in a query how do i bind that > to a report? I have a label sticker report based on a select query and I would like to add text to the sticker. The add text would change constantly so I would like to enter that on a form through a text box. Is there any hope? Thanks for your help "Kl...

Public Folders Problem!
I have used SBS premium 2003 that run with exchnage/SP2,Clients side using Outlook 2000 for connect to exchange; NOw; When Client try to connect the public folder using Outlook,The Outlook was not respond and then I can not using it. in this case What should check I? Thanks From now Best Regards. Dissolve <unknown@solve.net> wrote: > I have used SBS premium 2003 that run with exchnage/SP2,Clients side > using Outlook 2000 for connect to exchange; Since you have SBS2003, you can (and really should) install Outlook 2003 for all your users. It's a lot better (and OL2000 h...

problem sending a mail
I am facing a bit strange problem we are running ms exhange 5.5 for mailing purpose on winnt server and we have isdn connection for connectivity. From a couple of dayS we were not able to send mail to rediffmail.com users only from any of the systems . but we are able to recv mails from rediffmail.com site. this prob is particullary with rediffmail.com site pls do reply to my id avd_hawk@hotmail.com Can you manually connect to rediffmail.com via telnet on 25 and send a message? -- Neil Hobson Exchange MVP For Exchange news, links and tips, check: http://www.msexchangeblog.com "...

mny file on different computers
I can't seem to copy my .mny file from my desktop to use on my notebook. Using Money 2005 deluxe on both. Money starts and immediately wants to upgrade/convert my .mny file (seems to think its from a different version). If I try to let it do this this it comes back and says it can't open the file, might be read-only or the disk is write protected. I checked permissions and all that. Have plenty of disk space. I have admin priveledges. I've tried restoring a backup file also with same results. Any suggestions? Thanks. In microsoft.public.money, Bill S wrote: >I c...

how do I change the default font size in endnotes? 03-03-10
I cannot change the default font size in endnotes (Word 2003). If I use the font menu and seek to apply 12-pointas default, it reverts to 10-point every time I create a new endnote. Can somebody help? You should be able to change your default font. Click Format, Font, change font size, click on Default button to select the new size. The font size will be the same for your endnotes. "kar201245" wrote: > I cannot change the default font size in endnotes (Word 2003). If I use the > font menu and seek to apply 12-pointas default, it reverts to 10-point every >...

Problem using CPropertySheet over CFormView
Hi! I have three views in an MFC SDI application, split using CSplitterWnd. And in one of the views we have some edit controls and gird controls. In the same view, on selection of a menuitem, I create a modeless CPropertySheet with two pages and place it over the edit controls. Now on clicking the property sheet, I am getting the overlapped display of editcontrols in the view. How can I avoid this. Please help. Thanking you in anticipation. Best Regards! Babu PSM Babu wrote: > Hi! > > I have three views in an MFC SDI application, split using > CSplitterWnd. > And in one ...

countif/offset problem
Greetings, Experts, I'm sorry for not following the earlier advice, i just don't get it. perhaps i'm not explaining well. We're trying to define the formula that will look at a row of data and sum a specific number of cells into a new cell (called the new cell A2). then, cell B2 picks up summing the row for a specified number of cells and puts that sum into B2. Here's the sample data, in a row. Row 1: 10,35,50,7,25,48 Cell A7 has the value "3", which means that we'd like to put the sum of the first 3 numbers in Row1 into cell A2. Cell A8 has the v...

Bandwidth problem
Recently I am suffering very slow downloading when watching I player and I am told that my bandwidth is insufficient How can I rectify this? Blair bm wrote: > Recently I am suffering very slow downloading when watching I player > and I am told that my bandwidth is insufficient > How can I rectify this? > Blair By getting a faster service from your current or another ISP. -- dadiOH ____________________________ dadiOH's dandies v3.06... ....a help file of info about MP3s, recording from LP/cassette and tips & tricks on this and that. Get it at ...

Combining cells with text
I have two cells that both have text in them. Cell A2 contains the old status. Cell B2 contains the new status. I'd like to keep the history of the old status and update it with the new status on top. So cell A2 will now look like: 5/6 New Status 4/20 Old Status Can this be done? I'm using Excel 2003. I'm guessing it will be VBA code but don't know what it will say. Thanks. =A1 & " Old status" and copy paste special - values to keep the value static. -- Regards Dave Hawley www.ozgrid.com "Nadine" <Nadine@discussion...

pivot table
hi Though I have been using Excel for quite a while. I just did my first pivot table today. I need a report based on specific date (Actually it is every Sunday). The date I have entered are Nov 1, 2009 and Nov 8, 2009) in the Excel but when I used date as the page report filter. The date filter is <Nov 1 > Nov 9 with many dates in between. How do I make it to show only Nov 1, 2009 and Nov 8, 2009. I really very happy because pivot table really useful tool except for my problem re date. -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.aspx/exce...

combine text from 2 cells HELP! PLEASE!
I have text in cell A and Cell B. I would like to add the text in cell B to the end of the text in cell A while seperating them with a | (pipe). One way: =A1&"|"&B1 or if you want spaces on both sides of the pipe: =A1&" | "&B1 HTH, ryanb. "John Adams" <johnadams@comcast.net> wrote in message news:nk17sv0h9j37coum79h30ac071gr7o8jdt@4ax.com... > I have text in cell A and Cell B. I would like to add the text in cell > B to the end of the text in cell A while seperating them with a | > (pipe). > John, Try a formula like ...

date difference expression
I am using the DateDiff expression to obtain the difference between 2 dates.However I can't get it to run.How exactly is it entered into the query ..I am using MS 2002 -- Insurance Guy PJ wrote: > I am using the DateDiff expression to obtain the difference between 2 > dates.However I can't get it to run.How exactly is it entered into > the query .I am using MS 2002 AliasName: DateDiff("x", FirstDateField, SecondDateField) ....where x is the interval you want to count ("d" = days, "h" = hours, etc.). For more details see the help topic for t...

Problem with My MSN
I'm using IE8(+ WindowsXPSP3) and have MSN.com as my home page. When I press the button to go to MyMSN, the MyMSN page come up but with a message that says "Your request could not be processed at this time, please refresh this page or try again later". When I try to add content to the page(weather, news etc.) it says "done but with errors on page" and no content is added. I also have Firefox on my computer so I tried to set up the MyMSN page with the content that I want in Firefox and found that it works fine there with no error messages. Any ideas on ho...

Font for composing messages won't change
I am using Office 2000 premium suite Outlook 2000 Word 2000 Word is email editor. I seem to be stuck with Arial 10 point as default. How can I change this? Someone told me to change the Word email template, but I don't know where that template is stored (or what it is called) Steve Ok, first launch a new e-mail in your Word editor. Click down in th message area, then click on the "Format" button on your menu bar. Choose "Font." Select the font and size (color, etc.) you would lik in this box, then click the "Default" button at the bottom right of th d...

problems with CHeaderCtrl
We are using CHeaderCtrl with CListCtrl in the report view format. Sometimes, when a column in the header is clicked on (for sorting), the first column in the header goes blank. The column is still there but the column name no longer appears. This seems to only be an issue in NT and 2000, not XP. Has anyone encountered this before? ...

Money 2003/2004 Problem
I was able to use direct statements in Money 2003, in Money 2004 I can only download statements. Has anyone else experienced this? In microsoft.public.money, Chris wrote: >I was able to use direct statements in Money 2003, in >Money 2004 I can only download statements. Has anyone >else experienced this? No. ...