First-principles Studies of Anion Engineering in Functional Ceramics