-
Notifications
You must be signed in to change notification settings - Fork 95
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
Build color fonts #30
Comments
We should support them all, yes. Easiest to make MS-style fonts from vector only, and Google & Apple style fonts from bitmap only. SVG can be made from both, and would be really cool indeed if we did. |
one step towards this is extending UFO to allow linking a GLIF to an SVG file. |
Here's what I think is needed to allow building color fonts with fontmake. We need a Initially for simplicity we should support specifying glyph images as either vector graphics (SVG) or as bitmap (PNG), but not both (we may revise this later). The PNG sources can be used to generate sbix, CBLT/CBDT, OT-SVG color formats, but not COLR/CPAL (unless we can trace them but that's non trivial). The (vector) SVG sources can be used for generating all four color formats (for sbix and CBLT/CBDT we would use skia or cairo to rasterize). SVG with mixed vector/bitmap graphics are tricky, and I'll ignore them for now. The primary source format (UFO) needs to be extended to support storing references to SVG files, which may contain vector paths (either filled or stroked) and the respective transforms, colors, gradients, or even embedded bitmap images. Currently the UFO GLIF spec only allows PNG as images. These are traditionally understood as background images to be used while designing, rather than for exporting color or icon fonts. Then we need a way parse SVGs into something that fontmake (or rather ufo2ft) can consume from python. FontTools has an SVG-native is of course only a subset of SVG. Ideally we will have some method for converting from SVG to SVG-native (e.g. linebender/resvg#135). I plan to use noto-emoji as a test font to experiment with this build workflow, since it has both SVG and PNG sources. Let me know if you have any comments or suggestion, thanks. |
https://github.com/djrrb/Bungee/tree/master/fonts/Bungee_Color_Fonts are available for testing It was built with https://github.com/jenskutilek/RoboChrome which has its own demo fonts, https://github.com/jenskutilek/RoboChrome/tree/master/demo |
https://github.com/twitter/twemoji is likely another good test set for svg. |
Thanks for the links. I also started a shared doc here: |
I commented this on the shared doc:
Also: using UFO layers as color font sources has the huge advantage is that everything that works for regular outlines "just works" for color layer outlines. Not just manual editing, but also scripting functionality. It's all there. |
I agree very strongly with what @justvanrossum said. UFO layers were designed with color fonts as one of their primary use cases. If layers don't support something that is needed, address it from that angle rather than adding a new deeply complex outline type. |
Given the attitude shown, I suggest those of us who actively work on extending OpenType fork UFO and be done with gatekeepers. |
@behdad is that some sort of entitlement thing you picked up at Facebook? |
I don't understand.
Just because we don't immediately give in to your wishes you get to call us gatekeepers with an attitude? I think that is way out of line and abusive. |
You are right. I apologize. :) I think changing UFO image element to allow other image types is a change that should be made without much resistance. What other tools (fontmake) does with that image or the layers, is outside the scope of UFO itself to specify.
This doesn't make sense to me. Emoji are designed by graphics designers in graphic design tools. Are you saying we must force them to design emoji in font design tools only?
I disagree. |
What is so wrong with this option that it requires a tool-breaking change to the spec? |
No need to fork anything :) |
To me, the spec should /not/ say anything other than maybe a note that PNG is the widely supported format. It's up to each implementation to decide what to implement.
The alternative I prefer is, UFO spec is updated to /allow/ other image formats. fontmake consumes them, then we ask font editor developers to please support other image formats in their next versions. For the most part they don't even care. They are using system libraries to render the image anyway, and it probably transparently automatically already work for JPG and SVG anyway. In that scheme, there's no need for (all!) font editors to support any fontmake-specific extensions whatsoever. That was the original design goal of fontmake from the beginning: to consume whatever sources people work with naturally. Using fontmake extensions makes fontmake broken for people who just want to edit things in an editor and call fontmake on the results. Does that make some sense? |
To provide context (not sure if this is common knowledge or not), at Google today (and I believe other places as well) designers often work in design tools that readily output SVG and never touch a font editor when building icon or emoji fonts. The ability to feed fontmake a pile of svgs plus some metadata and get out a functional color font, particularly if COLR gains gradient support, is thus very desirable. |
This is precisely what I was trying to prevent by restricting it to PNG. One of my initial drafts of UFO 3 said that anything was allowed. While I was developing the spec I was also building an implementation (ufoLib, defcon, defconAppKit) of it to check the feasibility of what I was specifying. I quickly fell down the rabbit hole of supporting every image format and decided to go the opposite direction and lock the format down very specifically. I didn't want to get into a situation where a user opens a font in one editor and doesn't see official data because the editor developer chose not to support something. (You know me. I'm always trying to keep things consistent for the user. :) Backing up a little bit, I think I understand the problem that you are trying to address. Is this a good summary?
(If that's not accurate, please let me know.) This was a significant design challenge in UFO 3. There were times when I had a model that would allow individual glyphs to have their own layer details rather than the layer details being consistent across the whole font. I also had a draft that specified fill color, stroke color, stroke width, stroke dash, everything for individual contours. Erik pointed out that I was reinventing the Illustrator file specification and that it was going to be extremely difficult for editors to support all of this. He was right, I went back to a more abstract layering system and figured that if we needed more complexity we'd address it when it came up. So, I guess this is the needed complexity coming up. :) My concern about using the I very much like the idea of keeping the SVG in an external file and making a reference to the file rather than putting the SVG's XML inside of GLIF. (Putting SVG inside of GLIF was something else I explored in UFO 3. It made parsing very difficult. I shudder at the thought of what it would have meant for validating and normalizing.) We could do this with these changes:
This could be implemented pretty easily and it wouldn't be a breaking change. This is the kind of use case that What do you think? PS: Should this discussion move to the UFO Spec issue tracker since we're talking about a UFO change? |
Behdad is right to say that the HTML does no specify image formats. But UFO is not independent of OpenType — it heavily references OpenType. In a sense, UFO is a bit subordinate to OT. And OT does currently limit image formats a bit. I also agree that SVG should not be treated the same way as bitmap images. I can see how one structure could be expressed generic "image", and not necessarily dictate whether the image should be JPG, PNG, WebP or HEIC. But SVG is very different. For starters, it’s XML. SVG that is used in fonts actually contains data that is font-specific. Let’s also remember that SVG in OpenType can contain a number of SVG documents which may be used by glyphs, but this is an n:m relationship. It’s extremely limiting to assign some SVG document to just one glyph. If you want to use SVG “components” (the Let’s also not think that SVG in fonts is somehow limited to emoji. Just saying :) |
How would the UFO select the right data within one SVG document that represents a glyph? In OT, there is a mechanism for that. |
+1 :)
Good point. Modeling the structure GLIF lib's |
In the meantime, here is something that works: googlefonts/ufo2ft#359 |
I feel like there's a lot of miscommunication going on. Let me explain what I suggest Cosimo do. These are my personal opinions, and I'm not a maintainer or developer of either fontmake or ufo2ft.
I'm confused as to how the spec allowing more image types is deemed as "tool-breaking change", whereas adding a new Anyway. Here is my plan; I hope each step is self-motivating, and the full picture would justify the design. Before that, I like to inform you all of two ongoing developments:
Plan
|
Because tools need to be updated if they don't want to crash on image formats that they previously didn't expect, whereas a lib key is a new addition, that tools can opt-in to implement at their leisure. I think that's a huge difference. The specified lib and data folder behavior ensures that tools that do not know about specific keys or data items will not corrupt the "unknown" data, even when performing "save as". The rest of your proposal sounds great. |
Thanks. I understand your point of view. But let's be realistic: most tools don't open the image. Those will keep working. Font editors render the image. If they crash on a bad image file, that's really a bug in the editor that needs to be fixed. I highly doubt they crash. If someone has scripts or plugings, etc that open the image and only work if it's PNG, then those tools need to be updated before they can consume UFO's using the proposed features. But that's life with all standards. Data using new spec features needs tools to be updated to fully understand it.
Thanks. |
@behdad I'm very confused by your resistance to the lib/data proposal. Repurposing |
See #30 (comment)
See my previous reply: #30 (comment)
Hyperbole.
Which issues particularly? Let's talk about actual issues one by one.
Please explain. I have no clue whatsoever what you are talking about.
Again, no idea what you are talking about.
I don't care what approach is used. What I care about is to make I'm going to stop replying to unsubstantiated comments from now on. I'm interested in designing and building things. |
I can and have substantiated all of this (and more) for you over many years. You continue to dismiss anything I say that doesn't match your immediate desires.
Likewise. I'm done with trying to reason with bullies. |
Really? You and I have not communicated much. Definitely not about color fonts.
Sure. Become one. |
@behdad you’re ignoring a proposal that solves your immediate needs. |
I have no immediate need or any stakes on this whatsoever. I'm providing what I think is a good design. Who does what with it is separate. |
I’m siding with @typesupply on this. @behdad — unfortunately (or not) SVG objects are not images, certainly not the way they've been implemented in OT+SVG. The relationship between font glyphs and SVG documents is an n:m one, and this actually is great, because it allows the re-use of SVG I feel that treating SVG like "scalable PNGs" is way too limiting, and is not necessary. This might work for emojis, but even there you have a lot of repetitive shapes. Running svgo only solves a part — but SVGs can be really smart sources, and if used smartly, they can reduce the size a lot. But not with the "like PNG" approach. I think a dedicated data structure is better, one that allows the n:m mapping that is paramount to the efficiency of SVG-based OT fonts. |
Fwiw for emoji we expect to make the compiler identify reusable elements for both svg and colr. |
@twardoch I think you are conflating separate things. SVG as image input should be supported. That's independent of OT+SVG or any other output technology. By suggesting that UFO needs to add new syntax for SVG.. that's just bad design. Imagine if imaging libraries made you call different API names to open different types of images. To a designer / user an image is an image. JPEG and PNG are extremely different internally and in what each is good for. Would you argue that they would need to be addressed differently in HTML, other places? OT+SVG is not SVG. Get over it. Now, the compiler should convert SVGs into OT+SVG table if asked to. The compiler should also optimize, while possibly giving lowlevel control if desired. But you can't just drop any SVG in OT+SVG. So there's gonna be need for a compiler. And guess what, is trivial to see how UFO should support manual SVG element sharing. Make the UFO glyphs refer to eg. "emoticons.svg#smiling-face". What's problem with that? Also, compiler needs to rewrite the element names to reflect glyph numbers anyway. Compiler can also optimize and remove unused elements. Imagine every time Intel released CPUs with new features we ran and changed our programming languages to add those features. We don't. We extend the programming language in generic extensible ways, and we make compilers generate faster better code given the same input. |
...Same way that we don't require designers design with quadratic curve if they intend to generate TrueType. The compiler takes care of it. If certain designers find designing using quadratics better for certain usecases, that's says nothing about TrueType outlines being better than CFF. That just says there are usecases that it makes sense for the design tool to let designer use quadratic curves. Compilers know how to convert quadratic<->cubic so the output is completely irrelevant. |
There are emoji fonts that start with vector assets. And there are emoji fonts that start with bitmap assets. And in both cases, it's desired to generate emoji fonts that work on a wide variety of platforms. Decoupling input and output is just good software design / architecture. |
SVG can do all kind of crazy/cool stuff: scale, move, reference other pieces. But how to make a svg that really uses those things? Svgs for color fonts are 100% made by designers in design tools and everyone treats them as an image format. So building a spec around a theoretical use case and making it more complicated for everyone? So I’m with @behdad on this. |
Just to add some info about what "tools" do: In FontLab we do both: we have internal structures which mimic simplified SVG (and which are fully editable with the current exception of gradients) + we have SVG-as-image that is "just rendered". On the other hand our PhotoFont color font format supports reference to the image as rectangle inside the bigger image, which is somewhat similar to what OT-SVG can do. |
What is the current state of building color fonts with fontmake today? |
COLR/CPAL can be built from layered UFOs, given the right lib keys. Some details are here: googlefonts/ufo2ft#359, but more documentation would be better. |
So, not possible to build SVG-in-OT fonts with fontmake? |
no, not at the moment. You can try use nanoemoji. |
It would be nice if fontmake could build color fonts.
Glyphs already supports color fonts, both as vectors and images. Therefore, a glyphs file should contain all information needed to build color fonts in various formats.
Sadly, color font formats are very fragmented. As a general tool chain, I think fontmake should be agnostic about formats and try to support them all. (Of course, it would be nice if the industry could converge eventually). As an intermediate format, SVG might work because it can be easily converted into PDF, PNG, and JPEG images. Later in the pipeline, those images can then be packaged into sbix, CBDT, COLR, CBDT/CBLC, and similar tables depending on what format was requested.
The text was updated successfully, but these errors were encountered: