Results 1 to 6 of 6

Thread: Transparent text rendering?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Lesser Knight
    Join Date
    Jul 2011
    Posts
    57

    Default Transparent text rendering?

    Hello again.
    Currently it seems that transparent text rendering isn't possible in ClanLib(as of version 2.2 I'm using). I thought it should work by assigning alpha value to the color of the rendered text but it doesn't working.
    I've made my own little dirty fix for my goals but it is ugly and working only for sprite fonts so I really can't suggest it as patch for ClanLib. So it would be nice if someone could implement this feature pretty and correctly.

  2. #2
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    Yes it does work. The "DisplayTarget" example uses it.

    However, it is different for ClanLib 2.2 to 2.3 via a breaking change

    It seems http://clanlib.org/wiki/BreakingChanges is missing the docs.

    It just says

    CL_Font's by default have sub-pixel rendering enabled. To disable it, use CL_FontDescription set_subpixel(false)
    Once you have done that, you can use transparency in fonts

  3. #3
    Lesser Knight
    Join Date
    Jul 2011
    Posts
    57

    Default

    hmm, I'm loading my font via resource, and setting subpixel="false" in resource description isn't working for me. I'm using ClanLib 2.2

  4. #4
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    Oh, you are using ClanLib 2.2, I thought 2.3. Ignore what I said above

    Code:
    CL_Font font(......)
    gc.draw_text(100, 100, "Hello World", CL_Colorf(1.0f, 1.0f, 1.0f, 0.5f));
    Should work. If should draw it at 50% alpha

    I do not know about loading font via a resource.

  5. #5
    Lesser Knight
    Join Date
    Jul 2011
    Posts
    57

    Default

    But what about CL_Font_Sprite?

  6. #6
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    oops, my previous post should have said "font.draw_text(...)".

    This should work (not tested, from memory)

    Code:
    CL_ResourceManager app_resources("ClanLib/Tests/GUI/GUIFont/resources.xml");
    
    CL_Font_Sprite font_sprite(gc, "ClanFont", &app_resources);
    
    font_sprite.draw_text(100, 100, "Hello World", CL_Colorf(1.0f, 0.0f, 0.0f, 0.5f));
    For a red font with 50% transparency

    (ClanLib/Tests/GUI/GUIFont contains a free sprite based font. You do not need to use the GUI, the font can be used anywhere)

Similar Threads

  1. Rendering to textures that has special size
    By Ferrum in forum Official ClanLib SDK Forums
    Replies: 3
    Last Post: 07-10-2011, 07:23 AM
  2. Transparent window?
    By rhurst in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 06-04-2011, 12:04 PM
  3. GUI / Rendering Display
    By Fr3DBr in forum Official ClanLib SDK Forums
    Replies: 4
    Last Post: 08-22-2009, 11:00 PM
  4. The GDI Target Rendering Pixelbuffers
    By rombust in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 02-15-2009, 09:46 PM
  5. Font rendering acceleration in v0.9
    By z42 in forum Official ClanLib SDK Forums
    Replies: 3
    Last Post: 02-18-2008, 12:09 PM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •