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

Add SVG marker support #242

Closed
wants to merge 1 commit into from
Closed

Conversation

supertxtnet
Copy link

@supertxtnet supertxtnet commented Aug 25, 2023

Include qualified selector styles when performing styling

Fix problem with unsupported font is used from fc-match in
FindLocalFont.

Unescape XML encoded strings for text.

Default font-size medium absolute size to the default font
size.

font.go Outdated
@@ -118,10 +117,11 @@ var sysfontFinder = struct {
func FindLocalFont(name string, style FontStyle) string {
// TODO: use style to match font
// try with fc-match first
filename, err := exec.Command("fc-match", "--format=%{file}", name).Output()
// TODO: this causes a panic on Linux "panic: requested font style not found"
Copy link
Author

Choose a reason for hiding this comment

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

This optimization was causing problems on my end on Linux with svg's generated from graphviz. There was the panic shown here in the comments.

Copy link
Author

Choose a reason for hiding this comment

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

The problem is because the fc-match is returning old X11 fonts on my system, which causes problems further down the line.

Copy link
Owner

Choose a reason for hiding this comment

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

I've added a custom system font finder with b78baf2, let me know how that goes.

@@ -344,91 +399,64 @@ func (svg *svgParser) skipToEndTag(l *xml.Lexer, tt xml.TokenType) xml.TokenType
return tt
}

func (svg *svgParser) parseDefs(l *xml.Lexer) {
Copy link
Author

@supertxtnet supertxtnet Aug 25, 2023

Choose a reason for hiding this comment

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

This section was causing the elemStack to get corrupted. I have styles on one of my svg files that make reference to the top svg element and they would never accept the elements because that element was missing from the stack. I hope that this rearrangement is a little less error prone.

@supertxtnet supertxtnet force-pushed the markers branch 2 times, most recently from dc1e972 to a541df0 Compare August 25, 2023 21:47
Include qualified selector styles when performing styling

Fix problem with unsupported font is used from fc-match in
FindLocalFont.

Unescape XML encoded strings for text.

Default font-size medium absolute size to the default font
size.
@tdewolff
Copy link
Owner

tdewolff commented Sep 14, 2023

I've just merged some changes to support markers, it will need some polishing though. Let me know if that works. I've incorporated many of your changes and fixes as well.

@tdewolff tdewolff closed this Sep 14, 2023
@tdewolff tdewolff mentioned this pull request Sep 14, 2023
@supertxtnet
Copy link
Author

I've just merged some changes to support markers, it will need some polishing though. Let me know if that works. I've incorporated many of your changes and fixes as well.

There are a few regressions from the svg examples I have on my end. I'll see what I can do to figure out what goes wrong with the latest changes. Perhaps there could be some test cases that could help with this.

@supertxtnet
Copy link
Author

I think the main problem I'm seeing is that if there are markers then everything behind gets erased. Also, the scaling of the overall canvas is off suddenly. The fill color of the markers is sometimes different than the outline, and that's not getting picked up either.

This is and SVG I'm trying at the top of this page:
https://supertxt.net/00-intro.html

This is what it looks like with the latest changes rendered in gioui:
image

tdewolff added a commit that referenced this pull request Sep 14, 2023
tdewolff added a commit that referenced this pull request Sep 14, 2023
@tdewolff
Copy link
Owner

Pushed out some fixes, your example works on my end, let me know how it goes!

@supertxtnet
Copy link
Author

@tdewolff thanks so much. The newest version is working much better.

I've opened #250 with a few small fixes for problems I've encountered in my test set, which includes graphviz on Linux.

tdewolff added a commit that referenced this pull request Sep 16, 2023
… *LocalFont* for *SystemFont* functions; adjust FontStyle values according to OpenType and CSS defaults, see #242 and fixes #248
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants