From: Kenichi Handa <handa@m17n.org>
To: Kenichi Handa <handa@m17n.org>
Cc: emacs-devel@gnu.org, sdl.web@gmail.com, rms@gnu.org, storm@cua.dk
Subject: Re: A bug in tetris
Date: Thu, 23 Aug 2007 21:17:25 +0900 [thread overview]
Message-ID: <E1IOBcr-0002cn-S9@etlken.m17n.org> (raw)
In-Reply-To: <E1INSWq-0003IU-BH@etlken.m17n.org> (message from Kenichi Handa on Tue, 21 Aug 2007 21:08:12 +0900)
In article <E1INSWq-0003IU-BH@etlken.m17n.org>, Kenichi Handa <handa@m17n.org> writes:
> I don't have a strong objection to it. Anyway, I found that
> the current problem is in the different place. gamegrid.el
> has this function.
> (defun gamegrid-setup-default-font ()
> (setq gamegrid-face
> (copy-face 'default
> (intern (concat "gamegrid-face-" (buffer-name)))))
> (when (eq gamegrid-display-mode 'glyph)
> (let ((max-height nil))
> (loop for c from 0 to 255 do
> (let ((glyph (aref gamegrid-display-table c)))
> (when (and (listp glyph) (eq (car glyph) 'image))
> (let ((height (cdr (image-size glyph))))
> (if (or (null max-height)
> (< max-height height))
> (setq max-height height))))))
> (when (and max-height (< max-height 1))
> (set-face-attribute gamegrid-face nil :height max-height)))))
> It tries to make a face height shorter than the grid-glyph
> height. I confirmed that when I change the last line to:
> (set-face-attribute gamegrid-face nil :height (- max-height 0.1))))))
> the resulting face is good and doesn't produce 1-dot
> horizontal gap in the play field. I'm now investigating
> why the original code isn't good enough.
The source of the problem is the rounding off done while
converting a point size to pixel size. In my environment,
resolution of the screen is 96dpi, grid-glyph height is
16dots, canonical char height is 20dots, the default font
height is 12.1pt, thus the requested height of the font is
9.6pt (== 12.1 * (16 / 20)). The corresponding pixel size
is 12.75 (== 96 * (9.6 / 72.27)). So, it's rounded off to 13,
but what we want here is a font of 12 pixel size.
So, I've just installed the attached change. It may be
possible to add a special face attribute to tell not to
choose a font that is larger than the requested size, but
that require many C code changes. In addition, I think such
a case (need a font equal to or smaller than a requested
size) is rare.
---
Kenichi Handa
handa@m17n.org
Index: gamegrid.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/play/gamegrid.el,v
retrieving revision 1.16.4.12
retrieving revision 1.16.4.13
diff -u -r1.16.4.12 -r1.16.4.13
--- gamegrid.el 27 Jul 2007 10:47:51 -0000 1.16.4.12
+++ gamegrid.el 23 Aug 2007 12:13:24 -0000 1.16.4.13
@@ -320,7 +320,14 @@
(< max-height height))
(setq max-height height))))))
(when (and max-height (< max-height 1))
- (set-face-attribute gamegrid-face nil :height max-height)))))
+ (let ((default-font-height (face-attribute 'default :height))
+ (resy (/ (display-pixel-height) (/ (display-mm-height) 25.4)))
+ point-size pixel-size)
+ (setq point-size (/ (* (float default-font-height) max-height) 10)
+ pixel-size (floor (* resy (/ point-size 72.27)))
+ point-size (* (/ pixel-size resy) 72.27))
+ (set-face-attribute gamegrid-face nil
+ :height (floor (* point-size 10))))))))
(defun gamegrid-initialize-display ()
(setq gamegrid-display-mode (gamegrid-display-type))
next prev parent reply other threads:[~2007-08-23 12:17 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-18 18:45 A bug in tetris Leo
2007-08-19 15:07 ` Johan Bockgård
2007-08-19 15:22 ` Mathias Dahl
2007-08-19 15:37 ` Johan Bockgård
2007-08-19 16:00 ` Mathias Dahl
2007-08-19 18:02 ` Leo
2007-08-19 18:27 ` Sven Joachim
2007-08-19 18:52 ` Leo
2007-08-19 22:27 ` Kim F. Storm
2007-08-20 1:30 ` Kenichi Handa
2007-08-20 10:37 ` Kim F. Storm
2007-08-20 18:30 ` Richard Stallman
2007-08-21 8:32 ` Kim F. Storm
2007-08-21 12:08 ` Kenichi Handa
2007-08-23 12:17 ` Kenichi Handa [this message]
2007-08-23 12:38 ` Leo
2007-08-21 23:24 ` Richard Stallman
2007-08-20 15:16 ` Richard Stallman
2007-08-20 17:25 ` Leo
2007-08-19 22:30 ` Richard Stallman
2007-08-19 17:58 ` Leo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1IOBcr-0002cn-S9@etlken.m17n.org \
--to=handa@m17n.org \
--cc=emacs-devel@gnu.org \
--cc=rms@gnu.org \
--cc=sdl.web@gmail.com \
--cc=storm@cua.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.