Scale feature labels and symbols according to the system text-size setting.

Use case
Use this pattern to improve map readability for users who increase text size in their operating system’s accessibility settings. Enable MapView.useSystemTextScale to scale feature labels automatically.
How to use the sample
Change the text size in the operating system’s accessibility settings to see the restaurant labels and symbols resize. On iOS, open Settings > Accessibility > Display & Text Size > Larger Text. On Linux (GNOME), open Settings > Accessibility > Seeing > Large Text.
Clear Apply system text size to labels to stop labels from following the system text size, then select it again to restore system text scaling. Restaurant symbols continue to follow the system text size independently of this setting. The legend and current values show how labels and symbols are scaled.
Select a restaurant to show its name and WGS 84 coordinates in a callout. Select elsewhere to clear the callout.
How it works
- Create a
Mapand add aFeatureLayer. - Load the
restaurantsymbol fromEsri2DPointSymbolsStyleand apply it with aSimpleRenderer. - Load the feature layer, then add a
LabelDefinitionwith aTextSymbol. - To scale labels, enable
MapView.useSystemTextScale. - To scale symbols, read
SystemTextScaleMonitor::textScale()and connect to itstextScaleChangedsignal. This sample helper monitors the platform’s system text-size setting. SetMultilayerPointSymbol::setSize()to the base symbol size multiplied by the system text-scale factor. - Use the checkbox to toggle system text scaling for labels without changing symbol scaling.
- Identify a restaurant with
GeoView::identifyLayerAsyncand show its name and WGS 84 coordinates in a callout.
Relevant API
- GeoView.useSystemTextScale
About the data
This sample uses a Redlands restaurants feature layer covering food establishments in Redlands, California. Each feature represents a single restaurant.
The restaurant symbol comes from Esri’s 2D point symbol web style.
Additional information
GeoView.useSystemTextScale is supported on iOS, Android, Windows, and Linux (GNOME desktop environments only). It is not supported on macOS.
Tags
accessibility, label, readability, scale, symbol, text, visual impairment
Sample code
// [WriteFile Name=UpdateLabelsAndSymbolsToScaleForVisualAccessibility, Category=Accessibility]// [Legal]// Copyright 2026 Esri.//// Licensed under the Apache License, Version 2.0 (the "License");// you may not use this file except in compliance with the License.// You may obtain a copy of the License at// http://www.apache.org/licenses/LICENSE-2.0//// Unless required by applicable law or agreed to in writing, software// distributed under the License is distributed on an "AS IS" BASIS,// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.// See the License for the specific language governing permissions and// limitations under the License.// [Legal]
#ifdef PCH_BUILD#include "pch.hpp"#endif // PCH_BUILD
// sample headers#include "UpdateLabelsAndSymbolsToScaleForVisualAccessibility.h"
// ArcGIS Maps SDK headers#include "AttributeListModel.h"#include "CalloutData.h"#include "Error.h"#include "Feature.h"#include "FeatureLayer.h"#include "GeometryEngine.h"#include "IdentifyLayerResult.h"#include "LabelDefinition.h"#include "LabelDefinitionListModel.h"#include "LabelingTypes.h"#include "LayerListModel.h"#include "Map.h"#include "MapQuickView.h"#include "MapTypes.h"#include "MultilayerPointSymbol.h"#include "Point.h"#include "ServiceFeatureTable.h"#include "SimpleLabelExpression.h"#include "SimpleRenderer.h"#include "SpatialReference.h"#include "SymbolStyle.h"#include "TextSymbol.h"#include "Viewpoint.h"
// qt_common headers#include "SystemTextScaleMonitor/SystemTextScaleMonitor.h"
// Qt headers#include <QBuffer>#include <QFuture>#include <QImage>#include <QMouseEvent>
using namespace Esri::ArcGISRuntime;
UpdateLabelsAndSymbolsToScaleForVisualAccessibility::UpdateLabelsAndSymbolsToScaleForVisualAccessibility(QObject* parent /* = nullptr */) : QObject(parent), m_map(new Map(BasemapStyle::ArcGISLightGray, this)){ m_systemTextScaleMonitor = AccessibilitySample::SystemTextScaleMonitor::sharedInstance(); connect(m_systemTextScaleMonitor.get(), &AccessibilitySample::SystemTextScaleMonitor::textScaleChanged, this, [this](float) { updateSymbolSize(); }); updateSymbolSize();
m_map->setInitialViewpoint(Viewpoint(Point(-117.1793, 34.0556, SpatialReference::wgs84()), 2500));
// Create a feature layer of restaurants in Redlands and add it to the map ServiceFeatureTable* restaurantsTable = new ServiceFeatureTable(QUrl("https://services2.arcgis.com/ZQgQTuoyBrtmoGdP/arcgis/rest/services/redlands_food/FeatureServer/0"), this); m_restaurantsLayer = new FeatureLayer(restaurantsTable, this); m_map->operationalLayers()->append(m_restaurantsLayer);
// Once the feature layer has loaded, label the restaurants with their names connect(m_restaurantsLayer, &FeatureLayer::doneLoading, this, [this](const Error& error) { if (error.isEmpty()) { addLabels(); } });
loadRestaurantSymbol();}
UpdateLabelsAndSymbolsToScaleForVisualAccessibility::~UpdateLabelsAndSymbolsToScaleForVisualAccessibility() = default;
void UpdateLabelsAndSymbolsToScaleForVisualAccessibility::init(){ // Register the map view for QML qmlRegisterType<MapQuickView>("Esri.Samples", 1, 0, "MapView"); qmlRegisterType<UpdateLabelsAndSymbolsToScaleForVisualAccessibility>("Esri.Samples", 1, 0, "UpdateLabelsAndSymbolsToScaleForVisualAccessibilitySample");}
MapQuickView* UpdateLabelsAndSymbolsToScaleForVisualAccessibility::mapView() const{ return m_mapView;}
// Set the view (created in QML)void UpdateLabelsAndSymbolsToScaleForVisualAccessibility::setMapView(MapQuickView* mapView){ if (!mapView || mapView == m_mapView) { return; }
m_mapView = mapView; m_mapView->setMap(m_map);
connect(m_mapView, &MapQuickView::mouseClicked, this, &UpdateLabelsAndSymbolsToScaleForVisualAccessibility::identifyRestaurant);
emit mapViewChanged();}
QUrl UpdateLabelsAndSymbolsToScaleForVisualAccessibility::symbolSwatchUrl() const{ return m_symbolSwatchUrl;}
void UpdateLabelsAndSymbolsToScaleForVisualAccessibility::setSymbolSize(double symbolSize){ if (symbolSize <= 0 || qFuzzyCompare(m_symbolSize, symbolSize)) { return; }
m_symbolSize = symbolSize; if (m_restaurantSymbol) { m_restaurantSymbol->setSize(m_symbolSize); }}
void UpdateLabelsAndSymbolsToScaleForVisualAccessibility::updateSymbolSize(){ const double textScale = m_systemTextScaleMonitor->textScale(); setSymbolSize(24.0 * textScale);}
void UpdateLabelsAndSymbolsToScaleForVisualAccessibility::loadRestaurantSymbol(){ // Get the restaurant symbol from Esri's 2D point symbol web style SymbolStyle* symbolStyle = new SymbolStyle("Esri2DPointSymbolsStyle", nullptr, this); symbolStyle->fetchSymbolAsync({"restaurant"}, this) .then(this, [this](Symbol* symbol) { MultilayerPointSymbol* restaurantSymbol = qobject_cast<MultilayerPointSymbol*>(symbol); if (!restaurantSymbol) { return; }
m_restaurantSymbol = restaurantSymbol; restaurantSymbol->setSize(m_symbolSize);
// Display the restaurants with the symbol m_restaurantsLayer->setRenderer(new SimpleRenderer(restaurantSymbol, this));
restaurantSymbol->createSwatchAsync().then(this, [this](const QImage& swatch) { QByteArray swatchBytes; QBuffer buffer(&swatchBytes); buffer.open(QIODevice::WriteOnly); swatch.save(&buffer, "PNG");
m_symbolSwatchUrl = QUrl("data:image/png;base64," + swatchBytes.toBase64()); emit symbolSwatchUrlChanged(); }); });}
void UpdateLabelsAndSymbolsToScaleForVisualAccessibility::addLabels(){ // Create a text symbol for the labels TextSymbol* textSymbol = new TextSymbol(this); textSymbol->setColor(QColor(31, 35, 40)); textSymbol->setHaloColor(Qt::white); textSymbol->setHaloWidth(2); textSymbol->setSize(12);
// Label each restaurant with its name, above the restaurant symbol LabelDefinition* labelDefinition = new LabelDefinition(new SimpleLabelExpression("[name]", this), textSymbol, this); labelDefinition->setDeconflictionStrategy(LabelDeconflictionStrategy::None); labelDefinition->setPlacement(LabelingPlacement::PointAboveCenter);
m_restaurantsLayer->labelDefinitions()->append(labelDefinition); m_restaurantsLayer->setLabelsEnabled(true);}
void UpdateLabelsAndSymbolsToScaleForVisualAccessibility::identifyRestaurant(const QMouseEvent& mouseEvent){ // Clear any previous selection and callout m_restaurantsLayer->clearSelection(); m_mapView->calloutData()->setVisible(false);
// Identify at most one restaurant near the selected screen position m_mapView->identifyLayerAsync(m_restaurantsLayer, mouseEvent.position(), 12, false, 1, this) .then(this, [this](IdentifyLayerResult* result) { if (!result) { return; }
result->deleteLater();
if (result->geoElements().isEmpty()) { return; }
Feature* restaurant = static_cast<Feature*>(result->geoElements().constFirst()); const QString name = restaurant->attributes()->attributeValue("name").toString().trimmed();
// Project the restaurant location to WGS 84 to get its latitude and longitude const Point location(restaurant->geometry()); const Point wgs84Location(GeometryEngine::project(location, SpatialReference::wgs84()));
// Select the restaurant and show its name and coordinates in a callout m_restaurantsLayer->selectFeature(restaurant);
CalloutData* calloutData = m_mapView->calloutData(); calloutData->setLocation(location); calloutData->setTitle(name.isEmpty() ? tr("Restaurant") : name); calloutData->setDetail(tr("Lat: %1, Lon: %2").arg(wgs84Location.y(), 0, 'f', 5).arg(wgs84Location.x(), 0, 'f', 5)); calloutData->setVisible(true); });}// [WriteFile Name=UpdateLabelsAndSymbolsToScaleForVisualAccessibility, Category=Accessibility]// [Legal]// Copyright 2026 Esri.//// Licensed under the Apache License, Version 2.0 (the "License");// you may not use this file except in compliance with the License.// You may obtain a copy of the License at// http://www.apache.org/licenses/LICENSE-2.0//// Unless required by applicable law or agreed to in writing, software// distributed under the License is distributed on an "AS IS" BASIS,// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.// See the License for the specific language governing permissions and// limitations under the License.// [Legal]
#ifndef UPDATELABELSANDSYMBOLSTOSCALEFORVISUALACCESSIBILITY_H#define UPDATELABELSANDSYMBOLSTOSCALEFORVISUALACCESSIBILITY_H
// Qt headers#include <QObject>#include <QUrl>
// STL headers#include <memory>
namespace AccessibilitySample{ class SystemTextScaleMonitor;}
namespace Esri::ArcGISRuntime{ class FeatureLayer; class Map; class MapQuickView; class MultilayerPointSymbol;} // namespace Esri::ArcGISRuntime
class QMouseEvent;
Q_MOC_INCLUDE("MapQuickView.h")
class UpdateLabelsAndSymbolsToScaleForVisualAccessibility : public QObject{ Q_OBJECT
Q_PROPERTY(Esri::ArcGISRuntime::MapQuickView* mapView READ mapView WRITE setMapView NOTIFY mapViewChanged) Q_PROPERTY(QUrl symbolSwatchUrl READ symbolSwatchUrl NOTIFY symbolSwatchUrlChanged)
public: explicit UpdateLabelsAndSymbolsToScaleForVisualAccessibility(QObject* parent = nullptr); ~UpdateLabelsAndSymbolsToScaleForVisualAccessibility() override;
static void init();
signals: void mapViewChanged(); void symbolSwatchUrlChanged();
private: Esri::ArcGISRuntime::MapQuickView* mapView() const; void setMapView(Esri::ArcGISRuntime::MapQuickView* mapView); QUrl symbolSwatchUrl() const; void setSymbolSize(double symbolSize); void updateSymbolSize();
void loadRestaurantSymbol(); void addLabels(); void identifyRestaurant(const QMouseEvent& mouseEvent);
Esri::ArcGISRuntime::Map* m_map = nullptr; Esri::ArcGISRuntime::MapQuickView* m_mapView = nullptr; Esri::ArcGISRuntime::FeatureLayer* m_restaurantsLayer = nullptr; Esri::ArcGISRuntime::MultilayerPointSymbol* m_restaurantSymbol = nullptr; std::shared_ptr<AccessibilitySample::SystemTextScaleMonitor> m_systemTextScaleMonitor; double m_symbolSize = 24; QUrl m_symbolSwatchUrl;};
#endif // UPDATELABELSANDSYMBOLSTOSCALEFORVISUALACCESSIBILITY_H// [WriteFile Name=UpdateLabelsAndSymbolsToScaleForVisualAccessibility, Category=Accessibility]// [Legal]// Copyright 2026 Esri.
// Licensed under the Apache License, Version 2.0 (the "License");// you may not use this file except in compliance with the License.// You may obtain a copy of the License at// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software// distributed under the License is distributed on an "AS IS" BASIS,// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.// See the License for the specific language governing permissions and// limitations under the License.// [Legal]
import QtQuickimport QtQuick.Controlsimport Esri.ArcGISRuntime.Toolkitimport Esri.Samples
Item {
MapView { id: view anchors.fill: parent
// Scale labels according to the system text-size setting useSystemTextScale: labelScaleCheckBox.checked
Component.onCompleted: { // Set and keep the focus on MapView to enable keyboard navigation forceActiveFocus(); }
Callout { calloutData: view.calloutData accessoryButtonVisible: false leaderPosition: Callout.LeaderPosition.Automatic } }
// Instructions, legend, label scaling toggle, and current values Pane { id: panel anchors { top: parent.top right: parent.right margins: 10 } width: Math.min(350, parent.width - 20) height: Math.min(implicitHeight, parent.height - 20) padding: 10
ScrollView { anchors.fill: parent contentWidth: panel.availableWidth ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
Column { id: contentColumn width: parent.width spacing: 8
Label { width: parent.width horizontalAlignment: Text.AlignHCenter wrapMode: Text.Wrap text: qsTr("Change the system text size to scale feature labels and symbols, then select a feature to view its name and coordinates.") }
Rectangle { width: parent.width height: 1 color: "darkgrey" }
Label { width: parent.width horizontalAlignment: Text.AlignHCenter wrapMode: Text.Wrap font.bold: true text: qsTr("Scaling source") }
Row { anchors.horizontalCenter: parent.horizontalCenter spacing: 8
Label { id: labelsLegendIcon anchors.verticalCenter: parent.verticalCenter width: Math.max(symbolsLegendIcon.width, implicitWidth) horizontalAlignment: Text.AlignHCenter font.bold: true text: qsTr("Aa") }
Label { anchors.verticalCenter: parent.verticalCenter // Wrap instead of growing wider than the panel at large text sizes width: Math.min(implicitWidth, contentColumn.width - labelsLegendIcon.width - parent.spacing) wrapMode: Text.Wrap text: qsTr("Labels: GeoView API") } }
Row { anchors.horizontalCenter: parent.horizontalCenter spacing: 8
Image { id: symbolsLegendIcon anchors.verticalCenter: parent.verticalCenter width: 24 height: width fillMode: Image.PreserveAspectFit source: model.symbolSwatchUrl }
Label { anchors.verticalCenter: parent.verticalCenter width: Math.min(implicitWidth, contentColumn.width - symbolsLegendIcon.width - parent.spacing) wrapMode: Text.Wrap text: qsTr("Symbols: system text size") } }
Rectangle { width: parent.width height: 1 color: "darkgrey" }
Label { width: parent.width horizontalAlignment: Text.AlignHCenter wrapMode: Text.Wrap font.bold: true text: qsTr("Toggles") }
Row { anchors.horizontalCenter: parent.horizontalCenter
Item { anchors.verticalCenter: parent.verticalCenter width: labelScaleCheckBox.width * labelScaleCheckBox.scale height: labelScaleCheckBox.height * labelScaleCheckBox.scale
CheckBox { id: labelScaleCheckBox anchors.centerIn: parent checked: true Accessible.name: labelScaleLabel.text } }
Label { id: labelScaleLabel anchors.verticalCenter: parent.verticalCenter width: Math.min(implicitWidth, contentColumn.width - labelScaleCheckBox.width * labelScaleCheckBox.scale) wrapMode: Text.Wrap text: qsTr("Apply system text size to labels")
TapHandler { onTapped: labelScaleCheckBox.toggle() } } }
Rectangle { width: parent.width height: 1 color: "darkgrey" }
Label { width: parent.width horizontalAlignment: Text.AlignHCenter wrapMode: Text.Wrap font.bold: true text: qsTr("Current controls") }
Label { width: parent.width horizontalAlignment: Text.AlignHCenter wrapMode: Text.Wrap text: view.useSystemTextScale ? qsTr("Labels: <b>scaled by MapView.useSystemTextScale.</b>") : qsTr("Labels: <b>API text scaling is disabled.</b>") } } } }
// Declare the C++ instance which creates the map etc. and supply the view UpdateLabelsAndSymbolsToScaleForVisualAccessibilitySample { id: model mapView: view }}