Files
OpenCellular/scripts/newbitmaps/strings/text_to_bmp
Hung-Te Lin 3852698b0b vboot_reference: add pango based text_to_bmp converter
pango provides TTF fontset rendering, which solves i18n text issue.

BUG=chromium-os:13037
TEST=./text_to_bmp localized_text/ja/*.txt
     display localized_text/ja/*.bmp $ looks fine

Change-Id: Id2731efa131516125ea9bd27016d44cdd4c50974
Reviewed-on: http://gerrit.chromium.org/gerrit/7152
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Tested-by: Hung-Te Lin <hungte@chromium.org>
2011-09-06 21:15:54 -07:00

54 lines
1.6 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.
#
# 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="Helvetica"
small_pointsize=22
large_color="white"
large_font="Helvetica"
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 \
--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"
echo "wrote $bmpfile"
;;
*.TXT)
pango-view -q \
--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"
echo "wrote $bmpfile"
;;
*)
echo "Ignoring $txtfile. Filname should end with .txt or .TXT"
;;
esac
done