GithubHelp home page GithubHelp logo

sfmltextaline's Introduction

Sfml Text "Aline"

Alignable Multi-line SFML Text

Currently a work-in-progress and is in a useable state with some other features still to come.

It is a single-object multi-line text object for SFML.
It is similar to SFML's own sf::Text object but has some extra features (but doesn't include some of sf::Text's features as yet - see below).

Features:

  • Lines are alignable globally (throughout the entire object) to the left, centre, right and justified (distributed/separated characters or spread through whitespace only).
  • Individual lines can also be customised (including having their own alignment, colour, positional offset, bold and italic)
  • Positional offset is any offset that a single line can be given (allowing each line to be moved around freely - after alignments)
  • Can be assigned an sf::Text to reproduce it automatically (within its own features - so far)
  • The length of a tab character can be customised to any set number of spaces
  • Kerning is applied
  • Some text styles (bold and italic - italic shear amount is customisable)
  • Letter spacing
  • Line spacing
  • Bounds
  • A minimum width can be specified that allows for a virtual right side margin when aligning

Planned - but currently missing - features:

  • Other text styles (underline and strike-through)
  • Outline

Note that these missing features are available in the original sf::Text but yet included here.

You now use just the shortcut class name Aline instead of its full name SfmlTextAline. If you would like to cancel the shortcut from being created, define SFMLTEXTALINE_NO_CLASS_SHORTCUT before including the class.

The alignment enum class has been renamed to make it more convenient. It is now just Alignment instead of LineAlignment.

So, you can access the alignment enum class by simply using it like this: Aline::Alignment::Center.

sfmltextaline's People

Contributors

hapaxia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

xparq

sfmltextaline's Issues

Warning: Unsafe access to vectors

m_lineAlignments[lineIndex] = lineAlignment;

The API should provide some getLineCount() so the programmer can check whether they are trying to access a valid line.

Also it is symptomatic to C++ APIs to do unchecked accesses to arrays in the name of "speed", making it harder to write safe programs. Consider using at() method when accessing arrays, it does the boundary check and throws an exception if the index is out of bounds. If you wish, you could then do also unchecked versions of each method (like SetLineAlignmentUnsafe which can be clearly marked as noexcept that would keep using the operator[]).

It might sound like a nitpick, but realistically, who is going to change line alignment sixty times per second all of the time vs the number of people who will forget to check whether they are using a valid index?

Syntax error: stray/leftover comment-close

Dear Maestro! If I'm correct, there's a syntax error (a stray comment-closing */) introduced in fb9039e (0.2) in the header.
I've created a change request (#5) for it (sorry, I'm kinda reluctant to call it "pull request" :) ), basically to practice it (I'm not a fervent collaborator, you see), but you may prefer issues instead, so here.

(The interesting puzzle to me, however, is this: I have a mild case of ADD, so things like this are especially familiar and perfectly normal to me, and I'd have never even noticed it, only the compiler did. But how did this survive not one, but two (nontrivial) commits with your setup? And then add #1 to the plot. I mean you must have run it somehow, I guess. Please, I can't sleep until this mystery is solved! :)Thx!)

Suggestion: Naming

Hey there! I like your project, multiline texts are cool and there are many interesting features that could be added (like formatting a single line text into multiple lines within a given frame). I could even help you with that (for example CI and packaging, I have some experience, you can look at https://github/nerudaj/dgm-lib.

Anyways, I have some usability suggestions with regards to naming. SfmlTextAline is a horrible name to type in the editor and it doesn't really capture what the class is doing. Calling it simply MultilineText would make it much clearer. Also, it would help immensely if the class was in its own namespace sfmt for example, standing for "Sfml Multiline Text".

Having your own namespace would allow you to extract the LineAlignment enum from the SfmlTextAline class, so the users don't have to type SfmlTextAline::LineAlignment::Left all of the time (or create extra using directives).

It's just a suggestion, however I think it would go a long way in improving user experience with your library (and it would allow extra classes with interesting behaviour in the future).

Add Justification Alignment

Add option to allow the use of justification.

Whether a line's whitespace would be stretched by word, by space, by either or by a controlled mixture of both can still be considered.

Round vertex coordinates on Center

Non-integer drawing coordinates cause unwanted softening (even with anti-aliasing set to 0) of fine structures, like thin lines, which is especially noticeable with rendering text, giving it an uneven appearance.

Without rounding:

image

With rounding:

image

-> xparq/SfmlTextAline@a6b32d6

(Other places where coordinates may also become fractional would need checking! I'm not familiar with the code yet, not sure if there's anything else.)

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.