I would appreciate any thoughts on the following issue.
Windows has a display option for scaling text and Apps on the screen. I have not been able to pick up this scale value in Media Query. When the scaler is set to 100% and a graphic window and texture box are set to the same width and height, then the texture box is correctly sized and the image is centered in that box. When the Windows Display Setting scale is set > 100% then the texture box is correctly sized but the image is scaled to match the Windows Display Setting and the image is off-centered in the Texture box. That would not be an issue if I could detect the scaling factor. Media Query has a TextScaler, but it does not appear to report the Windows setting value. Without that value I cannot correct for a change in this desktop setting.
As a test if I build the App at 100% then change the desktop setting, the image remains centered in the texture and the texture is zoomed to the new size. If instead I set scale to 150% then build the App the image is 150% larger in the same sized window and is off center. This setting is in Windows 10 and 11.
I tried to force the MediaData TextScaler to 100%, but that had no effect (See below).
Here is some code
@override
Widget build(BuildContext context) {
TextScaler scale = MediaQuery.of(context).textScaler;
double width = MediaQuery.of(context).size.width;
double height = MediaQuery.of(context).size.height;
double dpr = MediaQuery.of(context).devicePixelRatio;
print ('scale = ${MediaQuery.of(context).textScaler}');
return RepaintBoundary(
child: GraphicArea(width, height, dpr),
);
}
or this change
return MediaQuery(
data: MediaQuery.of(context).copyWith(
textScaler: const TextScaler.linear(1.0),
),
child: RepaintBoundary(
child: GraphicArea(width, height, dpr),
),
);
The GraphicArea Widget paints to a texture as follows.
@override
Widget build(BuildContext context) {
if (!initialized) {
return const Center(child: CircularProgressIndicator());
}
final int? textureId = graphic3D.three3dRender.textureId;
if (textureId == null || textureId == 0) {
return Container();
}
return SizedBox(
width: widget.width,
height: widget.height,
child: Texture(textureId: textureId),
);
}
Thanks for any help on this!