2018-12-28

Amazing

Around 18 months ago I made a Russian Doll Puzzle Box on thingiverse. This was after initially doing a simple two part box. The idea was pretty simple - the box has a maze on it, so the lid has to be moved around the maze to close or open the box.

It is surprisingly popular, with over 150,000* views on thingiverse and no idea how many from my site that makes the random versions on the fly.


The original code was almost all done in OpenSCAD, with a small bit of C code to create a random maze and set the various parameters used by the OpenSCAD script. It worked, but rendering the OpenSCAD was quite slow.

This Christmas I thought I would have a bit of fun re-doing it. There have been various requests and suggestions since the original design was posted. So I have incorporated a lot of those. The big one was having the maze on the inside of the box so making it way harder to solve! I have also added a helical option, and ability to emboss an initial on the ends of the box.

I decided to take a new approach. Instead of designing in OpenSCAD, I designed it all in C code, making OpenSCAD from scratch from the C. This is only subtly different, and it uses OpenSCAD to carve the maze from a cylinder in much the same way as before - just more of a long list of functions generated by C code rather than iterative OpenSCAD script. This worked, after a lot of tinkering, and after a couple of days I had a whole new set of test mazes. There are loads of tweaks once you print something for real on a 3D printer, and that takes a lot of time, so the test cycle is slow...

Last night I ended up re-writing a whole chunk of it in my sleep! Today I coded the changes, and it works. The change was simple in concept - instead of using OpenSCAD to carve shapes from a cylinder, I would construct a polyhedron from scratch in the C code to make the maze surface.

This was not as easy as it was in my sleep as I learned a bit about manifold polyhedrons, but it works. It makes the OpenSCAD unreadable as it is a huge list of 3D points and faces.

The end result is a much neater maze, and it is away quicker. The most complex test I had was taking OpenSCAD over an hour to convert to STL, but the new version is just over a minute, and most tests are a few seconds.


The other big difference is I have also released the C code on github. Enjoy.

See https://www.me.uk/puzzlebox for a custom maze SCAD.

P.S. Updated many times since I started on Christmas day. Always one extra tweak :-)

*I do not trust the download count - the file download count goes up way faster, so even counting "download all" as one download it is way off, and there are 50 files. It seems someone downloads every minute or two, and just as many access my web site to make custom mazes - amazing!

P.P.S. One more tweak - I added a mode to alternate "inside" and "outside" maze :-


P.P.P.S. One of the things I have done in this case (as you can see from the source) is make use of popt more than usual. Apart from just using as command line arguments, the same structure is then used to parse QUERY_STRING args, generate the comments in the header of the output, and even generate a web form. This means I can add new options in one place and not repeat myself.

P.P.P.P.S. I worked out a way to make the maze more challenging: The maze is drawn by a path from a point, taking random turns (with some bias) and back tracking when no options. I have now made it run multiple paths from the starting point concurrently so that there should be multiple reasonably long paths from that point, all but one of which will ultimately be a dead end.

2018-12-24

Meaning of an Amazon Christmas?

I heard that Coca Cola managed to get the red coat on Santa due to advertising in the 30s - though wikipedia suggests not quite that (here).

It seems odd in many ways quite how quickly "tradition" changes, and when you have a tradition you assume it has been the case for all time. Basically, anything that was the way it is before you were born, and even more so, before your parents were born, has always been so...

The history (assuming this video is correct) is quite crazy, in fact...



So I was pondering where it will end up in another generation or two. Even if Coca Cola did not have as much influence as it seems, I can see how a large company may want to create a change in "tradition" for its own ends.

It probably just takes a book, or more likely a book and a film and maybe a theme park, to change a tradition. So what could come next?

My guess is Amazon do something where Santa's "North Pole" operation is actually an Amazon fulfilment centre. After all, under the brown paper wrapping, almost (not quite) all of the presents I have wrapped are then in Amazon boxes (some even unopened, just wrapped up when they arrived). And some that did not arrive in Amazon boxes have then been put in spare Amazon boxes as easier to wrap.


As I mentioned in an earlier post, unusually, I have ended up buying more presents this year, and a part of that is the ease of buying from Amazon. Several presents have been a result of a passing comment over coffee and I whip out my phone and quietly order the very thing my wife, or someone else, wants, even for delivery Christmas Eve!

P.S. Merry Christmas or other holiday to which you are looking forward, and have a happy Gregorian calendar new year.

2018-12-18

Is my LG TV haunted?

A few days ago my TV announced it had new s/w to download, so I let it do its thing and upgrade.

Maybe that was a mistake. Yesterday I came in to my man-cave and the TV was on, no signal. That is odd for two reasons: (a) I turned it off the night before, and (b) it turns off after a while with no signal (or used to).

I assumed I was being silly. But this morning the same, and I was suspicious.

Later during the day I popped out today for a coffee, and I definitely turned the TV off when leaving. My wife saw me do it - I am not going crazy. When I came back, there it is, on, no signal.

So I did a test - I turned off the TV.

It turns itself back on!

