Monday, November 21, 2011

Spanish election results confirm “Catalonia is not Spain”

El Punt Avui - Catalonia is not SpainThe Catalan language newspaper, El Punt Avui proclaims in English that “Catalonia is not Spain” this morning, in an attempt at explaining how the Catalan conservative party CiU managed to stem the blue tide of the rightist Spanish Popular Party that swept through most of the rest of Spain. The slogan in English, usually used by protesters at international events to bring attention to the ongoing struggle for more autonomy in Catalonia, neatly sums up the election results: the rightist Partido Popular swept the ruling PSOE party out of office in a stunning defeat, but were unable to make inroads in Catalonia, where the Catalanist though perhaps equally conservative CiU party took the region for the first time ever in general Spanish elections.

Spanish Election ResultsWhat the slogan doesn't explain to outsiders is why Catalonia is so different, and how the PP could have had such lackluster results there while sweeping every other part of Spain except the Basque Country, as shown in the map to the right.

The answer is that elections in Catalonia, especially “general elections” in which the seats in the Spanish Parliament are chosen, have various axes, not only right vs left, but Catalanist vs Spainist, for want of better terms. The important leftist parties in Spain have local affiliates in Catalonia that are mostly seen as hewing to the centralist party line. They tend to win country-wide elections and lose local ones. The right in Catalonia, however, is divided between the local affiliate of the Spanish Popular Party—whose francoist roots make it a particularly hard sell in Catalonia—and the completely homegrown CiU, whose wildly popular leader, Jordi Pujol was president of the Catalan Parliament for 23 years between 1980 and 2003, and with these results completed the trifecta after already having triumphed in recent municipal and Catalonia-wide elections.

It seems unsurprising that Catalans would want to kick the Socialists out, but would choose to do so without running into the arms of the PP, whose party was behind the recent trampling of Catalonia's new Statute of Autonomy, as well as attacks on the successful and popular Catalan-immersive educational system.

CiU clenched the deal with a big promise: they will demand a “fiscal pact” with Madrid, and if rebuffed, will demand political independence. Catalonia currently pays some 10% more in taxes than they receive in services from the central government, and the current fiscal crisis is fueling resentment in Catalonia. Catalans see brand new schools, free highways, and high speed trains in sparsely populated areas of Spain while being forced to make substantial cuts in medical, educational, and transportation services of their own.

As Salvador Cardús put it in What Catalans Want, “We live in a situation in which we are denied the guarantee that our daily work will contribute in any way to our prosperity.”

It's important to remember that Duran i Lleida, CiU's candidate, is more unionist than separatist, despite convenient rhetoric to the contrary. Last night he said, “Catalonia is different from the rest of the country. Today, these results confirm more than ever that we are a nation.”


It will be interesting to watch these next few months.

Thursday, November 17, 2011

Taking Screenshots with Kindle Fire

Renumbered at 4:02pm; Updated 3:47pm, thanks to corrections made by Wangen. (The mistakes were mine, not Erica’s.) Thanks, Wangen!

I just got off the phone with Erica Sadun, geek girl extraordinaire, who had posted instructions yesterday on how to take screenshots on a Kindle Fire but who kindly walked me through the process today. I'll explain what she told me in case you too are interested.

Let me preface this with the fact that I've never used Android before today. If you, too, are new to Android, you should find everything you need in these instructions. If you already know Android, you'll probably be bored.

1First, connect your Kindle Fire to your Mac. (I don't think the process is very different on a Windows or Unix box, but to be honest, I really don't know.) 

2Next, download the Android SDK. You can find that here: http://dl.google.com/android/android-sdk_r15-macosx.zip. You don't have to install anything else besides this.

3Unzip the folder and place it wherever you would like it to be on your computer. I put mine in my Documents folder. You'll need to know the location later on in the process, so I would recommend not burying it too deeply into your folder hierarchy. The folder starts out with the name android-sdk-macosx but you can change it to something faster to type (like android). Don't change the names of the things inside that folder.

4Next, open Terminal. It should be in the Utilities folder inside the Applications folder.

