  This paper introduces a novel boundary integral equation (BIE) method for the
numerical solution of problems of planewave scattering by periodic line arrays
of two-dimensional penetrable obstacles. Our approach is built upon a direct
BIE formulation that leverages the simplicity of the free-space Green function
but in turn entails evaluation of integrals over the unit-cell boundaries. Such
integrals are here treated via the window Green function method. The windowing
approximation together with a finite-rank operator correction -- used to
properly impose the Rayleigh radiation condition -- yield a robust second-kind
BIE that produces super-algebraically convergent solutions throughout the
spectrum, including at the challenging Rayleigh-Wood anomalies. The corrected
windowed BIE can be discretized by means of off-the-shelf Nystr\"om and
boundary element methods, and it leads to linear systems suitable for iterative
linear-algebra solvers as well as standard fast matrix-vector product
algorithms. A variety of numerical examples demonstrate the accuracy and
robustness of the proposed methodology
