File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
server/api/registry/badge/[type] Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -31,8 +31,13 @@ const COLORS = {
3131 white : '#ffffff' ,
3232}
3333
34- function measureTextWidth ( text : string ) : number {
35- const charWidth = 7
34+ const DEFAULT_CHAR_WIDTH = 7
35+ const CHARS_WIDTH = {
36+ engines : 5.5 ,
37+ }
38+
39+ function measureTextWidth ( text : string , charWidth ?: number ) : number {
40+ charWidth ??= DEFAULT_CHAR_WIDTH
3641 const paddingX = 8
3742 return Math . max ( 40 , Math . round ( text . length * charWidth ) + paddingX * 2 )
3843}
@@ -288,7 +293,10 @@ export default defineCachedEventHandler(
288293 const finalLabelColor = rawLabelColor ?. startsWith ( '#' ) ? rawLabelColor : `#${ rawLabelColor } `
289294
290295 const leftWidth = measureTextWidth ( finalLabel )
291- const rightWidth = measureTextWidth ( finalValue )
296+ const rightWidth = measureTextWidth (
297+ finalValue ,
298+ CHARS_WIDTH [ strategyKey as keyof typeof CHARS_WIDTH ] ,
299+ )
292300 const totalWidth = leftWidth + rightWidth
293301 const height = 20
294302
You can’t perform that action at this time.
0 commit comments