By the way... once I make the class handle multiple axis coordinates it would be reasonable for me to rename it from *SPIVariableFontAxisOrNormal* to *SPIFontVariationSettings*
2017-06-13 0:20 GMT-03:00 Felipe Sanches <juca@...2270...>:
Today I continued working Variable Fonts support on Inkscape. More specifically, I focused on adding parsing/handling of the *font-variation-settings* property (CSS Fonts Module Level 4). The code is here:
https://gitlab.com/fsanches/inkscape/commit/2a6a42a1389eb29b3ac94c5db9321a 72000b5bb5
A shortcoming of the above code is that it only deals with a single axis coordinate, while the CSS spec allows for an arbitrary number of axis names and correspondent design-space coordinates. I do have an uncommited draft of the *SPIVariableFontAxisOrNormal* class which uses a C++ *std::mapGlib::ustring, SPILength* for storing the parsed key/values from the property, but that code is still work-in-progress and it is what I'll be working on tomorrow.
After getting that to work, I intend to modify the *font_instance* font_factory::FaceFromStyle(SPStyle const *style)* method to instantiate font_instance objects taking the newly parsed property values in consideration.
One next milestone could be to get a well-formed SVG file containing a bunch of different variable-font coordinates in several chunks of text declared using the CSS property to load and render properly (without bothering about an editing UI at first). And after that I can work on the UI and the harder problem of how to decide whether a new font_instance object should be created or whether it should be recicled upon user edits.
Please let me know if you think I'm doing something wrong here. The description above is my current understanding of a possible path towards an implementation of this feature. I'm open to getting feedback on that.
Happy Hacking, Felipe Sanches
2017-06-10 2:35 GMT-03:00 Felipe Sanches <juca@...2270...>:
Hi there!
I was expecting to get some feedback on this thread from other Inkscape developers, but still did not really get any. So I continued investigating the issue by myself. At the moment I'm mapping out where and how the font_instances are created, deleted and used throughout the code-base because any changes I make have to consider all side-effects that may surface. I did feel a bit overwhelmed at first with the complexity of the text-handling code, but I think I'm on the right track now.
To alleviate the anxiety of dealing with such a complex large-chunk of code, I got my hands dirty by refactoring a few portions of libnrtype/Layout-*.cpp files (it's like gardening: we can't keep just staring at it :-P) and I also talked to some friends. Since a few Brazilian friends shared the enthusiasm of OpenType Variable Fonts at LGM earlier this year here in Brazil, I wrote a bit about the ongoing effort at an online forum here: https://forum.fiozera.com.br/t /suporte-a-opentype-variable-fonts-no-inkscape/115 It is all in Brazilian Portuguese, sorry, so it is probably not much useful here, but it is also not much different from what I already talked about here in this email thread which is still the official place for me to provide progress updates. Also the forum thread does not cover a lot of areas of the code I've been studying. Writing at that forum was more of a way of relaxing and getting ideas to flow again. I'll probably do so again from time to time. :-)
Since Inkscape has finally migrated to git today ("upstream" repo is now at https://gitlab.com/inkscape/inkscape), I did fork it at https://gitlab.com/fsanches/inkscape and also got my user account approved with push-rights. I was an active Inkscape developer on Bazar several years ago with equivalent commit rights.
Then I tried the "Merge Requests" workflow, but then I figured that probably the Inkscape team will (at least for a while) prefer to work directly committing to the master branch, instead of opening requests for merge. I pushed to master a few of the aforementioned refactoring commits and created a "variable_fonts" branch on my local working copy where I'll resume all of the experimental OpenType coding (to avoid polluting master before the feature is ready to land).
So, next week I plan to get back to contributing to FontBakery ( https://github.com/googlefonts/fontbakery/ ) and gradually work a bit more on Inkscape as well. Exactly which of both tasks will take most of my time will depend on the availability of Lasse's upcoming FontBakery pull request and also on the level of feedback that I may (or may not) get from Inkscape developers. I guess perhaps no-one else who originally dealt with the text-handling code in Inkscape is active in the team nowadays ? If that's the case, then I'll have to really "take ownership" of that portion of code and improve it based on my best judgement of what would be the best approaches.
One final thing: I'm really interested in talking to whoever is planning to work on a text feature on Google Summer of Code this year. Who's the student ?! Please contact me.
Happy Hacking, Felipe "Juca" Sanches
2017-06-05 17:57 GMT-03:00 Felipe Sanches <juca@...2270...>:
I'm writing this message addressed both to UI-designers in general as well as (to some extent) to senior Inkscape developers who may provide some more feedback on the actual code. ====
My current understanding regarding variable fonts is that any time the user tweaks parameters in a variable font, Inkscape will have to decide whether to modify those design-space coordinates on the font instance associated with the currently selected chunk of text or to instantiate a new font_instance object. Here's my rationale behind this:
If the SVG document has the same font applied to more than a single chunk of text, then we need to create a new font instance so that the edits to one chunk of text won't affect other chunks that were previously sharing the same font_instance. That would work as a lazy "un-clone" of the font resource once the differentiation is really needed. It is good (in order to avoid wasting memory) to share a font_instance for chunks of text that use the same non-variable font, or that use the default design space coordinates of a given variable font.
I think that allowing variable font design-space tweaks to individual chunks of text is desirable from the user perspective and also required from the SVG spec perspective. The SVG spec does not talk about variable fonts, but it allows individual text chunks to have their own font-family and style attributes which then apparently means allowing them to have their own variable font design space coordinates as well (If I understood it correctly). I think this is analogous to individual paths having their own individual fill/stroke styles.
It just occurred to me that this leads to a possible confusion and we probably have to make a UI design choice here. There may be occasions when the user may want to modify the design-space coordinates of a given variable font globally on the document. Do you think this is a valid concern / valid usage scenario ? In that case, a variable font instance may behave like a shared resource, analogous to a shared gradient or filter-effect. But then we would need to make this an explicit user-choice, perhaps by providing a dedicated dialog for setting up such shared font resources. Like a "palette of font instances". Does it make sense ? Also, from a codebase point of view, would you suggest a prefered way to approach this? (Thinking about how to manage these variable-font instances)
2017-06-02 22:35 GMT-03:00 Felipe Sanches <juca@...2270...>:
Hi there,
These past days I've been adding an experimental UI to Inkscape for tweaking parameters in OpenType variable fonts. One major roadblock I stumbled upon is requiring me to think more carefully about some potentially deeper architectural changes. In the screenshot attached to this message you can see some text written with the Decovar variable font. The slider labeled "Testing" in the "Text & Font" dialog is wired to invoke a callback upon value-change. This callback detects the currently selected font based on the canvas text-tool cursor position, retrieves the corresponding font_instance object and invokes Freetype's FT_Set_Var_Design_Coordinates method with the updated design-space coordinates (the slider in this experiment is hardwired to adjust the weight axis of Decovar).
(I really miss a Freetype method to alter a single design-space coordinate, instead of having to pass the full array, by the way)
The way things work right now, unfortunately, leads to the glyphs not changing on-canvas because once they are loaded, they seem to be kept in a cache. As you can see in the screenshot, each glyph has a different weigth, based on the slider setting when the glyph was loaded for the first time. It seems quite obvious that I should do something to invalidate the cache upon dragging the slider. But that, on the other hand, should not alter glyphs in other places where the same variable font is being used in the same document.
Based on all that, I think that the proper implementation would involve creating individual font_instance objects for each text chunk where a variable-font is used with non-default design-space coordinates so that they can be tweaked independently. Achieving that, though, will surely involve a bit deeper fiddling with Inkscape's text internals, which is what I expect to do in my next few days of work on this.
cheers, Felipe Sanches
PS: I'm crossposting this to the Inkscape-devel mailing list as the rest of the development community may be interested in receiving updates on this topic. I may as well move all future updates to the Inkscape mailing list directly.
PS2: I heard that there's a GSoC student this year who's going to work on Inkscape's text implementation (fixing compliance issues to the SVG spec, I think...) It would be really great to keep in contact with him/her and the mentor to coordinate efforts.
2017-05-30 7:48 GMT-03:00 Khaled Hosny <khaledhosny@...3544...>:
On Tue, May 30, 2017 at 12:35:24AM -0300, Felipe Sanches wrote:
The relationship between pango and harfbuzz is still not very clear
to me,
as I have the impression that even pango_shape() invokes hb_shape()
under
the hood nowadays.
It will eventually call HarfBuzz on Linux, but in Windows and Mac it will call Uniscribe and Core Text, respectively. Switching to HarfBuzz on all platforms is kinda on Pango’s TODO list, but I don’t think anyone is working on it currently.
-- You received this message because you are subscribed to the Google Groups "Google Fonts Discussions" group. To unsubscribe from this group and stop receiving emails from it, send an email to googlefonts-discuss+unsubscribe@...3168... To post to this group, send email to googlefonts-discuss@...3546... ps.com. Visit this group at https://groups.google.com/grou p/googlefonts-discuss. To view this discussion on the web visit https://groups.google.com/d/msgid/googlefonts-discuss/201705 30104838.GC24994%40macbook. For more options, visit https://groups.google.com/d/optout.