GNU bug report logs -
#75712
HAVE_RSVG: svg_css_length_to_pixels doesn't handle RSVG_UNIT_CH
Previous Next
Full log
Message #11 received at 75712 <at> debbugs.gnu.org (full text, mbox):
"Stefan Kangas" <stefankangas <at> gmail.com> writes:
> Stefan Kangas <stefankangas <at> gmail.com> writes:
>
>> In Bug#75451, Pip Cet <pipcet <at> protonmail.com> writes:
>>
>>> svg_css_length_to_pixels doesn't handle the RSVG_UNIT_CH case. I don't
>>> know at which version rsvg started to offer this unit; it's not
>>> indicated in the header file.
>>
>> It seems to have been added in 2.58:
>>
>> https://gnome.pages.gitlab.gnome.org/librsvg/Rsvg-2.0/enum.Unit.html
>
> I came up with the following patch, but it's not ideal.
I think it will do for the case of that single unit, but I was hoping
for an improvement for what used to be the default case: we should
probably error in the case of an unknown unit, or at least print a
warning. I was assuming RSVG would provide a simple interface to get
the string for a unit enum value, so we could print a meaningful
message, but it seems an int is all we get.
The header comment (which doesn't include the version numbers, thanks
for providing a link to those!) reads:
* If you test for the values of this enum, please note that librsvg may add other units in the future
* as its support for CSS improves. Please make your code handle unknown units gracefully (e.g. with
* a `default` case in a `switch()` statement).
But I have no idea how to do that given the API defined by that file.
As this is a fall-back case of a fall-back case, it may not be worth
spending too much time on: set a flag to let the code after the switch
statement know we've failed, print the integer value, error.
> Unfortunately, this patch doesn't take into account the "direction" or
> "writing-mode" CSS attributes, which is what seems to specify the above.
> I couldn't find a way to easily get these CSS attributes using librsvg.
>
> Instead, I just naively assume that they are set to their default
> non-vertical value, and thus use 0.5em. That's not always going to
> work, obviously.
>
> While the "ch" attribute seems to be rarely used, it would be nice to
> get this detail right. I'm just not sure how to do it. Maybe look
> through the CSS by hand, searching for these strings and then parsing it
> out? But that's likely to be brittle, ugly, and hard to maintain.
I assumed this would be useful for SVG-based fonts, so we should
probably make it depend on the Emacs environment rather than trying to
derive it from the CSS.
> Anyone have any good ideas here? It's my first time fiddling with
> librsvg, so it's quite possible that I'm overlooking something.
I'm afraid I can't really help. If I'd looked at the context of this
bug more closely, maybe I would have ignored it.
Pip
This bug report was last modified 118 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.