Skip to content

Commit

Permalink
the mantissa truncated to 6 digits when svg path scaling is performed (
Browse files Browse the repository at this point in the history
…fontello#9)

also fixed bug that caused repetetive scaling on already scaled value
  • Loading branch information
shmelev committed Feb 21, 2012
1 parent 50f7fae commit 96f09af
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions js/fontomas.js
Expand Up @@ -48,6 +48,7 @@ var myapp = (function () {
preview_icon_sizes: [32, 24, 16],
live_update: true,
fix_edges: true,
scale_precision: 6, // truncate the mantissa when scaling svg paths
basic_latin: {
str: "", // precalculated by initGlobals()
begin: 33,
Expand Down Expand Up @@ -914,7 +915,7 @@ var myapp = (function () {
console.log("undefined myglyphs[", g_id, "]");
return;
}
var g = $(myglyphs[g_id].dom_node);
var g = $(myglyphs[g_id].dom_node).clone();
g.attr("unicode", unicode);
if (myglyphs[g_id].units_per_em != cfg.output.units_per_em) {
var scale = cfg.output.units_per_em
Expand All @@ -929,8 +930,9 @@ var myapp = (function () {
};

var scalePath = function (path, scale) {
path = path.replace(/(-?\d*\.?\d*(?:e[\-+]?\d+)?)/g, function (num) {
num = parseFloat(num) * scale;
path = path.replace(/(-?\d*\.?\d*(?:e[\-+]?\d+)?)/ig, function (num) {
num = (parseFloat(num) * scale).toPrecision(cfg.scale_precision);
num = parseFloat(num); // extra parseFloat to strip trailing zeros
return isNaN(num) ? "" : num;
});
return path;
Expand Down

0 comments on commit 96f09af

Please sign in to comment.