non fixed width fonts ?

Posted By: EPATATA

non fixed width fonts ? - 08/02/06 17:57

how can I use non fixed width fonts to show text strings in the screen?
Posted By: Claus_N

Re: non fixed width fonts ? - 08/02/06 18:23

You mean True-type fonts?

Code:
// Example:
font Arial_font = "Arial",30,1;


Posted By: EPATATA

non fixed width fonts ? - 08/09/06 19:58

Im using font-generator to generate pcx images of fonts used, but when I write text strings in the screen, all letters have the same width.

example: dots "." have same width as "M".
How to make dots and other narrow letters use less space in the screen than wider letters ???
Posted By: Claus_N

Re: non fixed width fonts ? - 08/09/06 20:54

If you don't want fixed-width fonts, you need to use true-type fonts. 'M' and '.' will ALWAYS have the same width in "non-True-type fonts".
Posted By: HeelX

Re: non fixed width fonts ? - 08/10/06 10:00

You can actually render fonts on a bitmap basis as non-fixedwidthfonts (so to say analog to TTFs). The trick is, to extract from the font bitmap each letter as single bitmap, whereas you clipped the left and right pixels which cover nothing, until the letter itself comes.

I did this before and its easy: I create an alphachannel for the font and analyzed tha alpha value. Example:

Let us say, this is a semicolon, the o's are solid and the #'s are transparent.

Code:

###o###
#######
###o###
##o####



When I want a minimum column of 1px before and after the last row in which one solid pixel is placed, I crop it like this:

Code:

##o#
####
##o#
#o##



Now, if you take a string and you stitch each (cropped) letter together your returning bitmap covers a string, rendered with no blank spaces and like a TTF - but basing on a bmap!
Posted By: EPATATA

Re: non fixed width fonts ? - 08/10/06 12:23

thank you Claus_N, now I know I can use TT fonts

@HeelX I got your method, and already I think in that, but how can I show the string in the screen? each letter will be an image correct? so I will need to join all letters in a single string?
Posted By: HeelX

Re: non fixed width fonts ? - 08/10/06 13:58

No, you should build a function like this:

bmap_for_str(bmap* font, string* string);
return: bmap*

Note: your font isnt declared as font*, but as a bitmap now!!! That is very important.

So you can easily let your script render a bitmap with your string build up on these bitmap chunks and then you can assign this bmap to a panel. Works pretty fast when I coded it that time and with those new bitmap features (bmap_blit) and so its much faster now.
Posted By: EPATATA

Re: non fixed width fonts ? - 08/11/06 11:09

that is good
Ill try script it, if I found dificulties then will return here later.
© 2023 lite-C Forums