#!/usr/local/bin/ruby
#
#
# ./charwidth.rb

require "ClibPDF"

x = 7.0
y = 9.0
ybump = 0.5
i, j, ibase = 128
strbuf = []
fontname = "AvantGarde-BookOblique"

pdf = ClibPDF::PDF.open(0)
pdf.enableCompression(ClibPDF::YES)
pdf.init
pdf.pageInit(1, ClibPDF::PORTRAIT, ClibPDF::LETTER, ClibPDF::LETTER)

pdf.beginText(0)
pdf.setFont(fontname, "WinAnsiEncoding", 32.0)
pdf.textAligned(x, y, 0.0, ClibPDF::TEXTPOS_LR, fontname)

for j in 12..26
  ibase = j * 10
  for i in 0..9
	strbuf[i] = i + ibase
  end
  y -= ybump
  pdf.textAligned(x, y, 0.0, ClibPDF::TEXTPOS_LR, strbuf.pack("CCCCCCCCCC"))
end

pdf.endText

pdf.finalizeAll
pdf.savePDFmemoryStreamToFile("charwidth.pdf")
#pdf.launchPreview
pdf.close
