How to subpixel render glyphs with XRender extension - x11

I found this great example of text rendering using XRender extension.
But the font is loaded from Freetype in grayscale format, is there a way to ustilize XRender to draw subpixel (LCD) antialiased glyphs? If yes, how?

Glyphs can be in any format you see in QueryPictFormats response (but all glyphs in glyphset share same format). Basically you render subpixel antialiased glyphs with freetype, upload it to rgba32 glyphset and rest is the same as when you use a8 (alpha only, see https://github.com/ereslibre/x11/blob/master/xrender/rendertext.c#L46-L47)

Related

Can I convert from swf (or fla or svg or snap or sprite.js) to bodymovin

I have a bunch of animated vector graphic files that I would like to convert to bodymovin (I assume I would need to convert them into after effects first and use the bodymovin extension).
I animated files in swf, fla, svg (using the animate element inside the svg), snap and sprite.js html5 formats. I need to preserve the animations (recreating them is not an option)
Is this possible? Any ideas?
I have imported one of my animated swfs directly into after effects and exported to an mp4 but it won't export to bodymovin (I think swf and the vector graphics are very different)
I had the same problem. You should get Bodymovin plugin for Adobe Animate CC. Have a look here: https://github.com/airbnb/lottie-web/issues/1604

SFML drawing, square appears when changing the png file with paint

I am newbie in SFML C++, i have a problem:
When i am programing on "Doodle game", with the original image of "Doodle", it works correctly.
But when i change the Doodle.png, such as erasing the doodle's head (with paint.exe), the game displays this:
A square displays behind the doodle image, as you see! Please, i really want to know what happened with the png file and how can i create the png file like the original one? Do I need an application other than Paint?
Microsoft Paint doesn't properly support alpha transparency in PNG images. As such it will replace the former transparent pixels with pure white.
Use a different editor with proper support for alpha channels, such as Paint.NET (freeware) should solve this problem.

Animated bitmaps (APNG) in OTF fonts

The Open Type font format standard 1.7 officially supports three types of colored glyphs, as required for emojis. As of late 2016, version 1.8 has added support for another variant. Platform support varies:
Microsoft’s/Mozilla’s COLR/CPAL tables use standard Truetype glyf or Postscript CFF  outlines.
Mozilla’s/Adobe’s/W3C’s SVG  table uses SVG outlines and CSS Variables.
Google’s CBDT/CBLC tables use embedded PNG bitmaps.
Apple’s sbix table uses embedded PNG, JPEG or TIFF bitmaps (and PDFs outside the standard). Support for masks and aliases is planned.
The SVG table explicitly considers animation – using CSS, JS, SMIL or embedded files – but I’m not sure that has been implemented anywhere yet:
Glyph Rendering
The SVG glyph descriptions may be rendered statically or with animation enabled.
Does any of the PNG-based implementations support animation using APNG? How about tools?
Compressed Color Bitmaps
Images for each individual glyph are stored as straight PNG data. Only the following chunks are allowed in such PNG data: IHDR, PLTE, tRNS, sRGB, IDAT, and IEND. If other chunks are present, the behavior is undefined.
JFTR, APNG relies on three additional chunks which both OS X / macOS and iOS natively support:
acTL Animation Control
fcTL Frame Control
fdAT Frame Data
So, if I’m not mistaken, APNGs should work in sbix verbatim, but not in CBDT.
APNG seems to be supported in Firefox and Safari only, so that'll be the same when used as font glyphs.
I figure you already considered this, but if GIF suffices, your best bet would be OpenType SVG. It has the widest support, and you can embed bitmap images in the SVG: see glyph 0050 in this test font.
Regarding non-bitmap animations in OpenType SVG, unfortunately you can't use JavaScript animations, and with SMIL on the way out you're stuck with CSS animations... which don't currently work in Firefox and Edge 🙃

Is it possible to check if a PDF is CMYK or RGB using GhostScript?

Is it possible to check if a PDF is CMYK or RGB using GhostScript?
I am aware of the inkcov feature, but this just returns values in terms of CMYK (with silent conversion)?
Is the real check, a check for RGB colours or RGB images within the PDF? not sure if both RGB and CMYK images can exist in the same PDF?
Images aren't the only thing that can be in a PDF file, you can also have text, linework and shadings. Also transparency blending can be specified in specific colour spaces. Colour spaces are not limited to RGB or CMYK but can also include Gray and spot (Separation) colours, as well as ICCBased colour spaces and certain specific CIE colour spaces such as Lab.
All of these colour spaces can potentially be present in a PDF file simultaneously.
Ghostscript doesn't contain any tools currently to tell you what colour spaces are used in a PDF file, though the pdf_info.ps script could be modified to do so for unusual (not grey/RGB/CMYK) spaces. You could also write a small piece of PostScript which could tell you when a colour space was used, and what kind of colour it is.
The inkcov device is a CMYK device, so all colours specified in the PDF are converted to CMYK before being 'printed' to the inkcov device which counts up the coverage. It doesn't tell you anything about the original PDF file.
My understanding is that a PDF can contain both RGB and CMYK images, so you'd need to have a tool that can review all images and report on their mode.
If GhostScript doesn't include options to do so, you may have to write a script to use a PDF library for parsing the image and reporting details on the elements it contains.
For example, this Cam::PDF module in Perl says it can parse any PDF v1.5 formatted file.

Alpha transparency in indexed-png images

Here is an image:
This image is a simple black-to-transparent gradient saved in full RGBA PNG.
Here is the same image, converted to indexed-alpha PNG by GIMP (Photoshop produces the same result)
As you can see, the gradient is now half-opaque, half-transparent.
Here is the same image again, only this time it was converted to indexed-alpha PNG by a PHP script I wrote:
So my question is: Why are GIMP and Photoshop unable to support partial transparency in indexed images, when the PHP script clearly shows that such an image can be created with no problems?
Is there anything "wrong" with an image whose pallette contains alpha information?
A more programming-related question: Does this transparency in the last image work in Internet Explorer 6?
I've finally found the actual answer: There is a metadata entry that allows you to define the alpha value of each colour in the colour table. Most graphics programs don't make use of this, but it does exist and can be used, in particular by GD.
Another option besides fireworks is pngquant, a command line application that will convert a rgba png into an indexed png with transparency.
I found this post which talks some more about how to use it.
IE6 and earlier in windows does not support variable transparency PNGs without annoying workarounds. An indexed PNG will only show the fully opaque parts which usually works pretty well. A drop shadow would disappear but the opaque parts of the logo or icon would continue to show.
This page has a better explanation and instructions with more png compression and quantization tools: http://calendar.perfplanet.com/2010/png-that-works/
For the record, PNG does not literally support indexed images with an alpha channel. What is really happening is that PNG allows you to add additional colors to the color table (i.e. index) with alpha values in those colors... not a complete alpha channel. FWIW...
Yeah I know what you mean. Fireworks is the only image editing program that I know of that can create and edit PNG8+Alpha without problems. I wish more paint programs would support this format cause Fireworks is expensive!
I found a way in GIMP to create or convert an image with reduced color palette and alpha channel.
The trick is to add a mask to the layer.
Full steps to reproduce:
Have your image in one layer
Add a mask to the layer. Select Transfer layer's alpha channel.
Convert to Indexed (Image -> Mode -> Indexed...)
Save as PNG
Now your image has reduced colors and reduced size, but it keeps your smooth transparency.

Resources