Skip to content

Commit

Permalink
Enhance alignment method
Browse files Browse the repository at this point in the history
  • Loading branch information
dy committed Jun 9, 2017
1 parent 9aff350 commit 5a5a635
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,17 @@ function atlas(options) {

//hack tinysdf char-draw method
if (fit) {
scale = h*(fit) / (props.radius*h*2)
var fitRatio = fit
if (Array.isArray(fit)) {
fitRatio = fit[i]
}
var vert = (props.bounds[3]-props.bounds[1])*.5
var horiz = (props.bounds[2]-props.bounds[0])*.5
var maxSide = Math.max( vert , horiz )
var diag = Math.sqrt(vert*vert + horiz*horiz)
var maxDist = props.radius*.333 + maxSide*.333 + diag*.333

scale = h*fitRatio / (maxDist*h*2)
sdf.ctx.font = size*scale + 'px ' + family;
}
else {
Expand Down

1 comment on commit 5a5a635

@etpinard
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥇

Please sign in to comment.