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

Textsymbolizer from OlStyle #14

Merged
merged 3 commits into from
Jul 19, 2018
Merged

Conversation

ahennr
Copy link
Contributor

@ahennr ahennr commented Jul 18, 2018

This PR containing commits by @annarieger implementing getTextSymbolizerFromOlStyle function to parse text symbolizer from ol style with set text property.

Credits go to @annarieger

Please review

Follow up to #13

Copy link
Contributor

@chrismayer chrismayer left a comment

Choose a reason for hiding this comment

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

Thank you very much for this @annarieger! Looks good to me. One little point regarding the font parser should be changed before merging, IMHO.
For me it would be enough if we agree on the simple cases taking the font-weight into respect, like bold 12px serif. More sophisticated cases also appreciated of course 😉

const offsetX = olTextStyle.getOffsetX();
const offsetY = olTextStyle.getOffsetY();
const font = olTextStyle.getFont();
const fontSize = parseInt(font.split('px')[0], 10);
Copy link
Contributor

Choose a reason for hiding this comment

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

Since font in an ol.style.Text is a CSS 'font' value this does not seem to work for all cases. E. g. when a font-weight is set: bold 5px arial, sans-serif
Even more complicated cases are thinkable: italic bold 12px/30px Georgia, serif. See https://www.w3schools.com/cssref/pr_font_font.asp for more infomations.

Copy link
Contributor Author

@ahennr ahennr Jul 19, 2018

Choose a reason for hiding this comment

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

In 62dd6df I added some logic to parse even more complex CSS font values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

However, this currently only works with font-size values given in pixel.
Since font-size can be a string value as well (see https://www.w3schools.com/cssref/pr_font_font-size.asp, e.g. large) the model of TextSymbolizer (size?: number;) should be changed. This is is beyond the scope of this PR, IMHO. What do you think @chrismayer @KaiVolland ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need to support this atm. This would make many things very complicated.

But we should improve the feedback of the parser. Maybe return an feedback object or throw errors. I created a ticket regarding this: geostyler/geostyler#286

const font = olTextStyle.getFont();

// font-size is always the first part of font-size/line-height
const fontStyleWightSize: string = font.split('px')[0].trim();
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo...non-blocking

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@ahennr
Copy link
Contributor Author

ahennr commented Jul 19, 2018

Thx for review. I'll merge as soon as Travis is happy.

@ahennr ahennr merged commit 847749d into geostyler:master Jul 19, 2018
@ahennr ahennr deleted the textsymbolizer branch July 19, 2018 09:49
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.

None yet

3 participants