問題タブ [uifontdescriptor]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
ios - Using the fontWithSize API with San Francisco
The new San Francisco fonts in iOS 9 are optimized for the size it will be used at, by adjusting tracking and dynamically switching between SF Display and SF Text. It was noted in the WWDC session #804 developers should not use San Francisco by attempting to initialize a UIFont
using fontWithName
, for example:
This is because the system cannot optimize the font for the new size when using the fontWithName
API.
Instead it was recommended to get the UIFontDescriptor
from the original font and create a new font from that at the new size, like so:
However, they did not mention if the following allows for optimizations or not:
My question is, does the fontWithSize
API behave like the fontWithName
API or the fontWithDescriptor
API - does it result in an optimized font for the new size or not?
ios - iOS - UIFont SystemFont Italic と Thin (fontWithName: を使用せずに) を作成することは可能ですか?
私のアプリはシステムフォントのみを使用しており、関数を使用してそれらを作成しています-
ウェイトUIFontWeightThinでシステムフォントをイタリックにするにはどうすればよいですか?
システム フォントのみにしたいので、特定のファミリ フォント (fontWithName:) の呼び出しを使用できません。
ありがとう :)
swift2 - TextKit: Swift で太字フォントを「UnBold」に変更できない
フォントがBoldのテキストを含む TextView があります。そして、私はボタンを持っています。このボタンをタップすると、ボールド フォントが「UnBold」に変わります。
ViewController と、TextKit/UITextView のフォントを管理する「FontManager」というクラスがあります。
FontManager の私のコード:
selectedRange で Font を Bold に設定するこのコードは問題なく動作します
すでに太字のテキストがある場合は、ここでチェックします。そうでない場合 (== NSNotFound)、selectedRange のテキストは太字の「特性」になります
(1) selectedRange のフォントが太字の場合 (そうでない場合: != NSNotFound)、フォントは通常 (UnBold) に設定する必要があります。
そして今、ViewController のコード:
ボタンの最初のタップで (1) にスキップし、それ以外の場合は...
しかし、これは起こりません。デバッグモードでそれを見ることができますか???
どんなアイデアでも大歓迎です!
ios - fontDescriptorWithSymbolicTraits ios 8バグの迅速な代替
Swift カスタム テキスト エディター (ライト バージョン) を作成しようとしていますが、iOS 8 の fontDescriptorWithSymbolicTraits のバグでスタックし、nil が返されます。Swift の回避策はありますか?
ここに小さなプロジェクト サンプルを作成しました。次のシナリオをダウンロードして実行できます。
- テキストを選択
- 「B」ボタンをクリック
- 「私」ボタンをクリック
アプリがクラッシュし、:(をfontDescriptorWithSymbolicTraits
返しますnil
サンプルプロジェクトをざっと見てみることを強くお勧めします
どのようなオプションがありますか?
また、Apple のドキュメントでは、他のユーザーが使用していたメソッドが SDK とドキュメントから欠落していることも確認しました。
これについて他の人が言うこと:
ios - swift 2.0 UIFontDescriptorSymbolicTraits を CTFontSymbolicTraits に変換
を に変換するにはどうすればよいUIFontDescriptorSymbolicTraits
ですCTFontSymbolicTraits
か?
ios - UIFont 初期化子が返すオブジェクトとアプリをクラッシュさせます
私の iOS アプリは iOS 8.2 でクラッシュし、iOS 9 以降では完全に動作します。クラッシュログを確認したところ、以下の関数でクラッシュしていました(NSMutableAttributedString
拡張子に書いてあります)
クラッシュログ
*** キャッチされない例外 'NSInvalidArgumentException' が原因でアプリを終了します。理由: 'NSConcreteMutableAttributedString addAttribute:value:range:: nil value'
その関数で使用されている変数をデバッグしてログに記録すると、descriptor
&newFont
の両方が次のように表示されます<uninitialized>
どちらも「 UIFont will not be nil 」というエラーをスローするため、ここで使用if let
または確認することはできません。このクラッシュを修正するにはどうすればよいですか? (または、オブジェクトが初期化されているかどうかを確認するにはどうすればよいですか?) 私のユーザーの大半はまだ iOS 8 を使用しているため、この問題に本当に悩まされています。newFont != nil