kientructayho Posted March 30, 2021 Share Posted March 30, 2021 Hello, I am designing a card game in Affinity Publisher and Designer (both v1.9.1) on my Mac. I have a data file that contains image paths, card text, various details, and formatting data such as layer visibility, text color, and object/region fill colors (could be RGB or hex). I have successfully used the Data Manager to import the file, and the Fields studio to assign text and image path content to a Data Merge layout object. But I cannot figure out if I can control the formatting or visibility of layers via that data file. If I were programmatically building an SVG in python, I can read such a file, and render the given elements with the desired formatting specified by the data file. But after seeing AP's Data Merge in action, I scrapped that effort, especially since I'm not a SVG wizard. And of course, AP & AD are so much nicer to exist in rather than staring at abstract code wondering why my layering is busted. I realize I could split my data into several subsets, and then create AP layouts for each version (with the text, layers, and visibilities set to all the needed permutations), then export and slice to be merged again into a master for printing on card stock for play testing. But I'm trying to avoid that sort of busy-work, and it sounds prone to manual errors. I've also considered pre-rendering static resources in the desired formatting permutations, and then just setting those elements in AP Data Merge as a simple image path, but that's one more step to the process. jacobwilson9600 1 Quote Link to comment Share on other sites More sharing options...
Old Bruce Posted March 30, 2021 Share Posted March 30, 2021 7 hours ago, kientructayho said: But I cannot figure out if I can control the formatting or visibility of layers via that data file. You cannot, none of the Affinity applications have any support for scripting. 7 hours ago, kientructayho said: I've also considered pre-rendering static resources in the desired formatting permutations, and then just setting those elements in AP Data Merge as a simple image path, but that's one more step to the process. I think this would be your best bet. Quote Mac Pro (Late 2013) Mac OS 12.7.2 Affinity Designer 2.3.1 | Affinity Photo 2.3.1 | Affinity Publisher 2.3.1 | Beta versions as they appear. I have never mastered color management, period, so I cannot help with that. Link to comment Share on other sites More sharing options...
jacobwilson9600 Posted April 4, 2022 Share Posted April 4, 2022 (edited) On 3/30/2021 at 10:37 AM, Old Bruce said: You cannot, none of the Affinity applications have any support for scripting. I think this would be your best bet. Say I wanted to change the color of a layer based on a variable determined in my data merge file. Would it be possible for me to change the color of a layer for each iteration in the column? So the first page would be red, the second yellow, the third blue, etc. Edited April 4, 2022 by jacobwilson9600 Quote Link to comment Share on other sites More sharing options...
Komatös Posted April 4, 2022 Share Posted April 4, 2022 5 hours ago, jacobwilson9600 said: Say I wanted to change the color of a layer based on a variable determined in my data merge file. Would it be possible for me to change the color of a layer for each iteration in the column? So the first page would be red, the second yellow, the third blue, etc. Short. No! There is no way with data merge to define page/layer colors within the data merge database file. Quote AMD Ryzen 7 5700X | INTEL Arc A770 LE 16 GB | 32 GB DDR4 3200MHz | Windows 11 Pro 23H2 (22631.3085) AMD A10-9600P | dGPU R7 M340 (2 GB) | 8 GB DDR4 2133 MHz | Windows 10 Home 22H2 (1945.3803) Affinity Suite V 2.3.1 & Beta 2.(latest) Better translations with: https://www.deepl.com/translator Need a system wide color picker? Try Microsoft's (New) Power Toys Need a robust PDF Solution? Have a look at Stirling PDF There's nothing you get used to faster than working slowly! Link to comment Share on other sites More sharing options...
lacerto Posted April 4, 2022 Share Posted April 4, 2022 15 hours ago, jacobwilson9600 said: Say I wanted to change the color of a layer based on a variable determined in my data merge file. Would it be possible for me to change the color of a layer for each iteration in the column? So the first page would be red, the second yellow, the third blue, etc. By using workarounds, you could achieve something like this E.g. below database defined SVG images and color glyphs are used to determine background colors: EDIT: Note that color font based backgrounds will be rasterized on PDF export but that would not typically be a problem as the colors would normally be uniform. The text would still stay as text, and SVG based backgrounds as vector objects. Quote Link to comment Share on other sites More sharing options...
lacerto Posted April 6, 2022 Share Posted April 6, 2022 I had another look on possibility to use color fonts for defining color attributes for the use of Publisher Data Merge, and tried to search for fonts that would have e.g. Web palette or some common palettes defined as glyphs, but could not find any (I am pretty sure there are some available, though). In lack of anything better, I created a color font of my own, using bitmaps with tens of percentage of R, G and B color values. With an Excel sheet and simple calculations, it is easy to map the glyphs to percentage color values to define colors for text objects and different kinds of shapes and have them applied in Data Merge (a simple rounding and conversion function from e.g. hex values could be used). Working with color components and blend modes is of course a pretty complex work around (and not colorwise very accurate), but It would be pretty easy to create programmatically palette fonts that have a good selection of basic colors covered without needing to apply blending. The glyphs could perhaps be named with hex values expressing the RGB values, and could easily be picked from the Glyphs panel as if from a palette. I used 1000px x 1000px sRGB bitmaps (72 dpi nominal ppi) copy pasted from Photoshop to FontLab 7 -- for some reason bitmaps copied from Affinity Photo did not work. FontLab lets produce four kinds of color fonts but I only could make sbix based fonts work with Affinity apps (macOS version). The SVG-fonts, even if bitmap-based, did not work on Windows version so perhaps the rectangles need to be vectors... Quote Link to comment Share on other sites More sharing options...
lacerto Posted April 6, 2022 Share Posted April 6, 2022 Here is yet another example, where color attributes for the text and background are defined by copy pasting hex 255 values into an Excel sheet, where hidden formulas convert the value to percentages rounded off to nearest ten and then map the decimal to the equivalent color swatch glyph in a custom color font. Once set up, the color rectangles with clipped in color fonts that get values from a database can easily be copied and used to color any vector based object, including text that gets contents from the database. The small rectangles with "A" show the color values of original 8-bit hex values, which in this font need to be rounded to one of the ten possible shades of red, green and blue. As mentioned, the Apple based color font is a bitmap (the text itself colored with the font remains as text). I tried to create the same font with vectors on Windows but have not so far managed to output anything that Affinity apps can use. VectorStyler could use the SVG color font that I created but it seems these fonts are not supported by Affinity apps yet, whether in bitmap or vector format. UPDATE: I subsequently managed to create a Microsoft CPAL/COLR vector color font that works with Affinity Windows versions, so color-font based formatting in context of data merge works nicely on both platforms, and it is very easy to add glyphs for specific color swatches so that there is no need for overlaying and blending R, G and B glyph layers to get a desired color. Creating color fonts is probably possible also with free tools (I have tested only commercial FontLab7 and Glyphs 3 [macOS only] apps and both can produce both sbix and CPAL/CLR fonts that work with Affinity apps, the former format on macOS and the latter on Windows). Quote Link to comment Share on other sites More sharing options...
lacerto Posted January 17, 2023 Share Posted January 17, 2023 @EatMoreBacon -- I reply here (instead to PM) as the question related to color fonts in context of data merge (as a device to encode color attributes) might interest other users, as well. You can basically use any color font to pick and encode color attributes to be used with merged data. Ideally the glyphs to be used should be ones that resemble color wells and consist of coherent color regions. If they have details, borders, etc., you can use vertical and horizontal scaling and aligning to use just a specific area of the glyph for coloring. Two free color fonts that work with Affinity apps (which have only rather limited support for color fonts) are Segoe UI Emoji and Apple Color Emoji, which can be used in the attached demo (this is for Windows; on macOS, the font should be changed to Apple Color Emoji, it has its color wells encoded in the same Unicode code points as Segoe UI Emoji). colorcells.xlsx colorcells.afpub colorcells_merged.afpub Some of my other posts in this thread use my own fonts that only consist of color wells, which are used to create a basic sRGB kind of palette (but only consisting of 10 instead of 255 shades per channel; and equivalent CMYK palette) which I then use with blend modes to mix 10 x 10 x 10 = 1,000 shades to be used in data merge tasks. The method is a bit convoluted but if someone is interested, I might be interested to explain and share. But basically the same can be achieved with any color fonts; it is the encoding (finding the glyphs to serve as palette wells) that would be a bit tedious, compared to a specific font that consists just of a "palette". I have not managed to find such color fonts -- if someone knows, please post! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.