func convertColorAttrs(printerTags map[string][]string) *cdd.Color { colorSupported, exists := printerTags[attrPrintColorModeSupported] if !exists { return nil } colorDefault, exists := printerTags[attrPrintColorModeDefault] if !exists || len(colorDefault) != 1 { colorDefault = colorSupported[:1] } var c cdd.Color for _, color := range colorSupported { var co cdd.ColorOption var exists bool if co, exists = colorByKeyword[color]; !exists { co = cdd.ColorOption{ VendorID: fmt.Sprintf("%s%s%s", attrPrintColorMode, internalKeySeparator, color), Type: cdd.ColorTypeCustomColor, CustomDisplayNameLocalized: cdd.NewLocalizedString(color), } } if color == colorDefault[0] { co.IsDefault = true } c.Option = append(c.Option, co) } return &c }
func convertColorAttrs(printerTags map[string][]string) *cdd.Color { colorSupported, exists := printerTags[attrPrintColorModeSupported] if !exists { return nil } colorDefault, exists := printerTags[attrPrintColorModeDefault] if !exists || len(colorDefault) != 1 { colorDefault = colorSupported[:1] } var c cdd.Color for _, color := range colorSupported { var co cdd.ColorOption var exists bool if co, exists = colorByKeyword[color]; !exists { co = cdd.ColorOption{ VendorID: color, Type: cdd.ColorTypeCustomColor, CustomDisplayNameLocalized: cdd.NewLocalizedString(color), } } if color == colorDefault[0] { co.IsDefault = true } c.Option = append(c.Option, co) } for i := range c.Option { // Color can be specified by either attribute or PPD. // Therefore, prepend "ColorModel" to these ColorOptions. c.Option[i].VendorID = attrPrintColorMode + c.Option[i].VendorID } return &c }