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. The Lounge
  3. Well it's been a good past 24 hours

Well it's been a good past 24 hours

Scheduled Pinned Locked Moved The Lounge
graphicsdesigncomhardwareiot
10 Posts 4 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.
  • H Offline
    H Offline
    honey the codewitch
    wrote on last edited by
    #1

    I got my font caches working. One is for measuring. The other is for drawing. You can use none, one or both. Expiring is still not as efficient as I'd like, but: You can set the number of bytes, and/or the number of items to limit them to. It's easy to get statistics on them. It's just generally easy to use

    m_font_draw_cache.initialize();
    m_font_measure_cache.initialize();
    m_font_draw_cache.max_entries(21);
    m_font_measure_cache.max_memory_size(512);

    From there you can just pass them to the font's render() and draw() methods as desired. Only wrinkle is you can potentially screw up your caching if you reuse the cache for a different font without the clearing the cache first. I decided to make the caching on a per font basis to give you that level of control. It's embedded so you're dealing in a constrained environment and constantly robbing peter to pay paul. This way you have fine control over trading RAM for speed. In addition, I think I finally got my text measuring code working correctly. I got 3 different kinds of font working with a common base class - 16-bit windows .fon/.fnt files, .VLW anti-aliased raster, and TrueType/OpenType. Also the way I handle drawing it is kinda nice. You can use draw::text<>() and give it the font, or you can use the font's draw() method with a callback in which case I provide you a series of alpha transparency maps, and locations. You can simply draw using my lib's draw::icon<>() function:

    static gfx_result draw_cb(spoint16 location,const const_bitmap>& glyph, void* state) {
    draw_cb_state* st = (draw_cb_state*)state;
    control_surface_type& dst = *(control_surface_type*)st->dst;
    const srect16 r(location,(ssize16)glyph.dimensions());
    //draw::rectangle(dst,r,color_t::blue);
    if(r.intersects(st->clip)) {
    return draw::icon(dst,location,glyph,rgb_pixel<16>(rand()%32,rand()%64,rand()%32));
    } else {
    return gfx_result::success;
    }
    }

    Also I made my text encoding pluggable so I'm not stuck with just latin1 and UTF8.

    Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

    K R 2 Replies Last reply
    0
    • H honey the codewitch

      I got my font caches working. One is for measuring. The other is for drawing. You can use none, one or both. Expiring is still not as efficient as I'd like, but: You can set the number of bytes, and/or the number of items to limit them to. It's easy to get statistics on them. It's just generally easy to use

      m_font_draw_cache.initialize();
      m_font_measure_cache.initialize();
      m_font_draw_cache.max_entries(21);
      m_font_measure_cache.max_memory_size(512);

      From there you can just pass them to the font's render() and draw() methods as desired. Only wrinkle is you can potentially screw up your caching if you reuse the cache for a different font without the clearing the cache first. I decided to make the caching on a per font basis to give you that level of control. It's embedded so you're dealing in a constrained environment and constantly robbing peter to pay paul. This way you have fine control over trading RAM for speed. In addition, I think I finally got my text measuring code working correctly. I got 3 different kinds of font working with a common base class - 16-bit windows .fon/.fnt files, .VLW anti-aliased raster, and TrueType/OpenType. Also the way I handle drawing it is kinda nice. You can use draw::text<>() and give it the font, or you can use the font's draw() method with a callback in which case I provide you a series of alpha transparency maps, and locations. You can simply draw using my lib's draw::icon<>() function:

      static gfx_result draw_cb(spoint16 location,const const_bitmap>& glyph, void* state) {
      draw_cb_state* st = (draw_cb_state*)state;
      control_surface_type& dst = *(control_surface_type*)st->dst;
      const srect16 r(location,(ssize16)glyph.dimensions());
      //draw::rectangle(dst,r,color_t::blue);
      if(r.intersects(st->clip)) {
      return draw::icon(dst,location,glyph,rgb_pixel<16>(rand()%32,rand()%64,rand()%32));
      } else {
      return gfx_result::success;
      }
      }

      Also I made my text encoding pluggable so I'm not stuck with just latin1 and UTF8.

      Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

      K Offline
      K Offline
      k5054
      wrote on last edited by
      #2

      So you got your [Hashing weirdness. Need troubleshooting ideas](https://www.codeproject.com/Questions/5386900/Hashing-weirdness-Need-troubleshooting-ideas) issue sorted, then?

      "A little song, a little dance, a little seltzer down your pants" Chuckles the clown

      H 1 Reply Last reply
      0
      • K k5054

        So you got your [Hashing weirdness. Need troubleshooting ideas](https://www.codeproject.com/Questions/5386900/Hashing-weirdness-Need-troubleshooting-ideas) issue sorted, then?

        "A little song, a little dance, a little seltzer down your pants" Chuckles the clown

        H Offline
        H Offline
        honey the codewitch
        wrote on last edited by
        #3

        Ah yes. I forgot about that. Thanks. I'll close it now. Unfortunately I don't have an easy explanation for what I did.

        Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

        K 1 Reply Last reply
        0
        • H honey the codewitch

          Ah yes. I forgot about that. Thanks. I'll close it now. Unfortunately I don't have an easy explanation for what I did.

          Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

          K Offline
          K Offline
          k5054
          wrote on last edited by
          #4

          Write an article?

          "A little song, a little dance, a little seltzer down your pants" Chuckles the clown

          H 1 Reply Last reply
          0
          • K k5054

            Write an article?

            "A little song, a little dance, a little seltzer down your pants" Chuckles the clown

            H Offline
            H Offline
            honey the codewitch
            wrote on last edited by
            #5

            I will eventually, but not on this code specifically. The caching isn't very generic or general purpose. The reason being is that it's part of a much larger graphics library I'm create a major version update of. I will be writing an article on that once it's ready, but I have a lot of work to do before then.

            Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

            1 Reply Last reply
            0
            • H honey the codewitch

              I got my font caches working. One is for measuring. The other is for drawing. You can use none, one or both. Expiring is still not as efficient as I'd like, but: You can set the number of bytes, and/or the number of items to limit them to. It's easy to get statistics on them. It's just generally easy to use

              m_font_draw_cache.initialize();
              m_font_measure_cache.initialize();
              m_font_draw_cache.max_entries(21);
              m_font_measure_cache.max_memory_size(512);

              From there you can just pass them to the font's render() and draw() methods as desired. Only wrinkle is you can potentially screw up your caching if you reuse the cache for a different font without the clearing the cache first. I decided to make the caching on a per font basis to give you that level of control. It's embedded so you're dealing in a constrained environment and constantly robbing peter to pay paul. This way you have fine control over trading RAM for speed. In addition, I think I finally got my text measuring code working correctly. I got 3 different kinds of font working with a common base class - 16-bit windows .fon/.fnt files, .VLW anti-aliased raster, and TrueType/OpenType. Also the way I handle drawing it is kinda nice. You can use draw::text<>() and give it the font, or you can use the font's draw() method with a callback in which case I provide you a series of alpha transparency maps, and locations. You can simply draw using my lib's draw::icon<>() function:

              static gfx_result draw_cb(spoint16 location,const const_bitmap>& glyph, void* state) {
              draw_cb_state* st = (draw_cb_state*)state;
              control_surface_type& dst = *(control_surface_type*)st->dst;
              const srect16 r(location,(ssize16)glyph.dimensions());
              //draw::rectangle(dst,r,color_t::blue);
              if(r.intersects(st->clip)) {
              return draw::icon(dst,location,glyph,rgb_pixel<16>(rand()%32,rand()%64,rand()%32));
              } else {
              return gfx_result::success;
              }
              }

              Also I made my text encoding pluggable so I'm not stuck with just latin1 and UTF8.

              Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

              R Offline
              R Offline
              Ron Anders
              wrote on last edited by
              #6

              It's finally fast(er) then?

              H 1 Reply Last reply
              0
              • R Ron Anders

                It's finally fast(er) then?

                H Offline
                H Offline
                honey the codewitch
                wrote on last edited by
                #7

                Fast enough now.

                Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                R E 2 Replies Last reply
                0
                • H honey the codewitch

                  Fast enough now.

                  Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                  R Offline
                  R Offline
                  Ron Anders
                  wrote on last edited by
                  #8

                  Good for you.

                  1 Reply Last reply
                  0
                  • H honey the codewitch

                    Fast enough now.

                    Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                    E Offline
                    E Offline
                    englebart
                    wrote on last edited by
                    #9

                    “enough” The difference between engineering and design!

                    H 1 Reply Last reply
                    0
                    • E englebart

                      “enough” The difference between engineering and design!

                      H Offline
                      H Offline
                      honey the codewitch
                      wrote on last edited by
                      #10

                      It all kind of runs together for me but also I know what you mean. :)

                      Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                      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