mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
49 lines
1.8 KiB
Python
Executable file
49 lines
1.8 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
# Copyright 2001 - 2020 by Eric House (xwords@eehouse.org)
|
|
#
|
|
# This program is free software; you can redistribute it and/or
|
|
# modify it under the terms of the GNU General Public License
|
|
# as published by the Free Software Foundation; either version 2
|
|
# of the License, or (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program; if not, write to the Free Software
|
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
# Given arguments consisting of triples, first a string and then pbitm
|
|
# files representing bitmaps. For each triple, print out the string and
|
|
# then the converted bitmaps.
|
|
|
|
import os, subprocess, struct, sys
|
|
|
|
def doFile(bmp):
|
|
assert os.path.exists(bmp), 'no such file: {}'.format(bmp)
|
|
with open(bmp, 'r') as file:
|
|
subprocess.run(['../pbitm2bin.py'], stdin=file)
|
|
|
|
def doOne( face, largebmp, smallbmp ):
|
|
# print('doOne({}, {}, {})'.format(face, largebmp, smallbmp), file=sys.stderr)
|
|
with os.fdopen(sys.stdout.fileno(), 'wb', closefd=False) as stdout:
|
|
encoded = face.encode('utf-8')
|
|
stdout.write(struct.pack('B', len(encoded)))
|
|
stdout.write(encoded)
|
|
|
|
for fil in [ largebmp, smallbmp ]:
|
|
print('looking at {}'.format(fil), file=sys.stderr)
|
|
doFile(fil)
|
|
|
|
def main():
|
|
argv = sys.argv
|
|
for first in range(1, len(argv), 3):
|
|
(face, largebmp, smallbmp) = argv[first:first+3]
|
|
doOne(face, largebmp, smallbmp)
|
|
|
|
##############################################################################
|
|
if __name__ == '__main__':
|
|
main()
|