ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Gallery of fonts
@ 2014-09-10  6:44 Procházka Lukáš Ing. - Pontex s. r. o.
  2014-09-16 17:29 ` Procházka Lukáš Ing. - Pontex s. r. o.
  0 siblings, 1 reply; 2+ messages in thread
From: Procházka Lukáš Ing. - Pontex s. r. o. @ 2014-09-10  6:44 UTC (permalink / raw)
  To: ConTeXt

Hello ConTeXtists,

there are many fonts distributed with Ctx standalone (minimals).

I'd like to create a "gallery" (or "preview") of fonts - one font per page (A4) with all its "kinds" (italic, bold, semibold; ss, rm, hw atc.), and a couple of sizes (10, 11, 12, 16, 24 pt).

Is there a way how to create such gallery, which would walk through Ctx fonts directory (on my machine: c:\ConTeXt\tex\texmf\fonts\*) automatically?

- This would allow user to have a better overview over AVAILABLE fonts and their LOOK;
and the code for the gallery generator would help user to see how to use/access fonts in a Ctx document.

Thanks in advance.

Best regards,

Lukas


-- 
Ing. Lukáš Procházka | mailto:LPr@pontex.cz
Pontex s. r. o.      | mailto:pontex@pontex.cz | http://www.pontex.cz
Bezová 1658
147 14 Praha 4

Tel: +420 241 096 751
Fax: +420 244 461 038

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Gallery of fonts
  2014-09-10  6:44 Gallery of fonts Procházka Lukáš Ing. - Pontex s. r. o.
@ 2014-09-16 17:29 ` Procházka Lukáš Ing. - Pontex s. r. o.
  0 siblings, 0 replies; 2+ messages in thread
From: Procházka Lukáš Ing. - Pontex s. r. o. @ 2014-09-16 17:29 UTC (permalink / raw)
  To: ConTeXt

[-- Attachment #1: Type: text/plain, Size: 530 bytes --]

Hello,

I (partially) succeeded with creation of the font "showcase";
the script attached generates simple preview of how the font looks.

If anyone interested, the result (~2.2 MB) may be downloaded from:

http://leteckaposta.cz/309703124

(The link will be valid for about 1 month from now.)

Best regards,

Lukas


-- 
Ing. Lukáš Procházka | mailto:LPr@pontex.cz
Pontex s. r. o.      | mailto:pontex@pontex.cz | http://www.pontex.cz
Bezová 1658
147 14 Praha 4

Tel: +420 241 096 751
Fax: +420 244 461 038

[-- Attachment #2: FontShow.cld --]
[-- Type: application/octet-stream, Size: 3158 bytes --]

local C = context

--

C.setuppagenumbering{location = ""} -- No page numbers
C.setuplayout{ backspace= "2.5cm", width = "17cm",
               topspace = "2cm", header = "0cm", headerdistance = "0cm", height = "25.5cm",
               footerdistance = "0cm", footer = "0cm", }

--

local showFont = -- Show a text with the font
                 function(name,
                          fn) -- Opt.
  C.blank{"big"}

  C.bgroup()
    C.definefont({"Font"}, {name})
    C.Font(name)

    if fn then
      C.hfill()
      C.Font("(" .. (fn:match("/texmf/fonts/(.*)") or fn) .. ")")
    end

    C.hfill()
    C.blackrule{width = "5mm"}
    C.par()

    C.Font("0123456789"); C.par()
    C.Font("abcdefghijklmnopqrstuvwxyz"); C.par()
    C.Font("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); C.par()
    --C.Font(C.nested.input("tufte"))
  C.egroup()
end

--

local map = { names = {} } -- Existing fonts

--

local extractFontName = function(fn) -- Find the font name in a font file
  local fh, name

  if fn:match("%.pfb") then
    local fh = assert(io.open(fn, "r"))

    for ln in fh:lines() do
      name = ln:match("/FullName%((.+)%)")

      if name then break end
    end
  else
    -- Handle other types
  end

  if fh then fh:close() end

  return name
end

--

local main = function(ffn) -- Do with one single font name
  local name = extractFontName(ffn)

  if name then
    table.insert(map.names, name)
    map[name] = ffn

    print("- Adding", name, ffn)
  end
end

--

local forEach; forEach = function(path) -- Walk through font directory
  for fn in lfs.dir(path) do
    local ffn = path .. "/" .. fn
    local atts = lfs.attributes(ffn)

    if atts.mode == "file" then main(ffn)
    elseif not fn:match("^%.") and atts.mode == "directory" then
      forEach(ffn)
    else
      -- Ignore
    end
  end
end

--

--C.starttext(); C.showlayout(); C.stoptext(); do return end

C.starttext()
  -- Test

  --[[
  --showFont("TeXGyreAdventor-Bold", "ttt")
  --showFont("TeXGyreSchola-Italic")
  showFont("iwonanormal")
  showFont("iwonaregular")

  do return end
  --]]

  -- Scan font directory, extract font names

  --[[
  local path = "c:/Ctx-Beta/tex/texmf/fonts"

  forEach(path)
  --]]

  -- Another (better) way: use result of 'mtxrun --script font...'

  do
    local fn_flist = "FontList.txt"

    os.execute("_InitCtx.bat & mtxrun --script font --list --all > " .. fn_flist)

--do return end

    --

    local fh = assert(io.open(fn_flist, "r"))

    for ln in fh:lines() do
      local _, name, fn = ln:match("%s*(%S+)%s*(%S+)%s*(%S+)")

      if name then
        io.write("- " .. name .. "... ")

        if fn:find("/windows/") then
          print("ignored.")
        else
          if not map[name] then
            table.insert(map.names, name)
            map[name] = fn

            print("added.")
          end
        end
      end
    end

    fh:close()
  end

  -- Print demo for each font

  for _, name in ipairs(map.names) do
    showFont(name, map[name])
  end

C.stoptext()

[-- Attachment #3: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-09-16 17:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-10  6:44 Gallery of fonts Procházka Lukáš Ing. - Pontex s. r. o.
2014-09-16 17:29 ` Procházka Lukáš Ing. - Pontex s. r. o.

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).