chaoticbob / cinder-sdftext Goto Github PK
View Code? Open in Web Editor NEWlibcinder.org
License: SIL Open Font License 1.1
libcinder.org
License: SIL Open Font License 1.1
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).
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
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:
Cinder-SdfText/src/cinder/gl/SdfText.cpp
Line 1914 in 9933c6d
But I am not sure how to fix this.
What does this error mean?
Thanks!
Boris
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.
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!
This is not an issue, but a list of ways to improve efficiency:
Feel free to add more bullet points.
If you use drawString
, instead of drawStringWrapped
, text is always rendered left aligned.
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.
It's also clear that the two lines of text do not have the same height, even though they should roughly be the same.
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
Scale = 3.0
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.
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!
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?
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!
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.