Precision measurement of antiprotonic hydrogen and deuterium X-rays