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

  • SEARCH
  • Home
  • 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 4270406
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:18:06+00:00 2026-05-21T07:18:06+00:00

I am implementing a text editor in C++ just using the vanilla Win32 API

  • 0

I am implementing a text editor in C++ just using the vanilla Win32 API and I’m trying to find the best way to implement syntax highlighting. I know that there are existing controls out there like scintilla, but I’m doing this for fun so I want to do most of the work myself. I also want it to be fast and lightweight.

From what I’ve learned so far, it looks like the most low level option for drawing text in GDI is the TextOut function. However, if I need to keep changing the font color then that means I will need to make many calls to TextOut in order to draw one body of text with mixed formatting. Is this inefficient? When syntax highlighting and rich text controls are implemented, would they be likely to use TextOut behind the scenes or is there some other way? Is every other method of drawing text in GDI just a higher level wrapper around TextOut?

  • 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-21T07:18:07+00:00Added an answer on May 21, 2026 at 7:18 am

    Both DrawText and TextOut are wrappers for ExtTextOut, so ExtTextOut is the low-level API. In my experience, ExtTextOut is pretty fast, so I doubt you’ll see any performance issues with ExtTextOut itself. However, creating/selecting fonts can be a source of performance issues, so if you are switching back and forth between fonts, you can realize significant performance gains by caching and reusing fonts (HFONT) rather than CreateFont / SelectObject / DeleteObject each time. Basically, the first time you call SelectObject after creating a new font, Windows will perform a font matching process to find the best physical font for the logical font that you have requested. This is a fairly complex process, so you want to minimize the number of times that occurs in situations where performance is important.

    I developed a rich edit control many years ago that was essentially a mini version of Microsoft Word. I used ExtTextOut as the main workhorse for all text output. The control would maintain a font cache of the most recently used fonts (default cache size was 10 fonts). It supported WYSIWYG layout, so it was actually doing all layout using a printer DC and fonts, then would render a screen compatible version using a screen DC and similar fonts, so there was a lot of extra work going on that likely is not applicable to your situation. Even so, performance was excellent running on typical hardware of the day (e.g., 266 mhz Pentium).

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

Sidebar

Related Questions

When implementing a needle search of a haystack in an object-oriented way, you essentially
I'm implementing YUI Editor (2.8.2rc1), and need the font size to be a dropdown
I have been trying there last days to extend the default editor (java, xml,
I'm trying to create an editable text field in a page which highlights the
I'm looking at the feasability of implementing a bi-directional text parsing framework to allow
Implementing Equals() for reference types is harder than it seems. My current canonical implementation
Implementing a 'sandbox' environment in Python used to be done with the rexec module
When implementing Quicksort, one of the things you have to do is to choose
I implementing a EventQueue and get notified when AWTEvents are send. I wait till
When implementing a singleton in C++, is it better for GetInstance() to return a

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.