It also turns on the (connected) Apple TV (as I would expect), and after a while the Apple TV goes off leaving the TV on with no signal. It stays on!

I can only assume this is LG's latest "burn up your OLED pixels quickly" software update. I can't think of any other reason they would do this. Very annoying. Not quite sure what to do - the power socket is an option, but annoyingly all hidden behind the cabinet, and rather tedious to say the least.

FYI I went in to menus and it has "turn on by WiFi" and "turn on by bluetooth", both of which I have disabled, but no different.




P.S. Disabling the simlink stuff "fixes" it, but why was it suddenly broken. It was fine before. Arrrg!

Game Over for Stargate playing cards

I am really sorry to have to admit defeat.

After a lot of work on this, and a lot of obstacles, I believe it is impossible to get a licence from MGM. Whilst their contract has a number of issues, by far the most problematic is that in order to purchase a licence from them, they require me to assign all copyright in my product to them. No, they don't pay me for that! If this seems backwards to you, you are not alone.

I made it clear from the start that the designs included some creative commons work - so they knew it would never work all along. Even if that could be solved by a lot of re-design, it would mean rights in my playing cards designs assigned to them - which means all the other playing cards I have made being theirs - so I'd need to buy a licence to use those (even though I designed them!). This is not, in my view, how copyright is meant to work!

Anyway, this is the video I made earlier. I have not had any further reply from the licensing people, which I can only take as confirmation of my understanding. A bit rude to just ignore me, but seems to be typical of all of the interactions I have had on this. Shame.

I went to Cal Mah, and sadly there was not much merchandise using MGM copyright material (apart from "Stargate Command" stuff which I believe is MGM) - now I know why.

Sorry for getting anyone's hopes up. I'll be removing the Alteran Bridge Club pages, etc.

2018-12-15

Another new toy

I have posted before, saying I am trying to lose weight, and things have been going slow and steady. Thanks for all the feedback and advice.

With the weather getting worse the "walking" had somewhat stopped, which was a slight issue.

I now have a treadmill! It means I can walk and walk and walk and still be in front of the TV. It goes quite well with my new watch setting goals for daily activity.

Weight loss is once again happening. Yay!

P.S. The watch is still going


2018-12-12

Ho Ho Ho!

My wife usually manages most of the Christmas presents, but this year I have got a few.

It all started with seeing something and thinking "Oh, Lewis would like that", or "Oh, Bobby would like that". Before I knew it I had a few things stacked up for grandchildren and then something for my children.

Of course, with two more grandchildren, next year is going to get even more complicated.

I hope they like the wrapping paper :-)

2018-12-08

New watch

I got myself an early present. A new watch. To be honest, there was nothing wrong with my old one - it never needed charging (solar) and had radio clock so always accurate.

However, I saw this new watch and thought it was at last a vaguely "smart" watch that does not need charging.

I told myself I was not getting a "smart watch" until there was one that did not need charging. I had a Garmin one once, and it needed charging every night and I hated that.

My son, quite sensibly, berated me for buying anything off a Facebook advert on the basis that they are all scams (and sadly, one other thing I bought was a scam and I am waiting to get £40 back from Amex for that). However, to my surprise the watch does not seem to be a scam!


It's a Matrix Power Watch, waterproof, and to my surprise thermally powered! It links to my phone via bluetooth and does calories, steps, distance (how?), and sleep tracking. It has an e-ink type display. It actually has a choice of watch face display, and I hope they add more choices later as I'd rather see one like the above but with larger date and day of week rather than "REALTIME POWER" which is pointless being on the display. It even has a back light!

Also, the strap was crap (in my view), but it is a standard 24mm fitting, so I was able to get a nice metal black strap from Amazon, which is (in my view) much nicer.

So now I am doing the whole "completing the circles" thing, with a new treadmill (another new toy), and trying to get fit :-)

It will be interesting to see how it goes.

I am, however, of the view that these devices are really crap at even counting steps, let alone distance. But if it is consistent itself that will still help ensure I keep up the exercise.

Update: Yeh, it has odd ideas, like 500 steps already when I got up this morning (I don't sleep walk).

Update: After several weeks using it, very few quirks, it actually works, and it its counting steps sensibly it seems. Later s/w is nicer.

2018-12-04

Scripted font generation using fontforge

This is my first attempt at making fonts using scripts... Well, apart from a digits only font, it is my first attempt to make any font! It seemed like a good use of a Sunday afternoon :-)

The plan was to make some fonts based on classic 5x9 dot matrix characters. Not a huge challenge you may think - but I did not want to spend ages positioning dots in a graphical user interface. So I ended up making some C code, that produces SVG for each character and then Python script to use fontforge to make a font from the SVG.

My 5x9 characters are defined in the C code using hex.

   {"A", {{0x20, 0x50, 0x88, 0x88, 0xF8, 0x88, 0x88}}},

That defines the capital A to look like :-
My C code makes an SVG that looks like :-

