Code Monkey home page Code Monkey logo

richtext's Issues

Consider support for outlines

With one of the newer SFML 2.x version (iirc 2.4) the sf::Text class received outline support. Would be nice if RichText could make use of this. Additionally, setColor has been deprecated in favor of setFillColor in order to differentiate between fill and outline coloring.

Such a change would bumped the minimum required SFML version to something like 2.4.

Printing individual lines

This is more of a question to the developer than an issue per say:
From my current understanding, a RichText is a matrix, two dimensional vector, of Texts. If my belief is true, which it could certainly be false, I should in theory be able to print individual vectors separately. Is there any way to do this?
Say I want all r's to be red, and all b's to be blue, and c's indicate carriage returns. Could I do the following:
rbbbbbrc
rrbbrrrrc
bbbbbbc
... and so on.
I figure since there's a .setCharacterColor, each character must be it's own Text?
Also, since you have a class for each line, I should be able to print lines individually?
Thank you for your time!

Access violation in RichText.hpp?

Here's my error:
Unhandled exception at 0x0FAA49EF (sfml-graphics-d-2.dll) in SFMLGameStates2.exe: 0xC0000005: Access violation reading location 0xCCCCCCD0. occurred
It occurs in RichText.hpp in RichText::Line::draw(), so I don't know what I'm doing wrong.

Adding line break during run time

Hi, excellent work.

I am writing a textbox for my program and all works smoothly except now I want to be able to add a line break to the text when I press the return key. I've tried doing: enteredRaw.push_back("\\n"); when return key is pressed, all elements from enteredRaw get put into a string s and used like thus:

sfe::RichText text(font);
text << sf::Text::Regular << sf::Color::Black <<  s;

however the rendered string is on the same line

image

When checking the output of the string and even what is rendered on screen, both have "\n" in them, so what am I doing wrong?

Define a collection type

Use typedef to define de collection type, so it's easy to change, as Hiura suggested here.

Wouldn't vector be more efficient here (instead of list) ? (Insertion is only at the end so it's should be O(1) most of the time, and > iteration is quite frequent in this class so it should be faster with continuous memory.) I know that at this scale it doesn't really > matter which collection you use but it's a good programming practice.

On the style level, using a typedef std::somecollectionsf::Text CollectionType; would allow changing the collection in one line editing.

"Tail" characters intrude on lines beneath them

This affects the letters which dip beneath the bottom of other characters, such as p or q.
A picture is worth a thousand words, so here is an example of the bug:
(notice how the 'y' in "matey" connects to the 's' in "wish")
screenshot from 2014-03-01 12 27 19

Spaces are eaten

The following code shows an unexpected behavior with spaces : text2 is printed as "ab" instead of "a b". (Well, it seems that GitHub has also a bug with spaces... See picture below to get the idea).

#include "RichText.hpp"
#include <SFML/Graphics.hpp>

int main()
{
    sfe::RichText text;
    text << "a           b";

    sfe::RichText text2;
    text2 << "a           " << "b";

    text.setCharacterSize(25);
    text.setPosition(100, 100);

    text2.setCharacterSize(25);
    text2.setPosition(100, 125);

    sf::RenderWindow window;
    window.create(sf::VideoMode(400, 300), "Rich text");

    while(window.isOpen())
    {
        sf::Event event;
        while(window.pollEvent(event))
        {
            if(event.type == sf::Event::Closed || (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape))
                window.close();
        }

        window.clear();
        window.draw(text);
        window.draw(text2);
        window.display();
    }
}

screenshot

Both lines (i.e., both text and text2) should display the same.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.