5When you open a Terminal window it defaults to your home directory. You have to navigate to the android sdk folder you just downloaded. Since I put mine in my Documents directory and I changed its name to "android", I typed:

cd Documents/android

(The cd stands for change directory.) Terminal will confirm that you are now "in" that directory by changing the prompt at the beginning of the line.

6Next type this:

./android

The Android SDK Manager should appear.

Erica told me to choose the "Android SDK Platform-tools" box and deselect everything else. Then click "Install 1 package…" at the bottom right.

Android SDK Manager

Next, you'll get the "Choose Packages to Install" window. Make sure it's the Android SDK Platform Tools in the upper left corner, and then click Install.

Choose Packages to Install

Once the package is installed, the ADB will have to be restarted. Click Yes.

ADB Restart

7Next, go back to the same window in Terminal, and create a symbolic link (a sort of alias) by typing:

ln -s ../platform-tools/adb adb

8Now, still in Terminal, to see if the Fire is connected, type

./adb devices

The output that you want looks like this:

List of devices attached
6C78000600000001    device


If you do see that, skip on ahead.

If, instead, you just see

List of devices attached

all by its lonesome—which is what I saw—we have to do a few more steps.

9First, we'll stop and restart the adb server. First type:

./adb kill-server

10And then type

./adb start-server

You should see this:

* daemon not running. starting it now on port 5037 *
* daemon started successfully *


11Now see again if your Kindle Fire device is listed, by typing

./adb devices

If it still doesn't show up, we'll edit the adb_usb.ini file.

12To do that, open a brand new Terminal window, leaving the old one open since we'll go back to it.

13As ever, Terminal starts you out in your home directory. Type:

cd .android

It turns out that this is the default location for android stuff on any Unix machine (like a Mac).

14Now type

touch adb_usb.ini

15That creates the adb_usb.ini file. Make sure you have a text editor that can save with Unix line endings like the free TextWrangler (or more powerful but not free BBEdit). Then type

open -a TextWrangler adb_usb.ini

16(Or type open -a BBEdit adb_usb.ini if you have that program.) Copy into it, the following four lines, being very careful to create a return after the last line:

# ANDROID 3RD PARTY USB VENDOR ID LIST -- DO NOT EDIT.
# USE 'android update adb' TO GENERATE.
# 1 USB VENDOR ID PER LINE.
0x1949



17Choose Save as and make sure that Unix (LF) is chosen in the Line breaks menu.

SaveUnixLF

18Then type

cat adb_usb.ini

in order to see your work. If you see it just as it appears above, you can continue to the next step. Unfortunately, mine appeared all jumbled on a single line (because I originally used TextEdit) and so Erica surmised that I had somehow entered the returns incorrectly and she emailed me the file. (You can download a zipped copy of that file here.

19Be sure to unzip it and place it on your Desktop before continuing as below.) I copied it to my Desktop and then from the second Terminal window, typed:

mv ~/Desktop/adb_usb.ini .

Which says "move the adb_usb.ini file from the Desktop to the current directory (represented by that final period).

Again I typed

cat adb_usb.ini