<?xml version="1.0" encoding="UTF-8">
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="816" height="1024">
   <g>
      <circle cx="255" cy="51" r="40"/>
      <circle cx="153" cy="153" r="40"/>
      <circle cx="357" cy="153" r="40"/>
      <circle cx="51" cy="255" r="40"/>
      <circle cx="459" cy="255" r="40"/>
      <circle cx="51" cy="357" r="40"/>
      <circle cx="459" cy="357" r="40"/>
      <circle cx="51" cy="459" r="40"/>
      <circle cx="153" cy="459" r="40"/>
      <circle cx="255" cy="459" r="40"/>
      <circle cx="357" cy="459" r="40"/>
      <circle cx="459" cy="459" r="40"/>
      <circle cx="51" cy="561" r="40"/>
      <circle cx="459" cy="561" r="40"/>
      <circle cx="51" cy="663" r="40"/>
      <circle cx="459" cy="663" r="40"/>
   </g>
</svg>

Which, as you can see was simple enough.

I also make a Python script (from the C code) along the lines of :-

#!/usr/bin/python
import psMat
import fontforge
f=fontforge.font()
f.version="1.0"
f.encoding="unicodeFull"
f.copyright="Adrian Kennard"
f.weight="Regular"
f.familyname="FiveByNineLED"
f.fontname="FiveByNineLED-Regular"
f.fullname="FiveByNineLED Regular"
f.em=1024
f.ascent=714
f.descent=310

Which has for that letters :-

g=f.createMappedChar("u0041")
g.width=612
g.importOutlines("u0041.svg")
g.removeOverlap()
g.simplify()
g.autoHint()

And finally saves :-

f.generate("FiveByNineLED-Regular.ttf")

Simple enough :-)

As you might guess, I was not going to just make a font as simple as that. For a start it was sensible to make some different weights and an italic variant.

For different weights, I just changed the size of the dots :-


For italic I simply adjusted the position of the dots, and told the font it was italic. I picked 10 degrees.


But that was not all. A simple dotty font looked nice but I felt I could do me. You will note I called this "LED" on the basis that it looks like a simple array of round LEDs as seen on railway stations and many such signs.

But what of LCD. For this I made squares.


For bold I actually made the squares touch, and the overlap removal in fontforge creates an outline of the joined up squares.

However, to make an italic version I could not simply move the positions as I did for the LED version as that creates a staggered row of squares. Instead I had to skew the whole glyph.

My first thought was to simply put an transform="skew(-10)" in the SVG. That worked, but there are limits to what the SVG import will do on fontforge it seems. Combinations of translations on individual components and a group object with a skew did not quite work as expected. I had to make the SVG very simple. Later, with some overlapping rectangles I actually managed to not just make errors from fontforge but segfault it! So I ended up doing the skew in the python!

g.transform(psMat.skew(0.174528))

That seemed to work well for this...


But I could do more... What about the way these fonts looked on an old fashioned CRT? So I made a CRT version which joined the dots horizontally with rectangles.


But there's more. This is something I did in something like 1981 when making a printer driver for a spark jet printer that could screen print BBC Micro MODE7 but not look like crap. Back then I created 45 degree lines joining octagonal dots. This works well for most letters.


But some needed help, notably where a diagonal joins a horizontal or vertical line, I would create a right angle not a diagonal. The fix was making a second "layer" of the bit map. For LED and LCD and CRT this did not matter, a dot was a dot, but for this JTD (Join The Dots) mode, it was needed to allow for things like the diagonal of an R to work...


This was another case which was a challenge. I originally planned on using an SVG path to join the dots, but that did not work. The import messed up the translations somehow, and then the overlap removal in fontforge just did not work. By simply creating a rectangle to join each circle, that worked, even the 45 degree ones, until I tried to apply a skew at the SVG level and that got very upset. A skew applied at the phython stage worked. Oddly the 45 degree ones are still making warnings but creating clean glyphs, so close enough.

Creating a simple ASCII character set was not hard. But these days we need a bit more, and so I went through the extended latin and did a lot of them (that I could sensibly work in a 5x9 matrix). I am sure there are more I can add. Thanks to Ray for pointing me to the SAA5050 data sheet with additional characters. So far over 400 characters, and more may be added over time.



The accents all look a lot better in the join-the-dots version as I could make the joins allow for the accents and not stick the accent to the letter in an odd way...


P.S. In honour of a previous blog post...



P.P.S. the "TXT" version is an attempt to mimic the Mullard SAA5050 character rounding logic.

So this is the result (may be updated from time to time if I add more characters) :-

