% -*-LaTeX-*-
% Copyright 2003-2006 Han The Thanh <hanthethanh@gmx.net>.
% This file is part of vntex.  License: LPPL, version 1.3 or newer,
% according to http://www.latex-project.org/lppl.txt

\ifx\documentclass\undefined\endinput\fi

\newif\ifbookmarks

\ProvidesClass{vnsample}[2005/08/27]
\NeedsTeXFormat{LaTeX2e}

\LoadClass[a4paper]{article}

\RequirePackage{ifpdf}

\ifpdf\IfFileExists{cmap.sty}{\RequirePackage{cmap}}{
\ClassWarningNoLine{vnsample}{I can't find the file `cmap.sty'.\MessageBreak
The search tool in your PDF browser will miss many\MessageBreak
words containing Vietnamese characters}}\fi

\RequirePackage[viscii]{vietnam}
\RequirePackage{multicol}
\RequirePackage{geometry}
\RequirePackage{array}
\RequirePackage{fancyhdr}

\DeclareOption{sample}{
  \geometry{a4paper,nofoot,left=1cm,right=1cm,top=2cm,bottom=1cm}
  \pagestyle{fancy}
  \rhead{\thepage}
  \lhead{\textrm{\rightmark}}\cfoot{}\lfoot{}\rfoot{}
  \raggedright
  \parindent0pt
  \lineskiplimit -100pt
  \bookmarkstrue
}

\DeclareOption{test}{
  \geometry{a4paper,landscape,top=1cm,bottom=1cm,left=1cm,right=1cm,%
    nofoot,nohead}
  \pagestyle{empty}
  \bookmarksfalse
  \advance\oddsidemargin -7mm \evensidemargin=\oddsidemargin
  \hbadness=10000\relax\hfuzz=\maxdimen
  \AtBeginDocument{\extrarowheight=5pt}
}

\ProcessOptions

\newdimen\dimenA
\newbox\boxA
\newbox\boxB

\def\vnchars{%
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
% \break
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar 
\dochar 
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar 
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar �
\dochar 
\dochar �
\dochar 
\dochar 
\par
}

\def\dochar #1 {%
    #1\kern.1em\penalty0%
}

\def\SL{-Slant}
\def\EMPH#1{\textbf{\textit{#1}}}

