Kiev: newbitmaps: Finalize text layout & font settings.

This change contains select parts of the following changes
that are relevant for Kiev:
https://gerrit.chromium.org/gerrit/30369
https://gerrit.chromium.org/gerrit/30679

This pulls in font and layout changes from ToT without
bringing in the Makefile refactoring or profile changes.

BRANCH=kiev
BUG=chrome-os-partner:8510
TEST=make # verify bitmap block works.

Change-Id: Ieb04d48b20ba23bf1b889ea49a010044ed885d56
Reviewed-on: https://gerrit.chromium.org/gerrit/33654
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Tested-by: Dave Parker <dparker@chromium.org>
diff --git a/scripts/newbitmaps/strings/build_font b/scripts/newbitmaps/strings/build_font
index 5d5b752..d7a6671 100755
--- a/scripts/newbitmaps/strings/build_font
+++ b/scripts/newbitmaps/strings/build_font
@@ -8,8 +8,8 @@
 SCRIPT="$(readlink -f "$0")"
 SCRIPT_DIR="$(dirname "$SCRIPT")"
 GLYPHS='* 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ{}-_'
-COLOR="#464646"
-FONT="Verdana"
+COLOR="#505050"
+FONT=""
 MARGIN="3"
 
 die() {
diff --git a/scripts/newbitmaps/strings/hwid_placeholder.TXT b/scripts/newbitmaps/strings/hwid_placeholder.TXT
index 78bc28d..42ca3be 100644
--- a/scripts/newbitmaps/strings/hwid_placeholder.TXT
+++ b/scripts/newbitmaps/strings/hwid_placeholder.TXT
@@ -1 +1 @@
-HWID GOES HERE 4857
+<span color="#505050">HWID GOES HERE 4857</span>
diff --git a/scripts/newbitmaps/strings/localized_text/Makefile b/scripts/newbitmaps/strings/localized_text/Makefile
index 96d8c8a..bfbf933 100644
--- a/scripts/newbitmaps/strings/localized_text/Makefile
+++ b/scripts/newbitmaps/strings/localized_text/Makefile
@@ -6,20 +6,9 @@
 	hu id it iw ja kn ko lt lv ml mr ms nl no pl pt_BR pt_PT ro ru sk sl \
 	sr sv ta te th tr uk vi zh_CN zh_TW
 
-DIR_TARGETS=$(foreach DIR,$(LOCALES),$(DIR)-dir)
-
-CVT=../text_to_png
-
-default: $(DIR_TARGETS)
-
-%-dir:
-	$(CVT) --lan=$(subst -dir,,$@) \
-	--font="$$(sed -nre 's/^$(subst -dir,,$@)="(.*)"/\1/p' font.conf)" \
-	$(subst -dir,,$@)/*.txt
-
+all:
+	./build_message $(LOCALES)
 clean:
 	rm -f */*.png
 
-$(DIR_TARGETS) : FORCE
-
-.PHONY: FORCE
+.PHONY: clean all $(DIR_TARGETS)
diff --git a/scripts/newbitmaps/strings/localized_text/build_message b/scripts/newbitmaps/strings/localized_text/build_message
new file mode 100755
index 0000000..e4cfaa8
--- /dev/null
+++ b/scripts/newbitmaps/strings/localized_text/build_message
@@ -0,0 +1,39 @@
+#!/bin/sh
+# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Generates localized text images
+
+SCRIPT="$(readlink -f "$0")"
+SCRIPT_DIR="$(dirname "$SCRIPT")"
+TXT_TO_PNG=$(readlink -f "$SCRIPT_DIR/../text_to_png")
+
+die() {
+  echo "ERROR: $*" >&2
+  exit 1
+}
+
+do_locale() {
+  local locale_dir="$1"
+  local locale="$(basename $locale_dir)"
+  local file conf entry font
+
+  font="$(sed -nre "s/^$locale: *(.*) *$/\1/p" $SCRIPT_DIR/font.conf)"
+  for file in $locale_dir/*.txt; do
+    entry="$(basename $file)"
+    entry="${entry%%.*}"
+    conf="$(sed -nre "s/^$entry: *(.*) *$/\1/p" $SCRIPT_DIR/text.conf)"
+    $TXT_TO_PNG --lan="$locale" --font="$font" $conf $file
+  done
+}
+
+main() {
+  [ "$#" -gt "0" ] || die "Usage: $0 locale(s)..."
+  for locale in "$@"; do
+    do_locale "$locale"
+  done
+}
+
+set -e
+main "$@"
diff --git a/scripts/newbitmaps/strings/localized_text/cs/for_help_right.txt b/scripts/newbitmaps/strings/localized_text/cs/for_help_right.txt
index 9c558e3..8b13789 100644
--- a/scripts/newbitmaps/strings/localized_text/cs/for_help_right.txt
+++ b/scripts/newbitmaps/strings/localized_text/cs/for_help_right.txt
@@ -1 +1 @@
-.
+
diff --git a/scripts/newbitmaps/strings/localized_text/de/for_help_right.txt b/scripts/newbitmaps/strings/localized_text/de/for_help_right.txt
index 9c558e3..8b13789 100644
--- a/scripts/newbitmaps/strings/localized_text/de/for_help_right.txt
+++ b/scripts/newbitmaps/strings/localized_text/de/for_help_right.txt
@@ -1 +1 @@
-.
+
diff --git a/scripts/newbitmaps/strings/localized_text/en/devmode.txt b/scripts/newbitmaps/strings/localized_text/en/devmode.txt
index 12a04e2..e14b255 100644
--- a/scripts/newbitmaps/strings/localized_text/en/devmode.txt
+++ b/scripts/newbitmaps/strings/localized_text/en/devmode.txt
@@ -1,3 +1,3 @@
-OS verification is OFF
+OS verification is <b>OFF</b>
 
 Press SPACE to re-enable.
diff --git a/scripts/newbitmaps/strings/localized_text/en/insert_kiev.txt b/scripts/newbitmaps/strings/localized_text/en/insert_kiev.txt
index b42f8e8..6415526 100644
--- a/scripts/newbitmaps/strings/localized_text/en/insert_kiev.txt
+++ b/scripts/newbitmaps/strings/localized_text/en/insert_kiev.txt
@@ -1,4 +1,4 @@
 Chrome OS is missing or damaged.
 
 Please insert a recovery USB stick into one of the 4 ports
-in the BACK of the device.
+in the <b>BACK</b> of the device.
diff --git a/scripts/newbitmaps/strings/localized_text/en_GB/devmode.txt b/scripts/newbitmaps/strings/localized_text/en_GB/devmode.txt
index 12a04e2..e14b255 100644
--- a/scripts/newbitmaps/strings/localized_text/en_GB/devmode.txt
+++ b/scripts/newbitmaps/strings/localized_text/en_GB/devmode.txt
@@ -1,3 +1,3 @@
-OS verification is OFF
+OS verification is <b>OFF</b>
 
 Press SPACE to re-enable.
diff --git a/scripts/newbitmaps/strings/localized_text/en_GB/insert_kiev.txt b/scripts/newbitmaps/strings/localized_text/en_GB/insert_kiev.txt
index b42f8e8..6415526 100644
--- a/scripts/newbitmaps/strings/localized_text/en_GB/insert_kiev.txt
+++ b/scripts/newbitmaps/strings/localized_text/en_GB/insert_kiev.txt
@@ -1,4 +1,4 @@
 Chrome OS is missing or damaged.
 
 Please insert a recovery USB stick into one of the 4 ports
-in the BACK of the device.
+in the <b>BACK</b> of the device.
diff --git a/scripts/newbitmaps/strings/localized_text/es/for_help_right.txt b/scripts/newbitmaps/strings/localized_text/es/for_help_right.txt
index 73fbd95..8b13789 100644
--- a/scripts/newbitmaps/strings/localized_text/es/for_help_right.txt
+++ b/scripts/newbitmaps/strings/localized_text/es/for_help_right.txt
@@ -1 +1 @@
-.

+
diff --git a/scripts/newbitmaps/strings/localized_text/es_419/for_help_right.txt b/scripts/newbitmaps/strings/localized_text/es_419/for_help_right.txt
index 9c558e3..8b13789 100644
--- a/scripts/newbitmaps/strings/localized_text/es_419/for_help_right.txt
+++ b/scripts/newbitmaps/strings/localized_text/es_419/for_help_right.txt
@@ -1 +1 @@
-.
+
diff --git a/scripts/newbitmaps/strings/localized_text/lv/for_help_right.txt b/scripts/newbitmaps/strings/localized_text/lv/for_help_right.txt
index 9c558e3..8b13789 100644
--- a/scripts/newbitmaps/strings/localized_text/lv/for_help_right.txt
+++ b/scripts/newbitmaps/strings/localized_text/lv/for_help_right.txt
@@ -1 +1 @@
-.
+
diff --git a/scripts/newbitmaps/strings/localized_text/ru/for_help_right.txt b/scripts/newbitmaps/strings/localized_text/ru/for_help_right.txt
index 9c558e3..8b13789 100644
--- a/scripts/newbitmaps/strings/localized_text/ru/for_help_right.txt
+++ b/scripts/newbitmaps/strings/localized_text/ru/for_help_right.txt
@@ -1 +1 @@
-.
+
diff --git a/scripts/newbitmaps/strings/localized_text/text.conf b/scripts/newbitmaps/strings/localized_text/text.conf
new file mode 100644
index 0000000..3c1a4f4
--- /dev/null
+++ b/scripts/newbitmaps/strings/localized_text/text.conf
@@ -0,0 +1,9 @@
+devmode: --color=606060 --markup
+for_help: --color=888888
+for_help_left: --color=888888
+for_help_right: --color=888888
+insert_kiev: --color=606060 --markup
+language: --color=999999
+model: --color=888888
+remove: --color=606060
+yuck: --color=606060
diff --git a/scripts/newbitmaps/strings/text_to_png b/scripts/newbitmaps/strings/text_to_png
index 6972ab1..ad5b85c 100755
--- a/scripts/newbitmaps/strings/text_to_png
+++ b/scripts/newbitmaps/strings/text_to_png
@@ -22,13 +22,13 @@
 margin=3
 align="center"
 bgcolor="#ffffff"
-color="#464646"
+color="#000000"
 params=""
 
 while true ; do
   case "$1" in
     --lan=* | --language=*)
-      language="--language ${1##*=}"
+      language="--language=${1##*=}"
       shift
       ;;
     --font=*)
@@ -63,6 +63,12 @@
   esac
 done
 
+# Revise color. pango-view color syntax (in #rrggbb) may cause problem in shell
+# scripts, so let's also allow 'rrggbb'.
+color="${color###}"
+bgcolor="${bgcolor###}"
+[ -z "$color" ] || color="#$color"
+[ -z "$bgcolor" ] || bgcolor="#$bgcolor"
 
 # Image parameters
 # - New pango-view has --pixel to assign font size in pixel, but that is not
@@ -89,9 +95,9 @@
   esac
   pango-view -q $language \
     --hinting=full \
-    --background "$bgcolor" --foreground "$color" \
-    --font "$font $pointsize" --dpi 72 \
-    --margin $margin \
+    --background="$bgcolor" --foreground="$color" \
+    --font="$font $pointsize" --dpi 72 \
+    --margin=$margin \
     --align="$align" \
     $params $file_opt \
     --output "$pngfile" \