FiveByNineCRT-BoldItalic.ttf
FiveByNineCRT-Bold.ttf
FiveByNineCRT-LightItalic.ttf
FiveByNineCRT-Light.ttf
FiveByNineCRT-RegularItalic.ttf
FiveByNineCRT-Regular.ttf
FiveByNineJTD-BoldItalic.ttf
FiveByNineJTD-Bold.ttf
FiveByNineJTD-LightItalic.ttf
FiveByNineJTD-Light.ttf
FiveByNineJTD-RegularItalic.ttf
FiveByNineJTD-Regular.ttf
FiveByNineLCD-BoldItalic.ttf
FiveByNineLCD-Bold.ttf
FiveByNineLCD-LightItalic.ttf
FiveByNineLCD-Light.ttf
FiveByNineLCD-RegularItalic.ttf
FiveByNineLCD-Regular.ttf
FiveByNineLED-BoldItalic.ttf
FiveByNineLED-Bold.ttf
FiveByNineLED-LightItalic.ttf
FiveByNineLED-Light.ttf
FiveByNineLED-RegularItalic.ttf
FiveByNineLED-Regular.ttf
FiveByNineTXT-BoldItalic.ttf
FiveByNineTXT-Bold.ttf
FiveByNineTXT-LightItalic.ttf
FiveByNineTXT-Light.ttf
FiveByNineTXT-RegularItalic.ttf
FiveByNineTXT-Regular.ttf

2018-11-30

Making Tax Digital

The "challenge" continues.

Just a reminder - EVERY UK VAT REGISTERED COMPANY (that has to be registered) must be using the new "Making Tax Digital" API to submit VAT returns from April 2019. Do not forget!

We have s/w for this (Onion Accounts), tested, and approved, yay!

So we are trying to put the company (A&A) on the "pilot" so we can actually submit our own VAT return using the new system, before it is all mandatory. A final double check that all is working as it should.

We get to authorise it all, using OAUTH, and get an access token for the read:vat and write:vat access. But it does not work, we are told we are not authorised!

Checking the government gateway VAT pages it seems we have to "sign up" for the pilot. That may explain things, except if we are not signed up then why allow us to "authorise" the access? Surely the OAUTH process should be saying "You are not signed up for MTD VAT" rather than giving the access token and the failing when we try and get the VAT obligations? Crazy...

So, let's try and sign up.... Nope. We get "This service is only available to some limited companies, sole traders, partnerships and VAT groups." which is not that helpful.

We also get "You will be able to sign up for this service from April 2019."

Hang on?!?! This is "Sign up for the pilot". Why would I be able to sign up for a pilot in April 2019 when the pilot is surely over (as MTD VAT is mandatory from April 2019)? Surely they are not making people "sign up" for the mandatory process (they call it a "service" which I dislike).

A bit more digging and we find "You will not be able to take part in the pilot at the moment if you:" ... "currently trade with, or have traded with the EU".

Two issues with this...

Firstly, surely you want people on the pilot with the complex edge cases, not the "simple" cases. You want things to break (if they are going to break) in the pilot and not once the process goes live. So why exclude these edge cases?

Secondly, and this is where the mindset has got us brexit, what UK company does not trade with the EU? Hardly any, I bet. All of our customers and suppliers are in the EU! Yes, almost every single one is also in the UK, but the UK is part of the EU.

Is a Dutch company trading with a Dutch supplier, "trading with the EU"? If yes, then so is a UK company trading with a UK supplier. If no, then neither is a UK company trading with that Dutch supplier. Either the supplier (or customer) is in the EU, or they are not. They are not suddenly "not in the EU" if in the same country as the trading party. Next we'll say that trading with someone else in Bracknell is not trading with the UK, it is trading with Bracknell.

The ideas that there is the "UK", and there is this separate non-UK "EU", an idea perpetrated by HMRC in this case, is part of the problem, IMHO.

Update: Sounds like the "traded with EU" restriction goes away next week, so we may be able to make some progress!

Update: (4th Dec) We have "applied" for the trial.

Update: (5th Dec) We managed to file a VAT return, just in time.

2018-11-28

Granddaughters

I have grandsons, as you may know, but two of my daughters have been in a sort of race to produce our first granddaughter. Yes, I know it does not work like that, honest...

Alice

Alice was born on Saturday. Apart from being a few days earlier than expected, everything went exactly as planned, which is a huge relief. After what happened last time, we all knew the worst that could happen, and everyone was scared shitless that something would go wrong. I am so relieved, and pleased, to say everything went perfectly, and mother and baby are doing fine, back home, and starting the long journey ahead of them with a sweet innocent bundle of joy called Alice.

The hospital were great, and did everything right. Wales is a strange place - the hospital had plenty of parking, and it is free - we're still getting over the shock.

Alice

Odette

Odette was a little more drawn out in her arrival. At one point we thought she would be first, and at one point we thought they were both coming on the same day! My poor wife has been amazing, running back and forth between Wales and Bracknell to be with the girls when they need her. She has not slept for two days, but today (Wednesday) we welcome Odette in to the world.

Her big brother, Lewis, has been great. He clearly adores her already, and says she is cute.

So now I have two grand-daughters all of a sudden. Well done.

Odette

2018-11-19

Cal Mah

I nearly called this "Cal Meh" but I feel that is probably more a reflection of my expectation than the event itself. In case you missed it, Cal Mah was a Stargate fan event in Leicester this weekend. It was quite small (I felt), but that is probably to be expected for a UK event. It had some talks, and some of the actors, and a few stands with vendors. I went on the Saturday and felt it did not really justify two days, for me. I suspect that had the organiser not decided to unilaterally cancel my expensive ticket, then I may have had more fun with the extra evening events. Shame.

