Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Add guide about customizing fonts #292

Merged
merged 2 commits into from
Apr 30, 2020
Merged

Add guide about customizing fonts #292

merged 2 commits into from
Apr 30, 2020

Conversation

1ec5
Copy link
Contributor

@1ec5 1ec5 commented Apr 30, 2020

Split out a guide about customizing fonts, covering both server-side and client-side fonts following the changes in #189.

customizing-fonts

/cc @mapbox/maps-ios @mapbox/docs (FYI)

@1ec5 1ec5 added documentation Improvements or additions to documentation ios macOS labels Apr 30, 2020
@1ec5 1ec5 requested review from fabian-guerra, chloekraw and a team April 30, 2020 21:06
@1ec5 1ec5 self-assigned this Apr 30, 2020
@1ec5 1ec5 added this to the release-water milestone Apr 30, 2020
Split out a guide about customizing fonts, covering both server-side and client-side fonts.
@1ec5 1ec5 force-pushed the 1ec5-local-font-names-docs branch from 323168f to dd7b4f0 Compare April 30, 2020 21:10
Copy link
Contributor

@chloekraw chloekraw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, @1ec5! Thank you for writing this up.


First, the map attempts to apply a font that you specify the same way as you would specify a server-side font: in [Mapbox Studio](https://studio.mapbox.com/), in the `text-font` layout property in style JSON, or in the `MGLSymbolStyleLayer.textFontNames` property at runtime. Instead of downloading the glyphs, the map tries to find a [system font](https://developer.apple.com/fonts/system-fonts/) or a font [bundled with your application](https://developer.apple.com/documentation/uikit/text_display_and_fonts/adding_a_custom_font_to_your_app) that matches one of these fonts based on its family name (for example, “PingFang TC”), display name (“PingFang TC Ultralight”), or PostScript name (“PingFangTC-Ultralight”).

If none of the symbol layer’s fonts is available, or if these fonts do not contain the required glyphs, then the map tries to find a matching font in the [`MGLIdeographicFontFamilyName`](infoplist-keys.html#mglideographicfontfamilyname) Info.plist key. Like the `MGLSymbolStyleLayer.textFontNames` property, this key can contain a family name, display name, or PostScript name. This key is a global fallback that applies to all layers uniformly. It can either be a single string or an array of strings, which the map tries to apply in order from most preferred to least preferred.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If none of the symbol layer’s fonts is available, or if these fonts do not contain the required glyphs, then the map tries to find a matching font in the [`MGLIdeographicFontFamilyName`](infoplist-keys.html#mglideographicfontfamilyname) Info.plist key. Like the `MGLSymbolStyleLayer.textFontNames` property, this key can contain a family name, display name, or PostScript name. This key is a global fallback that applies to all layers uniformly. It can either be a single string or an array of strings, which the map tries to apply in order from most preferred to least preferred.
If none of the fonts specified on a symbol layer are available, or if the fonts do not contain the required glyphs, then the map tries to find a matching font in the [`MGLIdeographicFontFamilyName`](infoplist-keys.html#mglideographicfontfamilyname) Info.plist key. Like the `MGLSymbolStyleLayer.textFontNames` property, this key can contain a family name, display name, or PostScript name. This key is a global fallback that applies to all layers uniformly. It can either be a single string or an array of strings, which the map tries to apply in order from most preferred to least preferred.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nitpicks:

  • "none" should be followed by a plural verb because in this context, none refers to "if not any of the fonts are available". None is singular when it is used in reference to part of a single item, e.g., "none of my bread is yours."
  • suggested a rewording of the first clause of the first sentence that I think is clearer

Copy link
Contributor Author

@1ec5 1ec5 Apr 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an area where style guides differ. I’ve always followed the “not one” rule of thumb from a grade school English textbook, but it’s admittedly quite pedantic and it looks like some style guides like APA have gone the other way. Our internal style guide is silent on the matter. I’ll reword the sentence for clarity.


First, the map attempts to apply a font that you specify the same way as you would specify a server-side font: in [Mapbox Studio](https://studio.mapbox.com/), in the `text-font` layout property in style JSON, or in the `MGLSymbolStyleLayer.textFontNames` property at runtime. Instead of downloading the glyphs, the map tries to find a [system font](https://developer.apple.com/fonts/system-fonts/) or a font [bundled with your application](https://developer.apple.com/documentation/uikit/text_display_and_fonts/adding_a_custom_font_to_your_app) that matches one of these fonts based on its family name (for example, “PingFang TC”), display name (“PingFang TC Ultralight”), or PostScript name (“PingFangTC-Ultralight”).

If none of the symbol layer’s fonts is available, or if these fonts do not contain the required glyphs, then the map tries to find a matching font in the [`MGLIdeographicFontFamilyName`](infoplist-keys.html#mglideographicfontfamilyname) Info.plist key. Like the `MGLSymbolStyleLayer.textFontNames` property, this key can contain a family name, display name, or PostScript name. This key is a global fallback that applies to all layers uniformly. It can either be a single string or an array of strings, which the map tries to apply in order from most preferred to least preferred.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thought I'm mulling over: instead of writing out the information about MGLIdeographicFontFamilyName here, what do you think about linking to that section of the Info.plist guide for the details? I am generally hesitant to repeat information in more than one place, because it's one more place to remember to update if the behavior changes, which increases the chance that the information will go stale.

That said, at the same time, I really like the way this documentation reads as-is, so I don't have strong feelings about this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The guide does link to the relevant section of the Info.plist documentation, but the idea was to draw a parallel between the two places that accept font names. Fortunately, since these details are now part of the public API, it’s unlikely that they’ll change in a minor release.

@1ec5 1ec5 merged commit e780d13 into master Apr 30, 2020
@1ec5 1ec5 deleted the 1ec5-local-font-names-docs branch April 30, 2020 23:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Improvements or additions to documentation ios macOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants