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

#391 Improve text displaying #604

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
66 changes: 66 additions & 0 deletions Macaw.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

22 changes: 21 additions & 1 deletion MacawTests/MacawSVGTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class MacawSVGTests: XCTestCase {

private let testFolderName = "MacawTestOutputData"
private let shouldComparePNGImages = true
private let multipleTestsWillRun = false
private let multipleTestsWillRun = true
private let shouldSaveFaildedTestImage = false

override func setUp() {
Expand Down Expand Up @@ -814,6 +814,26 @@ class MacawSVGTests: XCTestCase {
validateJSON("masking-mask-02-f-manual")
}

func testTextIntro01() {
validateJSON("text-intro-01-t-manual")
}

func testTextIntro02() {
validateJSON("text-intro-02-b-manual")
}

func testTextIntro04() {
validateJSON("text-intro-04-t-manual")
}

func testTextIntro09() {
validateJSON("text-intro-09-b-manual")
}

func testTextIntro11() {
validateJSON("text-intro-11-t-manual")
}

func getImage(from svgName: String) -> MImage {
let bundle = Bundle(for: type(of: TestUtils()))
do {
Expand Down
16 changes: 16 additions & 0 deletions MacawTests/SceneSerialization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ class NodeSerializer {
if let baselineString = dictionary["baseline"] as? String {
text.baseline = baselineForString(baselineString)
}
if let directionString = dictionary["direction"] as? String{
text.direction = directionForString(directionString)
}

return text
}
Expand Down Expand Up @@ -174,6 +177,9 @@ extension Text: Serializable {
}
result["align"] = align.toString()
result["baseline"] = "\(baseline)"
if direction != .lre {
result["direction"] = "\(direction)"
}
return result
}
}
Expand Down Expand Up @@ -629,3 +635,13 @@ fileprivate func baselineForString(_ string: String) -> Baseline {
default: return .top
}
}

fileprivate func directionForString(_ string: String) -> Direction {
switch string {
case "lre": return .lre
case "lro": return .lro
case "rle": return .rle
case "rlo": return .rlo
default: return .lre
}
}
Binary file added MacawTests/png/text-intro-01-t-manual.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MacawTests/png/text-intro-02-b-manual.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MacawTests/png/text-intro-04-t-manual.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MacawTests/png/text-intro-09-b-manual.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MacawTests/png/text-intro-11-t-manual.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 9 additions & 9 deletions MacawTests/w3c-test-suite.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ There are [521 SVG tests](https://github.com/web-platform-tests/wpt/tree/master/
* [switch/object](https://www.w3.org/TR/SVG11/backward.html) (7)

The rest 306 tests can be split into following categories:
* 38.6% passed (118)
* 40.2% passed (123)
* 14.1% filters (43) [#390](https://github.com/exyte/Macaw/issues/390)
* 8.5% images (26) [wpt issue](https://github.com/web-platform-tests/wpt/issues/11178)
* 2.6% markers (8) [#392](https://github.com/exyte/Macaw/issues/392)
* 20.6% text (63) [#391](https://github.com/exyte/Macaw/issues/391)
* 15.7% blocked by issues (48)
* 19.0% text (58) [#391](https://github.com/exyte/Macaw/issues/391)
* 14.1% blocked by issues (43)

Status of each test:

Expand Down Expand Up @@ -289,23 +289,23 @@ Status of each test:
|[text-bidi-01-t-manual](w3cSVGTests/text-bidi-01-t-manual.svg) | [#391](https://github.com/exyte/Macaw/issues/391) |
|[text-deco-01-b-manual](w3cSVGTests/text-deco-01-b-manual.svg) | [#391](https://github.com/exyte/Macaw/issues/391) |
|[text-fonts-01-t-manual](w3cSVGTests/text-fonts-01-t-manual.svg) | ✅ |
|[text-fonts-02-t-manual](w3cSVGTests/text-fonts-02-t-manual.svg) | ✅ |
|[text-fonts-02-t-manual](w3cSVGTests/text-fonts-02-t-manual.svg) | ✅ |
|[text-fonts-03-t-manual](w3cSVGTests/text-fonts-03-t-manual.svg) | [#391](https://github.com/exyte/Macaw/issues/391) |
|[text-fonts-04-t-manual](w3cSVGTests/text-fonts-04-t-manual.svg) | [#391](https://github.com/exyte/Macaw/issues/391) |
|[text-fonts-05-f-manual](w3cSVGTests/text-fonts-05-f-manual.svg) | [#391](https://github.com/exyte/Macaw/issues/391) |
|[text-fonts-202-t-manual](w3cSVGTests/text-fonts-202-t-manual.svg) | [#391](https://github.com/exyte/Macaw/issues/391) |
|[text-fonts-203-t-manual](w3cSVGTests/text-fonts-203-t-manual.svg) | [#391](https://github.com/exyte/Macaw/issues/391) |
|[text-fonts-204-t-manual](w3cSVGTests/text-fonts-204-t-manual.svg) | [#391](https://github.com/exyte/Macaw/issues/391) |
|[text-intro-01-t-manual](w3cSVGTests/text-intro-01-t-manual.svg) | [#391](https://github.com/exyte/Macaw/issues/391) |
|[text-intro-02-b-manual](w3cSVGTests/text-intro-02-b-manual.svg) | [#391](https://github.com/exyte/Macaw/issues/391) |
|[text-intro-01-t-manual](w3cSVGTests/text-intro-01-t-manual.svg) | |
|[text-intro-02-b-manual](w3cSVGTests/text-intro-02-b-manual.svg) | |
|[text-intro-03-b-manual](w3cSVGTests/text-intro-03-b-manual.svg) | [#391](https://github.com/exyte/Macaw/issues/391) |
|[text-intro-04-t-manual](w3cSVGTests/text-intro-04-t-manual.svg) | [#391](https://github.com/exyte/Macaw/issues/391) |
|[text-intro-04-t-manual](w3cSVGTests/text-intro-04-t-manual.svg) | |
|[text-intro-05-t-manual](w3cSVGTests/text-intro-05-t-manual.svg) | [#391](https://github.com/exyte/Macaw/issues/391) |
|[text-intro-06-t-manual](w3cSVGTests/text-intro-06-t-manual.svg) | [#391](https://github.com/exyte/Macaw/issues/391) |
|[text-intro-07-t-manual](w3cSVGTests/text-intro-07-t-manual.svg) | [#391](https://github.com/exyte/Macaw/issues/391) |
|[text-intro-09-b-manual](w3cSVGTests/text-intro-09-b-manual.svg) | [#391](https://github.com/exyte/Macaw/issues/391) |
|[text-intro-09-b-manual](w3cSVGTests/text-intro-09-b-manual.svg) | |
|[text-intro-10-f-manual](w3cSVGTests/text-intro-10-f-manual.svg) | [#391](https://github.com/exyte/Macaw/issues/391) |
|[text-intro-11-t-manual](w3cSVGTests/text-intro-11-t-manual.svg) | [#391](https://github.com/exyte/Macaw/issues/391) |
|[text-intro-11-t-manual](w3cSVGTests/text-intro-11-t-manual.svg) | |
|[text-intro-12-t-manual](w3cSVGTests/text-intro-12-t-manual.svg) | [#391](https://github.com/exyte/Macaw/issues/391) |
|[text-path-01-b-manual](w3cSVGTests/text-path-01-b-manual.svg) | [#391](https://github.com/exyte/Macaw/issues/391) |
|[text-path-02-b-manual](w3cSVGTests/text-path-02-b-manual.svg) | [#391](https://github.com/exyte/Macaw/issues/391) |
Expand Down
212 changes: 212 additions & 0 deletions MacawTests/w3cSVGTests/text-intro-01-t-manual.reference
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
{
"contents" : [
{
"contents" : [
{
"align" : "min",
"baseline" : "bottom",
"fill" : {
"type" : "Color",
"val" : 255
},
"font" : {
"name" : "SVGFreeSansASCII,sans-serif",
"size" : 40,
"weight" : "normal"
},
"node" : "Text",
"place" : "1, 0, 0, 1, 5, 40",
"text" : "Test left-to-right text."
},
{
"contents" : [
{
"align" : "min",
"baseline" : "bottom",
"fill" : {
"type" : "Color",
"val" : 0
},
"font" : {
"name" : "MissingInAction, Georgia, 'Arial Hebrew', 'Arial Unicode MS', 'LucidaSansUnicode','MS-Gothic'",
"size" : 17,
"weight" : "normal"
},
"node" : "Text",
"place" : "1, 0, 0, 1, 10, 75",
"text" : "Polish: Mogę jeść szkło, i mi ..."
},
{
"align" : "min",
"baseline" : "bottom",
"fill" : {
"type" : "Color",
"val" : 0
},
"font" : {
"name" : "MissingInAction, Georgia, 'Arial Hebrew', 'Arial Unicode MS', 'LucidaSansUnicode','MS-Gothic'",
"size" : 17,
"weight" : "normal"
},
"node" : "Text",
"place" : "1, 0, 0, 1, 10, 110",
"text" : "Russian: Я могу есть стекло, ..."
},
{
"align" : "min",
"baseline" : "bottom",
"fill" : {
"type" : "Color",
"val" : 0
},
"font" : {
"name" : "MissingInAction, Georgia, 'Arial Hebrew', 'Arial Unicode MS', 'LucidaSansUnicode','MS-Gothic'",
"size" : 17,
"weight" : "normal"
},
"node" : "Text",
"place" : "1, 0, 0, 1, 10, 145",
"text" : "Greek: Μπορώ να φάω ..."
},
{
"align" : "min",
"baseline" : "bottom",
"fill" : {
"type" : "Color",
"val" : 0
},
"font" : {
"name" : "MissingInAction, Georgia, 'Arial Hebrew', 'Arial Unicode MS', 'LucidaSansUnicode','MS-Gothic'",
"size" : 17,
"weight" : "normal"
},
"node" : "Text",
"place" : "1, 0, 0, 1, 10, 180",
"text" : "Hebrew: אני יכול לאכול זכוכית ... "
},
{
"align" : "min",
"baseline" : "bottom",
"fill" : {
"type" : "Color",
"val" : 0
},
"font" : {
"name" : "MissingInAction, Georgia, 'Arial Hebrew', 'Arial Unicode MS', 'LucidaSansUnicode','MS-Gothic'",
"size" : 17,
"weight" : "normal"
},
"node" : "Text",
"place" : "1, 0, 0, 1, 10, 215",
"text" : "Yiddish: איך קען עסן גלאָז און ..."
}
],
"node" : "Group"
},
{
"contents" : [
{
"align" : "min",
"baseline" : "bottom",
"fill" : {
"type" : "Color",
"val" : 0
},
"font" : {
"name" : "MissingInAction, 'MS Song', SimHei,'LucidaSansUnicode', 'Arial Unicode MS'",
"size" : 17,
"weight" : "normal"
},
"node" : "Text",
"place" : "1, 0, 0, 1, 10, 250",
"text" : "Chinese:我能吞下玻璃而不伤身体。"
}
],
"node" : "Group"
},
{
"contents" : [
{
"align" : "min",
"baseline" : "bottom",
"fill" : {
"type" : "Color",
"val" : 0
},
"font" : {
"name" : "MissingInAction, 'MS-Gothic','LucidaSansUnicode', 'Arial Unicode MS'",
"size" : 17,
"weight" : "normal"
},
"node" : "Text",
"place" : "1, 0, 0, 1, 10, 285",
"text" : "Japanese: 私はガラスを食べます。"
}
],
"node" : "Group"
}
],
"node" : "Group"
},
{
"contents" : [
{
"align" : "min",
"baseline" : "bottom",
"fill" : {
"type" : "Color",
"val" : 0
},
"font" : {
"name" : "SVGFreeSansASCII,sans-serif",
"size" : 32,
"weight" : "normal"
},
"node" : "Text",
"place" : "1, 0, 0, 1, 10, 340",
"text" : "$Revision: 1.9 $"
}
],
"node" : "Group"
},
{
"form" : {
"h" : 358,
"type" : "Rect",
"w" : 478,
"x" : 1,
"y" : 1
},
"node" : "Shape",
"stroke" : {
"cap" : "butt",
"dashes" : [

],
"fill" : {
"type" : "Color",
"val" : 0
},
"join" : "miter",
"width" : 1
}
}
],
"layout" : {
"scalingMode" : "meet",
"svgSize" : {
"height" : "100.0%",
"width" : "100.0%"
},
"viewBox" : {
"h" : 360,
"type" : "Rect",
"w" : 480,
"x" : 0,
"y" : 0
},
"xAligningMode" : "mid",
"yAligningMode" : "mid"
},
"node" : "Canvas"
}
Loading