When I get imageWithSystemSymbolName, I get black graphics on a transparent background. How can I get white symbols?
When I look at the symbols (like triangle.circle) in SF Symbols, they're all white on transparent. For example, I want to draw triangle.circle.fill on a black screen, so I don't want a black image.
I'm doing something like this to get SF Symbols (as NSData to pass them as a byte array into Unity):
objc
NSData* GetSymbolImageAsBytes(int width, int height)
{
GCController *gc = [GCController current];
NSString *name = gc.extendedGamepad.buttonY.sfSymbolsName;
NSImage *image = [NSImage
imageWithSystemSymbolName: name
accessibilityDescription: nil
];
// https://stackoverflow.com/a/38442746/79125
NSSize size = NSMakeSize(width, height);
NSBitmapImageRep *rep = [[NSBitmapImageRep alloc]
initWithBitmapDataPlanes:NULL
pixelsWide:size.width
pixelsHigh:size.height
bitsPerSample:8
samplesPerPixel:4
hasAlpha:YES
isPlanar:NO
colorSpaceName:NSCalibratedRGBColorSpace
bytesPerRow:0
bitsPerPixel:0];
rep.size = size;
[NSGraphicsContext saveGraphicsState];
[NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithBitmapImageRep:rep]];
[image drawInRect:NSMakeRect(0, 0, size.width, size.height) fromRect:NSZeroRect operation:NSCompositingOperationCopy fraction:1.0];
[NSGraphicsContext restoreGraphicsState];
if (rep == nil)
{
return nil;
}
// Passing nil gives a warning but seems to work okay.
return [rep representationUsingType:NSBitmapImageFileTypePNG properties:nil];
}
Post
Replies
Boosts
Views
Activity
Summary
GCController's sfSymbolsName API returns the customized symbol names after customization is disabled until the app is restarted. It should be returning the uncustomized symbol names (to match the current button inputs).
Detailed Repro
I've connected a Horipad to my iPad (OS 14.3).
When I start the app, it starts printing the correct symbol names:
Controller HORIPAD ULTIMATE
buttonA: a.circle
buttonB: b.circle
buttonX: x.circle
buttonY: y.circle
I turn on customization (Settings General Game Controller Customizations Enable Customizations) and swap two face buttons with shoulders (using the global customization) and the symbol names change as expected:
Controller HORIPAD ULTIMATE
buttonA: l1.rectangle.roundedbottom
buttonB: r1.rectangle.roundedbottom
buttonX: x.circle
buttonY: y.circle
I swap buttonX and buttonY and the symbol names update:
Controller HORIPAD ULTIMATE
buttonA: l1.rectangle.roundedbottom
buttonB: r1.rectangle.roundedbottom
buttonX: y.circle
buttonY: x.circle
I turn off customization and the symbol names fail to update:
Controller HORIPAD ULTIMATE
buttonA: l1.rectangle.roundedbottom
buttonB: r1.rectangle.roundedbottom
buttonX: y.circle
buttonY: x.circle
I'd expect it to go back to the first set of names (a.circle, etc).
Launching the app with customization enabled and switching to settings to turn it off also continues to produce the customized sfSymbolsName values instead of the correct uncustomized values.
I'm testing from a Unity game (Unity 2019.4.7f1). Here's my minimal repro:
cs
// Assets/Scripts/GamepadTest.cs
using System;
using System.Runtime.InteropServices;
using UnityEngine;
namespace Game {
public class GamepadTest : MonoBehaviour {
#if UNITY_IOS || UNITY_TVOS
[DllImport("__Internal")]
private static extern void GCControllerInit();
[DllImport("__Internal")]
private static extern void GCControllerUpdate();
void Start() {
GCControllerInit();
}
void Update() {
GCControllerUpdate();
}
#endif // UNITY_IOS || UNITY_TVOS
}
}
objc
// Assets/Plugins/InputTest/iOS/gccontroller.m
#import stdint.h
#import Foundation/Foundation.h
#import GameController/GameController.h
static bool g_initialized = false;
static GCController* g_controller;
void GCControllerUpdate()
{
if(g_controller == NULL) {
return;
}
// BUG: First print is correct. First change to button mapping
// correctly transitions. Second change to button mapping doesn't
// transition.
NSLog(@"Controller %@\n", g_controller.vendorName);
NSLog(@"buttonA: %@\n", g_controller.extendedGamepad.buttonA.sfSymbolsName);
NSLog(@"buttonB: %@\n", g_controller.extendedGamepad.buttonB.sfSymbolsName);
NSLog(@"buttonX: %@\n", g_controller.extendedGamepad.buttonX.sfSymbolsName);
NSLog(@"buttonY: %@\n", g_controller.extendedGamepad.buttonY.sfSymbolsName);
}
static void onConnected(GCController* gcController)
{
NSLog(@"[Gamepad] CONNECTED: %@\n", gcController.vendorName);
if(g_controller) {
NSLog(@"[Gamepad] Already had connected: %@\n", g_controller.vendorName);
}
g_controller = gcController;
}
static void onDisconnected(GCController* gcController)
{
if(g_controller == gcController) {
NSLog(@"[Gamepad] Wasn't connected: %@\n", g_controller.vendorName);
return;
}
g_controller = NULL;
NSLog(@"[Gamepad] DISCONNECTED: %@\n", gcController.vendorName);
}
void GCControllerInit()
{
if(g_initialized) {
NSLog(@"[Gamepad] Warning! Already initialized!\n");
return;
}
g_controller = NULL;
for(GCController *gcController in [GCController controllers]) {
onConnected(gcController);
}
NSNotificationCenter * center = [NSNotificationCenter defaultCenter];
[center addObserverForName:
GCControllerDidConnectNotification
object: nil
queue: nil
usingBlock: ^(NSNotification *note) { onConnected(note.object); } ];
[center addObserverForName:
GCControllerDidDisconnectNotification
object: nil
queue: nil
usingBlock: ^(NSNotification *note) { onDisconnected(note.object); } ];
g_initialized = true;
GCControllerUpdate();
}
I tried to make a native app - https://github.com/idbrii/ios-GameControllerTest to demonstrate the problem, but it disconnects when it loses focus so the app restarts and gets valid values. I assume if I figured out how to make it run like a game and stay alive after losing focus it would have the same problem?
When running iTMSTransporter.cmd -m verify using this text in my version_whats_new section:
أﻛﻮاد اﻷﺻﺪﻗﺎء ﻹرﺳﺎل اﻟﺪﻋﻮات إﻟﯽ اﻷﺻﺪﻗﺎء
(Translation: Friend codes for sending invites to friends)
I get this error:
<main> ERROR: ERROR ITMS-4000: "Version '1.3.1', Locale 'ar-SA': What's New in This Version can�t contain the following character(s): ?." at Software/SoftwareMetadata/SoftwareVersion
I narrowed it down to U+FBFD:
ﯽ
Why is that character (ARABIC LETTER FARSI YEH FINAL FORM) not allowed?