Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Formatting text onto a DC

Formatting text onto a DC

Scheduled Pinned Locked Moved C / C++ / MFC
helpworkspacec++jsonperformance
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Santanu Lahiri
    wrote on last edited by
    #1

    This should be a simple problem, but I am unable to solve it! My environment is VStudio 2005 and MFC. The issue is printing text onto a DC. Should be simple enough, but here are some constraints: 1. The text may be rotated 0, 90, 180, 270 degrees. 2. The text may need reformatted within the bounding rectangle, meaning word-breaks. 3. The text will need to be aligned horizantally and vertically within the bounding rectangle - left, right, and center horizontally, top, center, bottom vertically. Rotating text is not a problem. Normally, I could use DrawText to print the text, but on rotated fonts, DrawText seems to choke. I tried TextOut and ExtTextOut. These rotate and position just fine, but can't seem to do word-wrap. Is there an API call or setup that I am missing? Or do I need to draw to a memory DC and somehow rotate it to fit? Or can someone please point me to some code that will accomplish this easily? Thank you for your time

    J S 3 Replies Last reply
    0
    • S Santanu Lahiri

      This should be a simple problem, but I am unable to solve it! My environment is VStudio 2005 and MFC. The issue is printing text onto a DC. Should be simple enough, but here are some constraints: 1. The text may be rotated 0, 90, 180, 270 degrees. 2. The text may need reformatted within the bounding rectangle, meaning word-breaks. 3. The text will need to be aligned horizantally and vertically within the bounding rectangle - left, right, and center horizontally, top, center, bottom vertically. Rotating text is not a problem. Normally, I could use DrawText to print the text, but on rotated fonts, DrawText seems to choke. I tried TextOut and ExtTextOut. These rotate and position just fine, but can't seem to do word-wrap. Is there an API call or setup that I am missing? Or do I need to draw to a memory DC and somehow rotate it to fit? Or can someone please point me to some code that will accomplish this easily? Thank you for your time

      J Offline
      J Offline
      James R Twine
      wrote on last edited by
      #2

      It might be Q&D, but what about drawing the text onto an in-memory bitmap/surface and then rotating it, and then blitting it to the target bitmap/surface?    Other than that, maybe the GDI+ libraries have something to offer?    Peace!

      -=- James
      Please rate this message - let me know if I helped or not! * * * If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
      Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
      See DeleteFXPFiles

      S 1 Reply Last reply
      0
      • J James R Twine

        It might be Q&D, but what about drawing the text onto an in-memory bitmap/surface and then rotating it, and then blitting it to the target bitmap/surface?    Other than that, maybe the GDI+ libraries have something to offer?    Peace!

        -=- James
        Please rate this message - let me know if I helped or not! * * * If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
        Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
        See DeleteFXPFiles

        S Offline
        S Offline
        Santanu Lahiri
        wrote on last edited by
        #3

        Unfortunately, I am out of options at this point... In-Memory bitmap and rotate would have to be the answer. I was kind of hoping some built-in API.

        1 Reply Last reply
        0
        • S Santanu Lahiri

          This should be a simple problem, but I am unable to solve it! My environment is VStudio 2005 and MFC. The issue is printing text onto a DC. Should be simple enough, but here are some constraints: 1. The text may be rotated 0, 90, 180, 270 degrees. 2. The text may need reformatted within the bounding rectangle, meaning word-breaks. 3. The text will need to be aligned horizantally and vertically within the bounding rectangle - left, right, and center horizontally, top, center, bottom vertically. Rotating text is not a problem. Normally, I could use DrawText to print the text, but on rotated fonts, DrawText seems to choke. I tried TextOut and ExtTextOut. These rotate and position just fine, but can't seem to do word-wrap. Is there an API call or setup that I am missing? Or do I need to draw to a memory DC and somehow rotate it to fit? Or can someone please point me to some code that will accomplish this easily? Thank you for your time

          S Offline
          S Offline
          Santanu Lahiri
          wrote on last edited by
          #4

          Stephen, I am not familiar with the World Transform functions, so I will have to go through the sections to pick up on them, but thank you for pointing me at them. From the initial look I had, they do look promising. Santanu

          1 Reply Last reply
          0
          • S Santanu Lahiri

            This should be a simple problem, but I am unable to solve it! My environment is VStudio 2005 and MFC. The issue is printing text onto a DC. Should be simple enough, but here are some constraints: 1. The text may be rotated 0, 90, 180, 270 degrees. 2. The text may need reformatted within the bounding rectangle, meaning word-breaks. 3. The text will need to be aligned horizantally and vertically within the bounding rectangle - left, right, and center horizontally, top, center, bottom vertically. Rotating text is not a problem. Normally, I could use DrawText to print the text, but on rotated fonts, DrawText seems to choke. I tried TextOut and ExtTextOut. These rotate and position just fine, but can't seem to do word-wrap. Is there an API call or setup that I am missing? Or do I need to draw to a memory DC and somehow rotate it to fit? Or can someone please point me to some code that will accomplish this easily? Thank you for your time

            S Offline
            S Offline
            Santanu Lahiri
            wrote on last edited by
            #5

            Stephen, Your suggestion was exactly what I needed. I used the SetWorldTransform API to rotate and align text along the required axes and let DrawText do the wordwrap part. Thank you very much.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups