@@ -29,6 +29,11 @@ class AsciiEffect {
29
29
let iFontWeight = options [ 'fontWeight' ] || 400 ;
30
30
let fCharScale = options [ 'charScale' ] || 1.0 ;
31
31
32
+ // Font size and line height calculations - declared here so updateVisualSettings can modify them
33
+ let baseFontSize = 2 / fResolution ;
34
+ let strFontSize = ( baseFontSize * fCharScale ) + 'px' ;
35
+ let fLineHeight = ( 2 / fResolution ) ;
36
+
32
37
// Cache for letter spacing calculation optimization
33
38
// Only recalculates when font-related parameters change
34
39
let cachedLetterSpacing = null ;
@@ -126,6 +131,7 @@ class AsciiEffect {
126
131
fResolution = newSettings . resolution ;
127
132
renderer . setPixelRatio ( fResolution ) ;
128
133
needsResolutionUpdate = true ;
134
+ needsFontRecalculation = true ; // Resolution affects font size calculations
129
135
130
136
}
131
137
@@ -151,16 +157,22 @@ class AsciiEffect {
151
157
152
158
}
153
159
154
- if ( needsResolutionUpdate ) {
160
+ // Recalculate font-dependent variables when needed
161
+ if ( needsFontRecalculation ) {
155
162
156
- initAsciiSize ( ) ;
163
+ // Recalculate font size and line height based on new parameters
164
+ baseFontSize = 2 / fResolution ;
165
+ strFontSize = ( baseFontSize * fCharScale ) + 'px' ;
166
+ fLineHeight = ( 2 / fResolution ) ;
167
+
168
+ // Force recalculation of letter spacing since font parameters changed
169
+ cachedLetterSpacing = null ;
157
170
158
171
}
159
172
160
- // Force recalculation of letter spacing since font parameters changed
161
- if ( needsFontRecalculation ) {
173
+ if ( needsResolutionUpdate || needsFontRecalculation ) {
162
174
163
- cachedLetterSpacing = null ;
175
+ initAsciiSize ( ) ;
164
176
165
177
}
166
178
@@ -268,12 +280,6 @@ class AsciiEffect {
268
280
269
281
}
270
282
271
- // Apply character scaling to font size (fully dynamic calculation)
272
- const baseFontSize = 2 / fResolution ;
273
- const strFontSize = ( baseFontSize * fCharScale ) + 'px' ;
274
-
275
- const fLineHeight = ( 2 / fResolution ) ;
276
-
277
283
// Calculate letter spacing for monospace fonts, so that each character fits in a perfect square
278
284
function calculateLetterSpacing ( fontFamily , fontSize , fontWeight , lineHeight ) {
279
285
0 commit comments