[Cuis] Fixed-Width Font
Dan Norton
dnorton at mindspring.com
Fri Jul 24 15:20:35 CDT 2015
On 20 Jul 2015 at 19:33, Juan Vuletich wrote:
>
> Hi Dan,
>
> On 7/19/2015 10:13 PM, Dan Norton wrote:
> On 19 Jul 2015 at 10:31, Juan Vuletich wrote:
>
> > On 7/18/2015 3:37 PM, Dan Norton wrote:
> > > On 11 Jul 2015 at 13:40, Juan Vuletich wrote:
> > >
> > >> Hi Folks,
> > >>
> > >> It is not too hard to build new StrikeFonts. You need to
> build,
> > by
> > >> hand,
> > >> files like the ones in here:
> > >>
> >
> https://dl.dropboxusercontent.com/u/13285702/BitmapDejaVuAllSizes.zi
> > >> p
> > >> and learn a bit about stuff like #installDejaVu2 . Maybe it
> was
> > with
> > >> this method and the files in this zip that built the
> existing
> > >> instances
> > >> of StrikeFont. Not sure.
> > >>
> > > That's intrigueing but I can't reproduce it. Maybe the .bmp
> but
> > where did you get the .txt?
> > >
> > > - Dan
> >
> > I wrote them with a text editor. Check #installDejaVu2 and
> really
> > try to
> > understand how StrikeFonts work and how they are built with
> this
> > method.
> > Maybe you'll become enlightened.
> >
>
> A StrikeFont consists of a characterToGlyphMap, xTable, glyphs,
> name, and several
> scalars. StrikeFont class methods create fonts by processing
> file pairs assumed to be in the
> "AAFonts" subdirectory. For example:
>
> DejaVu Sans Oblique 14.bmp
> DejaVu Sans Oblique 14.txt
>
> Is one such pair providing the italic (oblique) style for
> 14-point size. There is a pair for every
> font size and style: base, bold, italic, and bold italic.
> Therefore a font such as "DejaVu Sans"
> which is available in the size interval 5 to 24 requires 160
> files. The file names are stylized
> and encoded in the StrikeFont class methods.
>
> Glyphs come from the .bmp file. The .txt file is a string of
> numbers; the first three specify
> pointSize, ascent, and descent. The rest of the numbers in the
> .txt file are used to form the
> xTable, which is the index into the glyphs for a character. The
> characterToGlyphMap is an
> array of 256 entries which map a character's ascii value to the
> xTable and thence to the
> glyphs.
>
> The bold, italic, and bold italic styles are stashed as
> derivatives of the base and not
> selectable from the current menus.
>
> StrikeFont is a subclass of AbstractFont, which has class
> variables AvailableFonts and
> DefaultFont.
>
> If it can't find a file, StrikeFont will loop.
>
> Great! You got it all.
>
> In regard to creating the .bmp and .txt files, you say, " I
> wrote them with a text editor."
> Please tell me which text editor you used. None of mine do
> that.
>
> The bmp files can be created with screen capture program, after
> entering suitable text in it. Maybe
> you need to stitch several pieces together, etc. WRT the txt files,
> well, the editor didn't do it for
> me. I wrote them. I _typed_ them. Maybe I used some (long lost) code
> to look for white columns
> separating glyphs, but I'm not really sure. #xTallyPixelValue:orNot:
> and friends are great for this
> kind of stuff.
>
> In any case, it will be easier for you, as you want a monospaced
> font. Printing something like (32
> to: 255) collect: [ :ascii | ascii-32 * 9 ] into the file might be
> enough.
>
> You have all the pieces at hand. it just requires a bit of
> patience.
>
Encouraged by this, I have tried cobbling a fixed-width StrikeFont from Courier New which
comes with Windows7. At this point, if some kind of fixed-width smudges would appear then
it would be progress. Here's where I am:
The immediate problem is an error: 'Unsupported format. Try
"Graphics-Files-Additional.pck.st".' which arises when ImageReadWriter
class>>formFromStream: examines the .bmp file.
Higher in the context, Form class>>fromBinaryStream: has firstByte = 66 which I mention
because of the way the .bmp file was made. Here is the process I used, from the bottom up:
ImageMagick freeware produces the glyphs but with something stubbornly prepended. The
command line is:
convert -font \windows\fonts\cour.ttf -pointsize 12 label:@characters.txt
courier12.bmp
Using NotePad, save characters.txt with encoding: UTF-8.
Paste the character string onto a NotePad
Copy the character string.
In a Cuis workspace print:
str := String new writeStream.
(32 to: 255) do: [ :n | str nextPut: n asCharacter]
str contents.
Code package and files allegedly for courier strike fonts are attached if you're
interested.
- Dan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jvuletich.org/pipermail/cuis_jvuletich.org/attachments/20150724/bf929021/attachment-0004.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CourierExample.zip
Type: application/zip
Size: 25150 bytes
Desc: not available
URL: <http://jvuletich.org/pipermail/cuis_jvuletich.org/attachments/20150724/bf929021/attachment-0004.zip>
More information about the Cuis
mailing list