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).

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.