I am not one for dressing up, sorry, but I did go as far as a lab coat and an "Area 51 ID card". I even made a card for the organiser, and left at the desk when I left. No idea if he likes it, he has blocked me on twitter!

I seem to have been banished to a ship in a distant galaxy!

What was interesting was the number of people that did dress up, and some of them in quite impressive costumes. It seems like quite a community of fans, very friendly.


So, yes, a fun small event. If I can find someone to go with, I may consider one the the bigger events such as Gatecon in Vancouver, one day. I was surprised to see someone dressed as a full Star Trek captain though!

As for the event organisation, obviously I'm not impressed with my ticket being cancelled. It was three weeks after the "misunderstanding" on Facebook and with no warning. It was after I had spent money on a hotel room which he refused to cover. I still don't know who is actually running the event though - "FCD Events presents Cal Mah" does not explain the legal entity involved at all. I saw no terms and conditions as part of buying tickets, and the receipt from PayPal says it was paid to the organiser personally. It seems no data protection registration that I can find, and not complying with PECR (he emailed trying to sell more tickets using the email I used to buy the ticket, with no opt-in having been requested). No accessible privacy policy (just a generic contact link). I'm rather concerned that it is pitched as a charity, which has a whole set of rules of its own. Lots of rules (and laws) broken, or so it seems to me. In the end I decided to go, and not waste the hotel booking for which I would have no doubt had to sue to get my money from the organiser. It really was not the way to treat a fan (or a customer)! Had it gone better, not only would it have been a couple of expensive tickets but could have been a stand at the next event, etc. I am far happier being involved in events than just going to them. I could certainly have informally helped him with meeting some of the legislation! Oh well.

2018-11-11

SVG all the things!

I am quite amazed how many things in the business are postscript based, i.e. code or scripts generating postscript, or just hand crafted postscript files, which are then converted to PDF or printed.

I have been working all week on this, not just the plastic card printing, but now the invoices and statements and letters from the accounts system. Because of my new library for fonts I have also been updating systems that were already SVG based but coped badly with long names and strings.

But there is still a lot to do, so this is not going to happen over night.

The main change now for invoicing is the system generates SVG files. I originally planned on making simple multiple page SVG using inkscape style "layers" but actually inkscape is slow to load a multiple page SVG anyway even though it can pick out one page to convert to PDF. SVG does not (yet) have pages as a concept, but that may happen soon. Sadly I cannot seem to easily script loading once and then converting each page, so I ended up making multiple SVG files. But I have the option to make one SVG file, and I may make one that is interactive with page turn buttons, for use in a web page as well.

As has been a big topic on my blog, of late, fonts have been the challenge. I am getting the hang of it now. Latest annoyance if font family names - where some fonts have one family name and many weights and slants and so on, but others make each combination a different family name. I have ended up with code to "normalise" this (including, in one case, removing a trailing space from a family name which refused to work in the browser even in quotes!).

It also took me a while to realise that SVG font-style is *just* the slant (normal, italic, oblique), and also that SVG font-weight is 100-900 but free type uses a totally different scale. Oh, and it is normal, not "normal" when using in a style, but always "normal" when used as an XML attribute (obviously).

Anyway, finally we have a system which uses SVG masters as a letterhead and template for the content of invoices, statements and letters. This allows a lot of fine tuning (the accounts system is used by a lot of different companies). The old system using postscript allowed even more fine tuning but only if you could code postscript. This way you can edit a letterhead or layout in inkscape, which is a lot easier.

I have even set up a system to allow font control at various levels, even per account. This means we could set up an account for large print, for example. There are limits on what will fit with invoices and statements, but we can make text much larger in most cases, and text on letters even larger. We can also control font, such as using the Open Dyslexic font, if wanted. Whilst I doubt we would get many requests, especially as such documents are almost always emailed and so easily scaled on screen, we have the option now.

The other good thing is the new PDFs have much better copy/paste of content including good unicode support. I expect this would help screen readers extract text more easily.

Whilst mostly the plan was to make an equivalent system for invoices, statements, and letters, I have taken the chance to improve some things - such as a summary and totals on page 1 of invoices when they do not fit on one page.

Right now, some customers are on new format, so we can get some feedback, but we'll switch over completely soon. The "formal" invoice remains the PGP signed plain text that is emailed, but the PDF and print versions should be much nicer now.

Even so, much more to do - things like the call data records need changing and improving. This is a bit of a never ending task.

And finally, I have to say how excellent Google Fonts is. I have not loaded them all, but so far a reasonable selection can be seen on the card printing system, which I have managed to group by the base font family name. I'm happy to load any more free fonts if people have requests.


Thanks for the help from those that have been testing, especially Neil for his pedantry.

P.S. This seems odd in a way, laying out letters, as one of the very first projects I ever coded was a text editor and formatter for a TRS-80 written in Z80 code and printing to a daisy wheel printer over a Centronics interface. How time flies...

Non breaking spaces

Arrrg!

There is the normal space character (0x20), and there is the non breaking space character (0xA0).

