Skip to content

Commit

Permalink
Add a contrib script for using correct aspect ratio in an xterm
Browse files Browse the repository at this point in the history
  • Loading branch information
o11c committed Nov 23, 2016
1 parent 60b2c31 commit 648a6d8
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
Binary file added contrib/gearhead-xterm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions contrib/gearhead-xterm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh
# Start gearhead in an xterm, with proper aspect ratio.
# This does make text look funny to read at first, but you get used to it.
# Better alternatives involving code changes:
# * Use DECDWL.
# Pro: Simple to implement.
# Con: Can only be applied to whole lines, so single-width can only
# be used for the messages at the bottom of the screen, not for
# right-side-of-screen messages and popup dialogs.
# * Use double-width codepoint range starting at U+ff00.
# Pro: Can be disabled for *all* text, and enabled only for the screen.
# Con: Only ASCII. Currently fine, but disallows future new glyphs.

real_gearhead=/usr/games/gearhead
font_name='mono'
# Pick something that gives you 60-70 lines on your screen and is readable.
# This works for me on a 768-pixel-tall (minus taskbars) screen.
font_size=7
# Most fonts are 8x16 or so. Double the width for them.
font_stretch=2

# I'm not sure if gearhead takes any command-line arguments yet, but
# just in case, build the xterm argument list backwards to preserve them.
set -- -e "$real_gearhead" "$@"
# Important bit: set a TrueType font with the proper ratio.
# Xterm usually uses bitmap fonts, but they can't be scaled.
# With most fonts, hinting must be disabled, or they will violate the
# bounding box. This often shows as the last line of an "m" disappearing.
# You *could* try to use 'XTerm*useClipping' or 'XTerm*scaleHeight', but
# I haven't had any luck with that.
set -- -fa "$font_name"':matrix='"$font_stretch"' 0 0 1:hinting=False' -fs "$font_size" "$@"
# Force xterm to draw the line-drawing characters itself. Most TTFs don't
# line up *quite* right, especially when stretched.
set -- +fbx "$@"
# Gearhead emits the 'bold' code when it really just wants to change
# the color to the "bright" version.
set -- -pc -xrm 'XTerm*allowBoldFonts:false' "$@"
# Wait for window to be shown. Fixes a nondeterministic resize bug.
set -- -wf "$@"
# Or -fullscreen for a few more lines.
set -- -maximized "$@"
exec xterm "$@"

0 comments on commit 648a6d8

Please sign in to comment.