add letterSpacing

This commit is contained in:
jrkb 2023-05-02 17:38:23 +02:00
parent 30c1d7f5a2
commit dfe0f4872b
3 changed files with 4 additions and 3 deletions

View file

@ -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 <ofVboMesh> 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 <ofxGPUFont::Font::BoundingBox> bbs;
float advanceY = 0;

View file

@ -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;
}
}

View file

@ -31,6 +31,7 @@ class Layer {
float y = 200;
float rotation = 0;
float fontSize_px = 42;
float letterSpacing = 0;
std::array <float, 4> color = {0, 0, 0, 1};
bool mirror_x = false;
float mirror_x_distance = 0;