Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure locale invariant number formatting #103

Merged
merged 2 commits into from
Oct 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ import com.jzbrooks.vgo.core.graphic.command.VerticalLineTo
import com.jzbrooks.vgo.core.util.math.Point
import java.math.RoundingMode
import java.text.DecimalFormat
import java.text.DecimalFormatSymbols
import kotlin.math.sign

class ScalableVectorGraphicCommandPrinter(
@@ -28,6 +29,10 @@ class ScalableVectorGraphicCommandPrinter(
isGroupingUsed = false
roundingMode = RoundingMode.HALF_UP
minimumIntegerDigits = 0
decimalFormatSymbols =
DecimalFormatSymbols().apply {
decimalSeparator = '.'
}
}

override fun print(command: Command): String =
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ import org.w3c.dom.Document
import java.io.OutputStream
import java.math.RoundingMode
import java.text.DecimalFormat
import java.text.DecimalFormatSymbols
import java.util.Collections.emptySet
import javax.xml.parsers.DocumentBuilderFactory
import javax.xml.transform.OutputKeys
@@ -30,7 +31,12 @@ class ScalableVectorGraphicWriter(
maximumFractionDigits = 2 // todo: parameterize?
minimumIntegerDigits = 0
isDecimalSeparatorAlwaysShown = false
isGroupingUsed = false
roundingMode = RoundingMode.HALF_UP
decimalFormatSymbols =
DecimalFormatSymbols().apply {
decimalSeparator = '.'
}
}

override fun write(
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ import com.jzbrooks.vgo.core.graphic.command.VerticalLineTo
import com.jzbrooks.vgo.core.util.math.Point
import java.math.RoundingMode
import java.text.DecimalFormat
import java.text.DecimalFormatSymbols
import kotlin.math.sign

class VectorDrawableCommandPrinter(
@@ -27,6 +28,10 @@ class VectorDrawableCommandPrinter(
isDecimalSeparatorAlwaysShown = false
isGroupingUsed = false
roundingMode = RoundingMode.HALF_UP
decimalFormatSymbols =
DecimalFormatSymbols().apply {
decimalSeparator = '.'
}
}

override fun print(command: Command): String =
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ import org.w3c.dom.Document
import java.io.OutputStream
import java.math.RoundingMode
import java.text.DecimalFormat
import java.text.DecimalFormatSymbols
import java.util.Collections.emptySet
import javax.xml.parsers.DocumentBuilderFactory
import javax.xml.transform.OutputKeys
@@ -32,7 +33,12 @@ class VectorDrawableWriter(
maximumFractionDigits = 2 // todo: parameterize?
minimumIntegerDigits = 0
isDecimalSeparatorAlwaysShown = false
isGroupingUsed = false
roundingMode = RoundingMode.HALF_UP
decimalFormatSymbols =
DecimalFormatSymbols().apply {
decimalSeparator = '.'
}
}

override fun write(