and this time, it looked like the four lines above. (Don't forget that final return after the 0x1949 line!)

OK, almost there.

Now, we go back to the first Terminal window, and for good measure, we'll stop and start the server once more. Type

./adb kill-server

And then type

./adb start-server

You should see this:

* daemon not running. starting it now on port 5037 *
* daemon started successfully *


Now see again if your Kindle Fire device is listed, by typing

./adb devices

You should really see 

List of devices attached
6C78000600000001    device


If you still don't see a device, make sure that your Kindle Fire is connected, and that the adb_usb.ini file has been correctly configured.

20The next step is to start up ddms. In the first Terminal window, type

./ddms

You should see something like

2011-11-17 13:16:02.750 java[4451:1707] [Java CocoaComponent compatibility mode]: Enabled
2011-11-17 13:16:02.751 java[4451:1707] [Java CocoaComponent compatibility mode]: Setting timeout for SWT to 0.100000


21The Dalvik Debut Monitor window will appear. You should see your Kindle Fire in the upper-left corner. Select any of the lines under your device as shown here:

Dalvik Debug Monitor

22Now to make a screenshot, press Command-S.

Device Screen Capture

The first I tried it, it came up black, because my Kindle had gone to sleep. Just wake up your Fire and then click the Refresh button. Click the Rotate button to get it to go the right way around, and then Save to create a PNG file. Here was my first screenshot (note that I added the drop shadow with Skitch):

KindleFireScreenshot


To take screenshots of the Kindle in action, you'll have to dismount the Kindle from your Mac by clicking the Disconnect button.

If you've left the Device Screen Capture window open, you can hit the Refresh button to see whatever you now see on your Kindle. For example, the first few sample books that you've downloaded:





And I think that's it.


Many, many thanks to Erica Sadun, without whose help I wouldn't have known even where to start. If anyone wants to add what's different on Windows and Unix machines, please add them to the comments.

Friday, November 11, 2011

Embedding fonts in iBooks without bugs

Pablo Defendini posted an error to the #eprdctn group on Twitter this morning and Susan Neuhaus quickly concurred. Both posted screenshots and code. Chris Casey quickly googled a bug report and solution on StackOverflow. Amazing collaborative group!

I found the bug report a little hard to understand and tried to recreate the problem. But I couldn't. I tweeted back to Pablo who recommended I experiment with Google Web Fonts, which is what he had used. And lo and behold, I discover a whole treasure of open source fonts available for commercial use and embeddable in EPUB books. I send a heads-up to Eric Hellman who is doing a similar project with funding ebooks up front so that they too can be free. The Zen of Ebook Production.

I had looked at Google Web Fonts ages ago when it was still just on the web. You had to link to them and there was the worry that if Google went down, so would your fonts. This also made them unavailable for EPUB use. No longer. Now you can download Google Web Fonts (and there are some really nice ones) and embed them in your own books. Of course, you don't have to use Google Fonts, all the info here is valid for any embedded TrueType or Opentype font. Here's what you do:

Use this code in your CSS:

@font-face {
    font-family : NixieOne;

    font-weight: normal;
    font-style: normal;
    src : url("fonts/NixieOne.ttf");
}


NixieOne is the name of the font I used. The name you use for font-family shouldn't matter, but I have found that sometimes it does. To be safe, double-click the downloaded .ttf or .otf file, and use the name that's listed in the menu. You don't need to install it to use it for EPUB.

The font-weight and font-style items are required. It seems, though I find this unclear in the CSS3 spec (info welcome), that these should not be necessary as they are the default values. However, Webkit (on which Safari and iBooks are based), does not default to them, and without them, will not allow you to apply bold or italic formatting at all. So, use them!

Then in your CSS, when you want to use the font for a given selector, use font-family, as shown here:

h1 {
     font-family: NixieOne;
     ...
     }

And now back to the bug in iBooks. It turns out that if you embed a font—seems that it happens with both TrueType and OpenType fonts—and that font is formatted in bold, then iBooks will render it incorrectly, most noticeably with thinner fonts and at larger sizes. (This is a simple, single stroke font and should not look this blurry.)

iBooks double-rendering bold bug

Note that it doesn't matter if you set the font-weight: bold yourself as in:

p {
     font-family: NixieOne;
     font-weight: bold;
}

or if it's in the default stylesheet for the selector as in:

h1 {
     font-family: NixieOne;
     }

Since h1 (h2, h3, etc.) are all bold by default, this text will also be rendered incorrectly:

iBooks double rendering bold bug

The solution is to first remove the bold:

h1   {
      font-family: NixieOne;
      font-weight: normal;
}


and then, if desired, create the bold with something other than font-weight. The folks at StackOverflow recommended -webkit-text-stroke and text-shadow.

Here's 1px stroke:

h1   {
      font-family: NixieOne;
      font-weight: normal;
      -webkit-text-stroke: 1px black;
}

webkit text stroke

and with 2px stroke:

h1   {
      font-family: NixieOne;
      font-weight: normal;
      -webkit-text-stroke: 2px black;
}


2px webkit text stroke
and here's text-shadow with a value of 1px:

h1   {
      font-family: NixieOne;
      font-weight: normal;
      text-shadow: 1px 1px #000;
}

text shadow for bold

I think all three are reasonable options and the choice depends on aesthetics more than anything else.

More thanks for helping figure this all out. Paul Irish for his @font-face gotchas page. Webkit for explaining -webkit-text-stroke. And finally to Sandra Williams, who sent me this page just as I was finishing this post. Someone else will have to follow through with that code—especially given the caveat about Safari at the end. Still, it looked interesting.

Keeping it together - Page breaks in iBooks

I've been doing a lot of testing with InDesign CS 5.5 and was surprised this morning to find that the CSS it uses to create page breaks in EPUB documents actually works in iBooks. It used to be that iBooks only supported page breaks when they were in local CSS, and then it supported it in external CSS, and then for a while it didn't support even that, but now it looks like full iBooks support for page breaks is back.

Maybe this is a good time to go over the page breaks capabilities in CSS and what iBooks supports. While they don't give absolute control over where elements appear on a page, they have an enormous influence on how professional the page looks. (Note the design of these pages is bare-bones, the emphasis is on page breaks.)

The three CSS properties are page-break-before, page-break-after, and page-break-inside. Each one can take values of auto, always, and avoid, and the first two also accept left and right, though iBooks does not yet support those values.

If you want a title to appear alone on a page, you could use

.title {
     page-break-before: always;
     page-break-after: always;
     }

but note that if that is the first page in your EPUB, iBooks will show a blank page at the beginning (since it creates a page break before your title). In which case, you should only use:

.title {
     page-break-after: always;
     }

page-break-after


In order to make a header always start at the top of the page (together with the content that follows it), use:

.header {
     page-break-before: always; 
     page-break-after: avoid;
     }


page-break-before

And if you want to keep a photograph with its caption, you could use

.group {
page-break-inside: avoid;
}

assuming that you've got a div with class="group" that contains both the image and the caption.

page-break-inside-avoid

It would be really, really nice if iBooks would support the CSS widows and orphans properties. But it doesn't yet. (NOOK does, yay.)




Thursday, November 10, 2011

Non-allowed characters in filenames in EPUB

I got an email from a reader yesterday wondering about an error that iTunes Producer was giving as it rejected his EPUB submission to the iBookstore (despite having passed EpubCheck with nary a murmur), to wit:

ERROR ITMS-9000: "Invalid URI in NCX file Title Page.html :
Illegal character in path at index 5: Title Page.html" at Book
(MZItmspBookPackage)

When he converted the spaces to underscores, the errors went away and iTunes Producer accepted his book.

His book was originally created in InDesign, and it was InDesign that failed to convert the spaces to their hex equivalents so that iTunes Producer wouldn't choke.

Until Adobe updates its software, and for everyone who codes on their own or with some other tool, I recommend restricting filenames to the 26 unaccented letters of the English alphabet, the dash (-), and the underscore (_). That includes the names of documents in an InDesign book, images, videos, audio, CSS files you apply upon export, whatever.

Note that you can have spaces in titles, say Chapter 1, just not in filenames of those chapters, e.g., chapter1.xhtml.

A quick search on Mobile Read reveals that this is not a new issue.

Thanks so much to Edward Matte who brought this to my attention and shared his error reports and progress with me (and all of us).



Wednesday, November 9, 2011

Organic Farming and Ebook Piracy

Yesterday in my car I was listening to a recent episode of this excellent Catalan radio show about technology (and “what people do with technology”), l'Internauta, hosted by Vicent Partal. The filmmaker, Anna Boluda, was co-host, and the special guest was Simona Levi who was talking about "free culture" and lots of other interesting things

At 37:09, Vicent said something that really caught my ear (my translation, original at end of post):
Two things that I always put on the table and that at Vilaweb [Vicent's news portal] we are always thinking about and working on: the first is sufficiency, that is, you don't have to earn that much money, you just have to earn enough, no? I mean, is it possible to imagine a model in which, for example, in our case, those who are really interested and care about Vilaweb pay for it, and for those for whom it's just another website, well, thanks for reading. You don't have to make everyone pay, you can find a mass of people that is enough for you and you don't necessarily need everyone to pay you.
The second thing, said the other way around, is sustainability, that is, you have to know what you need to keep yourself financed and you have to act from that base of sustainability for your own project. In my opinion, that comes naturally and doesn't need complicated algorithms or arguments, it's just that there's a certain equilibrium, no? between the people who say I'll pay [and those who won't] and if the ones that are willing to pay are enough, well, you don't have to force the machine and turn yourself into a huge global power, I don't know, I see it as one of the keys, and of course, the only problem is that sufficiency ends up depending on each person, for one person it's enough to have a house, and for the next guy only a three masted yacht will do...
And it made me think about something I read in one of Barbara Kingsolver's books, maybe it was Prodigal Summer. It doesn't really matter where it came from; it's a common tenet of organic farming... that you have to plan to make a big enough crop so that losing some of it to "pests" isn't the end of the world. And not only that, if you spray pesticide over your crops to kill the bad bugs, you inevitably kill lots of beneficial bugs as well.

What are the beneficial bugs in the ebook ecosystem? They are your loyal readers who want to read your book and then will talk about it with other people so that they want to read your book too. When you tie your ebook up with DRM, you make it a hassle not just for pirates (who, like corn borers, just evolve to beat you another day) but for the folks who would buy your books and promote them to your friends.



You can find the recording at Vilaweb. Here's my rather wobbly transcript of Vicent's Valencian Catalan:
Dues claus que jo sempre poso sobre la taula i que també a Vilaweb estem d'alguna manera amb +Vilaweb pensant i treballant sobre tots aquests conceptes: un el de suficiència, és a dir, no cal guanyar tants diners, cal guanyar els justos, no? és a dir, és necessari, podem plantejar un model en el qual per exemple en el nostre cas, plantegem un model, a qui realment li interessi i li importi Vilaweb que ajudi pagant, però a qui som un més, gràcies per llegir-nos, no cal, per tant, no cal obligar a tothom a pagar, tu pots pagar un nucli de gent que és suficient per a tu ja i no necessites que et pagui tothom per dir-ho d'alguna forma i el segon que és girat al revés el de sostenibilitat és a dir, tu també has de saber el que necessites per finançar-te i per tant actuar sempre des d'aquesta base de la sostenibilitat del teu propi projecte. Per mi hi hauria una especie de diàleg molt difícil de fer segurament però a la vegada molt, tinc la sensació que molt natural, que naix de forma espontànea, que no requereix ni grans algoritmes ni grans discusions que és com un cert equilibri no? natural entre la gent que diu no, jo pague i aquells que diuen jo pague si ja són prou, no cal forçar la màquina per a convertir-te en un potentat, no, no sé, jo ho veig com una de les claus i clar, això, diguem, el defecte que pot tenir és que la suficiència al final acaba depenent de cadascú, per algú és suficient tenir una casa i per algú per ser suficient necesita un veler de tres pals...



Thursday, November 3, 2011

Where should an ebook begin?

Updated December 9. I meant to say use type="text" (as I do in my book) but wrote down "start" instead. Argh.

Thinking about ebooks and covers. Of course a cover is supposed to give you an idea of what the book is like, is supposed to inspire a sale. But on ebook commerce sites (say, Amazon or iBookstore), you only see a tiny icon of a cover

Kindle searchiPad search

So, some people think you should see the cover when you open the book. I'm not one of them. Let's take a look first at what is the norm right now. I downloaded the sample of John Grisham's The Litigators from the iBookstore, Kindle store, and Barnes & Noble. When I opened the sample on each device, this is what I saw:

Kindle first pageiPad cover

As you can see both Kindle (left) and iPad (as well as iPhone, not shown) open to the first page of the novel.

NOOK Color cover

Only the NOOK Color opened to the cover.

If you're reading on a NOOK, you then have to scroll through eight pages of front matter (copyright, toc, title page, etc.) to get to the first page. That's annoying (and may not discourage a sale if just the sample has been downloaded).

If you're reading on Kindle or iBooks, you have to scroll back several pages to get to the cover, which is indeed the first page of the EPUB file, but it's there if you want to go see it.

Kindle coveriPad cover first page

Or, if you're on an iPad (but not iPhone), you can see the cover by going to the navigational TOC and rotating the iPad to a horizontal position:

iPad cover opposite TOC

So, what's going on here? How can you control how and when the cover appears? First, you have to create a page in your EPUB document for your cover. It should be a separate XHTML file so you can ensure that it is the first page in your ebook, and so you can ensure that the cover image appears full screen. I explain how to do this in my “EPUB Straight to the Point” book. It basically consists of having the XHTML file be the first file referenced in the <spine> section of your content.opf file.

So, if the cover is the first page of the EPUB or Kindle file, why isn't it the first thing showing when you open a book for the first time? You can control which page opens first in the EPUB by including a line in the <guide> section of your content.opf file, with the type attribute set to text. (A value of start also works, but text is the standard value, accepted by the EPUB spec.)

<guide>
...
<reference type="text" title="Chapter 1" href="chapter1.xhtml" />
...
</guide>


This works on both iBooks and Kindle. I'm guessing that NOOK doesn't support this feature, and that's why the EPUB file (which should theoretically be the same for iBooks and NOOK and other EPUB compatible ereaders) starts with the first page of the book (the cover) instead of where the publisher specified.



Tuesday, November 1, 2011

Pricing books on Apple iBookstore

I have been selling ebooks on Apple's various iBookstores for several months now. I noticed last night that the amount I earned on books sold outside of the US and Canada was much closer to 60% rather than the 70% promised. Since I know that Amazon charges different amounts depending on the location of the buyer, I wondered if that was the issue here as well. It is, but for a different reason altogether.

When you set the price for a book in the US on the Apple iBookstore, the price does not include any sales tax. So, if you set the price at $4.99, Apple will send you $3.49 for each sale (70% * $4.99 = $3.49).

If you set the price of your books in Europe, something very different happens. Apple has cleverly based their European operation in Luxembourg which has the lowest taxes in Europe. Nevertheless, Apple is required to do two things: collect Luxembourg’s 15% VAT on digital books and advertise books with that 15% already included in the price.

What Apple doesn't make very clear, in my opinion, is that when you choose the price for your ebook in European iBookstores, you are choosing a price that already includes that 15% VAT. So, if you quickly convert your $4.99 into 3.65€, you might be tempted to choose an iBookstore price of 3.49€ for Europe. But you should know that .45€ of that amount is VAT and so the actual price of the book would only be 3.04€. This will become all the more clear when you get your sales reports from Apple and they only give you 2.12€ ($2.89) for each sale (which is roughly 70% of 3.04€, and only about 60% of 3.49€).

To figure out a better equivalent for your $4.99 book, do this:

1. Convert $4.99 to euros (google “$4.99 to euros” for a rough estimate): 3.65€
2. Multiply price in euros by 1.15 (adding 15% to price): 4.20€
3. Look for closest matching price tier in iTunes Producer: 3.99€ or 4.49€

One way to see what Apple will send you for each sale is to click on the question mark next to the Price Tier field in iTunes Producer or in iTunes Connect:

Price tiers 1

When you click the question mark, you'll see this list of Price Tiers and “Your Proceeds” which is how much Apple will send you for the sale of each book. Note that for EU customers, it's always 70% of the Tier price divided by 1.15 (70% * (Tier/1.15)).

Your Proceeds

Note also that if you click any Price Tier in the list, your book will be automatically and immediately updated to that Price Tier. No additional OK will be required, and no Cancel is available. To go back to the original price, you'll have to reselect the original price.

This same pricing issue also occurs with the Australian iBookstore (where the price you set includes about 10% tax).

This article is meant to be orientative, not definitive. I'm not a lawyer, tax or otherwise, or an accountant. You should consult one of those if you have doubts.

More of my books