I was not expecting to have to do anything with these specially in any way to be honest apart from spotting space characters for paragraph text wrapping logic...

However, I have run in to snags, and ended up having to add it as a special case in my code.

The first snag is simple - some fonts (and only a few) do not have the non-breaking space character encoded. So my new font system wants to know the size of every character to work out layout of text in SVG, and it "falls back" to Google NoTo fonts to find the character if missing.

This logic was originally for Emojis, but actually has the full Google NoTo set now, so does Egyptian hieroglyphics and so on. It works well (once you remove the Color[sic] Emoji font).

Thankfully most of the fonts I am using even have extended Latin, so things like Polish crossed "l" characters just work in the base font. Google's free fonts are pretty good!

The problem is that when the main selected font has no non breaking space I fall back, and I hit the Emoji font quite quickly which does, only it is about twice as wide as you expect!

So my text ends up with non breaking space encoded in the Emoji font, and being wide.

Well, this is not ideal, but why would I encounter non breaking spaces anyway? Well, because when I make the SVG output, extra spaces, and leading spaces, and trailing spaces, are all zapped. So any actual formatting with spaces (especially if using mono-spaced fonts) is totally lost. This is bad enough, but I have worked out the size with the spaces and so the result looks horridly stretch to fit the space it should take with all the spaces in place. This took me ages to find as one string I was testing with had a trailing space which I had not spotted. So now I convert all spaces to non breaking spaces for output to SVG.

This them hit the first snag that the non breaking spaces are not in the font, and so I ended up coding all spaces in Emoji (for some base fonts). Again, not spotted originally as the font I was using had non-breaking spaces encoded, but another font did not and just looks horrid spaced!

I have ended up:- (see P.S.)
  • Using only spaces for text wrapping (so non breaking spaces do in fact non-break)
  • Converting non breaking spaces to spaces for all width calculation
  • Converting all spaces to non-breaking spaces when making final SVG
It seems to finally work...

Fonts are fun!

P.S. xml:space="preserve" is your friend - it preserves spaces as they are.

2018-10-31

𓂸

One of the things that has always slightly amused and puzzled me is that unicode lacks a "cock" glyph. I mean, it seems to have characters and symbols from modern and historic cultures and forms of writing, and surely cave men have been drawing dicks on cave walls for tens of thousands of years, so why is this missing?

I can only assume someone is being prudish, and oddly enough people have used the eggplant 🍆 emoji for this, amongst others, so clearly there is a "demand" for this emoji.

What I never realised, until now, is there would appears to be one already, thanks to Egyptian Hieroglyphs!

There seem to be three of them!

𓂸𓂹𓂺

And for those of you on Windows with a censored font (what a thing!) this is what they look like.


They are rather innocuously named U+130B8: EGYPTIAN HIEROGLYPH D052, U+130B9: EGYPTIAN HIEROGLYPH D052A, and U+130BA: EGYPTIAN HIEROGLYPH D053.

I cannot actually work out what the middle one is meant to be doing, to be honest. Looks painful.

Someone will no doubt explain to me that in fact that is not what the hieroglyph is and that I just have a dirty mind, but if that were true, why are they apparently censored in some fonts?

Reference: http://xahlee.info/comp/unicode_egyptian_hieroglyph.html

Who knew?!

P.S. Why was I looking for unicode dicks? I was not, but was checking if hieroglyphs worked on my new card printing system, and to my surprise, they do! May have to be time for a new SSID I think :-)

P.P.S. (yes, all the daft ones are on 2.4GHz so don't impact any of our devices)


P.P.P.S Wow, what a time to be alive!


2018-10-26

Playing cards

Well, I am pleased to say we now have five packs of cards on Amazon. Sadly we don't have the Stargate cards yet, and I have a bad feeling that is going to finally hit a brick wall (more on that later).

Click on the pack for the Amazon page. Ideal Christmas present / stocking filler :-)



P.S. And yes, these are going for cost price, but if they are popular I'll buy in a larger quantity and get the price down.

A&A branded (with extra 11 card)
FireBrick branded (with extra 0 card)
RevK branded Left Handed deck
RevK branded Goodall & Son reproduction deck
RevK branded (well sort of) White Minimalist deck

All designed by me, see https://www.me.uk/cards for downloadable artwork for my card designs.

SVG being a tad special

I am pleased to say the work on fonts and SVG has, well, worked. FreeType just worked, and I was able to have a string of Google Noto fonts as backup for missing characters, so emojis, runes, Polish accents, all just worked. Even my new Farrington 7B font. Yay!

This is an update to A&A card printing.

But one aspect really fooled me.

In SVG you can have a text object, and that can be stand alone with the text as the content and attributes like font-family and font-size.

But you can include within it tspan objects. The advantage is that this allows different attributes for some text in-line.

For example changing to an Emoji font part way through, or some other font, or italic, etc, etc.

So far so good.

Then we come to the textLength attribute on text and tspan. This is meant to tell the application the calculated length of the text. As I now have FreeType working that out, and setting lower when I want to squash text, I have the figure to use. I added to the text element, and, err, nothing (when using tspan within text).