\long\def\vntext{%
\centerline{\textbf{Ch� Ph�o}}
\vskip -.5\baselineskip
\rightline{\textsc{--- Nam Cao}}
H�n v�a �i v�a ch�i. Bao gi� c�ng th�, c� r��u xong l� h�n ch�i. B�t �u
ch�i tr�i. C� h� g�? Tr�i c� c�a ri�ng nh� n�o? R�i h�n ch�i �i. Th�
c�ng ch�ng sao: �i l� t�t c� nh�ng ch�ng l� ai. T�c m�nh h�n ch�i ngay t�t
c� l�ng V� ��i. Nh�ng c� l�ng V� ��i ai c�ng nh�, \textit{``Ch�c n� tr�
m�nh ra!''} Kh�ng ai l�n ti�ng c�. T�c th�t! �! Th� n�y th� t�c th�t! T�c
ch�t �i ���c m�t! �� th�, h�n ph�i ch�i cha ��a n�o kh�ng ch�i nhau v�i
h�n. Nh�ng c�ng kh�ng ai ra �i�u. M� ki�p! Th� th� c� ph� r��u kh�ng? Th�
th� c� kh� h�n kh�ng? Kh�ng bi�t ��a ch�t m� n�o �� ra th�n h�n cho h�n kh�
�n n�ng n�i n�y? A ha! Ph�i �y, h�n c� th� m� ch�i, h�n ch�i ��a ch�t m�
n�o �� ra th�n h�n, �� ra c�i th�ng \EMPH{Ch� Ph�o}! H�n nghi�n r�ng v�o
m� ch�i c�i ��a �� �� ra Ch� Ph�o. Nh�ng m� bi�t ��a n�o �� �� ra
Ch� Ph�o? C� tr�i m� bi�t! H�n kh�ng bi�t, c� l�ng V� ��i c�ng kh�ng ai
bi�t.

M�t anh �i th� �ng l߽n, m�t bu�i s�ng tinh s߽ng �� th�y h�n
tr�n tru�ng v� x�m ng�t trong m�t v�y ��p � b�n m�t l� g�ch b�
kh�ng, anh ta r߾c l�y v� �em v� cho m�t ng߶i ��n b� g�a m�.
Ng߶i ��n b� g�a m� n�y b�n h�n cho m�t b�c ph� c�i kh�ng con, v�
khi b�c ph� c�i n�y ch�t th� h�n b� v�, h�t �i � cho nh� n�y l�i �i
� cho nh� n�. N�m hai m߽i tu�i, h�n l�m canh �i�n cho �ng l� Ki�n,
b�y gi� c� b� Ki�n, �n ti�n ch� l�ng. H�nh nh� c� m�y l�n b� ba nh�
�ng l�, c�n tr� l�m m� l�i hay �m l�ng, b�t h�n b�p ch�n, hay xoa
b�ng, �m l�ng g� �y. Ng߶i ta b�o �ng l� ra ��nh th� h�ch d�ch,
c� l�ng ph�i s�, m� v� nh� th� l�i s� c�i b� ba c�n tr� n�y. Ng߶i
b� �y ph�p ph�p, m� b� �y h�y h�y, m� �ng l� th� hay �au l�ng l�m;
nh�ng ng߶i c� b�nh �au l�ng hay s� v� m� ch�a �i l� kho� ghen.
C� ng߶i b�o �ng l� ghen v�i anh canh �i�n kho� m�nh m� s� b� ba
kh�ng d�m n�i. C� ng߶i th� b�o anh canh �i�n �y ���c b� ba quy�n
thu quy�n b� trong nh� tin c�n n�n l�y tr�m ti�n tr�m th�c nhi�u.
M�i ng߶i n�i m�t c�ch. Ch�ng bi�t ��u m� l�n. Ch� bi�t m�t h�m
Ch� b� ng߶i ta gi�i huy�n r�i bi�t t�m �n b�y, t�m n�m r�i m�t
h�m, h�n l�i l� l� � ��u l�n v�. H�n v� l�p n�y tr�ng kh�c
h�n, m�i �u ch�ng ai bi�t h�n l� ai. Tr�ng �c nh� th�ng s�ng
c�! C�i �u th� tr�c l�c, c�i r�ng c�o tr�ng h�n, c�i m�t th� �en
m� r�t c�ng c�ng, hai m�t g߶m g߶m tr�ng g�m ch�t! H�n m�c qu�n
�o n�i �en v�i �o T�y v�ng. C�i ng�c phanh, �y nh�ng n�t ch�m tr�
r�ng, ph��ng v�i m�t �ng th�y t߾ng c�m chu�, c� hai c�nh tay c�ng
th�. Tr�ng g�m ch�t!
}

