From ec7dc313549a10c83c8b03cec22f4221b20cc143 Mon Sep 17 00:00:00 2001 From: Jennifer Presto Date: Fri, 16 Mar 2018 11:40:29 -0400 Subject: [PATCH] use sharper filters on rendering and position text to full-pixel position when centering and justifying --- src/txt/TextLayout.cpp | 4 ++-- src/txt/gl/TextureRenderer.cpp | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/txt/TextLayout.cpp b/src/txt/TextLayout.cpp index 953795e..b198b88 100644 --- a/src/txt/TextLayout.cpp +++ b/src/txt/TextLayout.cpp @@ -392,7 +392,7 @@ namespace txt // Align in frame (if necessary) for( int i = 0; i < mLines.size(); i++ ) { - ci::app::console() << mLines[i].width << std::endl; + //ci::app::console() << mLines[i].width << std::endl; float remainingWidth = mSize.x - mLines[i].width; switch( mAlignment ) { @@ -401,7 +401,7 @@ namespace txt case CENTER: case RIGHT: { - float xOffset = ( mAlignment == CENTER ) ? remainingWidth / 2.f : remainingWidth; + int xOffset = ( mAlignment == CENTER ) ? remainingWidth / 2.f : remainingWidth; for( auto& run : mLines[i].runs ) { for( auto& glyph : run.glyphs ) { diff --git a/src/txt/gl/TextureRenderer.cpp b/src/txt/gl/TextureRenderer.cpp index 9db332c..740c32f 100644 --- a/src/txt/gl/TextureRenderer.cpp +++ b/src/txt/gl/TextureRenderer.cpp @@ -95,7 +95,11 @@ namespace txt // Allocate ci::gl::Fbo::Format fboFormat; - fboFormat.setColorTextureFormat( ci::gl::Texture2d::Format().internalFormat( GL_RGBA32F ) ); + ci::gl::Texture::Format texFormat; + texFormat.setMagFilter( GL_NEAREST ); + texFormat.setMinFilter( GL_LINEAR ); + //fboFormat.setColorTextureFormat( ci::gl::Texture2d::Format().internalFormat( GL_RGBA32F ) ); + fboFormat.setColorTextureFormat( texFormat ); fboFormat.setSamples( 1 ); mFbo = ci::gl::Fbo::create( fboSize, fboSize, fboFormat );