So... let's add to the tspan elements. I did this, and obviously I set the textLength on each tspan as the calculated length of that tspan.

It seems I am wrong. I do need to put the textLength on the tspan elements, but they have to be the total text calculated length not the length of the tspan!!!!

Update: For browsers I need textLength on tspan, but for inkscape (which makes the actual images for the card printing) I need textLength on the text object, so setting both!

Me no understand!

P.S. Everything but Safari struggles with a large value for font-size even when in a scaled SVG, showing things short (but stretched to textLength) and different if rotated! I may have to tinker with that at some point to work around. I am sure the SVG is fine!

P.P.S. I embedded fonts in the SVG for use as above, but even though that works in safari (and other browsers), it does not in inkscape. Shame.

P.P.P.S. This is what it looks like now.



P.P.P.P.S. I now have myself a nice svg/font library to do text objects, squashed, wrapped, justified, aligned, all sorts, based on system fonts using the fontconfig library to find system fonts and the freetype library to extract metrics. Works a treat and already deployed in four different systems we have using SVG (e.g. business cards if names are too long, etc).

2018-10-24

Better audio

I was getting pretty good (I think) with some of my videos, using two cameras and so on, but as I have said before, audio is always an issue. This is largely because my "man cave" is quite echoey.

I did get a lapel mic, and that improved things a lot, but I figured I could do better.

As an example, with the previous mic https://youtu.be/mYBRTz2ReZQ

But with the new mic https://youtu.be/mjJaOKZ4S0c

The new lapel mic is itself a lot better it seems, a lot clearer. But also I got a shotgun mic. So when recording messing with cards I pointed the shotgun mic at the cards for sound effects, and it hardly picked up any dialogue at all, perfect. My first attempt at mixing in an effect track with a dialogue track. I'll get the hang of it yet.

The new lapel mic is Movo LV8-C and the new shotgun mic is RODE NTG2, but also needed an XLR lead and mic holder.

I also got a Tascam recorder, as it seems able to do 4 tracks of 96kHz/24 bit with no problem, which is nice. It actually seems like quite a nice recorder, but I seriously doubt it is a factor in sounding better.

Of course, this is also the kit I have here for when I do live TV broadcasts from here :-)

2018-10-23

On the matter of fonts and copyright

I think I am making some progress on using FreeType to work with fonts (previous blog post). And no, I am not planning to include my new Not Alteran font (blog post).

The plan is to move some things I previous did using postscript to SVG, mainly because of its much improved unicode handling. By being able to determine metrics when creating the SVG I can create an SVG that does line breaks and stretching or whatever correctly for the font.

One of the targets for this work is my existing card design platform. It needs some improvement I know, and I have done quite a few things recently, but moving to SVG would make it much neater - not only to see the designs on screen, but also to make cards using unicode characters properly.

And no, not just for emojis (though they will be included in the logic), but for all of the accented characters. Even just doing cards for a school reunion ran in to issues with the default Postscript font, and I still cannot manage some Polish names! Unicode would solve that properly.

Thankfully there are quite a lot of free web fonts (google do loads), so the system can use those. But there is one font that is annoying me. The Farrington 7B font.

It is defined in ISO 7811-1 which is one of the specifications related to bank cards, and is the font for the main large digits on the card (e.g. credit card number). The ISO standard has an appendix with detail drawings of the character outlines with measurements. They are simple as they are lines and arcs only. I had a copy of ISO 7811-1 ages ago for work, but don't have one now. I could pay for one I guess. Somehow they do manage to kill off dodgy copies just on the Internet (having paid once for a copy I can no longer find, I feel somewhat justified in using a dodgy copy if I could find one).

Also, there are several sites selling the 7B font. And it got me wondering, I may as well make one (assuming I find / buy a copy of the ISO). But then I don't actually have a clue what he copyright issues are here!

Fonts are special from a copyright point of view in that the font itself has copyright, but instances of use of the font are allowed. i.e. the font is like the written recipe and the printed work using it is the cake.

But an ISO is meant to be a set of instructions you can follow. You can make the bank cards following the instructions in the ISO you paid for, and presumably follow them to make an embossing machine to emboss the Farrington 7B characters, and do so without copyright issues.

So can one make a font from the details in the ISO and not be breaking copyright by effectively copying that appendix of the ISO in to a font? I have no idea.

The other issue is the font design tools - I need to work out if I can enter co-ordinates. It seems that they are designed to allow one to draw and drag points, and set guide lines, and so on, not simply enter co-ordinates off an engineering drawing.

The other annoying thing is that I have the spec converted to a Postscript font which I use now. I must have done this at least two decades ago.. From this I should be able to re-work the drawings, but to be honest, that is probably more work than the cost of paying for the ISO again.

Anyway, if I do make a font, I'll publish it for free. It is 10 digits, and that is it.