\def\mksample#1{%
    \leftline{\normalsize\bf\fbox{line spacing #1}\hrulefill}
    \vskip 5pt
    \ifnum\pdftexversion<130\relax
      \dimenA=\pdffontsize\font pt\relax
    \else
      \dimenA=\pdffontsize\font
    \fi
    \setbox\boxA=\vbox{%
        \baselineskip=#1\dimenA
        \parskip=.5\baselineskip
        \noindent\vntext\par}%
    \setbox\boxB=\vsplit\boxA to 3in
    \nobreak
    \box\boxB
    \vskip 10pt
}

\def\showfontsize#1#2#3{{%
    \leftline{\large\bf\fbox{#2}\hrulefill}
    \nobreak
    \font\f=#1 at #2\f
    \baselineskip=#3
    \noindent
    \vnchars\par
    \vskip .5\baselineskip
}}

\def\mkfontname#1#2#3{\hbox{%
    \hbox to .25\textwidth{NFSS:\kern1em \texttt{#1}\hss}%
    \hbox to .25\textwidth{TFM:\kern1em \texttt{#2}\hss}%
    PostScript:\kern1em \texttt{#3}}}


\def\HasDesignSizes{\let\hasdesignsizes\relax}

\def\getdesignsize#1{\xdef\designsize{}%
  \expandafter\@tfor\expandafter\x\expandafter:\expandafter=#1
  \do{\ifcat\x0\edef\designsize{\designsize\x}\fi%
    \if\x-\def\designsize{}\fi}}


\def\showletters#1#2#3#4#5#6{%
    \ifx\hasdesignsizes\undefined
      \subsection{#2-#3-#4}{#5}%
    \else
      \getdesignsize{#5}%
      \subsection{#2-#3-#4 (\designsize pt)}{#5}%
    \fi
    \markright{\mkfontname{#1/#2/#3/#4}{#5}{#6}}
    \showfontsize{#5}{18pt}{27pt}
    \showfontsize{#5}{36pt}{54pt}
    \showfontsize{#5}{72pt}{108pt}
    \clearpage
}

\def\showCMfont#1#2#3#4#5#6{
    \showletters{#1}{#2}{#3}{#4}{#5}{#6}
    \clearpage
    \markright{#5}
    \subsection{Text}{#5-text}%
    \showtextsize{%
        \font\f=#5\f 
        \let\EMPH=\relax 
        \let\textit=\relax
        \let\textsc=\relax}
}

\def\showtextsize#1{
    \columnsep=20pt
    \columnseprule=.4pt
    \begin{multicols}{2}
    #1
    \mksample{1}
    \mksample{1.2}
    \mksample{1.4}
    \mksample{1.1}
    \mksample{1.3}
    \mksample{1.5}
    \end{multicols}
    \clearpage
}

\def\showtext#1#2#3#4#5#6{\subsection{Text}{#5-text}%
    \markright{#6 at 8pt}\showtextsize{\fontsize{8pt}{8pt}\usefont{#1}{#2}{#3}{#4}}
    \markright{#6 at 10pt}\showtextsize{\fontsize{10pt}{10pt}\usefont{#1}{#2}{#3}{#4}}
    \markright{#6 at 12pt}\showtextsize{\fontsize{12pt}{12pt}\usefont{#1}{#2}{#3}{#4}}
    \clearpage
}

\def\samplesentence{%
     H�n nghi�n r�ng v�o m� ch�i c�i ��a �� �� ra Ch� Ph�o l�ng V� ��i}

\newenvironment{shortsample}
    {\normalfont\fontencoding{OT1}\ttfamily \selectfont
     \begin{tabular*}{\textwidth}{llll<{\samplesentence}}
     NFSS&TFM&PostScript&\multicolumn{1}{l}{Sample}\\ \hline
    }
    {\end{tabular*}}

\def\shorttext#1#2#3#4#5#6{%
    #1/#2/#3/#4 & #5 & #6 & \normalsize\usefont{#1}{#2}{#3}{#4}\\}

%%%\endinput

\ifbookmarks\RequirePackage{hyperref}
  \def\section#1{\gdef\currsec{#1}\hypertarget{#1}{}\pdfbookmark[0]{#1}{#1}}
%\subsection{<Text>}{<label>}
  \def\subsection#1#2{\def\target{\currsec-#2}%
    \hypertarget{\target}{}\pdfbookmark[1]{#1}{\target}}
\fi


\def\mapfile#1{\ifpdf\IfFileExists{./useinternalmap}{\pdfmapfile{=#1.map}}{}\fi}
\IfFileExists{./nocompress}{\pdfcompresslevel0 }{\pdfcompresslevel9 }

% Local Variables:
% coding: viscii
% End:
