[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
shinking text
From: |
Idigoras Inaki |
Subject: |
shinking text |
Date: |
Thu, 4 May 2000 12:59:19 +0200 |
Hello,
I am working with the Freetype engine (1.3.1) for displaying TTF fonts in
screen and I have a problem:
I need to fit a string in a box whose width (in pixels) is given.
I first compute the lenght of the string without shrinking it (96 dpi) to
see if it fits in the box. If the computed length is larger than the box´s
width, I have to shrink it.
I do not know which is the best method for doing it, but I use the
resolution. I change the resolution in x of the instance, applying a
proportional resolution.
example:
Box size = 80 pixels
Text length = 86 pixels (at 96 dpi)
To fit the text to the box, I set a resolution of (80 / 86) * 96 = 89 dpi.
It works fine most of the times, but sometimes fails. I noticed that even
reducing the resolution, sometimes the advance width is not reduced, or
MAYBE it is LARGER!
for example, for a given font I get 21 pixels for char '1' (at 96 dpi) 22
pixels at 93 dpi!!
Algorithm used now:
***
get lenght at 96 dpi
if larger, reduce resolution proportionally
render text (SOMETIMES FAILS TO FIT)
***
SHOULD I use an iterative method like the one below (it will slow down my
application!) ?:
***
get lenght at 96 dpi
if larger than box size, reduce resolution proportionally
do
get length at new resolution
if larger than box size
reduce resolution
else
render text (SOMETIMES FAILS TO FIT)
while text not rendered
***
OR IS there a better way of dealing with shrinking?
__________________________________
Iñaki Idigoras Igartua <address@hidden>
IKERLAN - E&K Dpt. (http://www.ikerlan.es)
P.Box 146, 20500 Arrasate - Gipuzkoa
Phone +34 943 712400 - Fax. +34 943 796944
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- shinking text,
Idigoras Inaki <=