summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncan Laurie <dlaurie@chromium.org>2012-08-14 10:37:49 -0700
committerDuncan Laurie <dlaurie@chromium.org>2012-08-14 10:50:15 -0700
commit86ee9145a758dcb3d0341153c884e3c7fe22c2ec (patch)
tree74f5055d11cb310ecf1f45c81e122412b29593e8
parent093f614745c06d967d7ab056c006edb5971ba23e (diff)
downloadvboot-86ee9145a758dcb3d0341153c884e3c7fe22c2ec.tar.gz
Generate localized messages in PNG format.
To support rendering messages in multiple resolution profiles, we need to keep the images in its original format. BUG=chrome-os-partner:11078 TEST=./text_to_png # images were converted correctly. Old-Change-Id: I6e13331eddfa4c40b17b67b5cf56b5a0284e3b34 Reviewed-on: https://gerrit.chromium.org/gerrit/29605 Reviewed-by: Dave Parker <dparker@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Ready: Hung-Te Lin <hungte@chromium.org> Tested-by: Hung-Te Lin <hungte@chromium.org> (cherry picked from commit 7f06cfd68d7bd184b37748267b07fdee779b6a85) Change-Id: I6833a70bd5c942983323274421571fbbd12cfa45 Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/30239
-rw-r--r--scripts/newbitmaps/strings/localized_text/Makefile43
-rw-r--r--scripts/newbitmaps/strings/localized_text/font.conf8
-rwxr-xr-xscripts/newbitmaps/strings/text_to_png (renamed from scripts/newbitmaps/strings/text_to_bmp)37
3 files changed, 32 insertions, 56 deletions
diff --git a/scripts/newbitmaps/strings/localized_text/Makefile b/scripts/newbitmaps/strings/localized_text/Makefile
index 1e26b638..bd074288 100644
--- a/scripts/newbitmaps/strings/localized_text/Makefile
+++ b/scripts/newbitmaps/strings/localized_text/Makefile
@@ -1,4 +1,4 @@
-# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+# 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.
@@ -6,48 +6,19 @@ LOCALES=ar bg ca cs da de el en en_GB es es_419 et fa fi fil fr hi hr hu \
id it iw ja ko lt lv nl no pl pt_BR pt_PT ro ru sk sl sr sv th tr \
uk vi zh_CN zh_TW
-# Use "make PT=15" for 800x600 (x86)
-PT=15
-
-
DIR_TARGETS=$(foreach DIR,$(LOCALES),$(DIR)-dir)
-CVT=../text_to_bmp --point=$(PT)
-
+CVT=../text_to_png
default: $(DIR_TARGETS)
%-dir:
- $(CVT) $(subst -dir,,$@)/*.txt
-
-ar-dir:
- $(CVT) --rtl --font="Droid Sans Arabic" $(subst -dir,,$@)/*.txt
-
-fa-dir:
- $(CVT) --rtl $(subst -dir,,$@)/*.txt
-
-hi-dir:
- $(CVT) --font="Lohit-Hindi" $(subst -dir,,$@)/*.txt
-
-iw-dir:
- $(CVT) --rtl --font="Droid Sans Hebrew" $(subst -dir,,$@)/*.txt
-
-ja-dir:
- $(CVT) --font="IPAPGothic" $(subst -dir,,$@)/*.txt
-
-ko-dir:
- $(CVT) --font="NanumGothic" $(subst -dir,,$@)/*.txt
-
-th-dir:
- $(CVT) --font="Droid Sans Thai" $(subst -dir,,$@)/*.txt
-
-zh_CN-dir:
- $(CVT) --font="Droid Sans Fallback" $(subst -dir,,$@)/*.txt
-
-zh_TW-dir:
- $(CVT) --font="Droid Sans Fallback" $(subst -dir,,$@)/*.txt
-
+ $(CVT) --lan=$(subst -dir,,$@) \
+ --font="$$(sed -nre 's/^$(subst -dir,,$@)="(.*)"/\1/p' font.conf)" \
+ $(subst -dir,,$@)/*.txt
+clean:
+ rm -f */*.png
$(DIR_TARGETS) : FORCE
diff --git a/scripts/newbitmaps/strings/localized_text/font.conf b/scripts/newbitmaps/strings/localized_text/font.conf
new file mode 100644
index 00000000..ade7d26e
--- /dev/null
+++ b/scripts/newbitmaps/strings/localized_text/font.conf
@@ -0,0 +1,8 @@
+ar="Droid Sans Arabic"
+hi="Lohit-Hindi"
+iw="Droid Sans Hebrew"
+ja="IPAPGothic"
+ko="NanumGothic"
+th="Droid Sans Thai"
+zh_CN="Droid Sans Fallback"
+zh_TW="Droid Sans Fallback"
diff --git a/scripts/newbitmaps/strings/text_to_bmp b/scripts/newbitmaps/strings/text_to_png
index 54f35551..260ca1ae 100755
--- a/scripts/newbitmaps/strings/text_to_bmp
+++ b/scripts/newbitmaps/strings/text_to_png
@@ -8,21 +8,23 @@
#
# Options:
#
-# --rtl Render right-to-left languages
-# --font=FONTNAME Use specified font (instead of Helvetica)
+# --lan=LANGUAGE Render language (locale) settings
+# --font=FONTNAME Use specified font (instead of Droid Sans)
#
font="Droid Sans"
-rtl=""
+language=""
point=15
while true ; do
case "$1" in
- --rtl)
- rtl="--rtl"
+ --lan=* | --language=*)
+ language="--language ${1##*=}"
shift
;;
--font=*)
- font="${1##*=}"
+ # Allows empty string = default font.
+ param="${1##*=}"
+ [ -n "$param" ] && font="$param"
shift
;;
--point=*)
@@ -40,44 +42,39 @@ done
# - New pango-view has --pixel to assign font size in pixel, but that is not
# supported by old (ex, 1.24.5 in chroot) so we must assign --dpi 72 for
# pointsize.
+# TODO(hungte) Replace font color & size settings to pango --markup.
bg="#ffffff"
small_color="#000000"
small_font="$font"
small_pointsize="$point"
large_color="#585858"
large_font="$font"
-large_pointsize=40
-_x86_scale="-scale 59%x78%"
-_x86_opts="-colors 256 -compress none -alpha off"
+large_pointsize="$((point * 8 / 3))"
for txtfile in $*; do
# pango-view does not support assigning output format options for bitmap, so
- # we first create the images in PNG format and then convert into BMP by
- # ImageMagick.
+ # we must create images in PNG format and then post-process it (ex, convert
+ # into BMP by ImageMagick).
+
pngfile="${txtfile%.*}".png
- bmpfile="${txtfile%.*}".bmp
case "$txtfile" in
*.txt)
- pango-view -q $rtl --no-auto-dir \
+ pango-view -q $language \
--background "$bg" --foreground "$small_color" \
--font "$small_font $small_pointsize" --dpi 72 \
--margin=3 --align=center \
--output "$pngfile" \
"$txtfile"
- convert ${_x86_scale} ${_x86_opts} "$pngfile" BMP3:"$bmpfile"
- rm -f "$pngfile"
- echo "wrote $bmpfile"
+ echo "wrote $pngfile"
;;
*.TXT)
- pango-view -q $rtl --no-auto-dir \
+ pango-view -q $language \
--background "$bg" --foreground "$large_color" \
--font "$large_font $large_pointsize" --dpi 72 \
--margin=10 --align=center \
--output "$pngfile" \
"$txtfile"
- convert ${_x86_scale} ${_x86_opts} " $pngfile" BMP3:"$bmpfile"
- rm -f "$pngfile"
- echo "wrote $bmpfile"
+ echo "wrote $pngfile"
;;
*)
echo "Ignoring $txtfile. Filename should end with .txt or .TXT"