Fixing automatic accents in XeTeX

XeTeX includes functionality for automatically generating accented glyphs. Sometimes these glyphs can be incorrect. For example, take the letter ģ. If you use it in a document, XeTeX will by default output a cedilla under the letter instead of over it. The solution is to use \newunicodechar to redefine it.

	\usepackage{newunicodechar}
	\newunicodechar{ģ}{\v{g}}

Alternatively, you can use the \accent instead of \v but this will prevent correctly copy-pasting the character from PDF:

	\newunicodechar{ģ}{\accent\string"02C7 g}
	% this solution is worse because copy-paste yields "^g"