  We present a systematic method to calculate the universal scaling functions
for the critical Casimir force and the according potential of the
two-dimensional Ising model with various boundary conditions. Therefore we
start with the dimer representation of the corresponding partition function $Z$
on an $L\times M$ square lattice, wrapped around a torus with aspect ratio
$\rho=L/M$. By assuming periodic boundary conditions and translational
invariance in at least one direction, we systematically reduce the problem to a
$2\times2$ transfer matrix representation. For the torus we first reproduce the
results by Kaufman and then give a detailed calculation of the scaling
functions. Afterwards we present the calculation for the cylinder with open
boundary conditions. All scaling functions are given in form of combinations of
infinite products and integrals. Our results reproduce the known scaling
functions in the limit of thin films $\rho\to 0$. Additionally, for the
cylinder at criticality our results confirm the predictions from conformal
field theory.
