func MeasureString(fontId FontID, text string) float32 { cText := C.CString(text) defer C.free(unsafe.Pointer(cText)) return float32(C.XPLMMeasureString(C.XPLMFontID(fontId), cText, C.int(len(text)))) }
func DrawNumber(color color.Color, xOffset, yOffset int, value float64, digits, decimal int, showSign bool, fontId FontID) { r, g, b, _ := color.RGBA() cColor := [3]float32{float32(r>>8) / 255.0, float32(g>>8) / 255.0, float32(b>>8) / 255.0} C.XPLMDrawNumber((*C.float)(unsafe.Pointer(&cColor[0])), C.int(xOffset), C.int(yOffset), C.double(value), C.int(digits), C.int(decimal), C.int(goplane.FromBoolToInt(showSign)), C.XPLMFontID(fontId)) }
func GetFontDimensions(fontId FontID) (charWidth, charHeight int, digitsOnly bool) { var cDigitsOnly int C.XPLMGetFontDimensions(C.XPLMFontID(fontId), (*C.int)(unsafe.Pointer(&charWidth)), (*C.int)(unsafe.Pointer(&charHeight)), (*C.int)(unsafe.Pointer(&cDigitsOnly))) digitsOnly = cDigitsOnly == 1 return }
func DrawString(color color.Color, xOffset, yOffset int, text string, wordWrapWidth []int32, fontId FontID) { r, g, b, _ := color.RGBA() cColor := [3]float32{float32(r>>8) / 255.0, float32(g>>8) / 255.0, float32(b>>8) / 255.0} cText := C.CString(text) defer C.free(unsafe.Pointer(cText)) var cWordWrapWidth unsafe.Pointer if len(wordWrapWidth) > 0 { cWordWrapWidth = unsafe.Pointer(&wordWrapWidth[0]) } C.XPLMDrawString((*C.float)(unsafe.Pointer(&cColor[0])), C.int(xOffset), C.int(yOffset), cText, (*C.int)(cWordWrapWidth), C.XPLMFontID(fontId)) }