Automated program repair (APR) significantly improves development efficiency by automatically generating patches for defects in software. Recently, learning-based automatic program repair methods have been extensively studied. However, this approach still suffers from two obvious limitations: first, it is affected by the long-range dependency problem, which makes it difficult to handle long sequences of complex errors. The second is that the current patch ranking strategy does not consider the overall patch information, resulting in too many anomalously high-scoring patches in the candidate patch list, and thus ignoring the correct patches. To address the above limitations, we propose a novel automated program repair method PRFC (Program Repair combining Fix patterns and Code language models), which consists of three components:(1) By generalizing and organizing common fix patterns, we propose novel mask templates for enhancing the patch generation capability of code language models. (2) PRFC treats the repair task as a cloze task and utilizes the code language model to generate candidate patches based on the mask templates. (3) A novel patch reranking approach, which utilizes template coefficients to rerank candidate patches, greatly alleviates the problem of abnormally high-scoring patches. Experimental results show that PRFC correctly fixes 141 Defects4J bugs and 36 QuixBugs bugs under perfect fault localization conditions, which improves 11.02% and 33.33% over the optimal baseline, respectively.