Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3394342
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:09:32+00:00 2026-05-18T04:09:32+00:00

I am facing this problem of creating a font, other than the ones found

  • 0

I am facing this problem of creating a font, other than the ones found by default in windows folder, and using this font to draw some text on the screen.

What I am doing is simply adding this font to the windows folder, then within the code, I create the font using CreateFontIndirect function, passing the required LOGFONT struct which have the appropriate variables especially the lfFaceName variable, then selecting this font into a device context and last thing drawing some strings, but nothing is working, the only fonts that really work are arial, cour, times and tahoma which is the default system font, and even when using these default fonts, you can’t really grasp a real difference between them.

So is there any specific way to do that? or this thing can’t be done due to some limitation in Windows CE, or what exactly?

Thank you guys and really appreciate any help 🙂

Update: here is some code for the sake of clarity . . .

BOOL OnInitDialog()
{
    . . . .

    if (AddFontResource(L"\\windows\\spaceage.ttf") == 1)
    {
         OutputDebugString(L"Font added successfully");

         ::SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
    }

    . . . .
}

void OnPaint()
{
    CPaintDC dc(this);

    HDC hdcMem = ::CreateCompatibleDC(dc);

    HBITMAP hbmpMem = ::CreateCompatibleBitmap(dc, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));

    HBITMAP hbmpMemOld = (HBITMAP)::SelectObject(hdcMem, hbmpMem);

    int iPointSize = 12;

    wstring strFontName = L"spaceage";

    HFONT hFontOld;

    LOGFONT lf;
    memset(&lf, 0, sizeof(LOGFONT));

    int iFontHeight = -1 * (iPointSize * ::GetDeviceCaps(hdcMem, LOGPIXELSY) / 72);

    memset(&lf, 0, sizeof(LOGFONT));

    lf.lfHeight = iFontHeight;
    lf.lfWeight = FW_NORMAL;

    lstrcpy(lf.lfFaceName, m_strFontName.c_str());

    HFONT hFont = ::CreateFontIndirect(&lf);

    if(hFont != NULL)
    {
        hFontOld = (HFONT)::SelectObject(hdcMem, hFont);
    }

    . . . . .

    // do some stuff here

    // draw some text here

    . . . . . 

    ::BitBlt(dc, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), hdcMem, 0, 0, SRCCOPY);

    ::SelectFont(hdcMem, hOldFont);
    ::SelectObject(hdcMem, hbmpMemOld);
    ::DeleteObject(hbmpMem);
    ::DeleteDC(hdcMem);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T04:09:32+00:00Added an answer on May 18, 2026 at 4:09 am

    The problem was simply the font face name, I was using the name of the font file itself, rather than the font face name, which really differs and I didn’t know that.

    I discovered this by total chance, when I was debugging the code that enumerates the fonts available on the device, I saw that there is a difference between the file names of the fonts and the font face name, so I tried the face name given by the member variable elfFullName of the struct ENUMLOGFONT and everything went fine with English fonts, but Arabic fonts are not working 😀

    So I think I will continue looking why Arabic fonts are not working and if you have any suggestions guys, I really will appreciate them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am facing problem with creating some metadata structure inside annotations. We are using
I am facing a problem while creating a static cursor in DB2. This is
I'm creating a application using entity framework code-first and i'm facing some problems with
I am facing a strange problem while creating a file in java using MYSQL.
I am facing problem in creating more than one tables in sqllite database in
I'm facing this problem again and again, but can't find any solution (except mine,
I'm currently facing this problem with ruby on rails 3, devise and facebook oauth.
I am facing this problem upon pushing my app to Heroku: 500 internal server
I was facing this unique problem of generating a bit-mask based on the input
This is a problem am facing for long now also asked a question regarding

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.