Skip to content

Commit

Permalink
fixed monospaced fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
kulsoom2003 authored and noelwelsh committed Aug 31, 2024
1 parent 9f057c0 commit 7444aac
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
6 changes: 3 additions & 3 deletions svg/shared/src/main/scala/doodle/svg/algebra/Svg.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import cats.effect.IO
import doodle.algebra.Picture
import doodle.algebra.generic.Fill
import doodle.algebra.generic.Stroke
import doodle.core.*
import doodle.core._
import doodle.core.font.FontSize.Points
import doodle.core.font.*
import doodle.core.font._
import doodle.svg.effect.Size

import scala.collection.mutable
Expand Down Expand Up @@ -116,7 +116,7 @@ trait SvgModule { self: Base =>
font.family match {
case FontFamily.Serif => "serif"
case FontFamily.SansSerif => "sans-serif"
case FontFamily.Monospaced => "monospaced"
case FontFamily.Monospaced => "monospace"
case FontFamily.Named(name) => name
}

Expand Down
17 changes: 15 additions & 2 deletions svg/shared/src/test/scala/doodle/svg/effect/SvgSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ package doodle
package svg
package effect

import doodle.algebra.generic.*
import doodle.core.*
import doodle.algebra.generic._
import doodle.core._
import doodle.language.Basic
import munit.CatsEffectSuite

Expand Down Expand Up @@ -82,6 +82,19 @@ class SvgSpec
)
}

test("monospaced fonts render correctly") {
import doodle.core.font.Font
import doodle.core.font.FontFamily

assertEquals(
Svg
.textTag("abc", Font.defaultSansSerif.family(FontFamily.monospaced))
.toString,
"""<text font-family="monospace" style="font-style: normal;" font-size="12pt" font-weight="normal">abc</text>"""
)

}

test("paths of points render correctly") {
val path1 = "M 5,5 L 10,10 L 20,20 "
val path2 = "M 5,5 L 10,10 L 20,20 Z"
Expand Down

0 comments on commit 7444aac

Please sign in to comment.