Code Monkey home page Code Monkey logo

cinder-sdftext's People

Contributors

collingreen avatar haing avatar petroskataras avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

cinder-sdftext's Issues

Kerning / positioning is wobbly.

I am sure this is on your TODO list, but text kerning and positioning is not precise enough, leading to low quality text layout. This is especially apparent when using small font sizes. Fonts in the following image are scaled up or down to make them appear roughly the same size, but the font size used to create the mesh is different.

sdf_layout

It's also clear that the two lines of text do not have the same height, even though they should roughly be the same.

Font size incorrect when loading from binary.

When I create a font with a specific size (e.g. 12) and then create the SdfText by loading a binary SDFT file, the size of the font is the size stored in the binary file, not 12.

Build Details

Hi,

I am new to Cinder and really want to test this library out.

How do I add Freetype to sources in Visual Studio? When I open the project it looks for freetype alongside gl and msdfgen. But none of those files are available.

I downloaded the latest freetype source, but don't see anything in there that matches the source structure.

I also tried installing the freetype package in Nuget, but I am still getting not found build errors.

Thank you for this awesome lib!

Feature request: use bin packing instead of fixed spacing.

More glyphs would fit on a single texture if bin packing were used. For this kind of stuff, offline bin packing can be used when adding many characters at once (or when doing an optimization step) and online bin packing can be used when adding one character at a time.

I happen to have a bin packing implementation ready for use, let me know if you're interested. It's not perfect and starts to slow down when packing >1000 glyphs, but it's a start. This will complicate texture creation, but only marginally.

-Paul

Sample does not correctly handle font style.

Not sure if this is an issue with the sample or with FreeType, but it seems the font style (bold, italic, etc.) is not always applied correctly. For instance, compare Arial to Arial Bold or Arial Italic: there is no difference.

Font scaling and getAscent()/getDescent()

Hello, I'm trying to fit SdfText into an existing text layout framework and I'm running into trouble getting the appropriate sizes of text. Namely, I need the ascent and descent info for the font at a desired font size. However, despite creating the SdfText object from a SdfText::Font object created at a larger size, the ascent and descent data are still the same.

I have also tried looking at both SdfText::getAscent() and SdfText::Font::getAscent() but these also return the same values regardless of how large or small the font is created.

I saw SdfText::measureString() returns the proper size so I checked out the measureStringImpl() method and found these lines curious:

	const auto& sdfScale = mTextureAtlases->mSdfScale;
	const auto& sdfPadding = mTextureAtlases->mSdfPadding;
	const vec2 fontRenderScale = vec2( mFont.getSize() ) / ( 32.0f * mTextureAtlases->mSdfScale );
	const vec2 fontOriginScale = vec2( mFont.getSize() ) / 32.0f;
	const float scale = options.getScale();

Can you shed some light on all the different scaling going on under the hood? Are the different getAscent()/getDescent() methods supposed to return the same value?

Thanks in advance! Very excited to pull this great block into our framework!

Possible for 3d manipulation of characters/glyphs?

Is it possible to position each glyph individually in 3d? Right now I'm able to manually position each character in 2d for text effects using getGlyphPlacementsWrapped():

mGlyphMap = mSdfText->getGlyphPlacementsWrapped(text, bounds, drawOptions);

for (auto& pair : mGlyphMap) {
    pair.second = ci::vec2(ci::randFloat(0, 800), ci::randFloat(0, 800));
}

mSdfText->drawGlyphs(mGlyphMap, ci::vec2(50, 50), drawOptions);

But there's no version of the GlyphPlacements that uses ci::vec2, only ci::vec3. I also thought about just manually keeping track of z position in a separate std::vector<float> and manually calling gl::translate() on a glyph-by-glyph basis, but there's no way to draw each glyph separately either.

It looks like it's not possible to do this with the current block, so I think I'm about to go down the road of implementing it myself -- what would be the best way to approach this? I'm happy to do the dev and submit a PR, but want to make sure I'm approaching it in the smartest way before I go down that path...

thanks!

Efficiency

This is not an issue, but a list of ways to improve efficiency:

  • Using a texture size of 512 or smaller may require more than one texture for all glyphs. If more than one texture is used, the number of draw calls to render the text increases. This leads to a lower frame rate. Instead of creating one draw call per texture, consider using an actual texture atlas, so that we can still render all text with single draw call.
  • Bin-packing will increase the number of glyphs that fit on a single texture. I have made good progress with it. One step of the algorithm does a brute force intersection test that could be improved. It helps to reduce the texture size to 512, because this will lower the number of intersection tests considerably.
  • The MSDFGEN algrotihm could potentially run on a separate thread, as long as access to FreeType is made thread-safe. I've tried this and it drastically improves performance. I used one thread per full texture, which rendered all glyphs assigned to that texture. The texture was also uploaded using a Pbo on a shared context.

Feel free to add more bullet points.

Scaling individual runs?

Hi,

I want to be able to scale the a Run after its been created. I dont want to destroy it and create it in the new scale. This seems wasteful and slow. I would rather keep the original run and change the scale in DrawOptions. The scale in Run::Options does not seem to be used anywhere.

I have added a non-const getOptions() function to Run so that i can call Run->getOptions()->setDrawScale(new scale) .

I can now scale a Run after i have created (unless you have already implemented this another way).
This works fine for text that does not have any line breaks(i.e does not fit on one line). But for text that does have line breaks the space between the lines grows exponentially. Instead of being based on the new scaled height of the text.

So how to scale individual runs that have line breaks?

Scale = 1.0

