-->

where are the SAPUI5 icons stored?

2020-07-28 10:29发布

问题:

I have an SAPUI5 based application in which I'm setting the button icons using the url to the icon under the SAP site https://sapui5.hana.ondemand.com/iconExplorer.html.

sample code

<Button id="excel" text="Excel" icon="sap-icon://excel-attachment" type="Accept" enabled="false" press="onDataExport"/>

Now we have to migrate to a different environment in which we cannot use these url's. We downloaded the SAPUI5 api and reference it remotely within the app. I looked under the folders but I cannot find where these icons are stored. Does anyone know where I can find the sap icons within the api folder? Assuming they are stored in there. If not, is there a way to get these icons so I can store them locally?

回答1:

Yes. they are fonts at https://sapui5.hana.ondemand.com/resources/sap/ui/core/themes/base/fonts/SAP-icons.ttf

And if you check https://sapui5.hana.ondemand.com/resources/sap/ui/core/IconPool-dbg.js, you can see the mapping between icon name and a numeric value which represents the char code of an icon in the 'SAP-icons' font.

You can also check this blog for the UI5 Icon mapping logic and quote here about Fonts.

"Fonts are a vector representation of images instead of binaries like GIF, JPEG or PNG. This means that they are able to be sized to any dimension without the loss of quality."

Thank you!



回答2:

icons in SAPUI5 are stored as a font: the name of the font is SAP-icons.ttf. If you install the font on your system, you can check the character map and see the different icons.



标签: sapui5