Files
OpenCellular/scripts/newbitmaps/strings/text_to_bmp
Bill Richardson 7b32cad272 Finally final results from l10n team.
* Updated the text strings using the latest results from the localization
  experts.

* Strip the leading byte-order-mark and trailing whitespace from the text
  files, since it's not used for anything and sometimes renders as a box.

* Added options to the text_to_bmp script to handle right-to-left languages
  and to override the font.

* Added scripts/newbitmaps/strings/localized_text/Makefile to regenerate all
  the bitmaps from the text strings. This handles right-to-left languages
  correctly.

* Modified make_default_yaml so that the th/model.txt string is moved up a
  bit to align it properly with the HWID.

* Regenerated DEFAULT.yaml using the new bitmaps.

BUG=chromium-os:13037
TEST=none

Change-Id: I095830a46ba831742d437867a9caac88c8e28de1
Reviewed-on: http://gerrit.chromium.org/gerrit/8834
Tested-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
2011-10-07 09:08:51 -07:00

80 lines
2.0 KiB
Bash
Executable File

#!/bin/bash -e
# Copyright (c) 2011 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.
#
# Render a text file into a bitmap. Files named '*.txt' are small font, those
# named '*.TXT' are large font.
#
# Options:
#
# --rtl Render right-to-left languages
# --font=FONTNAME Use specified font (instead of Helvetica)
#
font="Helvetica"
rtl=""
while true ; do
case "$1" in
--rtl)
rtl="--rtl"
shift
;;
--font=*)
font="${1##*=}"
shift
;;
*)
break
;;
esac
done
# Image parameters
# - 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.
bg='#607c91'
small_color='#9ccaec'
small_font="$font"
small_pointsize=22
large_color="white"
large_font="$font"
large_pointsize=40
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.
pngfile="${txtfile%.*}".png
bmpfile="${txtfile%.*}".bmp
case "$txtfile" in
*.txt)
pango-view -q $rtl --no-auto-dir \
--background "$bg" --foreground "$small_color" \
--font "$small_font $small_pointsize" --dpi 72 \
--margin=3 --align=center \
--output "$pngfile" \
"$txtfile"
convert -colors 256 -compress none -alpha off "$pngfile" "$bmpfile"
rm -f "$pngfile"
echo "wrote $bmpfile"
;;
*.TXT)
pango-view -q $rtl --no-auto-dir \
--background "$bg" --foreground "$large_color" \
--font "$large_font $large_pointsize" --dpi 72 \
--margin=10 --align=center \
--output "$pngfile" \
"$txtfile"
convert -colors 256 -compress none -alpha off "$pngfile" "$bmpfile"
rm -f "$pngfile"
echo "wrote $bmpfile"
;;
*)
echo "Ignoring $txtfile. Filname should end with .txt or .TXT"
;;
esac
done