%% Farrington 7 B characters (credit cards)
/7B 50 dict dup begin
/FontMatrix [1 233.7 div 0 0 1 233.7 div 0 0] def
/FontType 3 def
/FontBBox [20 0 120 170] def
/FontName (Farrington 7 B) def
/PaintType 3 def
/Encoding 256 array def
/CharStrings 11 dict def
0 1 255 { Encoding exch /null put}for
/Private 10 dict dup begin
/m/moveto load def
/l/lineto load def
/x{currentpoint exch pop lineto} bind def
/y{currentpoint pop exch lineto} bind def
/cp/closepath load def
/an /arcn load def
/a /arc load def
CharStrings /null {} put
/c {Encoding 1 index dup (0)0 get add exch ( ) cvs cvn put
    ( ) cvs cvn CharStrings exch 3 -1 roll put} bind def
{-15 80 m 15 50 30 90 0 an 15 -50 30 0 -90 an -15 -50 30 -90 -180 an -15 50 30 180 90 an
 15 70 m -15 50 20 90 180 a -15 -50 20 -180 -90 a 15 -50 20 -90 0 a 15 50 20 0 90 a}0 c
{-5 80 m 5 x -70 y 45 x -80 y -45 x -70 y -5 x 60 y -15 x 70 y}1 c
{-45 74 m -15 0 80 110 90 an 15 50 30 90 0 an 15 25 30 0 -90 an
 -15 -25 20 90 180 a -70 y 45 x -80 y -45 x -15 -25 30 180 90 an
 15 25 20 -90 0 a 15 50 20 0 90 a -15 0 70 90 110 a -41 65 l}2 c
{-45 74 m -15 0 80 110 90 an 15 50 30 90 0 an 15 25 30 0 -60 an 15 -25 30 60 0 an
 15 -50 30 0 -90 an -15 0 80 -90 -110 an -45 -74 l -41 -65 l -15 0 70 -110 -90 a
 15 -50 20 -90 0 a 15 -25 20 0 90 a -25 x 5 y 15 25 20 -90 0 a 15 50 20 0 90 a
 -15 0 70 90 110 a -41 65 l}3 c
{-45 80 m -35 x 5 y 10 x 80 y 20 x 5 y 45 x -5 y 20 x -80 y 10 x -5 y -45 x}4 c
{-45 80 m 45 x 70 y -35 x 5 y 15 -25 30 90 0 an 15 -50 30 0 -90 an
 -15 0 80 -90 -110 an -45 -74 l -41 -65 l -15 0 70 -110 -90 a 15 -50 20 -90 0 a
 15 -25 20 0 90 a -45 x}5 c
{-45 80 m -35 x 0 y -15 -25 30 110 90 an 15 -25 30 90 0 an 15 -50 30 0 -90 an
 -15 -50 30 -90 -180 an -45 80 l 15 -5 m -15 -25 20 90 180 a -15 -50 20 -180 -90 a
 15 -50 20 -90 0 a 15 -25 20 0 90 a}6 c
{-45 80 m 45 x -80 y 35 x 70 y -45 x}7 c
{-20 80 m 20 55 25 90 0 an 20 35 25 0 -30 an 10 0 l 20 -35 25 60 0 an 20 -55 25 0 -90 an
 -20 -55 25 -90 -180 an -20 -35 25 180 120 an -10 0 l -20 35 25 -120 -180 an
 -20 55 25 180 90 an 20 70 m -20 55 15 90 180 a -20 35 15 -180 -120 a 0 6 l
 20 35 15 -60 0 a 20 55 15 0 90 a -20 -70 m 20 -55 15 -90 0 a 20 -35 15 0 60 a
 0 -6 l -20 -35 15 120 180 a -20 -55 15 -180 -90 a}8 c
{45 -80 m 15 50 30 0 90 a -15 50 30 90 180 a -15 25 30 -180 -90 a 15 25 30 -90 -70 a
 35 0 l -80 y cp -15 70 m 15 50 20 90 0 an 15 25 20 0 -90 an -15 25 20 -90 -180 an
 -15 50 20 180 90 an}9 c
end def
/BuildChar
{
 exch begin Private begin
 140 0 FontBBox aload pop setcachedevice 70 85 translate
 1 setlinecap 1 setlinejoin 10 setlinewidth
 newpath Encoding exch get CharStrings exch get exec closepath
 gsave
 %strokepath
 %0 setlinewidth
 stroke
 grestore
 fill
 end end
} bind def
end definefont pop

Update: First attempt at font here.


P.S. I was slightly cursing ISO 7811-1 as (apart from a couple of obvious typos) the dimensions were nasty and did not even add up exactly. E.g. character width 2.54mm but adding the stroke width to the control points gave 2.55mm. I am, of course, being thick, convert the dimensions to tho (1/1000th of an inch) and they come out as nice round numbers. Even the small rounding radius (0.13mm) comes out as 5/1000", and pretty much everything comes out as a multiple of 5/1000". I probably should have converted to tho first as it would have made it a lot easier to work out the co-ordinates. I may re-do some time.

P.P.S. I did redraw, converting to 1/5000th of an inch, which made some nice round numbers.

FB9000

I know techies follow this, so I thought it was worth posting and explaining... The FB9000 is the latest FireBrick. It is the "ISP...