mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-11 10:25:20 +00:00
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>
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
8
scripts/newbitmaps/strings/localized_text/font.conf
Normal file
8
scripts/newbitmaps/strings/localized_text/font.conf
Normal file
@@ -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"
|
||||
@@ -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"
|
||||
Reference in New Issue
Block a user