From dfe0f4872bf8846e02c9c777075c45d8066ad975 Mon Sep 17 00:00:00 2001 From: themancalledjakob Date: Tue, 2 May 2023 17:38:23 +0200 Subject: [PATCH] add letterSpacing --- src/GPUFontAtlasLayerCombo.cpp | 3 --- src/GPUFontLayer.cpp | 3 +++ src/Layer.h | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/GPUFontAtlasLayerCombo.cpp b/src/GPUFontAtlasLayerCombo.cpp index bc6588f..ce740f6 100644 --- a/src/GPUFontAtlasLayerCombo.cpp +++ b/src/GPUFontAtlasLayerCombo.cpp @@ -165,7 +165,6 @@ void GPUFontAtlasLayerCombo::draw(int width, int height){ //antiAliasingWindowSize = ofMap(ofGetMouseX(), 0, ofGetWidth(), 1, 3); //enableSuperSamplingAntiAliasing = ofGetMouseY() > ofGetHeight() / 2; - float superLineHeight = 0; if(font){ OFX_PROFILER_SCOPE("draw font"); fontShaderProgram = fontShader->program; @@ -202,9 +201,7 @@ void GPUFontAtlasLayerCombo::draw(int width, int height){ std::vector outerBoundingBoxes; for(const auto & layer : layers){ OFX_PROFILER_SCOPE("draw layer"); - float lineHeight = font->getLineHeight(layer->getProps().fontSize_px); float ascender = font->getAscender(layer->getProps().fontSize_px); - superLineHeight = lineHeight; ofxGPUFont::Font::BoundingBox bb; std::vector bbs; float advanceY = 0; diff --git a/src/GPUFontLayer.cpp b/src/GPUFontLayer.cpp index 6a63b74..17f186a 100644 --- a/src/GPUFontLayer.cpp +++ b/src/GPUFontLayer.cpp @@ -95,6 +95,7 @@ void GPUFontLayer::setProps(const Props & props){ glyphAppearance.charcode = glyphIdentity.charcode; glyphAppearance.color = vProps.color; glyphAppearance.fontSize_px = vProps.fontSize_px; + glyphAppearance.letterSpacing = vProps.letterSpacing; for(const auto & fv : vProps.fontVariations){ glyphIdentity.coords.push_back( std::move(ofxGPUFont::float2f16dot16(round(fv.value * 0.1) * 10)) // convert to FT @@ -109,11 +110,13 @@ void GPUFontLayer::setProps(const Props & props){ } if(!setAppearanceAlready && (lastProps.fontSize_px != props.fontSize_px + || lastProps.letterSpacing != props.letterSpacing || lastProps.color != props.color)){ for(int i = 0; i < props.text.size(); i++){ const Props & vProps = propsBufferEmpty ? props : getProps(i * props.letterDelay); ofxGPUFont::GlyphAppearance & glyphAppearance = variationTextAppearance[i]; glyphAppearance.fontSize_px = vProps.fontSize_px; + glyphAppearance.letterSpacing = vProps.letterSpacing; variationTextAppearance[i].color = vProps.color; } } diff --git a/src/Layer.h b/src/Layer.h index 5b9b235..11141f1 100644 --- a/src/Layer.h +++ b/src/Layer.h @@ -31,6 +31,7 @@ class Layer { float y = 200; float rotation = 0; float fontSize_px = 42; + float letterSpacing = 0; std::array color = {0, 0, 0, 1}; bool mirror_x = false; float mirror_x_distance = 0;