diff options
author | Hung-Te Lin <hungte@chromium.org> | 2012-08-08 18:50:48 +0800 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-08-09 01:56:45 -0700 |
commit | 7f06cfd68d7bd184b37748267b07fdee779b6a85 (patch) | |
tree | f35913b302801c00d7072395e63fb9f71870b0f9 /scripts | |
parent | c11d83513f6dccdd8ec9556f9297f74ea3e71d2c (diff) | |
download | vboot-7f06cfd68d7bd184b37748267b07fdee779b6a85.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.
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>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/newbitmaps/strings/localized_text/Makefile | 43 | ||||
-rw-r--r-- | scripts/newbitmaps/strings/localized_text/font.conf | 8 | ||||
-rwxr-xr-x | scripts/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" |