unscaled

Scale = 3.0

scaled

Feature request: jobify sdf generation.

Would be nice if creation of the SDF for a single glyph is done on a separate thread, then copied to the texture using a quick blit. If you'd use jobs (task based system), you could optionally wait for all glyphs to be rendered and all cores could help, speeding things up considerably. Jobs aren't easy to program, though, but I have a nice C++14 implementation lying around that could be a great addition to Cinder in the future. One can dream. Simple threads will work, too, of course.

Crash if glyph is missing.

I tried to render Japanese text using Arial, but the application crashed here and here.

It could not find the glyph index, so iter becomes end. To me, it looks like missing glyphs are not automatically added to the texture yet.

PNG Ident not found

Hey,

After a rebuild and update of all my blocks I am getting:

|fatal  | cinder::app::AppBase::executeLaunch[192] Uncaught exception, type: class cinder::Exception, what: PNG ident not found

I traced it to the file here:

throw ci::Exception( "PNG ident not found" );

But I am not sure how to fix this.
What does this error mean?

Thanks!
Boris

Feature request: save and load fonts.

Just ignore me if you had enough :) , but it would be great if we could save and load fonts, to speed up the generation of the textures. Before saving, an optimization might be applied to minimize texture space (e.g. use bin packing, see issue #4).

'ft2build.h' file not found

Running into this error on OS X:

CompileC /Users/andrew/Library/Developer/Xcode/DerivedData/Cinder-SdfText-ckvvprrqdidxdacgbmjvneplksvf/Build/Intermediates/Cinder-SdfText.build/Debug/cinder-sdftext-macosx.build/Objects-normal/x86_64/ftlcdfil.o /Users/andrew/projects/Cinder/src/freetype/base/ftlcdfil.c normal x86_64 c com.apple.compilers.llvm.clang.1_0.compiler
    cd /Users/andrew/projects/Cinder/blocks/Cinder-SdfText/xcode
    export LANG=en_US.US-ASCII
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c -arch x86_64 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wunreachable-code -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -mmacosx-version-min=10.8 -g -Wno-sign-conversion -Wno-infinite-recursion -iquote /Users/andrew/Library/Developer/Xcode/DerivedData/Cinder-SdfText-ckvvprrqdidxdacgbmjvneplksvf/Build/Intermediates/Cinder-SdfText.build/Debug/cinder-sdftext-macosx.build/cinder-sdftext-generated-files.hmap -I/Users/andrew/Library/Developer/Xcode/DerivedData/Cinder-SdfText-ckvvprrqdidxdacgbmjvneplksvf/Build/Intermediates/Cinder-SdfText.build/Debug/cinder-sdftext-macosx.build/cinder-sdftext-own-target-headers.hmap -I/Users/andrew/Library/Developer/Xcode/DerivedData/Cinder-SdfText-ckvvprrqdidxdacgbmjvneplksvf/Build/Intermediates/Cinder-SdfText.build/Debug/cinder-sdftext-macosx.build/cinder-sdftext-all-target-headers.hmap -iquote /Users/andrew/Library/Developer/Xcode/DerivedData/Cinder-SdfText-ckvvprrqdidxdacgbmjvneplksvf/Build/Intermediates/Cinder-SdfText.build/Debug/cinder-sdftext-macosx.build/cinder-sdftext-project-headers.hmap -iquote../../../include -iquote../include -I/Users/andrew/projects/Cinder/blocks/Cinder-SdfText/lib/macosx/Debug/include -I../../../include -I../include -I/Users/andrew/Library/Developer/Xcode/DerivedData/Cinder-SdfText-ckvvprrqdidxdacgbmjvneplksvf/Build/Intermediates/Cinder-SdfText.build/Debug/cinder-sdftext-macosx.build/DerivedSources/x86_64 -I/Users/andrew/Library/Developer/Xcode/DerivedData/Cinder-SdfText-ckvvprrqdidxdacgbmjvneplksvf/Build/Intermediates/Cinder-SdfText.build/Debug/cinder-sdftext-macosx.build/DerivedSources -F/Users/andrew/projects/Cinder/blocks/Cinder-SdfText/lib/macosx/Debug -DFT2_BUILD_LIBRARY -MMD -MT dependencies -MF /Users/andrew/Library/Developer/Xcode/DerivedData/Cinder-SdfText-ckvvprrqdidxdacgbmjvneplksvf/Build/Intermediates/Cinder-SdfText.build/Debug/cinder-sdftext-macosx.build/Objects-normal/x86_64/ftlcdfil.d --serialize-diagnostics /Users/andrew/Library/Developer/Xcode/DerivedData/Cinder-SdfText-ckvvprrqdidxdacgbmjvneplksvf/Build/Intermediates/Cinder-SdfText.build/Debug/cinder-sdftext-macosx.build/Objects-normal/x86_64/ftlcdfil.dia -c /Users/andrew/projects/Cinder/src/freetype/base/ftlcdfil.c -o /Users/andrew/Library/Developer/Xcode/DerivedData/Cinder-SdfText-ckvvprrqdidxdacgbmjvneplksvf/Build/Intermediates/Cinder-SdfText.build/Debug/cinder-sdftext-macosx.build/Objects-normal/x86_64/ftlcdfil.o

/Users/andrew/projects/Cinder/src/freetype/base/ftlcdfil.c:19:10: fatal error: 'ft2build.h' file not found
#include <ft2build.h>
         ^
1 error generated.

I've got freetype2 installed via homebrew so I'm not sure if that's conflicting somehow?

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.